167 lines
5.4 KiB
QML
167 lines
5.4 KiB
QML
import QtQuick
|
|
import QtQuick.Layouts
|
|
import QtQuick.Controls as QQC2
|
|
import org.kde.plasma.plasmoid
|
|
import org.kde.kirigami as Kirigami
|
|
|
|
Kirigami.ScrollablePage {
|
|
id: page
|
|
|
|
// Core configuration aliases (Two-way binding)
|
|
property alias cfg_unslothUrl: unslothUrlField.text
|
|
property alias cfg_apiToken: apiTokenField.text
|
|
property alias cfg_systemPrompt: systemPromptField.text
|
|
property alias cfg_defaultModel: defaultModelField.text
|
|
property alias cfg_maxHistoryMessages: maxHistorySpinBox.value
|
|
|
|
// Default values passed by the Plasma config loader
|
|
// These resolve the "failed to set initial properties" errors
|
|
property string cfg_unslothUrlDefault
|
|
property string cfg_apiTokenDefault
|
|
property string cfg_systemPromptDefault
|
|
property string cfg_defaultModelDefault
|
|
property int cfg_maxHistoryMessagesDefault
|
|
|
|
ColumnLayout {
|
|
anchors.margins: Kirigami.Units.largeSpacing
|
|
spacing: Kirigami.Units.largeSpacing
|
|
|
|
// Help button in the header area
|
|
RowLayout {
|
|
Layout.fillWidth: true
|
|
spacing: Kirigami.Units.largeSpacing
|
|
|
|
QQC2.Label {
|
|
text: i18n("Configure Unsloth Chat")
|
|
Layout.fillWidth: true
|
|
font.bold: true
|
|
font.pointSize: Kirigami.Theme.defaultFont.pointSize
|
|
}
|
|
|
|
QQC2.Button {
|
|
text: i18n("Help →")
|
|
icon.name: "help-external-link"
|
|
onClicked: Qt.openUrlExternally("https://huitsinnevada.fi/projects")
|
|
}
|
|
}
|
|
|
|
// --- Unsloth Studio section ---
|
|
Kirigami.Separator { Layout.fillWidth: true }
|
|
|
|
Kirigami.Heading {
|
|
text: i18n("Unsloth Studio")
|
|
level: 2
|
|
Layout.fillWidth: true
|
|
}
|
|
|
|
QQC2.TextField {
|
|
id: unslothUrlField
|
|
placeholderText: i18n("Unsloth Studio URL (e.g., http://localhost:8888)")
|
|
Layout.fillWidth: true
|
|
}
|
|
|
|
QQC2.TextField {
|
|
id: apiTokenField
|
|
placeholderText: i18n("API Token")
|
|
echoMode: TextInput.Password
|
|
Layout.fillWidth: true
|
|
}
|
|
|
|
// --- System Prompt section ---
|
|
Kirigami.Separator { Layout.fillWidth: true }
|
|
|
|
Kirigami.Heading {
|
|
text: i18n("System Prompt")
|
|
level: 2
|
|
Layout.fillWidth: true
|
|
}
|
|
|
|
QQC2.TextArea {
|
|
id: systemPromptField
|
|
placeholderText: i18n("Enter the system prompt here...")
|
|
Layout.fillWidth: true
|
|
Layout.preferredHeight: 200
|
|
wrapMode: TextEdit.Wrap
|
|
clip: true
|
|
}
|
|
|
|
// --- Default Model section ---
|
|
Kirigami.Separator { Layout.fillWidth: true }
|
|
|
|
Kirigami.Heading {
|
|
text: i18n("Default Model")
|
|
level: 2
|
|
Layout.fillWidth: true
|
|
}
|
|
|
|
QQC2.TextField {
|
|
id: defaultModelField
|
|
placeholderText: i18n("Enter the default model name (e.g., unsloth/llama-3-8b)")
|
|
Layout.fillWidth: true
|
|
}
|
|
|
|
// --- Chat History section ---
|
|
Kirigami.Separator { Layout.fillWidth: true }
|
|
|
|
Kirigami.Heading {
|
|
text: i18n("Chat History")
|
|
level: 2
|
|
Layout.fillWidth: true
|
|
}
|
|
|
|
QQC2.Label {
|
|
text: i18n("Maximum number of messages to keep in chat history:")
|
|
wrapMode: TextEdit.WordWrap
|
|
Layout.fillWidth: true
|
|
}
|
|
|
|
QQC2.SpinBox {
|
|
id: maxHistorySpinBox
|
|
from: 1
|
|
to: 500
|
|
value: 50
|
|
enabled: true
|
|
Layout.fillWidth: true
|
|
}
|
|
|
|
Kirigami.Separator { Layout.fillWidth: true }
|
|
|
|
// --- Buttons ---
|
|
RowLayout {
|
|
Layout.alignment: Qt.AlignRight
|
|
spacing: Kirigami.Units.smallSpacing
|
|
|
|
QQC2.Button {
|
|
text: i18n("Reset")
|
|
onClicked: {
|
|
unslothUrlField.text = "http://localhost:8888";
|
|
apiTokenField.text = "";
|
|
systemPromptField.text = "";
|
|
defaultModelField.text = "";
|
|
maxHistorySpinBox.value = 50;
|
|
// Explicitly reset configuration values
|
|
plasmoid.configuration.unslothUrl = "http://localhost:8888";
|
|
plasmoid.configuration.apiToken = "";
|
|
plasmoid.configuration.systemPrompt = "";
|
|
plasmoid.configuration.defaultModel = "";
|
|
plasmoid.configuration.maxHistoryMessages = 50;
|
|
}
|
|
}
|
|
|
|
QQC2.Button {
|
|
text: i18n("Save")
|
|
onClicked: {
|
|
// Save all values explicitly (the cfg_ aliases update automatically
|
|
// via onTextChanged, but this ensures the values are written even
|
|
// if the user never edited a field)
|
|
plasmoid.configuration.unslothUrl = unslothUrlField.text;
|
|
plasmoid.configuration.apiToken = apiTokenField.text;
|
|
plasmoid.configuration.systemPrompt = systemPromptField.text;
|
|
plasmoid.configuration.defaultModel = defaultModelField.text;
|
|
plasmoid.configuration.maxHistoryMessages = maxHistorySpinBox.value;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|