Agents 0.0.2
Edge AI Agents SDK
Loading...
Searching...
No Matches
agent_context.h
1
10#pragma once
11
12#include <agents-cpp/coroutine_utils.h>
13#include <agents-cpp/llm_interface.h>
14#include <agents-cpp/memory.h>
15#include <agents-cpp/tool.h>
16#include <agents-cpp/types.h>
17#include <map>
18#include <memory>
19#include <vector>
20
25namespace agents {
26
30class AgentContext {
31public:
32 AgentContext();
33 ~AgentContext() = default;
34
39 void setLLM(std::shared_ptr<LLMInterface> llm);
40
45 std::shared_ptr<LLMInterface> getLLM() const;
46
51 void setSystemPrompt(const String& system_prompt);
52
57 const String& getSystemPrompt() const;
58
63 void registerTool(std::shared_ptr<Tool> tool);
64
70 std::shared_ptr<Tool> getTool(const String& name) const;
71
76 std::vector<std::shared_ptr<Tool>> getTools() const;
77
84 Task<ToolResult> executeTool(const String& name, const JsonObject& params);
85
90 std::shared_ptr<Memory> getMemory() const;
91
96 void addMessage(const Message& message);
97
102 std::vector<Message> getMessages() const;
103
109 Task<LLMResponse> chat(const String& user_message);
110
117
124
125private:
129 std::shared_ptr<LLMInterface> llm_;
130
134 std::shared_ptr<Memory> memory_;
135
139 std::map<String, std::shared_ptr<Tool>> tools_;
140
144 String system_prompt_;
145};
146
147} // namespace agents
void registerTool(std::shared_ptr< Tool > tool)
Register a tool.
const String & getSystemPrompt() const
Get the system prompt.
std::vector< std::shared_ptr< Tool > > getTools() const
Get all tools.
void setSystemPrompt(const String &system_prompt)
Set the system prompt.
std::shared_ptr< Memory > getMemory() const
Get the memory.
std::shared_ptr< LLMInterface > getLLM() const
Get the LLM.
Task< LLMResponse > chatWithTools(const String &user_message)
Run a chat completion with tools using coroutines.
Task< LLMResponse > chat(const String &user_message)
Run a chat completion with the current context using coroutines.
void setLLM(std::shared_ptr< LLMInterface > llm)
Set the LLM to use.
std::shared_ptr< Tool > getTool(const String &name) const
Get a tool by name.
Task< ToolResult > executeTool(const String &name, const JsonObject &params)
Execute a tool by name using coroutines.
void addMessage(const Message &message)
Add a message to the conversation history.
std::vector< Message > getMessages() const
Get all messages in the conversation history.
AsyncGenerator< String > streamChat(const String &user_message)
Stream chat results with AsyncGenerator.
A minimal AsyncGenerator implementation that doesn't rely on coroutines.
Definition coroutine_utils.h:142
Provide a future-based fallback for Task.
Definition coroutine_utils.h:115
Framework Namespace.
Definition agent.h:18
nlohmann::json JsonObject
JSON object type.
Definition types.h:39
std::string String
String type.
Definition types.h:27
Message in a conversation.
Definition types.h:105