From 503823aa2e84136ecbd171b3336d18378b58649e Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Sun, 15 Jun 2025 10:09:56 +0200 Subject: [PATCH] config options: add weeb and ai policies --- .../modules/common/ConfigOptions.qml | 5 +++++ .../sidebarLeft/SidebarLeftContent.qml | 19 +++++++++++++++++-- .config/quickshell/services/Ai.qml | 14 ++++++++++---- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/.config/quickshell/modules/common/ConfigOptions.qml b/.config/quickshell/modules/common/ConfigOptions.qml index 1a776a203..d0425cadb 100644 --- a/.config/quickshell/modules/common/ConfigOptions.qml +++ b/.config/quickshell/modules/common/ConfigOptions.qml @@ -4,6 +4,11 @@ pragma Singleton pragma ComponentBehavior: Bound Singleton { + property QtObject policies: QtObject { + property int ai: 1 // 0: No | 1: Yes | 2: Local + property int weeb: 1 // 0: No | 1: Open | 2: Closet + } + property QtObject ai: QtObject { property string systemPrompt: qsTr("Use casual tone. No user knowledge is to be assumed except basic Linux literacy. Be brief and concise: When explaining concepts, use bullet points (prefer minus sign (-) over asterisk (*)) and highlight keywords in bold to pinpoint the main concepts instead of long paragraphs. You are also encouraged to split your response with h2 headers, each header title beginning with an emoji, like `## 🐧 Linux`. When making changes to the user's config, you must get the config to know what values there are before setting.") } diff --git a/.config/quickshell/modules/sidebarLeft/SidebarLeftContent.qml b/.config/quickshell/modules/sidebarLeft/SidebarLeftContent.qml index b0358e7b4..8d67c2a7f 100644 --- a/.config/quickshell/modules/sidebarLeft/SidebarLeftContent.qml +++ b/.config/quickshell/modules/sidebarLeft/SidebarLeftContent.qml @@ -18,9 +18,9 @@ Item { required property var scopeRoot anchors.fill: parent property var tabButtonList: [ - {"icon": "neurology", "name": qsTr("Intelligence")}, + ...(ConfigOptions.policies.ai !== 0 ? [{"icon": "neurology", "name": qsTr("Intelligence")}] : []), {"icon": "translate", "name": qsTr("Translator")}, - {"icon": "bookmark_heart", "name": qsTr("Anime")}, + ...(ConfigOptions.policies.weeb === 1 ? [{"icon": "bookmark_heart", "name": qsTr("Anime")}] : []) ] property int selectedTab: 0 @@ -87,8 +87,23 @@ Item { } } + contentChildren: [ + ...(ConfigOptions.policies.ai !== 0 ? [aiChat.createObject()] : []), + translator.createObject(), + ...(ConfigOptions.policies.weeb === 0 ? [] : [anime.createObject()]) + ] + } + + Component { + id: aiChat AiChat {} + } + Component { + id: translator Translator {} + } + Component { + id: anime Anime {} } diff --git a/.config/quickshell/services/Ai.qml b/.config/quickshell/services/Ai.qml index dbb8869d7..40b920e04 100644 --- a/.config/quickshell/services/Ai.qml +++ b/.config/quickshell/services/Ai.qml @@ -297,12 +297,18 @@ Singleton { if (!modelId) modelId = "" modelId = modelId.toLowerCase() if (modelList.indexOf(modelId) !== -1) { + const model = models[modelId] + // See if policy prevents online models + if (ConfigOptions.policies.ai === 2 && !model.endpoint.includes("localhost")) { + root.addMessage(StringUtils.format(StringUtils.format("Policy disallows online models\n\nControlled by `policies.ai` config option"), model.name), root.interfaceRole); + return; + } PersistentStateManager.setState("ai.model", modelId); - if (feedback) root.addMessage(StringUtils.format(StringUtils.format("Model set to {0}"), models[modelId].name), root.interfaceRole) - if (models[modelId].requires_key) { + if (feedback) root.addMessage(StringUtils.format(StringUtils.format("Model set to {0}"), model.name), root.interfaceRole); + if (model.requires_key) { // If key not there show advice - if (root.apiKeysLoaded && (!root.apiKeys[models[modelId].key_id] || root.apiKeys[models[modelId].key_id].length === 0)) { - root.addApiKeyAdvice(models[modelId]) + if (root.apiKeysLoaded && (!root.apiKeys[model.key_id] || root.apiKeys[model.key_id].length === 0)) { + root.addApiKeyAdvice(model) } } } else {