🛰️航天仿真算法库 SpaceAST
0.0.1
载入中...
搜索中...
未找到
ChatSession.hpp
浏览该文件的文档.
1
19
20
#pragma once
21
22
#include "AstGlobal.h"
23
#include "AstAI/OpenAI.hpp"
24
#include "AstAI/ChatTool.hpp"
25
#include "AstAI/ChatMessages.hpp"
26
#include "AstAI/ChatTools.hpp"
27
#include <string>
28
#include <vector>
29
#include <functional>
30
31
AST_NAMESPACE_BEGIN
32
41
class
AST_AI_API
ChatSession
{
42
public
:
47
ChatSession
();
48
52
std::string sendMessage(
StringView
message);
53
56
void
setSystemPrompt(
StringView
systemPrompt);
57
60
ChatMessages
&
messages
(){
return
messages_;}
61
64
ChatTools
&
tools
(){
return
tools_;}
65
68
OpenAI
& client();
69
private
:
70
std::string makeChatCompletion(
int
maxInteractions=20);
71
75
void
handleToolCalls(
const
JsonValue
& toolCalls,
int
maxInteractions = 20);
76
79
std::string handleToolCall(
const
JsonValue
& toolCall);
80
81
private
:
82
OpenAI
* client_{
nullptr
};
83
OpenAI internalClient_;
84
ChatMessages messages_;
85
ChatTools tools_;
86
};
87
90
AST_NAMESPACE_END
ast::ChatMessages
聊天消息集合
定义
ChatMessages.hpp:39
ast::ChatSession
聊天会话
定义
ChatSession.hpp:41
ast::ChatSession::tools
ChatTools & tools()
获取工具集合
定义
ChatSession.hpp:64
ast::ChatSession::messages
ChatMessages & messages()
获取消息历史
定义
ChatSession.hpp:60
ast::ChatTools
AI工具集合
定义
ChatTools.hpp:39
ast::JsonValue
JSON 值类
定义
JsonValue.hpp:47
ast::OpenAI
OpenAI客户端
定义
OpenAI.hpp:41
ast::StringViewBasic< char >
src
AstAI
Chat
ChatSession.hpp
制作者
1.12.0