Context for an agent, containing tools, LLM, and memory.
More...
#include <context.h>
|
|
| Context () |
| | Default constructor for Context.
|
|
| ~Context ()=default |
| | Default destructor for Context.
|
| void | setLLM (std::shared_ptr< LLMInterface > llm) |
| | Set the LLM to use.
|
| std::shared_ptr< LLMInterface > | getLLM () const |
| | Get the LLM.
|
| void | setSystemPrompt (const std::string &system_prompt) |
| | Set the system prompt.
|
| const std::string & | getSystemPrompt () const |
| | Get the system prompt.
|
| void | registerToolRegistry (tools::ToolRegistry ®istry) |
| | Register tools from a ToolRegistry.
|
| void | registerTool (std::shared_ptr< Tool > tool) |
| | Register a tool.
|
| std::shared_ptr< Tool > | getTool (const std::string &name) const |
| | Get a tool by name.
|
| std::vector< std::shared_ptr< Tool > > | getTools () const |
| | Get all tools.
|
| Task< ToolResult > | executeTool (const std::string &name, const JsonObject ¶ms) |
| | Execute a tool by name using coroutines.
|
| std::shared_ptr< Memory > | getMemory () const |
| | Get the memory.
|
| void | addMessage (const Message &message) |
| | Add a message to the conversation history.
|
| std::vector< Message > | getMessages () const |
| | Get all messages in the conversation history.
|
| Task< LLMResponse > | chat (const std::string user_message, const std::vector< std::string > uris_or_data={}) |
| | Multimodal chat completion with the current context.
|
| Task< LLMResponse > | chatWithTools (const std::string user_message, const std::vector< std::string > uris_or_data={}) |
| | Multimodal chat completion with tools.
|
| AsyncGenerator< std::string > | streamChat (const std::string user_message, const std::vector< std::string > uris_or_data={}) |
| | Multimodal streaming chat (accepts one or more media URIs or data strings).
|
| AsyncGenerator< std::string > | streamChatWithTools (const std::string user_message, const std::vector< std::string > uris_or_data={}) |
| | Multimodal streaming chat with tools.
|
Context for an agent, containing tools, LLM, and memory.
◆ addMessage()
| void agents::Context::addMessage |
( |
const Message & | message | ) |
|
Add a message to the conversation history.
- Parameters
-
| message | The message to add |
◆ chat()
| Task< LLMResponse > agents::Context::chat |
( |
const std::string | user_message, |
|
|
const std::vector< std::string > | uris_or_data = {} ) |
Multimodal chat completion with the current context.
- Parameters
-
| user_message | The user message to send |
| uris_or_data | Optional URIs or data to use |
- Returns
- The LLM response
◆ chatWithTools()
| Task< LLMResponse > agents::Context::chatWithTools |
( |
const std::string | user_message, |
|
|
const std::vector< std::string > | uris_or_data = {} ) |
Multimodal chat completion with tools.
- Parameters
-
| user_message | The user message to send |
| uris_or_data | Optional URIs or data to use |
- Returns
- The LLM response
◆ executeTool()
Execute a tool by name using coroutines.
- Parameters
-
| name | The name of the tool to execute |
| params | The parameters to pass to the tool |
- Returns
- The result of the tool execution
◆ getLLM()
| std::shared_ptr< LLMInterface > agents::Context::getLLM |
( |
| ) |
const |
Get the LLM.
- Returns
- The LLM
◆ getMemory()
| std::shared_ptr< Memory > agents::Context::getMemory |
( |
| ) |
const |
Get the memory.
- Returns
- The memory
◆ getMessages()
| std::vector< Message > agents::Context::getMessages |
( |
| ) |
const |
Get all messages in the conversation history.
- Returns
- The messages
◆ getSystemPrompt()
| const std::string & agents::Context::getSystemPrompt |
( |
| ) |
const |
Get the system prompt.
- Returns
- The system prompt
◆ getTool()
| std::shared_ptr< Tool > agents::Context::getTool |
( |
const std::string & | name | ) |
const |
Get a tool by name.
- Parameters
-
| name | The name of the tool to get |
- Returns
- Pointer to tool
◆ getTools()
| std::vector< std::shared_ptr< Tool > > agents::Context::getTools |
( |
| ) |
const |
Get all tools.
- Returns
- The tools
◆ registerTool()
| void agents::Context::registerTool |
( |
std::shared_ptr< Tool > | tool | ) |
|
Register a tool.
- Parameters
-
◆ registerToolRegistry()
Register tools from a ToolRegistry.
- Parameters
-
| registry | The ToolRegistry to register from |
◆ setLLM()
| void agents::Context::setLLM |
( |
std::shared_ptr< LLMInterface > | llm | ) |
|
Set the LLM to use.
- Parameters
-
◆ setSystemPrompt()
| void agents::Context::setSystemPrompt |
( |
const std::string & | system_prompt | ) |
|
Set the system prompt.
- Parameters
-
| system_prompt | The system prompt to use |
◆ streamChat()
| AsyncGenerator< std::string > agents::Context::streamChat |
( |
const std::string | user_message, |
|
|
const std::vector< std::string > | uris_or_data = {} ) |
Multimodal streaming chat (accepts one or more media URIs or data strings).
- Parameters
-
| user_message | The user message to send |
| uris_or_data | Optional URIs or data to use |
- Returns
- The LLM response
◆ streamChatWithTools()
| AsyncGenerator< std::string > agents::Context::streamChatWithTools |
( |
const std::string | user_message, |
|
|
const std::vector< std::string > | uris_or_data = {} ) |
Multimodal streaming chat with tools.
- Parameters
-
| user_message | The user message to send |
| uris_or_data | Optional URIs or data to use |
- Returns
- The LLM response