forked from Shinonome/dots-hyprland
ai: add api key indicator
This commit is contained in:
@@ -199,7 +199,7 @@ Inline w/ backslash and round brackets \\(e^{i\\pi} + 1 = 0\\)
|
|||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id: statusItemRowLayout
|
id: statusItemRowLayout
|
||||||
spacing: 4
|
spacing: 0
|
||||||
MaterialSymbol {
|
MaterialSymbol {
|
||||||
text: statusItem.icon
|
text: statusItem.icon
|
||||||
iconSize: Appearance.font.pixelSize.huge
|
iconSize: Appearance.font.pixelSize.huge
|
||||||
@@ -232,18 +232,22 @@ Inline w/ backslash and round brackets \\(e^{i\\pi} + 1 = 0\\)
|
|||||||
|
|
||||||
RowLayout { // Status
|
RowLayout { // Status
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
spacing: 8
|
spacing: 10
|
||||||
|
|
||||||
|
StatusItem {
|
||||||
|
icon: Ai.currentModelHasApiKey ? "key" : "key_off"
|
||||||
|
statusText: ""
|
||||||
|
description: Ai.currentModelHasApiKey ? Translation.tr("API key is set") : Translation.tr("No API key\nSet it with /key YOUR_API_KEY")
|
||||||
|
}
|
||||||
|
StatusSeparator {}
|
||||||
StatusItem {
|
StatusItem {
|
||||||
icon: "device_thermostat"
|
icon: "device_thermostat"
|
||||||
statusText: Ai.temperature.toFixed(1)
|
statusText: Ai.temperature.toFixed(1)
|
||||||
description: Translation.tr("Temperature")
|
description: Translation.tr("Temperature")
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusSeparator {
|
StatusSeparator {
|
||||||
visible: Ai.tokenCount.total > 0
|
visible: Ai.tokenCount.total > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusItem {
|
StatusItem {
|
||||||
visible: Ai.tokenCount.total > 0
|
visible: Ai.tokenCount.total > 0
|
||||||
icon: "token"
|
icon: "token"
|
||||||
|
|||||||
@@ -23,6 +23,13 @@ Singleton {
|
|||||||
property var messageByID: ({})
|
property var messageByID: ({})
|
||||||
readonly property var apiKeys: KeyringStorage.keyringData?.apiKeys ?? {}
|
readonly property var apiKeys: KeyringStorage.keyringData?.apiKeys ?? {}
|
||||||
readonly property var apiKeysLoaded: KeyringStorage.loaded
|
readonly property var apiKeysLoaded: KeyringStorage.loaded
|
||||||
|
readonly property bool currentModelHasApiKey: {
|
||||||
|
const model = models[currentModelId];
|
||||||
|
if (!model || !model.requires_key) return true;
|
||||||
|
if (!apiKeysLoaded) return false;
|
||||||
|
const key = apiKeys[model.key_id];
|
||||||
|
return (key?.length > 0);
|
||||||
|
}
|
||||||
property var postResponseHook
|
property var postResponseHook
|
||||||
property real temperature: Persistent.states?.ai?.temperature ?? 0.5
|
property real temperature: Persistent.states?.ai?.temperature ?? 0.5
|
||||||
property QtObject tokenCount: QtObject {
|
property QtObject tokenCount: QtObject {
|
||||||
@@ -45,6 +52,8 @@ Singleton {
|
|||||||
property list<var> promptFiles: [...defaultPrompts, ...userPrompts]
|
property list<var> promptFiles: [...defaultPrompts, ...userPrompts]
|
||||||
property list<var> savedChats: []
|
property list<var> savedChats: []
|
||||||
|
|
||||||
|
// Gemini: https://ai.google.dev/gemini-api/docs/function-calling
|
||||||
|
// OpenAI: https://platform.openai.com/docs/guides/function-calling
|
||||||
property var tools: {
|
property var tools: {
|
||||||
"gemini": [{"functionDeclarations": [
|
"gemini": [{"functionDeclarations": [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user