feat: Add llama.cpp api key support

This commit is contained in:
Petr Mironychev
2026-04-24 10:57:38 +02:00
parent 6a8fbe1792
commit e0ab5080ea
4 changed files with 20 additions and 1 deletions

View File

@@ -9,6 +9,7 @@
#include "settings/CodeCompletionSettings.hpp" #include "settings/CodeCompletionSettings.hpp"
#include "settings/QuickRefactorSettings.hpp" #include "settings/QuickRefactorSettings.hpp"
#include "settings/GeneralSettings.hpp" #include "settings/GeneralSettings.hpp"
#include "settings/ProviderSettings.hpp"
#include "tools/ToolsRegistration.hpp" #include "tools/ToolsRegistration.hpp"
#include <QJsonArray> #include <QJsonArray>
@@ -31,7 +32,7 @@ QString LlamaCppProvider::name() const
QString LlamaCppProvider::apiKey() const QString LlamaCppProvider::apiKey() const
{ {
return {}; return Settings::providerSettings().llamaCppApiKey();
} }
QString LlamaCppProvider::url() const QString LlamaCppProvider::url() const

View File

@@ -97,6 +97,15 @@ ProviderSettings::ProviderSettings()
ollamaBasicAuthApiKey.setDefaultValue(""); ollamaBasicAuthApiKey.setDefaultValue("");
ollamaBasicAuthApiKey.setAutoApply(true); ollamaBasicAuthApiKey.setAutoApply(true);
// llama.cpp Settings
llamaCppApiKey.setSettingsKey(Constants::LLAMA_CPP_API_KEY);
llamaCppApiKey.setLabelText(Tr::tr("llama.cpp API Key:"));
llamaCppApiKey.setDisplayStyle(Utils::StringAspect::LineEditDisplay);
llamaCppApiKey.setPlaceHolderText(Tr::tr("Enter your API key here"));
llamaCppApiKey.setHistoryCompleter(Constants::LLAMA_CPP_API_KEY_HISTORY);
llamaCppApiKey.setDefaultValue("");
llamaCppApiKey.setAutoApply(true);
resetToDefaults.m_buttonText = Tr::tr("Reset Page to Defaults"); resetToDefaults.m_buttonText = Tr::tr("Reset Page to Defaults");
readSettings(); readSettings();
@@ -122,6 +131,8 @@ ProviderSettings::ProviderSettings()
Group{title(Tr::tr("Google AI Settings")), Column{googleAiApiKey}}, Group{title(Tr::tr("Google AI Settings")), Column{googleAiApiKey}},
Space{8}, Space{8},
Group{title(Tr::tr("Ollama Settings")), Column{ollamaBasicAuthApiKey}}, Group{title(Tr::tr("Ollama Settings")), Column{ollamaBasicAuthApiKey}},
Space{8},
Group{title(Tr::tr("llama.cpp Settings")), Column{llamaCppApiKey}},
Stretch{1}}; Stretch{1}};
}); });
} }
@@ -150,6 +161,9 @@ void ProviderSettings::setupConnections()
connect(&ollamaBasicAuthApiKey, &ButtonAspect::changed, this, [this]() { connect(&ollamaBasicAuthApiKey, &ButtonAspect::changed, this, [this]() {
ollamaBasicAuthApiKey.writeSettings(); ollamaBasicAuthApiKey.writeSettings();
}); });
connect(&llamaCppApiKey, &ButtonAspect::changed, this, [this]() {
llamaCppApiKey.writeSettings();
});
} }
void ProviderSettings::resetSettingsToDefaults() void ProviderSettings::resetSettingsToDefaults()
@@ -169,6 +183,7 @@ void ProviderSettings::resetSettingsToDefaults()
resetAspect(mistralAiApiKey); resetAspect(mistralAiApiKey);
resetAspect(googleAiApiKey); resetAspect(googleAiApiKey);
resetAspect(ollamaBasicAuthApiKey); resetAspect(ollamaBasicAuthApiKey);
resetAspect(llamaCppApiKey);
writeSettings(); writeSettings();
} }
} }

View File

@@ -25,6 +25,7 @@ public:
Utils::StringAspect codestralApiKey{this}; Utils::StringAspect codestralApiKey{this};
Utils::StringAspect googleAiApiKey{this}; Utils::StringAspect googleAiApiKey{this};
Utils::StringAspect ollamaBasicAuthApiKey{this}; Utils::StringAspect ollamaBasicAuthApiKey{this};
Utils::StringAspect llamaCppApiKey{this};
private: private:
void setupConnections(); void setupConnections();

View File

@@ -145,6 +145,8 @@ const char GOOGLE_AI_API_KEY[] = "QodeAssist.googleAiApiKey";
const char GOOGLE_AI_API_KEY_HISTORY[] = "QodeAssist.googleAiApiKeyHistory"; const char GOOGLE_AI_API_KEY_HISTORY[] = "QodeAssist.googleAiApiKeyHistory";
const char OLLAMA_BASIC_AUTH_API_KEY[] = "QodeAssist.ollamaBasicAuthApiKey"; const char OLLAMA_BASIC_AUTH_API_KEY[] = "QodeAssist.ollamaBasicAuthApiKey";
const char OLLAMA_BASIC_AUTH_API_KEY_HISTORY[] = "QodeAssist.ollamaBasicAuthApiKeyHistory"; const char OLLAMA_BASIC_AUTH_API_KEY_HISTORY[] = "QodeAssist.ollamaBasicAuthApiKeyHistory";
const char LLAMA_CPP_API_KEY[] = "QodeAssist.llamaCppApiKey";
const char LLAMA_CPP_API_KEY_HISTORY[] = "QodeAssist.llamaCppApiKeyHistory";
// context settings // context settings
const char CC_READ_FULL_FILE[] = "QodeAssist.ccReadFullFile"; const char CC_READ_FULL_FILE[] = "QodeAssist.ccReadFullFile";