#include <ChatSession.hpp>
◆ ChatSession()
| ast::ChatSession::ChatSession |
( |
| ) |
|
构造函数
- 参数
-
| api_key | API密钥 |
| model | 模型名称 |
| base_url | API基础URL |
◆ agent()
◆ chat()
| std::string ast::ChatSession::chat |
( |
StringView | message, |
|
|
int | maxIterForToolCalls = 100 ) |
对话,内部会处理工具调用循环直到没有更多工具调用或最大交互轮数到达,然后返回最终响应内容
- 参数
-
- 返回
- 最终响应内容(执行工具调用循环后的最终结果)
◆ chatStream()
流式输出对话,内部会处理工具调用循环直到没有更多工具调用或最大交互轮数到达,然后返回最终响应内容
- 参数
-
| message | 用户消息 |
| handler | 事件处理函数 |
- 返回
- 最终响应内容(执行工具调用循环后的最终结果)
◆ handleToolCalls()
| void ast::ChatSession::handleToolCalls |
( |
const JsonValue & | toolCalls | ) |
|
◆ makeChatCompletion()
| errc_t ast::ChatSession::makeChatCompletion |
( |
| ) |
|
生成聊天完成响应
- 返回
- 错误码,0表示成功,成功时响应消息追加到messages_末尾
◆ messages()
◆ sendMessage()
| errc_t ast::ChatSession::sendMessage |
( |
StringView | message | ) |
|
发送消息,不会处理工具调用,直接返回响应消息
- 参数
-
- 返回
- 错误码,0表示成功,消息追加到messages_末尾
◆ setSystemPrompt()
| void ast::ChatSession::setSystemPrompt |
( |
StringView | systemPrompt | ) |
|
◆ tools()
该类的文档由以下文件生成: