feat: Add chat-agent switcher in chat ui (#247)

* feat: Add chat-agent switcher in chat ui

fix: qml errors

refactor: Change top bar layout

fix: default value

* fix: update github action for qtc
This commit is contained in:
Petr Mironychev
2025-10-31 16:09:38 +01:00
committed by GitHub
parent 9117572f82
commit db82fb08e8
27 changed files with 244 additions and 140 deletions

View File

@ -199,7 +199,7 @@ jobs:
endif() endif()
- name: Download Qt Creator - name: Download Qt Creator
uses: qt-creator/install-dev-package@4046eda2efa77c0fe61d4cde7e622c050a4d65af uses: qt-creator/install-dev-package@1460787a21551eb3d867b0de30e8d3f1aadef5ac
with: with:
version: ${{ matrix.qt_config.qt_creator_version }} version: ${{ matrix.qt_config.qt_creator_version }}
unzip-to: 'qtcreator' unzip-to: 'qtcreator'

View File

@ -49,6 +49,7 @@ ChatRootView::ChatRootView(QQuickItem *parent)
, m_promptProvider(LLMCore::PromptTemplateManager::instance()) , m_promptProvider(LLMCore::PromptTemplateManager::instance())
, m_clientInterface(new ClientInterface(m_chatModel, &m_promptProvider, this)) , m_clientInterface(new ClientInterface(m_chatModel, &m_promptProvider, this))
, m_isRequestInProgress(false) , m_isRequestInProgress(false)
, m_isAgentMode(false)
{ {
m_isSyncOpenFiles = Settings::chatAssistantSettings().linkOpenFiles(); m_isSyncOpenFiles = Settings::chatAssistantSettings().linkOpenFiles();
connect( connect(
@ -142,12 +143,20 @@ ChatRootView::ChatRootView(QQuickItem *parent)
updateInputTokensCount(); updateInputTokensCount();
refreshRules(); refreshRules();
// Refresh rules when project changes
connect( connect(
ProjectExplorer::ProjectManager::instance(), ProjectExplorer::ProjectManager::instance(),
&ProjectExplorer::ProjectManager::startupProjectChanged, &ProjectExplorer::ProjectManager::startupProjectChanged,
this, this,
&ChatRootView::refreshRules); &ChatRootView::refreshRules);
QSettings appSettings;
m_isAgentMode = appSettings.value("QodeAssist/Chat/AgentMode", true).toBool();
connect(
&Settings::generalSettings().useTools,
&Utils::BaseAspect::changed,
this,
&ChatRootView::toolsSupportEnabledChanged);
} }
ChatModel *ChatRootView::chatModel() const ChatModel *ChatRootView::chatModel() const
@ -173,7 +182,7 @@ void ChatRootView::sendMessage(const QString &message)
} }
} }
m_clientInterface->sendMessage(message, m_attachmentFiles, m_linkedFiles); m_clientInterface->sendMessage(message, m_attachmentFiles, m_linkedFiles, m_isAgentMode);
clearAttachmentFiles(); clearAttachmentFiles();
setRequestProgressStatus(true); setRequestProgressStatus(true);
} }
@ -704,4 +713,26 @@ void ChatRootView::refreshRules()
emit activeRulesCountChanged(); emit activeRulesCountChanged();
} }
bool ChatRootView::isAgentMode() const
{
return m_isAgentMode;
}
void ChatRootView::setIsAgentMode(bool newIsAgentMode)
{
if (m_isAgentMode != newIsAgentMode) {
m_isAgentMode = newIsAgentMode;
QSettings settings;
settings.setValue("QodeAssist/Chat/AgentMode", newIsAgentMode);
emit isAgentModeChanged();
}
}
bool ChatRootView::toolsSupportEnabled() const
{
return Settings::generalSettings().useTools();
}
} // namespace QodeAssist::Chat } // namespace QodeAssist::Chat

View File

@ -47,6 +47,9 @@ class ChatRootView : public QQuickItem
Q_PROPERTY(QString lastErrorMessage READ lastErrorMessage NOTIFY lastErrorMessageChanged FINAL) Q_PROPERTY(QString lastErrorMessage READ lastErrorMessage NOTIFY lastErrorMessageChanged FINAL)
Q_PROPERTY(QVariantList activeRules READ activeRules NOTIFY activeRulesChanged FINAL) Q_PROPERTY(QVariantList activeRules READ activeRules NOTIFY activeRulesChanged FINAL)
Q_PROPERTY(int activeRulesCount READ activeRulesCount NOTIFY activeRulesCountChanged FINAL) Q_PROPERTY(int activeRulesCount READ activeRulesCount NOTIFY activeRulesCountChanged FINAL)
Q_PROPERTY(bool isAgentMode READ isAgentMode WRITE setIsAgentMode NOTIFY isAgentModeChanged FINAL)
Q_PROPERTY(
bool toolsSupportEnabled READ toolsSupportEnabled NOTIFY toolsSupportEnabledChanged FINAL)
QML_ELEMENT QML_ELEMENT
@ -107,6 +110,10 @@ public:
Q_INVOKABLE QString getRuleContent(int index); Q_INVOKABLE QString getRuleContent(int index);
Q_INVOKABLE void refreshRules(); Q_INVOKABLE void refreshRules();
bool isAgentMode() const;
void setIsAgentMode(bool newIsAgentMode);
bool toolsSupportEnabled() const;
public slots: public slots:
void sendMessage(const QString &message); void sendMessage(const QString &message);
void copyToClipboard(const QString &text); void copyToClipboard(const QString &text);
@ -134,6 +141,9 @@ signals:
void activeRulesChanged(); void activeRulesChanged();
void activeRulesCountChanged(); void activeRulesCountChanged();
void isAgentModeChanged();
void toolsSupportEnabledChanged();
private: private:
QString getChatsHistoryDir() const; QString getChatsHistoryDir() const;
QString getSuggestedFileName() const; QString getSuggestedFileName() const;
@ -152,6 +162,7 @@ private:
bool m_isRequestInProgress; bool m_isRequestInProgress;
QString m_lastErrorMessage; QString m_lastErrorMessage;
QVariantList m_activeRules; QVariantList m_activeRules;
bool m_isAgentMode;
}; };
} // namespace QodeAssist::Chat } // namespace QodeAssist::Chat

View File

@ -55,7 +55,10 @@ ClientInterface::ClientInterface(
ClientInterface::~ClientInterface() = default; ClientInterface::~ClientInterface() = default;
void ClientInterface::sendMessage( void ClientInterface::sendMessage(
const QString &message, const QList<QString> &attachments, const QList<QString> &linkedFiles) const QString &message,
const QList<QString> &attachments,
const QList<QString> &linkedFiles,
bool useAgentMode)
{ {
cancelRequest(); cancelRequest();
m_accumulatedResponses.clear(); m_accumulatedResponses.clear();
@ -83,10 +86,12 @@ void ClientInterface::sendMessage(
LLMCore::ContextData context; LLMCore::ContextData context;
const bool isToolsEnabled = Settings::generalSettings().useTools() && useAgentMode;
if (chatAssistantSettings.useSystemPrompt()) { if (chatAssistantSettings.useSystemPrompt()) {
QString systemPrompt = chatAssistantSettings.systemPrompt(); QString systemPrompt = chatAssistantSettings.systemPrompt();
if (Settings::generalSettings().useTools()) { if (isToolsEnabled) {
systemPrompt += "\n\n# Tool Usage Guidelines\n\n" systemPrompt += "\n\n# Tool Usage Guidelines\n\n"
"**Multi-tool workflows:**\n" "**Multi-tool workflows:**\n"
"- Code structure: search_project (symbol mode) → find_and_read_file\n" "- Code structure: search_project (symbol mode) → find_and_read_file\n"
@ -140,8 +145,8 @@ void ClientInterface::sendMessage(
config.apiKey = provider->apiKey(); config.apiKey = provider->apiKey();
config.provider config.provider->prepareRequest(
->prepareRequest(config.providerRequest, promptTemplate, context, LLMCore::RequestType::Chat); config.providerRequest, promptTemplate, context, LLMCore::RequestType::Chat, isToolsEnabled);
QString requestId = QUuid::createUuid().toString(); QString requestId = QUuid::createUuid().toString();
QJsonObject request{{"id", requestId}}; QJsonObject request{{"id", requestId}};

View File

@ -42,7 +42,8 @@ public:
void sendMessage( void sendMessage(
const QString &message, const QString &message,
const QList<QString> &attachments = {}, const QList<QString> &attachments = {},
const QList<QString> &linkedFiles = {}); const QList<QString> &linkedFiles = {},
bool useAgentMode = false);
void clearMessages(); void clearMessages();
void cancelRequest(); void cancelRequest();

View File

@ -65,7 +65,7 @@ ChatRootView {
id: topBar id: topBar
Layout.preferredWidth: parent.width Layout.preferredWidth: parent.width
Layout.preferredHeight: 40 Layout.preferredHeight: childrenRect.height + 10
saveButton.onClicked: root.showSaveDialog() saveButton.onClicked: root.showSaveDialog()
loadButton.onClicked: root.showLoadDialog() loadButton.onClicked: root.showLoadDialog()
@ -74,7 +74,7 @@ ChatRootView {
text: qsTr("%1/%2").arg(root.inputTokensCount).arg(root.chatModel.tokensThreshold) text: qsTr("%1/%2").arg(root.inputTokensCount).arg(root.chatModel.tokensThreshold)
} }
recentPath { recentPath {
text: qsTr("Latest chat file name: %1").arg(root.chatFileName.length > 0 ? root.chatFileName : "Unsaved") text: qsTr("Сhat name: %1").arg(root.chatFileName.length > 0 ? root.chatFileName : "Unsaved")
} }
openChatHistory.onClicked: root.openChatHistoryFolder() openChatHistory.onClicked: root.openChatHistoryFolder()
rulesButton.onClicked: rulesViewer.open() rulesButton.onClicked: rulesViewer.open()
@ -84,6 +84,13 @@ ChatRootView {
checked: typeof _chatview !== 'undefined' ? _chatview.isPin : false checked: typeof _chatview !== 'undefined' ? _chatview.isPin : false
onCheckedChanged: _chatview.isPin = topBar.pinButton.checked onCheckedChanged: _chatview.isPin = topBar.pinButton.checked
} }
agentModeSwitch {
checked: root.isAgentMode
enabled: root.toolsSupportEnabled
onCheckedChanged: {
root.isAgentMode = agentModeSwitch.checked
}
}
} }
ListView { ListView {
@ -108,7 +115,7 @@ ChatRootView {
if (model.roleType === ChatModel.Tool) { if (model.roleType === ChatModel.Tool) {
return toolMessageComponent return toolMessageComponent
} else if (model.roleType === ChatModel.FileEdit) { } else if (model.roleType === ChatModel.FileEdit) {
return fileEditSuggestionComponent return toolMessageComponent
} else { } else {
return chatItemComponent return chatItemComponent
} }

View File

@ -34,21 +34,20 @@ Rectangle {
property alias openChatHistory: openChatHistoryId property alias openChatHistory: openChatHistoryId
property alias pinButton: pinButtonId property alias pinButton: pinButtonId
property alias rulesButton: rulesButtonId property alias rulesButton: rulesButtonId
property alias agentModeSwitch: agentModeSwitchId
property alias activeRulesCount: activeRulesCountId.text property alias activeRulesCount: activeRulesCountId.text
color: palette.window.hslLightness > 0.5 ? color: palette.window.hslLightness > 0.5 ?
Qt.darker(palette.window, 1.1) : Qt.darker(palette.window, 1.1) :
Qt.lighter(palette.window, 1.1) Qt.lighter(palette.window, 1.1)
RowLayout { Flow {
anchors { anchors {
left: parent.left left: parent.left
leftMargin: 5
right: parent.right right: parent.right
rightMargin: 5
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
margins: 5
} }
spacing: 10 spacing: 10
QoAButton { QoAButton {
@ -69,107 +68,144 @@ Rectangle {
: qsTr("Pin chat window to the top") : qsTr("Pin chat window to the top")
} }
QoAButton { QoATextSlider {
id: saveButtonId id: agentModeSwitchId
icon { leftText: "chat"
source: "qrc:/qt/qml/ChatView/icons/save-chat-dark.svg" rightText: "AI Agent"
height: 15
width: 8
}
ToolTip.visible: hovered
ToolTip.delay: 250
ToolTip.text: qsTr("Save chat to *.json file")
}
QoAButton {
id: loadButtonId
icon {
source: "qrc:/qt/qml/ChatView/icons/load-chat-dark.svg"
height: 15
width: 8
}
ToolTip.visible: hovered
ToolTip.delay: 250
ToolTip.text: qsTr("Load chat from *.json file")
}
QoAButton {
id: clearButtonId
icon {
source: "qrc:/qt/qml/ChatView/icons/clean-icon-dark.svg"
height: 15
width: 8
}
ToolTip.visible: hovered
ToolTip.delay: 250
ToolTip.text: qsTr("Clean chat")
}
Text {
id: recentPathId
elide: Text.ElideMiddle
color: palette.text
}
QoAButton {
id: openChatHistoryId
icon {
source: "qrc:/qt/qml/ChatView/icons/file-in-system.svg"
height: 15
width: 15
}
ToolTip.visible: hovered
ToolTip.delay: 250
ToolTip.text: qsTr("Show in system")
}
QoAButton {
id: rulesButtonId
icon {
source: "qrc:/qt/qml/ChatView/icons/rules-icon.svg"
height: 15
width: 15
}
text: " "
ToolTip.visible: hovered ToolTip.visible: hovered
ToolTip.delay: 250 ToolTip.delay: 250
ToolTip.text: root.activeRulesCount > 0 ToolTip.text: {
? qsTr("View active project rules (%1)").arg(root.activeRulesCount) if (!agentModeSwitchId.enabled) {
: qsTr("View active project rules (no rules found)") return qsTr("Tools are disabled in General Settings")
Text {
id: activeRulesCountId
anchors {
bottom: parent.bottom
bottomMargin: 2
right: parent.right
rightMargin: 4
} }
return checked
color: palette.text ? qsTr("Agent Mode: AI can use tools to read files, search project, and build code")
font.pixelSize: 10 : qsTr("Chat Mode: Simple conversation without tool access")
font.bold: true
} }
} }
Item { Item {
Layout.fillWidth: true height: agentModeSwitchId.height
width: recentPathId.width
Text {
id: recentPathId
anchors.verticalCenter: parent.verticalCenter
width: Math.min(implicitWidth, root.width)
elide: Text.ElideMiddle
color: palette.text
font.pixelSize: 12
MouseArea {
anchors.fill: parent
hoverEnabled: true
ToolTip.visible: containsMouse
ToolTip.delay: 500
ToolTip.text: recentPathId.text
}
}
} }
Badge { RowLayout {
id: tokensBadgeId Layout.preferredWidth: root.width
ToolTip.visible: hovered spacing: 10
ToolTip.delay: 250
ToolTip.text: qsTr("Current amount tokens in chat and LLM limit threshold") QoAButton {
id: saveButtonId
icon {
source: "qrc:/qt/qml/ChatView/icons/save-chat-dark.svg"
height: 15
width: 8
}
ToolTip.visible: hovered
ToolTip.delay: 250
ToolTip.text: qsTr("Save chat to *.json file")
}
QoAButton {
id: loadButtonId
icon {
source: "qrc:/qt/qml/ChatView/icons/load-chat-dark.svg"
height: 15
width: 8
}
ToolTip.visible: hovered
ToolTip.delay: 250
ToolTip.text: qsTr("Load chat from *.json file")
}
QoAButton {
id: clearButtonId
icon {
source: "qrc:/qt/qml/ChatView/icons/clean-icon-dark.svg"
height: 15
width: 8
}
ToolTip.visible: hovered
ToolTip.delay: 250
ToolTip.text: qsTr("Clean chat")
}
QoAButton {
id: openChatHistoryId
icon {
source: "qrc:/qt/qml/ChatView/icons/file-in-system.svg"
height: 15
width: 15
}
ToolTip.visible: hovered
ToolTip.delay: 250
ToolTip.text: qsTr("Show in system")
}
QoAButton {
id: rulesButtonId
icon {
source: "qrc:/qt/qml/ChatView/icons/rules-icon.svg"
height: 15
width: 15
}
text: " "
ToolTip.visible: hovered
ToolTip.delay: 250
ToolTip.text: root.activeRulesCount > 0
? qsTr("View active project rules (%1)").arg(root.activeRulesCount)
: qsTr("View active project rules (no rules found)")
Text {
id: activeRulesCountId
anchors {
bottom: parent.bottom
bottomMargin: 2
right: parent.right
rightMargin: 4
}
color: palette.text
font.pixelSize: 10
font.bold: true
}
}
Badge {
id: tokensBadgeId
ToolTip.visible: hovered
ToolTip.delay: 250
ToolTip.text: qsTr("Current amount tokens in chat and LLM limit threshold")
}
} }
} }
} }

View File

@ -292,7 +292,8 @@ void LLMClientInterface::handleCompletion(const QJsonObject &request)
config.providerRequest, config.providerRequest,
promptTemplate, promptTemplate,
updatedContext, updatedContext,
LLMCore::RequestType::CodeCompletion); LLMCore::RequestType::CodeCompletion,
false);
auto errors = config.provider->validateRequest(config.providerRequest, promptTemplate->type()); auto errors = config.provider->validateRequest(config.providerRequest, promptTemplate->type());
if (!errors.isEmpty()) { if (!errors.isEmpty()) {

View File

@ -145,7 +145,11 @@ void QuickRefactorHandler::prepareAndSendRequest(
LLMCore::ContextData context = prepareContext(editor, range, instructions); LLMCore::ContextData context = prepareContext(editor, range, instructions);
provider->prepareRequest( provider->prepareRequest(
config.providerRequest, promptTemplate, context, LLMCore::RequestType::QuickRefactoring); config.providerRequest,
promptTemplate,
context,
LLMCore::RequestType::QuickRefactoring,
false);
QString requestId = QUuid::createUuid().toString(); QString requestId = QUuid::createUuid().toString();
m_lastRequestId = requestId; m_lastRequestId = requestId;

View File

@ -143,7 +143,6 @@ Item {
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
cursorShape: root.enabled ? Qt.PointingHandCursor : Qt.ArrowCursor cursorShape: root.enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
enabled: root.enabled
onClicked: { onClicked: {
if (root.enabled) { if (root.enabled) {

View File

@ -52,7 +52,8 @@ public:
QJsonObject &request, QJsonObject &request,
LLMCore::PromptTemplate *prompt, LLMCore::PromptTemplate *prompt,
LLMCore::ContextData context, LLMCore::ContextData context,
LLMCore::RequestType type) LLMCore::RequestType type,
bool isToolsEnabled)
= 0; = 0;
virtual QList<QString> getInstalledModels(const QString &url) = 0; virtual QList<QString> getInstalledModels(const QString &url) = 0;
virtual QList<QString> validateRequest(const QJsonObject &request, TemplateType type) = 0; virtual QList<QString> validateRequest(const QJsonObject &request, TemplateType type) = 0;

View File

@ -75,7 +75,8 @@ void ClaudeProvider::prepareRequest(
QJsonObject &request, QJsonObject &request,
LLMCore::PromptTemplate *prompt, LLMCore::PromptTemplate *prompt,
LLMCore::ContextData context, LLMCore::ContextData context,
LLMCore::RequestType type) LLMCore::RequestType type,
bool isToolsEnabled)
{ {
if (!prompt->isSupportProvider(providerID())) { if (!prompt->isSupportProvider(providerID())) {
LOG_MESSAGE(QString("Template %1 doesn't support %2 provider").arg(name(), prompt->name())); LOG_MESSAGE(QString("Template %1 doesn't support %2 provider").arg(name(), prompt->name()));
@ -99,8 +100,7 @@ void ClaudeProvider::prepareRequest(
applyModelParams(Settings::chatAssistantSettings()); applyModelParams(Settings::chatAssistantSettings());
} }
if (supportsTools() && type == LLMCore::RequestType::Chat if (isToolsEnabled) {
&& Settings::generalSettings().useTools()) {
auto toolsDefinitions = m_toolsManager->getToolsDefinitions( auto toolsDefinitions = m_toolsManager->getToolsDefinitions(
LLMCore::ToolSchemaFormat::Claude); LLMCore::ToolSchemaFormat::Claude);
if (!toolsDefinitions.isEmpty()) { if (!toolsDefinitions.isEmpty()) {

View File

@ -41,7 +41,8 @@ public:
QJsonObject &request, QJsonObject &request,
LLMCore::PromptTemplate *prompt, LLMCore::PromptTemplate *prompt,
LLMCore::ContextData context, LLMCore::ContextData context,
LLMCore::RequestType type) override; LLMCore::RequestType type,
bool isToolsEnabled) override;
QList<QString> getInstalledModels(const QString &url) override; QList<QString> getInstalledModels(const QString &url) override;
QList<QString> validateRequest(const QJsonObject &request, LLMCore::TemplateType type) override; QList<QString> validateRequest(const QJsonObject &request, LLMCore::TemplateType type) override;
QString apiKey() const override; QString apiKey() const override;

View File

@ -75,7 +75,8 @@ void GoogleAIProvider::prepareRequest(
QJsonObject &request, QJsonObject &request,
LLMCore::PromptTemplate *prompt, LLMCore::PromptTemplate *prompt,
LLMCore::ContextData context, LLMCore::ContextData context,
LLMCore::RequestType type) LLMCore::RequestType type,
bool isToolsEnabled)
{ {
if (!prompt->isSupportProvider(providerID())) { if (!prompt->isSupportProvider(providerID())) {
LOG_MESSAGE(QString("Template %1 doesn't support %2 provider").arg(name(), prompt->name())); LOG_MESSAGE(QString("Template %1 doesn't support %2 provider").arg(name(), prompt->name()));
@ -102,8 +103,7 @@ void GoogleAIProvider::prepareRequest(
applyModelParams(Settings::chatAssistantSettings()); applyModelParams(Settings::chatAssistantSettings());
} }
if (supportsTools() && type == LLMCore::RequestType::Chat if (isToolsEnabled) {
&& Settings::generalSettings().useTools()) {
auto toolsDefinitions = m_toolsManager->getToolsDefinitions( auto toolsDefinitions = m_toolsManager->getToolsDefinitions(
LLMCore::ToolSchemaFormat::Google); LLMCore::ToolSchemaFormat::Google);
if (!toolsDefinitions.isEmpty()) { if (!toolsDefinitions.isEmpty()) {

View File

@ -40,7 +40,8 @@ public:
QJsonObject &request, QJsonObject &request,
LLMCore::PromptTemplate *prompt, LLMCore::PromptTemplate *prompt,
LLMCore::ContextData context, LLMCore::ContextData context,
LLMCore::RequestType type) override; LLMCore::RequestType type,
bool isToolsEnabled) override;
QList<QString> getInstalledModels(const QString &url) override; QList<QString> getInstalledModels(const QString &url) override;
QList<QString> validateRequest(const QJsonObject &request, LLMCore::TemplateType type) override; QList<QString> validateRequest(const QJsonObject &request, LLMCore::TemplateType type) override;
QString apiKey() const override; QString apiKey() const override;

View File

@ -222,7 +222,8 @@ void LMStudioProvider::prepareRequest(
QJsonObject &request, QJsonObject &request,
LLMCore::PromptTemplate *prompt, LLMCore::PromptTemplate *prompt,
LLMCore::ContextData context, LLMCore::ContextData context,
LLMCore::RequestType type) LLMCore::RequestType type,
bool isToolsEnabled)
{ {
if (!prompt->isSupportProvider(providerID())) { if (!prompt->isSupportProvider(providerID())) {
LOG_MESSAGE(QString("Template %1 doesn't support %2 provider").arg(name(), prompt->name())); LOG_MESSAGE(QString("Template %1 doesn't support %2 provider").arg(name(), prompt->name()));
@ -250,8 +251,7 @@ void LMStudioProvider::prepareRequest(
applyModelParams(Settings::chatAssistantSettings()); applyModelParams(Settings::chatAssistantSettings());
} }
if (supportsTools() && type == LLMCore::RequestType::Chat if (isToolsEnabled) {
&& Settings::generalSettings().useTools()) {
auto toolsDefinitions = m_toolsManager->getToolsDefinitions( auto toolsDefinitions = m_toolsManager->getToolsDefinitions(
LLMCore::ToolSchemaFormat::OpenAI); LLMCore::ToolSchemaFormat::OpenAI);
if (!toolsDefinitions.isEmpty()) { if (!toolsDefinitions.isEmpty()) {

View File

@ -40,7 +40,8 @@ public:
QJsonObject &request, QJsonObject &request,
LLMCore::PromptTemplate *prompt, LLMCore::PromptTemplate *prompt,
LLMCore::ContextData context, LLMCore::ContextData context,
LLMCore::RequestType type) override; LLMCore::RequestType type,
bool isToolsEnabled) override;
QList<QString> getInstalledModels(const QString &url) override; QList<QString> getInstalledModels(const QString &url) override;
QList<QString> validateRequest(const QJsonObject &request, LLMCore::TemplateType type) override; QList<QString> validateRequest(const QJsonObject &request, LLMCore::TemplateType type) override;
QString apiKey() const override; QString apiKey() const override;

View File

@ -73,7 +73,8 @@ void LlamaCppProvider::prepareRequest(
QJsonObject &request, QJsonObject &request,
LLMCore::PromptTemplate *prompt, LLMCore::PromptTemplate *prompt,
LLMCore::ContextData context, LLMCore::ContextData context,
LLMCore::RequestType type) LLMCore::RequestType type,
bool isToolsEnabled)
{ {
if (!prompt->isSupportProvider(providerID())) { if (!prompt->isSupportProvider(providerID())) {
LOG_MESSAGE(QString("Template %1 doesn't support %2 provider").arg(name(), prompt->name())); LOG_MESSAGE(QString("Template %1 doesn't support %2 provider").arg(name(), prompt->name()));
@ -101,8 +102,7 @@ void LlamaCppProvider::prepareRequest(
applyModelParams(Settings::chatAssistantSettings()); applyModelParams(Settings::chatAssistantSettings());
} }
if (supportsTools() && type == LLMCore::RequestType::Chat if (isToolsEnabled) {
&& Settings::generalSettings().useTools()) {
auto toolsDefinitions = m_toolsManager->getToolsDefinitions( auto toolsDefinitions = m_toolsManager->getToolsDefinitions(
LLMCore::ToolSchemaFormat::OpenAI); LLMCore::ToolSchemaFormat::OpenAI);
if (!toolsDefinitions.isEmpty()) { if (!toolsDefinitions.isEmpty()) {

View File

@ -40,7 +40,8 @@ public:
QJsonObject &request, QJsonObject &request,
LLMCore::PromptTemplate *prompt, LLMCore::PromptTemplate *prompt,
LLMCore::ContextData context, LLMCore::ContextData context,
LLMCore::RequestType type) override; LLMCore::RequestType type,
bool isToolsEnabled) override;
QList<QString> getInstalledModels(const QString &url) override; QList<QString> getInstalledModels(const QString &url) override;
QList<QString> validateRequest(const QJsonObject &request, LLMCore::TemplateType type) override; QList<QString> validateRequest(const QJsonObject &request, LLMCore::TemplateType type) override;
QString apiKey() const override; QString apiKey() const override;

View File

@ -243,7 +243,8 @@ void MistralAIProvider::prepareRequest(
QJsonObject &request, QJsonObject &request,
LLMCore::PromptTemplate *prompt, LLMCore::PromptTemplate *prompt,
LLMCore::ContextData context, LLMCore::ContextData context,
LLMCore::RequestType type) LLMCore::RequestType type,
bool isToolsEnabled)
{ {
if (!prompt->isSupportProvider(providerID())) { if (!prompt->isSupportProvider(providerID())) {
LOG_MESSAGE(QString("Template %1 doesn't support %2 provider").arg(name(), prompt->name())); LOG_MESSAGE(QString("Template %1 doesn't support %2 provider").arg(name(), prompt->name()));
@ -271,8 +272,7 @@ void MistralAIProvider::prepareRequest(
applyModelParams(Settings::chatAssistantSettings()); applyModelParams(Settings::chatAssistantSettings());
} }
if (supportsTools() && type == LLMCore::RequestType::Chat if (isToolsEnabled) {
&& Settings::generalSettings().useTools()) {
auto toolsDefinitions = m_toolsManager->getToolsDefinitions( auto toolsDefinitions = m_toolsManager->getToolsDefinitions(
LLMCore::ToolSchemaFormat::OpenAI); LLMCore::ToolSchemaFormat::OpenAI);
if (!toolsDefinitions.isEmpty()) { if (!toolsDefinitions.isEmpty()) {

View File

@ -40,7 +40,8 @@ public:
QJsonObject &request, QJsonObject &request,
LLMCore::PromptTemplate *prompt, LLMCore::PromptTemplate *prompt,
LLMCore::ContextData context, LLMCore::ContextData context,
LLMCore::RequestType type) override; LLMCore::RequestType type,
bool isToolsEnabled) override;
QList<QString> getInstalledModels(const QString &url) override; QList<QString> getInstalledModels(const QString &url) override;
QList<QString> validateRequest(const QJsonObject &request, LLMCore::TemplateType type) override; QList<QString> validateRequest(const QJsonObject &request, LLMCore::TemplateType type) override;
QString apiKey() const override; QString apiKey() const override;

View File

@ -74,7 +74,8 @@ void OllamaProvider::prepareRequest(
QJsonObject &request, QJsonObject &request,
LLMCore::PromptTemplate *prompt, LLMCore::PromptTemplate *prompt,
LLMCore::ContextData context, LLMCore::ContextData context,
LLMCore::RequestType type) LLMCore::RequestType type,
bool isToolsEnabled)
{ {
if (!prompt->isSupportProvider(providerID())) { if (!prompt->isSupportProvider(providerID())) {
LOG_MESSAGE(QString("Template %1 doesn't support %2 provider").arg(name(), prompt->name())); LOG_MESSAGE(QString("Template %1 doesn't support %2 provider").arg(name(), prompt->name()));
@ -107,8 +108,7 @@ void OllamaProvider::prepareRequest(
applySettings(Settings::chatAssistantSettings()); applySettings(Settings::chatAssistantSettings());
} }
if (supportsTools() && type == LLMCore::RequestType::Chat if (isToolsEnabled) {
&& Settings::generalSettings().useTools()) {
auto toolsDefinitions = m_toolsManager->toolsFactory()->getToolsDefinitions( auto toolsDefinitions = m_toolsManager->toolsFactory()->getToolsDefinitions(
LLMCore::ToolSchemaFormat::Ollama); LLMCore::ToolSchemaFormat::Ollama);
if (!toolsDefinitions.isEmpty()) { if (!toolsDefinitions.isEmpty()) {

View File

@ -41,7 +41,8 @@ public:
QJsonObject &request, QJsonObject &request,
LLMCore::PromptTemplate *prompt, LLMCore::PromptTemplate *prompt,
LLMCore::ContextData context, LLMCore::ContextData context,
LLMCore::RequestType type) override; LLMCore::RequestType type,
bool isToolsEnabled) override;
QList<QString> getInstalledModels(const QString &url) override; QList<QString> getInstalledModels(const QString &url) override;
QList<QString> validateRequest(const QJsonObject &request, LLMCore::TemplateType type) override; QList<QString> validateRequest(const QJsonObject &request, LLMCore::TemplateType type) override;
QString apiKey() const override; QString apiKey() const override;

View File

@ -73,7 +73,8 @@ void OpenAICompatProvider::prepareRequest(
QJsonObject &request, QJsonObject &request,
LLMCore::PromptTemplate *prompt, LLMCore::PromptTemplate *prompt,
LLMCore::ContextData context, LLMCore::ContextData context,
LLMCore::RequestType type) LLMCore::RequestType type,
bool isToolsEnabled)
{ {
if (!prompt->isSupportProvider(providerID())) { if (!prompt->isSupportProvider(providerID())) {
LOG_MESSAGE(QString("Template %1 doesn't support %2 provider").arg(name(), prompt->name())); LOG_MESSAGE(QString("Template %1 doesn't support %2 provider").arg(name(), prompt->name()));
@ -101,8 +102,7 @@ void OpenAICompatProvider::prepareRequest(
applyModelParams(Settings::chatAssistantSettings()); applyModelParams(Settings::chatAssistantSettings());
} }
if (supportsTools() && type == LLMCore::RequestType::Chat if (isToolsEnabled) {
&& Settings::generalSettings().useTools()) {
auto toolsDefinitions = m_toolsManager->getToolsDefinitions( auto toolsDefinitions = m_toolsManager->getToolsDefinitions(
LLMCore::ToolSchemaFormat::OpenAI); LLMCore::ToolSchemaFormat::OpenAI);
if (!toolsDefinitions.isEmpty()) { if (!toolsDefinitions.isEmpty()) {

View File

@ -40,7 +40,8 @@ public:
QJsonObject &request, QJsonObject &request,
LLMCore::PromptTemplate *prompt, LLMCore::PromptTemplate *prompt,
LLMCore::ContextData context, LLMCore::ContextData context,
LLMCore::RequestType type) override; LLMCore::RequestType type,
bool isToolsEnabled) override;
QList<QString> getInstalledModels(const QString &url) override; QList<QString> getInstalledModels(const QString &url) override;
QList<QString> validateRequest(const QJsonObject &request, LLMCore::TemplateType type) override; QList<QString> validateRequest(const QJsonObject &request, LLMCore::TemplateType type) override;
QString apiKey() const override; QString apiKey() const override;

View File

@ -74,7 +74,8 @@ void OpenAIProvider::prepareRequest(
QJsonObject &request, QJsonObject &request,
LLMCore::PromptTemplate *prompt, LLMCore::PromptTemplate *prompt,
LLMCore::ContextData context, LLMCore::ContextData context,
LLMCore::RequestType type) LLMCore::RequestType type,
bool isToolsEnabled)
{ {
if (!prompt->isSupportProvider(providerID())) { if (!prompt->isSupportProvider(providerID())) {
LOG_MESSAGE(QString("Template %1 doesn't support %2 provider").arg(name(), prompt->name())); LOG_MESSAGE(QString("Template %1 doesn't support %2 provider").arg(name(), prompt->name()));
@ -102,8 +103,7 @@ void OpenAIProvider::prepareRequest(
applyModelParams(Settings::chatAssistantSettings()); applyModelParams(Settings::chatAssistantSettings());
} }
if (supportsTools() && type == LLMCore::RequestType::Chat if (isToolsEnabled) {
&& Settings::generalSettings().useTools()) {
auto toolsDefinitions = m_toolsManager->getToolsDefinitions( auto toolsDefinitions = m_toolsManager->getToolsDefinitions(
LLMCore::ToolSchemaFormat::OpenAI); LLMCore::ToolSchemaFormat::OpenAI);
if (!toolsDefinitions.isEmpty()) { if (!toolsDefinitions.isEmpty()) {

View File

@ -40,7 +40,8 @@ public:
QJsonObject &request, QJsonObject &request,
LLMCore::PromptTemplate *prompt, LLMCore::PromptTemplate *prompt,
LLMCore::ContextData context, LLMCore::ContextData context,
LLMCore::RequestType type) override; LLMCore::RequestType type,
bool isToolsEnabled) override;
QList<QString> getInstalledModels(const QString &url) override; QList<QString> getInstalledModels(const QString &url) override;
QList<QString> validateRequest(const QJsonObject &request, LLMCore::TemplateType type) override; QList<QString> validateRequest(const QJsonObject &request, LLMCore::TemplateType type) override;
QString apiKey() const override; QString apiKey() const override;