forked from Shinonome/dots-hyprland
config options: add weeb and ai policies
This commit is contained in:
@@ -4,6 +4,11 @@ pragma Singleton
|
|||||||
pragma ComponentBehavior: Bound
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
Singleton {
|
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 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.")
|
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.")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ Item {
|
|||||||
required property var scopeRoot
|
required property var scopeRoot
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
property var tabButtonList: [
|
property var tabButtonList: [
|
||||||
{"icon": "neurology", "name": qsTr("Intelligence")},
|
...(ConfigOptions.policies.ai !== 0 ? [{"icon": "neurology", "name": qsTr("Intelligence")}] : []),
|
||||||
{"icon": "translate", "name": qsTr("Translator")},
|
{"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
|
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 {}
|
AiChat {}
|
||||||
|
}
|
||||||
|
Component {
|
||||||
|
id: translator
|
||||||
Translator {}
|
Translator {}
|
||||||
|
}
|
||||||
|
Component {
|
||||||
|
id: anime
|
||||||
Anime {}
|
Anime {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -297,12 +297,18 @@ Singleton {
|
|||||||
if (!modelId) modelId = ""
|
if (!modelId) modelId = ""
|
||||||
modelId = modelId.toLowerCase()
|
modelId = modelId.toLowerCase()
|
||||||
if (modelList.indexOf(modelId) !== -1) {
|
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);
|
PersistentStateManager.setState("ai.model", modelId);
|
||||||
if (feedback) root.addMessage(StringUtils.format(StringUtils.format("Model set to {0}"), models[modelId].name), root.interfaceRole)
|
if (feedback) root.addMessage(StringUtils.format(StringUtils.format("Model set to {0}"), model.name), root.interfaceRole);
|
||||||
if (models[modelId].requires_key) {
|
if (model.requires_key) {
|
||||||
// If key not there show advice
|
// If key not there show advice
|
||||||
if (root.apiKeysLoaded && (!root.apiKeys[models[modelId].key_id] || root.apiKeys[models[modelId].key_id].length === 0)) {
|
if (root.apiKeysLoaded && (!root.apiKeys[model.key_id] || root.apiKeys[model.key_id].length === 0)) {
|
||||||
root.addApiKeyAdvice(models[modelId])
|
root.addApiKeyAdvice(model)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user