🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
ast::ChatSession类 参考

#include <ChatSession.hpp>

+ 类 ast::ChatSession 继承关系图:

Public 成员函数

 ChatSession ()
 
std::string chat (StringView message, int maxIterForToolCalls=100)
 
std::string chatStream (StringView message, ChatEventHandler &handler, int maxIterForToolCalls=100)
 
errc_t sendMessage (StringView message)
 
void setSystemPrompt (StringView systemPrompt)
 
ChatMessagesmessages ()
 
AssistantAgentagent () const
 
void setAgent (std::unique_ptr< AssistantAgent > agent)
 
ChatToolstools ()
 
LLMClientclient ()
 
const std::string & lastError () const
 
LLMConfigconfig ()
 
const LLMConfigconfig () const
 
errc_t makeChatCompletion ()
 
void handleToolCalls (const JsonValue &toolCalls)
 

详细描述

聊天会话

构造及析构函数说明

◆ ChatSession()

ast::ChatSession::ChatSession ( )

构造函数

参数
api_keyAPI密钥
model模型名称
base_urlAPI基础URL

成员函数说明

◆ agent()

AssistantAgent & ast::ChatSession::agent ( ) const

获取聊天智能体

返回
聊天智能体

◆ chat()

std::string ast::ChatSession::chat ( StringView message,
int maxIterForToolCalls = 100 )

对话,内部会处理工具调用循环直到没有更多工具调用或最大交互轮数到达,然后返回最终响应内容

参数
message用户消息
返回
最终响应内容(执行工具调用循环后的最终结果)

◆ chatStream()

std::string ast::ChatSession::chatStream ( StringView message,
ChatEventHandler & handler,
int maxIterForToolCalls = 100 )

流式输出对话,内部会处理工具调用循环直到没有更多工具调用或最大交互轮数到达,然后返回最终响应内容

参数
message用户消息
handler事件处理函数
返回
最终响应内容(执行工具调用循环后的最终结果)

◆ handleToolCalls()

void ast::ChatSession::handleToolCalls ( const JsonValue & toolCalls)

处理工具调用

参数
toolCalls工具调用列表

◆ makeChatCompletion()

errc_t ast::ChatSession::makeChatCompletion ( )

生成聊天完成响应

返回
错误码,0表示成功,成功时响应消息追加到messages_末尾

◆ messages()

ChatMessages & ast::ChatSession::messages ( )
inline

获取消息历史

返回
消息历史

◆ sendMessage()

errc_t ast::ChatSession::sendMessage ( StringView message)

发送消息,不会处理工具调用,直接返回响应消息

参数
message用户消息
返回
错误码,0表示成功,消息追加到messages_末尾

◆ setSystemPrompt()

void ast::ChatSession::setSystemPrompt ( StringView systemPrompt)

设置系统提示

参数
systemPrompt系统提示

◆ tools()

ChatTools & ast::ChatSession::tools ( )
inline

获取工具集合

返回
工具集合

该类的文档由以下文件生成: