mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-07-23 11:41:03 -04:00
* refactor: Migrate tests to Qt Creator plugin framework and update llmqore transports * refactor: Move conversation history into IDE-free session library * refactor: Extract turn context assembly behind injected ports * build: Add RunQodeAssistTests target for the plugin test suite * refactor: Route the chat through a Session and ChatBackend seam
80 lines
2.4 KiB
C++
80 lines
2.4 KiB
C++
// Copyright (C) 2024-2026 Petr Mironychev
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
// Additional attribution terms under GPLv3 §7(b) apply — see LICENSE
|
|
|
|
#pragma once
|
|
|
|
#include <QObject>
|
|
#include <QString>
|
|
|
|
#include "ChatModel.hpp"
|
|
#include "session/Session.hpp"
|
|
#include "templates/IPromptProvider.hpp"
|
|
#include <context/ContextManager.hpp>
|
|
|
|
namespace QodeAssist::Skills {
|
|
class SkillsManager;
|
|
}
|
|
|
|
namespace QodeAssist::Chat {
|
|
|
|
class ChatHistoryBridge;
|
|
class LlmChatBackend;
|
|
|
|
class ChatController : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit ChatController(
|
|
ChatModel *chatModel, Templates::IPromptProvider *promptProvider, QObject *parent = nullptr);
|
|
|
|
void setSkillsManager(Skills::SkillsManager *skillsManager);
|
|
|
|
void sendMessage(
|
|
const QString &message,
|
|
const QList<QString> &attachments = {},
|
|
const QList<QString> &linkedFiles = {},
|
|
bool useTools = false,
|
|
bool useThinking = false);
|
|
void clearMessages();
|
|
void cancelRequest();
|
|
void resetToRow(int rowIndex);
|
|
|
|
Session::Session *session() const;
|
|
Context::ContextManager *contextManager() const;
|
|
|
|
void setChatFilePath(const QString &filePath);
|
|
QString chatFilePath() const;
|
|
|
|
signals:
|
|
void errorOccurred(const QString &error);
|
|
void messageReceivedCompletely();
|
|
void requestStarted(const QString &requestId);
|
|
void messageUsageReceived(
|
|
int promptTokens, int completionTokens, int cachedPromptTokens, int reasoningTokens);
|
|
|
|
private:
|
|
QList<Session::ContentBlock> composeUserBlocks(
|
|
const QString &message, const QList<QString> &attachments);
|
|
std::optional<Session::TurnContext> buildTurnContext(
|
|
const QString &message, const QList<QString> &linkedFiles) const;
|
|
void recordFileEditStatus(
|
|
const QString &editId, const QString &status, const QString &fallbackMessage);
|
|
void registerHistoricalEdits();
|
|
|
|
bool isImageFile(const QString &filePath) const;
|
|
QString getMediaTypeForImage(const QString &filePath) const;
|
|
QString encodeImageToBase64(const QString &filePath) const;
|
|
|
|
Templates::IPromptProvider *m_promptProvider = nullptr;
|
|
ChatModel *m_chatModel = nullptr;
|
|
Context::ContextManager *m_contextManager = nullptr;
|
|
Skills::SkillsManager *m_skillsManager = nullptr;
|
|
Session::Session *m_session = nullptr;
|
|
LlmChatBackend *m_backend = nullptr;
|
|
QString m_chatFilePath;
|
|
};
|
|
|
|
} // namespace QodeAssist::Chat
|