LLMAgent (llm_agent v0.2.0)
View SourceLLMAgent is an abstraction library for building domain-specific intelligent agents based on Large Language Models (LLMs). It provides a core architecture and behavior definitions that simplify the development of specialized agents.
LLMAgent is built on top of AgentForge's signal-driven architecture and provides LLM-specific interaction patterns, signal types, message processing handlers, tool integration, and conversation management.
Key Features
- LLM-specific signal types for agent interactions
- Predefined handlers for processing LLM signals
- Standard flow compositions for common agent patterns
- Plugin-based extensions for LLM providers
- Task management for long-running operations
Usage Example
# Create agent with system prompt and basic tools
{flow, initial_state} = LLMAgent.Flows.conversation(
"You are a helpful assistant that can answer questions and use tools.",
[
%{
name: "search",
description: "Search the web for information",
parameters: %{
"type" => "object",
"properties" => %{
"query" => %{
"type" => "string",
"description" => "Search query"
}
},
"required" => ["query"]
},
execute: &MyApp.Tools.search/1
}
]
)
# Process a user message
{:ok, result, new_state} = AgentForge.process(
flow,
LLMAgent.Signals.user_message("What is the capital of France?"),
initial_state
)
Summary
Functions
Creates a new LLM agent with the given system prompt and tools.
Process a user message through an agent flow.
Returns the current version of LLMAgent.
Functions
Creates a new LLM agent with the given system prompt and tools.
This is a convenience function that creates a flow and initial state for a conversational agent.
Parameters
system_prompt
- The system prompt that defines the agent's behaviortools
- A list of tools that the agent can useoptions
- Additional options for configuring the agent
Returns
A tuple containing the flow and initial state for the agent.
Examples
iex> {flow, state} = LLMAgent.new("You are a helpful assistant.", [])
iex> is_function(flow) and is_map(state)
true
Process a user message through an agent flow.
Parameters
flow
- Flow to process the message with (function or list of handlers)state
- Current agent statemessage
- User message to processoptions
- Processing options
Returns
Result of processing the message through the flow.
Examples
iex> {flow, state} = LLMAgent.new("You are a helpful assistant.", [])
iex> {:ok, result, _} = LLMAgent.process(flow, state, "Hello")
iex> result.type == :response
true
Returns the current version of LLMAgent.
Examples
iex> LLMAgent.version()
"3.0.0"