diff --git a/share/qtcreator/lua-plugins/ai_asistant/images/settingscategory_ai_assistant.png b/share/qtcreator/lua-plugins/ai_asistant/images/settingscategory_ai_assistant.png new file mode 100644 index 00000000000..9a47fb24135 Binary files /dev/null and b/share/qtcreator/lua-plugins/ai_asistant/images/settingscategory_ai_assistant.png differ diff --git a/share/qtcreator/lua-plugins/ai_asistant/init.lua b/share/qtcreator/lua-plugins/ai_asistant/init.lua index 62b1d267ced..d4ba0fde6bc 100644 --- a/share/qtcreator/lua-plugins/ai_asistant/init.lua +++ b/share/qtcreator/lua-plugins/ai_asistant/init.lua @@ -36,6 +36,27 @@ local function createCommand() return cmd end +local function createInitOptions() + local llm_config = { + cppLLM = Settings.cppLLM.stringValue, + qmlLLM = Settings.qmlLLM.stringValue, + otherLLM = Settings.otherLLM.stringValue, + debugLLM = Settings.debugLLM.stringValue, + reviewLLM = Settings.reviewLLM.stringValue, + explainLLM = Settings.explainLLM.stringValue + } + + local auth_token_config = { + authTokenLama35 = Settings.authTokenLlama3.value, + authTokenClaude35 = Settings.authTokenClaude35.value + } + + return { + llm_config = llm_config, + auth_token_config = auth_token_config + } +end + local function installOrUpdateServer() -- TODO: Download/Update/Install end @@ -47,6 +68,7 @@ local function setupClient() name = 'AI Assistant Server', cmd = createCommand, transport = 'stdio', + initializationOptions = createInitOptions, languageFilter = { patterns = { '*.*' }, }, @@ -83,12 +105,45 @@ local function layoutSettings() br, }, st - } + }, + br, + Settings.cppLLM, br, + Settings.qmlLLM, br, + Settings.otherLLM, br, + Settings.debugLLM, br, + Settings.reviewLLM, br, + Settings.explainLLM, br, + Settings.authTokenLlama3, br, + Settings.authTokenClaude35 } return layout end +local available_llms = {"Llama 3 70B Fine-Tuned", "Claude 3.5 Sonnet"} + +local function createSelectionAspect(settingsKey, displayName) + return S.SelectionAspect.create({ + settingsKey = settingsKey, + options = available_llms, + displayStyle = S.SelectionDisplayStyle.ComboBox, + displayName = displayName + }) +end + +local function addLLMSetting(keySuffix, displayText) + Settings[keySuffix] = createSelectionAspect("AiAssistant." .. keySuffix, displayText) +end + +local function addAuthTokenSetting(llm_name, displayText) + Settings["authToken" .. llm_name] = S.StringAspect.create({ + settingsKey = "AiAssistant.AuthToken." .. llm_name, + labelText = displayText .. ":", + displayStyle = S.StringDisplayStyle.LineEdit, + defaultValue = "AUTH_TOKEN", + }) +end + local function setupAspect() Settings = S.AspectContainer.create({ autoApply = false, @@ -104,6 +159,25 @@ local function setupAspect() defaultPath = Utils.FilePath.fromUserInput("/path/to/server"), }) + addLLMSetting("cppLLM", "LLM for C++:") + addLLMSetting("qmlLLM", "LLM for QML:") + addLLMSetting("otherLLM", "LLM for other languages:") + addLLMSetting("debugLLM", "LLM for debug:") + addLLMSetting("reviewLLM", "LLM for review") + addLLMSetting("explainLLM", "LLM for explain:") + + addAuthTokenSetting("Llama3", "Llama 3 API authentication Token") + addAuthTokenSetting("Claude35", "Claude 3.5 API authentication Token") + + Options = S.OptionsPage.create({ + aspectContainer = Settings, + categoryId = "AiAssistant.OptionsPage", + displayName = tr("AI Assistant"), + id = "AiAssistant.Settings", + displayCategory = "AI Assistant", + categoryIconPath = PluginSpec.pluginDirectory:resolvePath("images/settingscategory_ai_assistant.png") + }) + return Settings end diff --git a/src/plugins/lua/meta/settings.lua b/src/plugins/lua/meta/settings.lua index caa8a5301a2..97f60d53b7e 100644 --- a/src/plugins/lua/meta/settings.lua +++ b/src/plugins/lua/meta/settings.lua @@ -12,7 +12,7 @@ settings.BaseAspect = {} function settings.BaseAspect:apply() end ---@class AspectCreate ----@field settingsKey? string The settings key of the aspect. +---@field settingsKey? string The settings key of the aspect. If not set, the aspect will not be saved to the settings persistently. ---@field displayName? string The display name of the aspect. ---@field labelText? string The label text of the aspect. ---@field toolTip? string The tool tip of the aspect.