|
NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
|
Standalone ReAct agent that loops between LLM calls and tool execution. More...
#include <agent.h>
Public Member Functions | |
| Agent (std::shared_ptr< Provider > provider, std::vector< std::unique_ptr< Tool > > tools, const std::string &instructions="", const std::string &model="") | |
| Construct an agent with a provider and tools. | |
| ChatCompletion | complete (const std::vector< ChatMessage > &messages) |
| Perform a single LLM completion (no tool loop). | |
| std::string | run (std::vector< ChatMessage > &messages, int max_iterations=10) |
| Run the agent loop until completion. | |
| std::string | run_stream (std::vector< ChatMessage > &messages, const StreamCallback &on_chunk, int max_iterations=10) |
| Run the agent loop with streaming token output. | |
Standalone ReAct agent that loops between LLM calls and tool execution.
The agent sends messages to the LLM, checks for tool calls, executes them, feeds results back, and repeats until the LLM produces a final text response or the iteration limit is reached.
| neograph::llm::Agent::Agent | ( | std::shared_ptr< Provider > | provider, |
| std::vector< std::unique_ptr< Tool > > | tools, | ||
| const std::string & | instructions = "", |
||
| const std::string & | model = "" |
||
| ) |
Construct an agent with a provider and tools.
| provider | LLM provider for making completions. |
| tools | Vector of tools available to the agent (ownership transferred). |
| instructions | Optional system prompt prepended to the conversation. |
| model | Optional model name override (empty = use provider default). |
| ChatCompletion neograph::llm::Agent::complete | ( | const std::vector< ChatMessage > & | messages | ) |
Perform a single LLM completion (no tool loop).
| messages | Conversation history (not modified). |
| std::string neograph::llm::Agent::run | ( | std::vector< ChatMessage > & | messages, |
| int | max_iterations = 10 |
||
| ) |
Run the agent loop until completion.
Iterates between LLM calls and tool execution until the LLM produces a response with no tool calls, or max_iterations is reached.
| [in,out] | messages | Conversation history (modified in-place with new messages). |
| max_iterations | Maximum number of LLM call iterations (default: 10). |
| std::string neograph::llm::Agent::run_stream | ( | std::vector< ChatMessage > & | messages, |
| const StreamCallback & | on_chunk, | ||
| int | max_iterations = 10 |
||
| ) |
Run the agent loop with streaming token output.
Same as run(), but streams the final response tokens via the callback.
| [in,out] | messages | Conversation history (modified in-place). |
| on_chunk | Callback invoked per token during the final LLM response. | |
| max_iterations | Maximum LLM call iterations (default: 10). |