Context for an agent, containing tools, LLM, and memory.
More...
#include <agent_context.h>
Context for an agent, containing tools, LLM, and memory.
- Examples
- actor_agent_example.cpp.
◆ addMessage()
void agents::AgentContext::addMessage |
( |
const Message & | message | ) |
|
Add a message to the conversation history.
- Parameters
-
message | The message to add |
◆ chat()
Run a chat completion with the current context using coroutines.
- Parameters
-
user_message | The user message to send |
- Returns
- The LLM response
◆ chatWithTools()
Run a chat completion with tools using coroutines.
- Parameters
-
user_message | The user message to send |
- 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::AgentContext::getLLM |
( |
| ) |
const |
Get the LLM.
- Returns
- The LLM
◆ getMemory()
std::shared_ptr< Memory > agents::AgentContext::getMemory |
( |
| ) |
const |
Get the memory.
- Returns
- The memory
◆ getMessages()
std::vector< Message > agents::AgentContext::getMessages |
( |
| ) |
const |
Get all messages in the conversation history.
- Returns
- The messages
◆ getSystemPrompt()
const String & agents::AgentContext::getSystemPrompt |
( |
| ) |
const |
Get the system prompt.
- Returns
- The system prompt
◆ getTool()
std::shared_ptr< Tool > agents::AgentContext::getTool |
( |
const 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::AgentContext::getTools |
( |
| ) |
const |
Get all tools.
- Returns
- The tools
◆ registerTool()
void agents::AgentContext::registerTool |
( |
std::shared_ptr< Tool > | tool | ) |
|
Register a tool.
- Parameters
-
◆ setLLM()
void agents::AgentContext::setLLM |
( |
std::shared_ptr< LLMInterface > | llm | ) |
|
Set the LLM to use.
- Parameters
-
◆ setSystemPrompt()
void agents::AgentContext::setSystemPrompt |
( |
const String & | system_prompt | ) |
|
Set the system prompt.
- Parameters
-
system_prompt | The system prompt to use |
◆ streamChat()
Stream chat results with AsyncGenerator.
- Parameters
-
user_message | The user message to send |
- Returns
- The LLM response