aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/assistant/Models.qml
blob: b1b2a38fb49b45521bf08379c94209e7bafa7503 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

import QtQuick
import ".."

// The model panel, over the transcript: the router's models, then the
// cloud ones, in the daemon's order. A pick applies to this chat from its
// next question.
Rectangle {
    id: panel
    property var canvas

    color: Qt.alpha(Theme.base, 0.97)
    radius: 8

    MouseArea { anchors.fill: parent }   // keep clicks off the transcript below

    ListView {
        id: rows
        anchors.fill: parent
        clip: true
        spacing: 2
        model: panel.canvas.models

        delegate: Rectangle {
            id: r
            required property var modelData
            readonly property bool picked: r.modelData.id === panel.canvas.wanted
            width: rows.width
            height: 34
            radius: 6
            color: hover.hovered ? Qt.alpha(Theme.surface, 0.9) : "transparent"
            border.width: r.picked ? 1 : 0
            border.color: Qt.alpha(Theme.accent, 0.5)

            HoverHandler { id: hover }
            MouseArea {
                anchors.fill: parent
                cursorShape: Qt.PointingHandCursor
                onClicked: panel.canvas.pickModel(r.modelData.id)
            }
            // nf-fa-cloud, present in Inconsolata Nerd Font.
            Text {
                id: icon
                anchors { left: parent.left; leftMargin: 8; verticalCenter: parent.verticalCenter }
                width: 16
                text: r.modelData.cloud ? "" : ""
                color: Theme.subtext
                font { family: Theme.iconFamily; pixelSize: Theme.fontSize - 4 }
            }
            Text {
                anchors { left: icon.right; leftMargin: 6; right: stat.left; rightMargin: 8
                          verticalCenter: parent.verticalCenter }
                // A cloud id without its provider: the right column says it.
                text: r.modelData.cloud ? r.modelData.id.slice(r.modelData.provider.length + 1)
                                        : r.modelData.id
                elide: Text.ElideRight
                color: Theme.text
                font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2; bold: r.picked }
            }
            Text {
                id: stat
                anchors { right: parent.right; rightMargin: 8; verticalCenter: parent.verticalCenter }
                text: r.modelData.cloud ? r.modelData.provider : r.modelData.status
                color: r.modelData.status === "loaded" ? Theme.green : Theme.subtext
                font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
            }
        }

        Text {
            anchors.centerIn: parent
            visible: rows.count === 0
            text: "No models: is llama-server running?"
            color: Theme.overlay
            font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2 }
        }
    }
}