🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
UiChatWorker.hpp
浏览该文件的文档.
1
12
13#pragma once
14
15#include "AstGlobal.h"
16#include <QThread>
17#include <QString>
18#include <QPointer>
19#include <memory>
20
21AST_NAMESPACE_BEGIN
22
23class ChatSession;
24class UiChatEventHandler;
25
39class AST_UIAI_API UiChatWorker : public QThread
40{
41 Q_OBJECT
42
43public:
50 explicit UiChatWorker(ChatSession* session,
51 const QString& userMessage,
52 UiChatEventHandler* handler,
53 int maxToolIterations = 100,
54 QObject* parent = nullptr);
55
56 ~UiChatWorker() override;
57
59 const std::string& response() const { return response_; }
60
62 int errorCode() const { return errorCode_; }
63
64Q_SIGNALS:
67 void workFinished(int errorCode);
68
69protected:
70 void run() override;
71
72private:
73 ChatSession* session_;
74 QString userMessage_;
75 QPointer<UiChatEventHandler> handler_;
76 int maxToolIterations_;
77 std::string response_;
78 int errorCode_{0};
79};
80
83AST_NAMESPACE_END
聊天会话
定义 ChatSession.hpp:44
流式聊天事件的 Qt 信号桥接器
定义 UiChatEventHandler.hpp:44
后台 LLM 对话工作线程
定义 UiChatWorker.hpp:40
void workFinished(int errorCode)
工作完成
int errorCode() const
获取错误码
定义 UiChatWorker.hpp:62
const std::string & response() const
获取本轮对话的最终响应
定义 UiChatWorker.hpp:59