From 661fcfd263dd2f30a0499c52d391b2a366e5c2d7 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Fri, 15 Aug 2025 22:07:56 +0700 Subject: [PATCH] ai: add gpt 5 nano via gh models --- .config/quickshell/ii/services/Ai.qml | 81 ++++++++++++------- .../ii/services/ai/OpenAiApiStrategy.qml | 3 + 2 files changed, 53 insertions(+), 31 deletions(-) diff --git a/.config/quickshell/ii/services/Ai.qml b/.config/quickshell/ii/services/Ai.qml index f265d953..9c52097a 100644 --- a/.config/quickshell/ii/services/Ai.qml +++ b/.config/quickshell/ii/services/Ai.qml @@ -132,44 +132,50 @@ Singleton { "openai": { "functions": [ { - "name": "switch_to_search_mode", - "description": "Search the web", + "type": "function", + "function": { + "name": "get_shell_config", + "description": "Get the desktop shell config file contents", + "parameters": {} + }, }, { - "name": "get_shell_config", - "description": "Get the desktop shell config file contents", - }, - { - "name": "set_shell_config", - "description": "Set a field in the desktop graphical shell config file. Must only be used after `get_shell_config`.", - "parameters": { - "type": "object", - "properties": { - "key": { - "type": "string", - "description": "The key to set, e.g. `bar.borderless`. MUST NOT BE GUESSED, use `get_shell_config` to see what keys are available before setting.", + "type": "function", + "function": { + "name": "set_shell_config", + "description": "Set a field in the desktop graphical shell config file. Must only be used after `get_shell_config`.", + "parameters": { + "type": "object", + "properties": { + "key": { + "type": "string", + "description": "The key to set, e.g. `bar.borderless`. MUST NOT BE GUESSED, use `get_shell_config` to see what keys are available before setting.", + }, + "value": { + "type": "string", + "description": "The value to set, e.g. `true`" + } }, - "value": { - "type": "string", - "description": "The value to set, e.g. `true`" - } - }, - "required": ["key", "value"] + "required": ["key", "value"] + } } }, { - "name": "run_shell_command", - "description": "Run a shell command in bash and get its output. Use this only for quick commands that don't require user interaction. For commands that require interaction, ask the user to run manually instead.", - "parameters": { - "type": "object", - "properties": { - "command": { - "type": "string", - "description": "The bash command to run", + "type": "function", + "function": { + "name": "run_shell_command", + "description": "Run a shell command in bash and get its output. Use this only for quick commands that don't require user interaction. For commands that require interaction, ask the user to run manually instead.", + "parameters": { + "type": "object", + "properties": { + "command": { + "type": "string", + "description": "The bash command to run", + }, }, - }, - "required": ["command"] - } + "required": ["command"] + } + }, }, ], "search": [], @@ -313,6 +319,19 @@ Singleton { "key_get_description": Translation.tr("**Instructions**: Log into Mistral account, go to Keys on the sidebar, click Create new key"), "api_format": "mistral", }), + "github-gpt-5-nano": aiModelComponent.createObject(this, { + "name": "GPT-5 Nano (GH Models)", + "icon": "github-symbolic", + "api_format": "openai", + "description": Translation.tr("Online via %1 | %2's model").arg("GitHub Models").arg("OpenAI"), + "homepage": "https://github.com/marketplace/models", + "endpoint": "https://models.inference.ai.azure.com/chat/completions", + "model": "gpt-5-nano", + "requires_key": true, + "key_id": "github", + "key_get_link": "https://github.com/settings/tokens", + "key_get_description": Translation.tr("**Pricing**: Free tier available with limited rates. See https://docs.github.com/en/billing/concepts/product-billing/github-models\n\n**Instructions**: Generate a GitHub personal access token with Models permission, then set as API key here\n\n**Note**: To use this you will have to set the temperature parameter to 1"), + }), "openrouter-deepseek-r1": aiModelComponent.createObject(this, { "name": "DeepSeek R1", "icon": "deepseek-symbolic", diff --git a/.config/quickshell/ii/services/ai/OpenAiApiStrategy.qml b/.config/quickshell/ii/services/ai/OpenAiApiStrategy.qml index 24a0892f..43c53259 100644 --- a/.config/quickshell/ii/services/ai/OpenAiApiStrategy.qml +++ b/.config/quickshell/ii/services/ai/OpenAiApiStrategy.qml @@ -21,6 +21,7 @@ ApiStrategy { }), ], "stream": true, + "tools": tools, "temperature": temperature, }; return model.extraParams ? Object.assign({}, baseData, model.extraParams) : baseData; @@ -36,6 +37,8 @@ ApiStrategy { if (cleanData.startsWith("data:")) { cleanData = cleanData.slice(5).trim(); } + + // console.log("[AI] OpenAI: Data:", cleanData); // Handle special cases if (!cleanData || cleanData.startsWith(":")) return {};