Overview

evolveRL supports multiple Language Model (LLM) backends to power its agents. Currently supported providers:
  • OpenAI (GPT-4o-mini)
  • Anthropic (Claude-3-5-sonnet)
  • LLaMA (Coming Soon)

LLM Configuration

LLM backends are configured using the LLMConfig class:
from evolverl.llm import LLMConfig, LLMBackend

# OpenAI configuration
openai_config = LLMConfig(
    model_name="gpt-4o-mini",
    model_type="openai",
    max_tokens=1000,
    temperature=0.7,
    openai_api_key="your-api-key"
)

# Anthropic configuration
anthropic_config = LLMConfig(
    model_name="claude-3-5-sonnet-20241022",
    model_type="anthropic",
    max_tokens=1000,
    temperature=0.7,
    anthropic_api_key="your-api-key"
)

# Create backend
backend = LLMBackend(openai_config)

Configuration Options

model_name
string
required
Name of the LLM model to use
model_type
string
required
Type of LLM provider (“openai” or “anthropic”)
max_tokens
integer
Maximum tokens in model responses
temperature
float
Temperature for response generation (0.0 - 1.0)

Using LLM Backends

Direct Usage

# Create backend
backend = LLMBackend(config)

# Generate text
response = await backend.generate(
    prompt="What is 2+2?",
    system_prompt="You are a math tutor."
)

With Agents

# Create agent with LLM config
agent = Agent(AgentConfig(llm_config))

# Send message
response = await agent.send_message("What is 2+2?")

Environment Variables

Store your API keys as environment variables:
# OpenAI
export OPENAI_API_KEY="your-api-key"

# Anthropic
export ANTHROPIC_API_KEY="your-api-key"
Or use a .env file:
OPENAI_API_KEY=your-api-key
ANTHROPIC_API_KEY=your-api-key

Model Selection

Choose models based on your needs:

OpenAI Models

  1. GPT-4o-mini
  2. o1-mini

Anthropic Models

  1. Claude-3-Opus
  2. Claude-3-5-Sonnet

Best Practices

  1. Error Handling: Always handle API errors gracefully
  2. Rate Limiting: Implement backoff strategies for API limits
  3. Cost Management: Monitor token usage and costs
  4. Model Selection: Start with simpler models and upgrade as needed
  5. Security: Never hardcode API keys in your code