mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2025-05-27 10:50:28 -04:00
Merge pull request #4 from Palm1r/version-0.0.6
Version 0.0.6 - Fix authorization to API - Fix reset to provider default settings after reboot qtc
This commit is contained in:
commit
ec26a31ec5
@ -282,10 +282,7 @@ LLMClientInterface::ContextPair LLMClientInterface::prepareContext(
|
||||
|
||||
void LLMClientInterface::updateProvider()
|
||||
{
|
||||
m_serverUrl = QUrl(QString("%1:%2%3")
|
||||
.arg(settings().url.value())
|
||||
.arg(settings().port.value())
|
||||
.arg(settings().endPoint.value()));
|
||||
m_serverUrl = QUrl(QString("%1%2").arg(settings().url(), settings().endPoint()));
|
||||
}
|
||||
|
||||
void LLMClientInterface::sendCompletionToClient(const QString &completion,
|
||||
@ -324,22 +321,29 @@ void LLMClientInterface::sendCompletionToClient(const QString &completion,
|
||||
|
||||
void LLMClientInterface::sendLLMRequest(const QJsonObject &request, const ContextPair &prompt)
|
||||
{
|
||||
QJsonObject qodeRequest = {{"model", settings().modelName.value()}, {"stream", true}};
|
||||
QJsonObject providerRequest = {{"model", settings().modelName.value()}, {"stream", true}};
|
||||
|
||||
auto currentTemplate = PromptTemplateManager::instance().getCurrentTemplate();
|
||||
currentTemplate->prepareRequest(qodeRequest, prompt.prefix, prompt.suffix);
|
||||
currentTemplate->prepareRequest(providerRequest, prompt.prefix, prompt.suffix);
|
||||
|
||||
auto &providerManager = LLMProvidersManager::instance();
|
||||
providerManager.getCurrentProvider()->prepareRequest(qodeRequest);
|
||||
providerManager.getCurrentProvider()->prepareRequest(providerRequest);
|
||||
|
||||
logMessage(
|
||||
QString("Sending request to llm: \nurl: %1\nRequest body:\n%2")
|
||||
.arg(m_serverUrl.toString())
|
||||
.arg(QString::fromUtf8(QJsonDocument(qodeRequest).toJson(QJsonDocument::Indented))));
|
||||
logMessage(QString("Sending request to llm: \nurl: %1\nRequest body:\n%2")
|
||||
.arg(m_serverUrl.toString(),
|
||||
QString::fromUtf8(
|
||||
QJsonDocument(providerRequest).toJson(QJsonDocument::Indented))));
|
||||
|
||||
QNetworkRequest networkRequest(m_serverUrl);
|
||||
networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
|
||||
QNetworkReply *reply = m_manager->post(networkRequest, QJsonDocument(qodeRequest).toJson());
|
||||
|
||||
if (providerRequest.contains("api_key")) {
|
||||
QString apiKey = providerRequest["api_key"].toString();
|
||||
networkRequest.setRawHeader("Authorization", QString("Bearer %1").arg(apiKey).toUtf8());
|
||||
providerRequest.remove("api_key");
|
||||
}
|
||||
|
||||
QNetworkReply *reply = m_manager->post(networkRequest, QJsonDocument(providerRequest).toJson());
|
||||
if (!reply) {
|
||||
logMessage("Error: Failed to create network reply");
|
||||
return;
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"Name" : "QodeAssist",
|
||||
"Version" : "0.0.5",
|
||||
"Version" : "0.0.6",
|
||||
"CompatVersion" : "${IDE_VERSION_COMPAT}",
|
||||
"Vendor" : "Petr Mironychev",
|
||||
"Copyright" : "(C) ${IDE_COPYRIGHT_YEAR} Petr Mironychev, (C) ${IDE_COPYRIGHT_YEAR} The Qt Company Ltd",
|
||||
|
@ -30,7 +30,6 @@ const char ENABLE_AUTO_COMPLETE[] = "QodeAssist.enableAutoComplete";
|
||||
const char ENABLE_LOGGING[] = "QodeAssist.enableLogging";
|
||||
const char LLM_PROVIDERS[] = "QodeAssist.llmProviders";
|
||||
const char URL[] = "QodeAssist.url";
|
||||
const char PORT[] = "QodeAssist.port";
|
||||
const char END_POINT[] = "QodeAssist.endPoint";
|
||||
const char MODEL_NAME[] = "QodeAssist.modelName";
|
||||
const char SELECT_MODELS[] = "QodeAssist.selectModels";
|
||||
|
@ -68,10 +68,6 @@ QodeAssistSettings::QodeAssistSettings()
|
||||
endPoint.setLabelText(Tr::tr("Endpoint:"));
|
||||
endPoint.setDisplayStyle(Utils::StringAspect::LineEditDisplay);
|
||||
|
||||
port.setSettingsKey(Constants::PORT);
|
||||
port.setLabelText(Tr::tr("Port:"));
|
||||
port.setRange(1, 65535);
|
||||
|
||||
modelName.setSettingsKey(Constants::MODEL_NAME);
|
||||
modelName.setLabelText(Tr::tr("LLM Name:"));
|
||||
modelName.setDisplayStyle(Utils::StringAspect::LineEditDisplay);
|
||||
@ -201,7 +197,6 @@ QodeAssistSettings::QodeAssistSettings()
|
||||
readStringsBeforeCursor.setEnabled(!readFullFile());
|
||||
PromptTemplateManager::instance().setCurrentTemplate(fimPrompts.stringValue());
|
||||
LLMProvidersManager::instance().setCurrentProvider(llmProviders.stringValue());
|
||||
updateProviderSettings();
|
||||
|
||||
setLoggingEnabled(enableLogging());
|
||||
|
||||
@ -215,7 +210,7 @@ QodeAssistSettings::QodeAssistSettings()
|
||||
enableLogging,
|
||||
Row{Stretch{1}, resetToDefaults}}}},
|
||||
Group{title(Tr::tr("LLM Providers")),
|
||||
Form{Column{llmProviders, Row{url, port, endPoint}, providerPaths}}},
|
||||
Form{Column{llmProviders, Row{url, endPoint}, providerPaths}}},
|
||||
Group{title(Tr::tr("LLM Model Settings")),
|
||||
Form{Column{Row{selectModels, modelName}}}},
|
||||
Group{title(Tr::tr("FIM Prompt Settings")),
|
||||
@ -288,7 +283,6 @@ void QodeAssistSettings::updateProviderSettings()
|
||||
if (provider) {
|
||||
logMessage(QString("currentProvider %1").arg(provider->name()));
|
||||
url.setValue(provider->url());
|
||||
port.setValue(provider->defaultPort());
|
||||
endPoint.setValue(provider->completionEndpoint());
|
||||
ollamaLivetime.setEnabled(provider->name() == "Ollama");
|
||||
}
|
||||
@ -347,7 +341,6 @@ void QodeAssistSettings::resetSettingsToDefaults()
|
||||
resetAspect(enableAutoComplete);
|
||||
resetAspect(llmProviders);
|
||||
resetAspect(url);
|
||||
resetAspect(port);
|
||||
resetAspect(endPoint);
|
||||
resetAspect(modelName);
|
||||
resetAspect(fimPrompts);
|
||||
|
@ -63,7 +63,6 @@ public:
|
||||
|
||||
Utils::SelectionAspect llmProviders{this};
|
||||
Utils::StringAspect url{this};
|
||||
Utils::IntegerAspect port{this};
|
||||
Utils::StringAspect endPoint{this};
|
||||
|
||||
Utils::StringAspect modelName{this};
|
||||
|
@ -34,7 +34,6 @@ public:
|
||||
|
||||
virtual QString name() const = 0;
|
||||
virtual QString url() const = 0;
|
||||
virtual int defaultPort() const = 0;
|
||||
virtual QString completionEndpoint() const = 0;
|
||||
|
||||
virtual void prepareRequest(QJsonObject &request) = 0;
|
||||
|
@ -39,12 +39,7 @@ QString LMStudioProvider::name() const
|
||||
|
||||
QString LMStudioProvider::url() const
|
||||
{
|
||||
return "http://localhost";
|
||||
}
|
||||
|
||||
int LMStudioProvider::defaultPort() const
|
||||
{
|
||||
return 1234;
|
||||
return "http://localhost:1234";
|
||||
}
|
||||
|
||||
QString LMStudioProvider::completionEndpoint() const
|
||||
|
@ -30,7 +30,6 @@ public:
|
||||
|
||||
QString name() const override;
|
||||
QString url() const override;
|
||||
int defaultPort() const override;
|
||||
QString completionEndpoint() const override;
|
||||
void prepareRequest(QJsonObject &request) override;
|
||||
bool handleResponse(QNetworkReply *reply, QString &accumulatedResponse) override;
|
||||
|
@ -39,12 +39,7 @@ QString OllamaProvider::name() const
|
||||
|
||||
QString OllamaProvider::url() const
|
||||
{
|
||||
return "http://localhost";
|
||||
}
|
||||
|
||||
int OllamaProvider::defaultPort() const
|
||||
{
|
||||
return 11434;
|
||||
return "http://localhost:11434";
|
||||
}
|
||||
|
||||
QString OllamaProvider::completionEndpoint() const
|
||||
|
@ -30,7 +30,6 @@ public:
|
||||
|
||||
QString name() const override;
|
||||
QString url() const override;
|
||||
int defaultPort() const override;
|
||||
QString completionEndpoint() const override;
|
||||
void prepareRequest(QJsonObject &request) override;
|
||||
bool handleResponse(QNetworkReply *reply, QString &accumulatedResponse) override;
|
||||
|
@ -39,12 +39,7 @@ QString OpenAICompatProvider::name() const
|
||||
|
||||
QString OpenAICompatProvider::url() const
|
||||
{
|
||||
return "http://localhost";
|
||||
}
|
||||
|
||||
int OpenAICompatProvider::defaultPort() const
|
||||
{
|
||||
return 1234;
|
||||
return "http://localhost:1234";
|
||||
}
|
||||
|
||||
QString OpenAICompatProvider::completionEndpoint() const
|
||||
|
@ -30,7 +30,6 @@ public:
|
||||
|
||||
QString name() const override;
|
||||
QString url() const override;
|
||||
int defaultPort() const override;
|
||||
QString completionEndpoint() const override;
|
||||
void prepareRequest(QJsonObject &request) override;
|
||||
bool handleResponse(QNetworkReply *reply, QString &accumulatedResponse) override;
|
||||
|
Loading…
Reference in New Issue
Block a user