🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
ChatEventHandler.hpp
浏览该文件的文档.
1
26
27#pragma once
28
29#include "AstGlobal.h"
30#include <string>
31
32AST_NAMESPACE_BEGIN
33
41class AST_AI_API ChatEventHandler
42{
43public:
44 ChatEventHandler() = default;
45 virtual ~ChatEventHandler() = default;
46
47 // ── 流式文本事件(在 LLM 生成过程中实时触发) ──
48
51 virtual void onContentChunk(const std::string& text) {}
52
54 virtual void onContentComplete(const std::string& text) {}
55
58 virtual void onReasoningChunk(const std::string& reasoning) {}
59
62 virtual void onReasoningComplete(const std::string& reasoning) {}
63
64
65 // ── 工具调用事件(在流式响应完成后触发) ──
66
71 virtual void onToolCallRequest(const std::string& toolCallId,
72 const std::string& functionName,
73 const std::string& arguments) {}
74
79 virtual void onToolCallResult(const std::string& toolCallId,
80 const std::string& functionName,
81 const std::string& result) {}
82
83 // ── 生命周期事件 ──
84
86 virtual void onComplete() {}
87
90 virtual void onError(const std::string& error) {}
91
94 virtual bool isCancelled() const { return false; }
95};
96
99AST_NAMESPACE_END
流式聊天事件处理器
定义 ChatEventHandler.hpp:42
virtual bool isCancelled() const
检查是否被取消
定义 ChatEventHandler.hpp:94
virtual void onComplete()
本轮对话完成
定义 ChatEventHandler.hpp:86
virtual void onToolCallRequest(const std::string &toolCallId, const std::string &functionName, const std::string &arguments)
LLM 请求调用工具(含完整函数名和参数)
定义 ChatEventHandler.hpp:71
virtual void onReasoningComplete(const std::string &reasoning)
收到完整推理内容
定义 ChatEventHandler.hpp:62
virtual void onReasoningChunk(const std::string &reasoning)
收到一块推理内容(delta)
定义 ChatEventHandler.hpp:58
virtual void onContentChunk(const std::string &text)
收到一块文本内容(delta)
定义 ChatEventHandler.hpp:51
virtual void onError(const std::string &error)
发生错误
定义 ChatEventHandler.hpp:90
virtual void onContentComplete(const std::string &text)
收到完整文本内容
定义 ChatEventHandler.hpp:54
virtual void onToolCallResult(const std::string &toolCallId, const std::string &functionName, const std::string &result)
工具执行完毕,返回结果
定义 ChatEventHandler.hpp:79