mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-05-30 10:59:30 -04:00
feat: Add session layout
This commit is contained in:
64
sources/Session/ResponseRouter.hpp
Normal file
64
sources/Session/ResponseRouter.hpp
Normal file
@@ -0,0 +1,64 @@
|
||||
// Copyright (C) 2024-2026 Petr Mironychev
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LLMQore/BaseClient.hpp>
|
||||
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
#include <QString>
|
||||
|
||||
#include "ResponseEvent.hpp"
|
||||
|
||||
namespace QodeAssist {
|
||||
|
||||
class ConversationHistory;
|
||||
|
||||
class ResponseRouter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(ResponseRouter)
|
||||
public:
|
||||
ResponseRouter(
|
||||
LLMQore::BaseClient *client,
|
||||
ConversationHistory *history,
|
||||
QObject *parent = nullptr);
|
||||
~ResponseRouter() override;
|
||||
|
||||
void beginRequest(const LLMQore::RequestID &id);
|
||||
void endRequest();
|
||||
|
||||
bool isActive() const noexcept { return !m_activeId.isEmpty(); }
|
||||
LLMQore::RequestID activeRequestId() const noexcept { return m_activeId; }
|
||||
|
||||
signals:
|
||||
void event(const QodeAssist::ResponseEvent &ev);
|
||||
|
||||
private slots:
|
||||
void onChunk(const LLMQore::RequestID &id, const QString &chunk);
|
||||
void onThinking(
|
||||
const LLMQore::RequestID &id, const QString &thinking, const QString &signature);
|
||||
void onToolStarted(
|
||||
const LLMQore::RequestID &id, const QString &toolId, const QString &toolName);
|
||||
void onToolResultReady(
|
||||
const LLMQore::RequestID &id,
|
||||
const QString &toolId,
|
||||
const QString &toolName,
|
||||
const QString &result);
|
||||
void onFinalized(const LLMQore::RequestID &id, const LLMQore::CompletionInfo &info);
|
||||
void onFailed(const LLMQore::RequestID &id, const QString &err);
|
||||
|
||||
private:
|
||||
void ensureAssistantOpen();
|
||||
void resetTurnState();
|
||||
|
||||
QPointer<LLMQore::BaseClient> m_client;
|
||||
QPointer<ConversationHistory> m_history;
|
||||
|
||||
LLMQore::RequestID m_activeId;
|
||||
bool m_assistantOpen = false;
|
||||
bool m_inToolResults = false;
|
||||
};
|
||||
|
||||
} // namespace QodeAssist
|
||||
Reference in New Issue
Block a user