forked from qt-creator/qt-creator
AI Assistant: Settings UI
Change-Id: Icb98ac9869d01295d9e64737766d37e51ba86a76 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
Binary file not shown.
After Width: | Height: | Size: 251 B |
@@ -36,6 +36,27 @@ local function createCommand()
|
|||||||
return cmd
|
return cmd
|
||||||
end
|
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()
|
local function installOrUpdateServer()
|
||||||
-- TODO: Download/Update/Install
|
-- TODO: Download/Update/Install
|
||||||
end
|
end
|
||||||
@@ -47,6 +68,7 @@ local function setupClient()
|
|||||||
name = 'AI Assistant Server',
|
name = 'AI Assistant Server',
|
||||||
cmd = createCommand,
|
cmd = createCommand,
|
||||||
transport = 'stdio',
|
transport = 'stdio',
|
||||||
|
initializationOptions = createInitOptions,
|
||||||
languageFilter = {
|
languageFilter = {
|
||||||
patterns = { '*.*' },
|
patterns = { '*.*' },
|
||||||
},
|
},
|
||||||
@@ -83,12 +105,45 @@ local function layoutSettings()
|
|||||||
br,
|
br,
|
||||||
},
|
},
|
||||||
st
|
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
|
return layout
|
||||||
end
|
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()
|
local function setupAspect()
|
||||||
Settings = S.AspectContainer.create({
|
Settings = S.AspectContainer.create({
|
||||||
autoApply = false,
|
autoApply = false,
|
||||||
@@ -104,6 +159,25 @@ local function setupAspect()
|
|||||||
defaultPath = Utils.FilePath.fromUserInput("/path/to/server"),
|
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
|
return Settings
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@ settings.BaseAspect = {}
|
|||||||
function settings.BaseAspect:apply() end
|
function settings.BaseAspect:apply() end
|
||||||
|
|
||||||
---@class AspectCreate
|
---@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 displayName? string The display name of the aspect.
|
||||||
---@field labelText? string The label text of the aspect.
|
---@field labelText? string The label text of the aspect.
|
||||||
---@field toolTip? string The tool tip of the aspect.
|
---@field toolTip? string The tool tip of the aspect.
|
||||||
|
Reference in New Issue
Block a user