Luagents.LLM (luagents v0.2.0)
View SourceLLM factory and interface for the ReAct agent.
Supports multiple LLM providers:
- Anthropic Claude (via Anthropix)
- Ollama (local models)
The effectiveness of this ReAct agent heavily depends on the underlying model's reasoning capabilities and code generation quality. For best results, use a high-quality model with strong logical reasoning and programming skills.
Usage
# Create an Anthropic LLM (default)
llm = LLM.new(provider: :anthropic)
# Create an Ollama LLM
llm = LLM.new(provider: :ollama, model: "mistral")
# Generate a response
{:ok, response} = LLM.generate(llm, "Your prompt here")
Summary
Types
@type provider() :: :anthropic | :ollama
@type t() :: Luagents.LLM.Anthropic.t() | Luagents.LLM.Ollama.t()
Functions
Generate a response from the LLM.
The LLM instance determines which provider implementation to use.
Create a new LLM instance with the specified provider.
Options
:provider- The LLM provider to use (:anthropicor:ollama)- Additional options are passed to the specific provider's
new/1function
Examples
# Use Anthropic Claude (default)
LLM.new()
LLM.new(provider: :anthropic, model: "claude-3-haiku-20240307")
# Use Ollama
LLM.new(provider: :ollama)
LLM.new(provider: :ollama, model: "mistral", host: "http://localhost:11434")