Skip to content

Building AI agents, atomically

Some final renaming + finalize upgrade guide

KennyVaneetvelde6fa7025a4e27
diff --git a/.gitignore b/.gitignore
index 545402e..323b589 100644
--- a/.gitignore
+++ b/.gitignore
@@ -145,4 +145,7 @@ personal_scripts/
.output/
# Logs
-debug.log
\ No newline at end of file
+debug.log
+
+# AI tools
+.claude
\ No newline at end of file
diff --git a/README.md b/README.md
index 6c69ed0..30c0517 100644
--- a/README.md
+++ b/README.md
@@ -18,6 +18,9 @@
- [Atomic Agents](#atomic-agents)
- [Table of Contents](#table-of-contents)
- [Overview](#overview)
+ - [πŸš€ Version 2.0 Released!](#-version-20-released)
+ - [Key Changes in v2.0:](#key-changes-in-v20)
+ - [⚠️ Upgrading from v1.x](#️-upgrading-from-v1x)
- [Documentation](#documentation)
- [Watch the Overview Video](#watch-the-overview-video)
- [Watch the Quickstart Video](#watch-the-quickstart-video)
@@ -44,6 +47,20 @@ All logic and control flows are written in Python, enabling developers to apply
**NEW: Join our community on Discord at [discord.gg/J3W9b5AZJR](https://discord.gg/J3W9b5AZJR) and our official subreddit at [/r/AtomicAgents](https://www.reddit.com/r/AtomicAgents/)!**
+## πŸš€ Version 2.0 Released!
+
+**Atomic Agents v2.0 is here with major improvements!** This release includes breaking changes that significantly improve the developer experience:
+
+### Key Changes in v2.0:
+- **Cleaner imports**: Eliminated `.lib` from import paths
+- **Renamed classes**: `BaseAgent` β†’ `AtomicAgent`, `BaseAgentConfig` β†’ `AgentConfig`, and more
+- **Better type safety**: Generic type parameters for tools and agents
+- **Enhanced streaming**: New `run_stream()` and `run_async_stream()` methods
+- **Improved organization**: Better module structure with `context`, `connectors`, and more
+
+### ⚠️ Upgrading from v1.x
+If you're upgrading from v1.x, please read our comprehensive [**Upgrade Guide**](UPGRADE_DOC.md) for detailed migration instructions.
+
## Documentation
[![Read the Docs](https://img.shields.io/badge/docs-read%20the%20docs-blue?logo=readthedocs&style=for-the-badge)](https://brainblend-ai.github.io/atomic-agents/)
@@ -137,7 +154,7 @@ Here's a quick snippet demonstrating how easy it is to create a powerful agent w
from pydantic import Field
from openai import OpenAI
import instructor
-from atomic_agents import BaseAgent, BaseAgentConfig, BaseAgentInputSchema, BaseIOSchema
+from atomic_agents import AtomicAgent, AgentConfig, BasicChatInputSchema, BaseIOSchema
from atomic_agents.context import SystemPromptGenerator, ChatHistory
# Define a custom output schema
@@ -166,8 +183,8 @@ system_prompt_generator = SystemPromptGenerator(
client = instructor.from_openai(OpenAI())
# Initialize the agent
-agent = BaseAgent[BaseAgentInputSchema, CustomOutputSchema](
- config=BaseAgentConfig(
+agent = AtomicAgent[BasicChatInputSchema, CustomOutputSchema](
+ config=AgentConfig(
client=client,
model="gpt-4o-mini",
system_prompt_generator=system_prompt_generator,
@@ -178,7 +195,7 @@ agent = BaseAgent[BaseAgentInputSchema, CustomOutputSchema](
# Example usage
if __name__ == "__main__":
user_input = "Tell me about atomic agents framework"
- response = agent.run(BaseAgentInputSchema(chat_message=user_input))
+ response = agent.run(BasicChatInputSchema(chat_message=user_input))
print(f"Agent: {response.chat_message}")
print("Suggested questions:")
for question in response.suggested_questions:
@@ -270,7 +287,7 @@ Here's how you can achieve this:
import instructor
import openai
from pydantic import Field
-from atomic_agents import BaseIOSchema, BaseAgent, BaseAgentConfig
+from atomic_agents import BaseIOSchema, AtomicAgent, AgentConfig
from atomic_agents.context import SystemPromptGenerator
# Import the search tool you want to use
@@ -283,8 +300,8 @@ class QueryAgentInputSchema(BaseIOSchema):
num_queries: int = Field(..., description="Number of queries to generate.")
# Initialize the query agent
-query_agent = BaseAgent[QueryAgentInputSchema, SearXNGSearchTool.input_schema](
- config=BaseAgentConfig(
+query_agent = AtomicAgent[QueryAgentInputSchema, SearXNGSearchTool.input_schema](
+ config=AgentConfig(
client=instructor.from_openai(openai.OpenAI()),
model="gpt-4o-mini",
system_prompt_generator=SystemPromptGenerator(
diff --git a/UPGRADE_DOC.md b/UPGRADE_DOC.md
index db62526..38581e3 100644
--- a/UPGRADE_DOC.md
+++ b/UPGRADE_DOC.md
@@ -1,84 +1,321 @@
-# Atomic Agents Import Strategy Upgrade Guide
+# Atomic Agents v2.0 Upgrade Guide
## Overview
-Atomic Agents now provides **simplified import paths** that eliminate the need for the `.lib` directory in imports. This is a breaking change that requires updating import paths.
+Atomic Agents v2.0 introduces breaking changes to improve the developer experience through cleaner imports and better type safety. This guide helps you migrate your code from v1.x to v2.0.
-## What Changed
+## Prerequisites
-We've refactored the package structure to use module re-exports, allowing shorter, cleaner import paths:
+- **Python Version**: Ensure your environment is running Python 3.12 or higher (v2.0 requires >=3.12)
+- **Update Dependencies**:
+ ```bash
+ poetry update atomic-agents
+ # or
+ pip install --upgrade atomic-agents>=2.0.0
+ ```
-- **Core classes**: All essential base classes available from main package
-- **Module re-exports**: Components moved to `context`, factories moved to `connectors` with MCP-specific functionality under `connectors.mcp`
-- **Class renames**: `SystemPromptContextProviderBase` β†’ `BaseDynamicContextProvider`
-- **Breaking change**: Old import paths using `.lib` are no longer supported.
+## Breaking Changes and Migration
-## New Import Patterns
+### 1. Import Path Restructuring
-### Core Imports (Essential Classes)
-All base classes available from the main package:
+The `.lib` directory has been eliminated from all imports, resulting in cleaner and more intuitive paths.
+
+#### Import Migration Map
+
+**Core Classes**
```python
-from atomic_agents import BaseAgent, BaseAgentConfig, BaseIOSchema, BaseTool, BaseToolConfig
+# OLD (v1.x)
+from atomic_agents.agents.base_agent import BaseAgent, BaseAgentConfig
+from atomic_agents.lib.base.base_io_schema import BaseIOSchema
+from atomic_agents.lib.base.base_tool import BaseTool, BaseToolConfig
+
+# NEW (v2.0)
+from atomic_agents import AtomicAgent, AgentConfig, BaseIOSchema, BaseTool, BaseToolConfig
```
-### Context Imports (Cleaner Paths)
-**New (Recommended):**
+**Context Components**
```python
+# OLD (v1.x)
+from atomic_agents.lib.components.agent_memory import AgentMemory
+from atomic_agents.lib.components.system_prompt_generator import SystemPromptGenerator, SystemPromptContextProviderBase
+
+# NEW (v2.0)
from atomic_agents.context import ChatHistory, SystemPromptGenerator, BaseDynamicContextProvider
-from atomic_agents.connectors.mcp import fetch_mcp_tools_async, MCPTransportType
-from atomic_agents.utils import format_tool_message
```
-**Old (No Longer Works):**
+**MCP Integration**
```python
-from atomic_agents.lib.components.system_prompt_generator import SystemPromptGenerator, SystemPromptContextProviderBase
-from atomic_agents.lib.components.chat_history import ChatHistory
+# OLD (v1.x)
from atomic_agents.lib.factories.mcp_tool_factory import fetch_mcp_tools_async
from atomic_agents.lib.factories.tool_definition_service import MCPTransportType
+
+# NEW (v2.0)
+from atomic_agents.connectors.mcp import fetch_mcp_tools_async, MCPTransportType
+```
+
+**Utilities**
+```python
+# OLD (v1.x)
from atomic_agents.lib.utils.format_tool_message import format_tool_message
+
+# NEW (v2.0)
+from atomic_agents.utils import format_tool_message
```
-## Migration Examples
+#### How to Migrate
-### Basic Agent Creation
-**Before:**
-```python
-from atomic_agents.agents.base_agent import BaseIOSchema, BaseAgent, BaseAgentConfig
-from atomic_agents.lib.components.system_prompt_generator import SystemPromptGenerator, SystemPromptContextProviderBase
-from atomic_agents.lib.components.chat_history import ChatHistory
+Use find-and-replace across your codebase:
+```
+"atomic_agents.lib.base." β†’ "atomic_agents."
+"atomic_agents.lib.components." β†’ "atomic_agents.context."
+"atomic_agents.lib.factories." β†’ "atomic_agents.connectors.mcp."
+"atomic_agents.lib.utils." β†’ "atomic_agents.utils."
+```
+
+### 2. Class Renames
+
+Several classes have been renamed for clarity and consistency:
+
+- `BaseAgent` β†’ `AtomicAgent`
+- `BaseAgentConfig` β†’ `AgentConfig`
+- `BaseAgentInputSchema` β†’ `BasicChatInputSchema`
+- `BaseAgentOutputSchema` β†’ `BasicChatOutputSchema`
+- `AgentMemory` β†’ `ChatHistory`
+- `SystemPromptContextProviderBase` β†’ `BaseDynamicContextProvider`
+
+#### How to Migrate
+
+Find and replace these class names throughout your code:
+```
+"BaseAgent" β†’ "AtomicAgent"
+"BaseAgentConfig" β†’ "AgentConfig"
+"BaseAgentInputSchema" β†’ "BasicChatInputSchema"
+"BaseAgentOutputSchema" β†’ "BasicChatOutputSchema"
+"AgentMemory" β†’ "ChatHistory"
+"SystemPromptContextProviderBase" β†’ "BaseDynamicContextProvider"
```
-**After:**
+Also update method calls:
```python
-from atomic_agents import BaseIOSchema, BaseAgent, BaseAgentConfig
-from atomic_agents.context import SystemPromptGenerator, BaseDynamicContextProvider, ChatHistory
+# OLD
+agent.reset_memory()
+
+# NEW
+agent.reset_history()
```
-### Custom Tool Creation
-**Before:**
+### 3. Generic Type Parameters for Tools
+
+**IMPORTANT**: `BaseTool` now uses generic type parameters similar to `AtomicAgent`. This is a breaking change that affects all custom tools.
+
+#### Tool Definition Changes
+
```python
+# OLD (v1.x) - Schemas as class attributes
from atomic_agents.lib.base.base_tool import BaseTool, BaseToolConfig
from atomic_agents.lib.base.base_io_schema import BaseIOSchema
-```
-**After:**
-```python
-from atomic_agents import BaseIOSchema, BaseTool, BaseToolConfig
+class MyTool(BaseTool):
+ input_schema = MyInputSchema
+ output_schema = MyOutputSchema
+
+ def run(self, params: MyInputSchema) -> MyOutputSchema:
+ # Tool logic
+ pass
+
+# NEW (v2.0) - Schemas as type parameters
+from atomic_agents import BaseTool, BaseToolConfig, BaseIOSchema
+
+class MyTool(BaseTool[MyInputSchema, MyOutputSchema]):
+ def run(self, params: MyInputSchema) -> MyOutputSchema:
+ # Tool logic
+ pass
```
-### MCP Integration
-**Before:**
+#### How to Migrate
+
+1. **Update tool class definitions**:
+ ```python
+ # Example with calculator tool
+ # OLD
+ class CalculatorTool(BaseTool):
+ input_schema = CalculatorInputSchema
+ output_schema = CalculatorOutputSchema
+
+ # NEW
+ class CalculatorTool(BaseTool[CalculatorInputSchema, CalculatorOutputSchema]):
+ # No need for input_schema and output_schema attributes
+ ```
+
+2. **The schemas are now accessed via properties** that use the generic type parameters
+
+### 4. Agent Creation and Configuration Changes
+
+v2.0 moves schemas from configuration to type parameters and updates several configuration fields:
+
+#### Schemas Move from Config to Type Parameters
+
```python
-from atomic_agents.lib.factories.mcp_tool_factory import fetch_mcp_tools_async
-from atomic_agents.lib.factories.tool_definition_service import MCPTransportType
+# OLD (v1.x) - Schemas passed in config
+from atomic_agents.agents.base_agent import BaseAgent, BaseAgentConfig
+from atomic_agents.lib.components.agent_memory import AgentMemory
+from atomic_agents.lib.base.base_io_schema import BaseIOSchema
+from pydantic import Field
+import instructor
+from openai import OpenAI
+
+# Define custom schemas
+class CustomInputSchema(BaseIOSchema):
+ """Custom input schema for specialized agent"""
+ query: str = Field(..., description="User's query")
+ context: str = Field(default="", description="Additional context")
+
+class CustomOutputSchema(BaseIOSchema):
+ """Custom output schema for specialized agent"""
+ answer: str = Field(..., description="Agent's response")
+ confidence: float = Field(..., description="Confidence score")
+
+# Setup client
+client = instructor.from_openai(OpenAI())
+
+# Using default schemas (implicitly)
+agent = BaseAgent(
+ BaseAgentConfig(
+ client=client,
+ model="gpt-4o-mini",
+ memory=AgentMemory()
+ # No schema parameters = uses BaseAgentInputSchema and BaseAgentOutputSchema
+ )
+)
+
+# Using custom schemas (passed in config)
+agent = BaseAgent(
+ BaseAgentConfig(
+ client=client,
+ model="gpt-4o-mini",
+ memory=AgentMemory(),
+ input_schema=CustomInputSchema, # Passed in config
+ output_schema=CustomOutputSchema # Passed in config
+ )
+)
```
-**After:**
```python
-from atomic_agents.connectors.mcp import fetch_mcp_tools_async, MCPTransportType
+# NEW (v2.0) - Schemas as type parameters
+from atomic_agents import AtomicAgent, AgentConfig, BaseIOSchema, BasicChatInputSchema, BasicChatOutputSchema
+from atomic_agents.context import ChatHistory
+from pydantic import Field
+import instructor
+from openai import OpenAI
+
+# Define custom schemas (same as before)
+class CustomInputSchema(BaseIOSchema):
+ """Custom input schema for specialized agent"""
+ query: str = Field(..., description="User's query")
+ context: str = Field(default="", description="Additional context")
+
+class CustomOutputSchema(BaseIOSchema):
+ """Custom output schema for specialized agent"""
+ answer: str = Field(..., description="Agent's response")
+ confidence: float = Field(..., description="Confidence score")
+
+# Setup client
+client = instructor.from_openai(OpenAI())
+
+# Using default schemas (explicitly as type parameters)
+agent = AtomicAgent[BasicChatInputSchema, BasicChatOutputSchema](
+ AgentConfig(
+ client=client,
+ model="gpt-4o-mini",
+ history=ChatHistory()
+ )
+)
+
+# Using custom schemas (as type parameters)
+agent = AtomicAgent[CustomInputSchema, CustomOutputSchema](
+ AgentConfig(
+ client=client,
+ model="gpt-4o-mini",
+ history=ChatHistory()
+ # No schema parameters in config!
+ )
+)
```
-## Benefits
+#### How to Migrate
+
+1. **Move schemas from config to type parameters**:
+ ```python
+ # Example with custom schemas:
+ from atomic_agents import BaseIOSchema
+ from pydantic import Field
+
+ class TranslationInput(BaseIOSchema):
+ text: str = Field(..., description="Text to translate")
+ target_language: str = Field(..., description="Target language code")
+
+ class TranslationOutput(BaseIOSchema):
+ translated_text: str = Field(..., description="The translated text")
+ confidence: float = Field(..., description="Translation confidence score")
+
+ # OLD - Schemas passed in config
+ agent = BaseAgent(
+ BaseAgentConfig(
+ client=client,
+ model="gpt-4o-mini",
+ memory=AgentMemory(),
+ input_schema=TranslationInput, # Was here
+ output_schema=TranslationOutput # Was here
+ )
+ )
+
+ # NEW - Schemas as type parameters
+ agent = AtomicAgent[TranslationInput, TranslationOutput](
+ AgentConfig(
+ client=client,
+ model="gpt-4o-mini",
+ history=ChatHistory() # Note: memory β†’ history
+ # Schemas no longer in config!
+ )
+ )
+ ```
+
+2. **Update configuration fields**:
+ ```python
+ # OLD - Direct parameters
+ config = BaseAgentConfig(
+ client=client,
+ model="gpt-4o-mini",
+ memory=AgentMemory(), # Old field name
+ temperature=0.7, # Direct parameter
+ max_tokens=1000 # Direct parameter
+ )
+
+ # NEW - Grouped parameters
+ config = AgentConfig(
+ client=client,
+ model="gpt-4o-mini",
+ history=ChatHistory(), # New field name
+ model_api_parameters={ # Temperature and max_tokens moved here
+ "temperature": 0.7,
+ "max_tokens": 1000,
+ "top_p": 0.9 # Can add any API parameters here
+ }
+ )
+ ```
+
+### 5. Module Organization
+
+The package structure has been reorganized for better logical grouping:
+
+- `lib/components/` β†’ `context/` - Better reflects the purpose of these components
+- `lib/factories/` β†’ `connectors/` - Groups all connectivity-related functionality
+- MCP-specific functionality is now under `connectors.mcp/`
+- All base classes are available from the main package
+
+### 6. Benefits of v2.0
+
+The v2.0 upgrade brings several key benefits:
1. **Shorter imports**: Eliminated `.lib` from import paths
2. **Consistent API**: All base classes from main package
@@ -89,19 +326,141 @@ from atomic_agents.connectors.mcp import fetch_mcp_tools_async, MCPTransportType
- `connectors` structure allows future extension for agent-to-agent communications and other connectivity modules
- More intuitive class naming (`BaseDynamicContextProvider` vs `SystemPromptContextProviderBase`)
+### 7. Streaming and Async Support
+
+v2.0 reorganizes methods to clearly separate streaming from non-streaming operations:
+
+#### Method Overview
+
+| Client Type | Non-Streaming | Streaming |
+|-------------|---------------|-----------|
+| Sync (OpenAI) | `run()` | `run_stream()` (NEW) |
+| Async (AsyncOpenAI) | `run_async()` (behavior changed) | `run_async_stream()` (NEW) |
+
+#### Synchronous Operations
+
+```python
+# Example: A chatbot that responds to user queries
+from openai import OpenAI
+from atomic_agents import AtomicAgent, AgentConfig, BasicChatInputSchema, BasicChatOutputSchema
+from atomic_agents.context import ChatHistory
+
+client = instructor.from_openai(OpenAI())
+agent = AtomicAgent[BasicChatInputSchema, BasicChatOutputSchema](
+ AgentConfig(client=client, model="gpt-4o-mini", history=ChatHistory())
+)
+
+# Non-streaming (same as v1.x) - Wait for complete response
+user_input = BasicChatInputSchema(chat_message="Explain quantum computing")
+response = agent.run(user_input)
+print(response.chat_message) # Prints complete response at once
+
+# Streaming (NEW in v2.0) - Show response as it's generated
+user_input = BasicChatInputSchema(chat_message="Write a story about a robot")
+for partial in agent.run_stream(user_input):
+ # Print incrementally as content arrives
+ print(partial.chat_message, end='', flush=True)
+print() # New line after complete
+```
+
+#### Asynchronous Operations
+
+```python
+# Example: An async chatbot for handling multiple conversations
+from openai import AsyncOpenAI
+import asyncio
+
+client = instructor.from_openai(AsyncOpenAI())
+agent = AtomicAgent[BasicChatInputSchema, BasicChatOutputSchema](
+ AgentConfig(client=client, model="gpt-4o-mini", history=ChatHistory())
+)
+
+# OLD (v1.x) - run_async was a streaming generator
+async def old_chat():
+ user_input = BasicChatInputSchema(chat_message="Hello!")
+ async for partial in agent.run_async(user_input):
+ print(partial.chat_message) # This was streaming
+
+# NEW (v2.0) - run_async returns complete response
+async def new_chat_complete():
+ user_input = BasicChatInputSchema(chat_message="Hello!")
+ response = await agent.run_async(user_input)
+ print(response.chat_message) # Complete response
+
+# NEW (v2.0) - run_async_stream for streaming
+async def new_chat_stream():
+ user_input = BasicChatInputSchema(chat_message="Tell me a joke")
+ async for partial in agent.run_async_stream(user_input):
+ print(partial.chat_message, end='', flush=True)
+ print() # New line after complete
+```
+
+**Key Breaking Change**: In v1.x, `run_async()` was a streaming generator. In v2.0, it returns a complete response. Use `run_async_stream()` for async streaming.
+
+#### How to Migrate
+
+If you were using `run_async()` for streaming:
+```python
+# OLD
+async for partial in agent.run_async(user_input):
+ print(partial.chat_message)
+
+# NEW - Option 1: Get complete response
+response = await agent.run_async(user_input)
+print(response.chat_message)
+
+# NEW - Option 2: Keep streaming behavior
+async for partial in agent.run_async_stream(user_input):
+ print(partial.chat_message)
+```
+
+### 8. MCP Tool Factory Enhancements
+
+The MCP (Model Context Protocol) integration has been significantly enhanced:
+
+#### New Transport Types
+```python
+from atomic_agents.connectors.mcp import MCPTransportType
+
+# v2.0 adds HTTP_STREAM transport as the new default
+transport_type = MCPTransportType.HTTP_STREAM # New default (changed from SSE)
+# Also available: MCPTransportType.SSE, MCPTransportType.STDIO
+```
+
+**Important**: The default transport type has changed from `SSE` in v1.x to `HTTP_STREAM` in v2.0. If your MCP servers only support SSE, you'll need to explicitly specify it.
+
+#### Async Tool Execution
+MCP tools now expose an `arun` method for async execution:
+
+```python
+# Each MCP tool now has both sync and async entry points
+result = tool.run(params) # Synchronous
+result = await tool.arun(params) # Asynchronous (new in v2.0)
+```
+
+**Note**: The `arun` method is automatically generated for MCP tools during tool factory creation.
+
+#### Fetching Tools Without Event Loop
+```python
+from atomic_agents.connectors.mcp import fetch_mcp_tools_async
+
+# New async fetcher that doesn't require an active event loop
+tools = await fetch_mcp_tools_async(
+ endpoint="http://localhost:3000",
+ transport_type=MCPTransportType.HTTP_STREAM
+)
+```
+
## Migration Strategy
### Required Migration
-This upgrade introduces breaking changes. All projects must be updated to use the new import paths.
+This upgrade introduces breaking changes. All projects must be updated to use the new import paths and class names.
### Recommended Approach
1. **Update all imports**: Replace old `.lib` imports with the new, shorter paths.
-2. **Test thoroughly**: Ensure all parts of your application work as expected after the migration.
-
-## Important Notes
-
-- **Breaking Changes**: This version is not backward compatible.
-- **Mandatory Migration**: You must update your import paths to continue using the library.
+2. **Rename all classes**: Use find-and-replace to update all class names as specified above.
+3. **Update tool definitions**: Convert tools to use generic type parameters.
+4. **Test thoroughly**: Ensure all parts of your application work as expected after the migration.
## Additional Updates
@@ -113,4 +472,284 @@ Examples and forge dependencies have been updated using `poetry update atomic-ag
## Version Information
-These import improvements are available starting from Atomic Agents v2.0.0.
+These improvements are available starting from Atomic Agents v2.0.0.
+
+## Complete Migration Examples
+
+### Example 1: Migrating a Custom Tool
+
+Here's how to migrate a custom tool from v1.x to v2.0:
+
+#### Before (v1.x)
+
+```python
+from atomic_agents.lib.base.base_tool import BaseTool, BaseToolConfig
+from atomic_agents.lib.base.base_io_schema import BaseIOSchema
+from pydantic import Field
+import requests
+
+class WeatherToolInputSchema(BaseIOSchema):
+ """Input schema for weather tool"""
+ city: str = Field(..., description="City name to get weather for")
+ units: str = Field(default="metric", description="Temperature units (metric/imperial)")
+
+class WeatherToolOutputSchema(BaseIOSchema):
+ """Output schema for weather tool"""
+ temperature: float = Field(..., description="Current temperature")
+ description: str = Field(..., description="Weather description")
+ humidity: int = Field(..., description="Humidity percentage")
+
+class WeatherTool(BaseTool):
+ """Tool for fetching weather information"""
+
+ input_schema = WeatherToolInputSchema
+ output_schema = WeatherToolOutputSchema
+
+ def __init__(self, api_key: str, config: BaseToolConfig = BaseToolConfig()):
+ super().__init__(config)
+ self.api_key = api_key
+
+ def run(self, params: WeatherToolInputSchema) -> WeatherToolOutputSchema:
+ # Tool implementation
+ response = requests.get(
+ f"https://api.weather.com/v1/weather",
+ params={"city": params.city, "units": params.units, "api_key": self.api_key}
+ )
+ data = response.json()
+ return WeatherToolOutputSchema(
+ temperature=data["temp"],
+ description=data["description"],
+ humidity=data["humidity"]
+ )
+```
+
+#### After (v2.0)
+
+```python
+from atomic_agents import BaseTool, BaseToolConfig, BaseIOSchema
+from pydantic import Field
+import requests
+
+class WeatherToolInputSchema(BaseIOSchema):
+ """Input schema for weather tool"""
+ city: str = Field(..., description="City name to get weather for")
+ units: str = Field(default="metric", description="Temperature units (metric/imperial)")
+
+class WeatherToolOutputSchema(BaseIOSchema):
+ """Output schema for weather tool"""
+ temperature: float = Field(..., description="Current temperature")
+ description: str = Field(..., description="Weather description")
+ humidity: int = Field(..., description="Humidity percentage")
+
+class WeatherTool(BaseTool[WeatherToolInputSchema, WeatherToolOutputSchema]):
+ """Tool for fetching weather information"""
+
+ def __init__(self, api_key: str, config: BaseToolConfig = BaseToolConfig()):
+ super().__init__(config)
+ self.api_key = api_key
+
+ def run(self, params: WeatherToolInputSchema) -> WeatherToolOutputSchema:
+ # Tool implementation (unchanged)
+ response = requests.get(
+ f"https://api.weather.com/v1/weather",
+ params={"city": params.city, "units": params.units, "api_key": self.api_key}
+ )
+ data = response.json()
+ return WeatherToolOutputSchema(
+ temperature=data["temp"],
+ description=data["description"],
+ humidity=data["humidity"]
+ )
+```
+
+### Example 2: Migrating a Customer Support Agent
+
+Here's a real-world example of migrating a customer support agent:
+
+#### Before (v1.x)
+
+```python
+from atomic_agents.agents.base_agent import BaseAgent, BaseAgentConfig, BaseAgentInputSchema
+from atomic_agents.lib.base.base_io_schema import BaseIOSchema
+from atomic_agents.lib.components.agent_memory import AgentMemory
+from atomic_agents.lib.components.system_prompt_generator import SystemPromptGenerator
+from pydantic import Field
+from typing import List
+import instructor
+from openai import OpenAI
+
+# Custom schemas for a support agent
+class SupportTicketInput(BaseIOSchema):
+ customer_name: str = Field(..., description="Customer's name")
+ issue_description: str = Field(..., description="Description of the issue")
+ priority: str = Field(..., description="Priority level: low, medium, high")
+
+class SupportTicketOutput(BaseIOSchema):
+ response_message: str = Field(..., description="Response to the customer")
+ suggested_actions: List[str] = Field(..., description="Suggested actions to resolve the issue")
+ estimated_resolution_time: str = Field(..., description="Estimated time to resolve")
+ needs_escalation: bool = Field(..., description="Whether this needs escalation")
+
+# Setup
+client = instructor.from_openai(OpenAI())
+memory = AgentMemory()
+
+# System prompt configuration
+system_prompt = SystemPromptGenerator(
+ background=["You are a helpful customer support agent."],
+ steps=["Analyze the issue", "Provide a solution", "Determine if escalation is needed"],
+ output_instructions=["Be empathetic and professional"]
+)
+
+# Create agent with old configuration
+agent = BaseAgent(
+ BaseAgentConfig(
+ client=client,
+ model="gpt-4o-mini",
+ memory=memory,
+ system_prompt_generator=system_prompt,
+ input_schema=SupportTicketInput,
+ output_schema=SupportTicketOutput,
+ temperature=0.7,
+ max_tokens=500
+ )
+)
+
+# Use the agent
+ticket = SupportTicketInput(
+ customer_name="John Doe",
+ issue_description="My order hasn't arrived after 2 weeks",
+ priority="high"
+)
+response = agent.run(ticket)
+print(f"Response: {response.response_message}")
+print(f"Needs escalation: {response.needs_escalation}")
+```
+
+#### After (v2.0)
+
+```python
+from atomic_agents import AtomicAgent, AgentConfig, BaseIOSchema
+from atomic_agents.context import ChatHistory, SystemPromptGenerator
+from pydantic import Field
+from typing import List
+import instructor
+from openai import OpenAI
+
+# Same custom schemas (no changes needed)
+class SupportTicketInput(BaseIOSchema):
+ customer_name: str = Field(..., description="Customer's name")
+ issue_description: str = Field(..., description="Description of the issue")
+ priority: str = Field(..., description="Priority level: low, medium, high")
+
+class SupportTicketOutput(BaseIOSchema):
+ response_message: str = Field(..., description="Response to the customer")
+ suggested_actions: List[str] = Field(..., description="Suggested actions to resolve the issue")
+ estimated_resolution_time: str = Field(..., description="Estimated time to resolve")
+ needs_escalation: bool = Field(..., description="Whether this needs escalation")
+
+# Setup
+client = instructor.from_openai(OpenAI())
+history = ChatHistory() # Renamed from AgentMemory
+
+# System prompt configuration (same structure)
+system_prompt = SystemPromptGenerator(
+ background=["You are a helpful customer support agent."],
+ steps=["Analyze the issue", "Provide a solution", "Determine if escalation is needed"],
+ output_instructions=["Be empathetic and professional"]
+)
+
+# Create agent with new configuration
+agent = AtomicAgent[SupportTicketInput, SupportTicketOutput]( # Schemas as type parameters
+ AgentConfig(
+ client=client,
+ model="gpt-4o-mini",
+ history=history, # Changed from memory
+ system_prompt_generator=system_prompt,
+ # No input_schema or output_schema in config
+ model_api_parameters={ # Temperature and max_tokens moved here
+ "temperature": 0.7,
+ "max_tokens": 500
+ }
+ )
+)
+
+# Use the agent (same usage)
+ticket = SupportTicketInput(
+ customer_name="John Doe",
+ issue_description="My order hasn't arrived after 2 weeks",
+ priority="high"
+)
+response = agent.run(ticket)
+print(f"Response: {response.response_message}")
+print(f"Needs escalation: {response.needs_escalation}")
+
+# NEW: Can also use streaming for real-time responses
+print("\nStreaming response:")
+for partial in agent.run_stream(ticket):
+ print(partial.response_message, end='', flush=True)
+```
+
+## Quick Reference
+
+| Feature | v1.x | v2.0 |
+|---------|------|------|
+| Python version | >=3.10 | >=3.12 |
+| Base imports | `from atomic_agents.lib.base.base_io_schema import BaseIOSchema` | `from atomic_agents import BaseIOSchema` |
+| Context imports | `from atomic_agents.lib.components.agent_memory import AgentMemory` | `from atomic_agents.context import ChatHistory` |
+| MCP imports | `from atomic_agents.lib.factories.mcp_tool_factory import ...` | `from atomic_agents.connectors.mcp import ...` |
+| Agent class | `BaseAgent` | `AtomicAgent` |
+| Agent config | `BaseAgentConfig` | `AgentConfig` |
+| Default input schema | `BaseAgentInputSchema` | `BasicChatInputSchema` |
+| Default output schema | `BaseAgentOutputSchema` | `BasicChatOutputSchema` |
+| Memory class | `AgentMemory()` | `ChatHistory()` |
+| Context provider base | `class MyProvider(SystemPromptContextProviderBase)` | `class MyProvider(BaseDynamicContextProvider)` |
+| Agent with custom schemas | `BaseAgent(config(input_schema=QueryInput, output_schema=AnalysisOutput))` | `AtomicAgent[QueryInput, AnalysisOutput](config)` |
+| Tool with custom schemas | `class MyTool(BaseTool): input_schema = In; output_schema = Out` | `class MyTool(BaseTool[In, Out]): pass` |
+| Async non-streaming | `async for partial in agent.run_async(input)` | `response = await agent.run_async(input)` |
+| Async streaming | `async for partial in agent.run_async(input)` | `async for partial in agent.run_async_stream(input)` |
+| Sync streaming | Not available | `for partial in agent.run_stream(input)` |
+| Reset conversation | `agent.reset_memory()` | `agent.reset_history()` |
+| Model parameters | `config(temperature=0.7, max_tokens=500)` | `config(model_api_parameters={"temperature": 0.7, "max_tokens": 500})` |
+
+## Troubleshooting
+
+### Import Errors
+
+If you encounter import errors after upgrading:
+
+1. Ensure all old `.lib` imports are updated
+2. Check that class renames are applied:
+ - `BaseAgent` β†’ `AtomicAgent`
+ - `BaseAgentConfig` β†’ `AgentConfig`
+ - `BaseAgentInputSchema` β†’ `BasicChatInputSchema`
+ - `BaseAgentOutputSchema` β†’ `BasicChatOutputSchema`
+ - `AgentMemory` β†’ `ChatHistory`
+3. Verify that the package is correctly installed with v2.0
+
+### Type Errors
+
+If you get type errors with the new generic AtomicAgent or BaseTool:
+
+1. Ensure you're specifying both input and output schemas: `AtomicAgent[InputSchema, OutputSchema]`
+2. Remove `input_schema` and `output_schema` from `AgentConfig`
+3. For tools, update from `class MyTool(BaseTool)` to `class MyTool(BaseTool[InputSchema, OutputSchema])`
+4. Make sure your schemas inherit from `BaseIOSchema`
+5. If using default schemas, specify them explicitly: `AtomicAgent[BasicChatInputSchema, BasicChatOutputSchema]`
+
+### Runtime Errors
+
+If you encounter runtime errors:
+
+1. Check that all references to `memory` are updated to `history`
+2. Verify that custom context providers inherit from `BaseDynamicContextProvider`
+3. Ensure Python version is 3.12 or higher
+
+## Support
+
+If you encounter issues during migration:
+
+1. Check the [GitHub Issues](https://github.com/BrainBlend-AI/atomic-agents/issues)
+2. Join the [Discord community](https://discord.gg/J3W9b5AZJR)
+3. Visit the [subreddit](https://www.reddit.com/r/AtomicAgents/)
+
diff --git a/atomic-agents/atomic_agents/__init__.py b/atomic-agents/atomic_agents/__init__.py
index 75339da..a493b27 100644
--- a/atomic-agents/atomic_agents/__init__.py
+++ b/atomic-agents/atomic_agents/__init__.py
@@ -3,17 +3,17 @@ Atomic Agents - A modular framework for building AI agents.
"""
# Core exports - base classes only
-from .agents.base_agent import BaseAgent, BaseAgentConfig, BaseAgentInputSchema, BaseAgentOutputSchema
+from .agents.base_agent import AtomicAgent, AgentConfig, BasicChatInputSchema, BasicChatOutputSchema
from .base import BaseIOSchema, BaseTool, BaseToolConfig
# Version info
__version__ = "2.0.0"
__all__ = [
- "BaseAgent",
- "BaseAgentConfig",
- "BaseAgentInputSchema",
- "BaseAgentOutputSchema",
+ "AtomicAgent",
+ "AgentConfig",
+ "BasicChatInputSchema",
+ "BasicChatOutputSchema",
"BaseIOSchema",
"BaseTool",
"BaseToolConfig",
diff --git a/atomic-agents/atomic_agents/agents/__init__.py b/atomic-agents/atomic_agents/agents/__init__.py
index d459c25..df4c32d 100644
--- a/atomic-agents/atomic_agents/agents/__init__.py
+++ b/atomic-agents/atomic_agents/agents/__init__.py
@@ -1,15 +1,15 @@
"""Agent implementations and configurations."""
from .base_agent import (
- BaseAgent,
- BaseAgentConfig,
- BaseAgentInputSchema,
- BaseAgentOutputSchema,
+ AtomicAgent,
+ AgentConfig,
+ BasicChatInputSchema,
+ BasicChatOutputSchema,
)
__all__ = [
- "BaseAgent",
- "BaseAgentConfig",
- "BaseAgentInputSchema",
- "BaseAgentOutputSchema",
+ "AtomicAgent",
+ "AgentConfig",
+ "BasicChatInputSchema",
+ "BasicChatOutputSchema",
]
diff --git a/atomic-agents/atomic_agents/agents/base_agent.py b/atomic-agents/atomic_agents/agents/base_agent.py
index 519c7de..0f4d5e6 100644
--- a/atomic-agents/atomic_agents/agents/base_agent.py
+++ b/atomic-agents/atomic_agents/agents/base_agent.py
@@ -36,7 +36,7 @@ PartialBase.model_from_chunks = classmethod(model_from_chunks_patched)
PartialBase.model_from_chunks_async = classmethod(model_from_chunks_async_patched)
-class BaseAgentInputSchema(BaseIOSchema):
+class BasicChatInputSchema(BaseIOSchema):
"""This schema represents the input from the user to the AI agent."""
chat_message: str = Field(
@@ -45,7 +45,7 @@ class BaseAgentInputSchema(BaseIOSchema):
)
-class BaseAgentOutputSchema(BaseIOSchema):
+class BasicChatOutputSchema(BaseIOSchema):
"""This schema represents the response generated by the chat agent."""
chat_message: str = Field(
@@ -57,7 +57,7 @@ class BaseAgentOutputSchema(BaseIOSchema):
)
-class BaseAgentConfig(BaseModel):
+class AgentConfig(BaseModel):
client: instructor.client.Instructor = Field(..., description="Client for interacting with the language model.")
model: str = Field(default="gpt-4o-mini", description="The model to use for generating responses.")
history: Optional[ChatHistory] = Field(default=None, description="History component for storing chat history.")
@@ -71,7 +71,7 @@ class BaseAgentConfig(BaseModel):
model_api_parameters: Optional[dict] = Field(None, description="Additional parameters passed to the API provider.")
-class BaseAgent[InputSchema: BaseIOSchema, OutputSchema: BaseIOSchema]:
+class AtomicAgent[InputSchema: BaseIOSchema, OutputSchema: BaseIOSchema]:
"""
Base class for chat agents.
@@ -94,12 +94,12 @@ class BaseAgent[InputSchema: BaseIOSchema, OutputSchema: BaseIOSchema]:
- Use this for parameters like 'temperature', 'max_tokens', etc.
"""
- def __init__(self, config: BaseAgentConfig):
+ def __init__(self, config: AgentConfig):
"""
- Initializes the BaseAgent.
+ Initializes the AtomicAgent.
Args:
- config (BaseAgentConfig): Configuration for the chat agent.
+ config (AgentConfig): Configuration for the chat agent.
"""
self.client = config.client
self.model = config.model
@@ -121,7 +121,7 @@ class BaseAgent[InputSchema: BaseIOSchema, OutputSchema: BaseIOSchema]:
if hasattr(self, "__orig_class__"):
TI, _ = get_args(self.__orig_class__)
else:
- TI = BaseAgentInputSchema
+ TI = BasicChatInputSchema
return TI
@@ -130,7 +130,7 @@ class BaseAgent[InputSchema: BaseIOSchema, OutputSchema: BaseIOSchema]:
if hasattr(self, "__orig_class__"):
_, TO = get_args(self.__orig_class__)
else:
- TO = BaseAgentOutputSchema
+ TO = BasicChatOutputSchema
return TO
@@ -351,11 +351,11 @@ if __name__ == "__main__":
return schema_table
- def _create_config_table(agent: BaseAgent) -> Table:
+ def _create_config_table(agent: AtomicAgent) -> Table:
"""Create a table displaying agent configuration.
Args:
- agent (BaseAgent): Agent instance
+ agent (AtomicAgent): Agent instance
Returns:
Table: Rich table containing configuration information
@@ -370,7 +370,7 @@ if __name__ == "__main__":
return info_table
- def display_agent_info(agent: BaseAgent):
+ def display_agent_info(agent: AtomicAgent):
"""Display information about the agent's configuration and schemas."""
console = Console()
console.print(
@@ -412,12 +412,12 @@ if __name__ == "__main__":
"""
if streaming:
client = instructor.from_openai(AsyncOpenAI())
- config = BaseAgentConfig(client=client, model="gpt-4o-mini")
- agent = BaseAgent[BaseAgentInputSchema, BaseAgentOutputSchema](config)
+ config = AgentConfig(client=client, model="gpt-4o-mini")
+ agent = AtomicAgent[BasicChatInputSchema, BasicChatOutputSchema](config)
else:
client = instructor.from_openai(OpenAI())
- config = BaseAgentConfig(client=client, model="gpt-4o-mini")
- agent = BaseAgent[BaseAgentInputSchema, BaseAgentOutputSchema](config)
+ config = AgentConfig(client=client, model="gpt-4o-mini")
+ agent = AtomicAgent[BasicChatInputSchema, BasicChatOutputSchema](config)
# Display agent information before starting the chat
display_agent_info(agent)
diff --git a/atomic-agents/tests/agents/test_base_agent.py b/atomic-agents/tests/agents/test_base_agent.py
index 315ee94..bf6624d 100644
--- a/atomic-agents/tests/agents/test_base_agent.py
+++ b/atomic-agents/tests/agents/test_base_agent.py
@@ -4,10 +4,10 @@ from pydantic import BaseModel
import instructor
from atomic_agents import (
BaseIOSchema,
- BaseAgent,
- BaseAgentConfig,
- BaseAgentInputSchema,
- BaseAgentOutputSchema,
+ AtomicAgent,
+ AgentConfig,
+ BasicChatInputSchema,
+ BasicChatOutputSchema,
)
from atomic_agents.context import ChatHistory, SystemPromptGenerator, BaseDynamicContextProvider
from instructor.dsl.partial import PartialBase
@@ -19,10 +19,10 @@ def mock_instructor():
# Set up the nested mock structure
mock.chat = Mock()
mock.chat.completions = Mock()
- mock.chat.completions.create = Mock(return_value=BaseAgentOutputSchema(chat_message="Test output"))
+ mock.chat.completions.create = Mock(return_value=BasicChatOutputSchema(chat_message="Test output"))
# Make create_partial return an iterable
- mock_response = BaseAgentOutputSchema(chat_message="Test output")
+ mock_response = BasicChatOutputSchema(chat_message="Test output")
mock_iter = Mock()
mock_iter.__iter__ = Mock(return_value=iter([mock_response]))
mock.chat.completions.create_partial.return_value = mock_iter
@@ -41,13 +41,13 @@ def mock_instructor_async():
# Make create method awaitable by using an async function
async def mock_create(*args, **kwargs):
- return BaseAgentOutputSchema(chat_message="Test output")
+ return BasicChatOutputSchema(chat_message="Test output")
mock.chat.completions.create = mock_create
# Mock the create_partial method to return an async generator
async def mock_create_partial(*args, **kwargs):
- yield BaseAgentOutputSchema(chat_message="Test output")
+ yield BasicChatOutputSchema(chat_message="Test output")
mock.chat.completions.create_partial = mock_create_partial
@@ -74,7 +74,7 @@ def mock_system_prompt_generator():
@pytest.fixture
def agent_config(mock_instructor, mock_history, mock_system_prompt_generator):
- return BaseAgentConfig(
+ return AgentConfig(
client=mock_instructor,
model="gpt-4o-mini",
history=mock_history,
@@ -84,12 +84,12 @@ def agent_config(mock_instructor, mock_history, mock_system_prompt_generator):
@pytest.fixture
def agent(agent_config):
- return BaseAgent[BaseAgentInputSchema, BaseAgentOutputSchema](agent_config)
+ return AtomicAgent[BasicChatInputSchema, BasicChatOutputSchema](agent_config)
@pytest.fixture
def agent_config_async(mock_instructor_async, mock_history, mock_system_prompt_generator):
- return BaseAgentConfig(
+ return AgentConfig(
client=mock_instructor_async,
model="gpt-4o-mini",
history=mock_history,
@@ -99,7 +99,7 @@ def agent_config_async(mock_instructor_async, mock_history, mock_system_prompt_g
@pytest.fixture
def agent_async(agent_config_async):
- return BaseAgent[BaseAgentInputSchema, BaseAgentOutputSchema](agent_config_async)
+ return AtomicAgent[BasicChatInputSchema, BasicChatOutputSchema](agent_config_async)
def test_initialization(agent, mock_instructor, mock_history, mock_system_prompt_generator):
@@ -112,43 +112,43 @@ def test_initialization(agent, mock_instructor, mock_history, mock_system_prompt
# model_api_parameters should have priority over other settings
def test_initialization_temperature_priority(mock_instructor, mock_history, mock_system_prompt_generator):
- config = BaseAgentConfig(
+ config = AgentConfig(
client=mock_instructor,
model="gpt-4o-mini",
history=mock_history,
system_prompt_generator=mock_system_prompt_generator,
model_api_parameters={"temperature": 1.0},
)
- agent = BaseAgent[BaseAgentInputSchema, BaseAgentOutputSchema](config)
+ agent = AtomicAgent[BasicChatInputSchema, BasicChatOutputSchema](config)
assert agent.model_api_parameters["temperature"] == 1.0
def test_initialization_without_temperature(mock_instructor, mock_history, mock_system_prompt_generator):
- config = BaseAgentConfig(
+ config = AgentConfig(
client=mock_instructor,
model="gpt-4o-mini",
history=mock_history,
system_prompt_generator=mock_system_prompt_generator,
model_api_parameters={"temperature": 0.5},
)
- agent = BaseAgent[BaseAgentInputSchema, BaseAgentOutputSchema](config)
+ agent = AtomicAgent[BasicChatInputSchema, BasicChatOutputSchema](config)
assert agent.model_api_parameters["temperature"] == 0.5
def test_initialization_without_max_tokens(mock_instructor, mock_history, mock_system_prompt_generator):
- config = BaseAgentConfig(
+ config = AgentConfig(
client=mock_instructor,
model="gpt-4o-mini",
history=mock_history,
system_prompt_generator=mock_system_prompt_generator,
model_api_parameters={"max_tokens": 1024},
)
- agent = BaseAgent[BaseAgentInputSchema, BaseAgentOutputSchema](config)
+ agent = AtomicAgent[BasicChatInputSchema, BasicChatOutputSchema](config)
assert agent.model_api_parameters["max_tokens"] == 1024
def test_initialization_system_role_equals_developer(mock_instructor, mock_history, mock_system_prompt_generator):
- config = BaseAgentConfig(
+ config = AgentConfig(
client=mock_instructor,
model="gpt-4o-mini",
history=mock_history,
@@ -156,13 +156,13 @@ def test_initialization_system_role_equals_developer(mock_instructor, mock_histo
system_role="developer",
model_api_parameters={}, # No temperature specified
)
- agent = BaseAgent[BaseAgentInputSchema, BaseAgentOutputSchema](config)
+ agent = AtomicAgent[BasicChatInputSchema, BasicChatOutputSchema](config)
_ = agent._prepare_messages()
assert isinstance(agent.messages, list) and agent.messages[0]["role"] == "developer"
def test_initialization_system_role_equals_None(mock_instructor, mock_history, mock_system_prompt_generator):
- config = BaseAgentConfig(
+ config = AgentConfig(
client=mock_instructor,
model="gpt-4o-mini",
history=mock_history,
@@ -170,7 +170,7 @@ def test_initialization_system_role_equals_None(mock_instructor, mock_history, m
system_role=None,
model_api_parameters={}, # No temperature specified
)
- agent = BaseAgent[BaseAgentInputSchema, BaseAgentOutputSchema](config)
+ agent = AtomicAgent[BasicChatInputSchema, BasicChatOutputSchema](config)
_ = agent._prepare_messages()
assert isinstance(agent.messages, list) and len(agent.messages) == 0
@@ -213,15 +213,15 @@ def test_unregister_context_provider(agent, mock_system_prompt_generator):
def test_no_type_parameters(mock_instructor):
- custom_config = BaseAgentConfig(
+ custom_config = AgentConfig(
client=mock_instructor,
model="gpt-4o-mini",
)
- custom_agent = BaseAgent(custom_config)
+ custom_agent = AtomicAgent(custom_config)
- assert custom_agent.input_schema == BaseAgentInputSchema
- assert custom_agent.output_schema == BaseAgentOutputSchema
+ assert custom_agent.input_schema == BasicChatInputSchema
+ assert custom_agent.output_schema == BasicChatOutputSchema
def test_custom_input_output_schemas(mock_instructor):
@@ -231,12 +231,12 @@ def test_custom_input_output_schemas(mock_instructor):
class CustomOutputSchema(BaseModel):
result: str
- custom_config = BaseAgentConfig(
+ custom_config = AgentConfig(
client=mock_instructor,
model="gpt-4o-mini",
)
- custom_agent = BaseAgent[CustomInputSchema, CustomOutputSchema](custom_config)
+ custom_agent = AtomicAgent[CustomInputSchema, CustomOutputSchema](custom_config)
assert custom_agent.input_schema == CustomInputSchema
assert custom_agent.output_schema == CustomOutputSchema
@@ -278,7 +278,7 @@ def test_base_io_schema_model_json_schema_no_description():
def test_run(agent, mock_history):
# Use the agent fixture that's already configured correctly
- mock_input = BaseAgentInputSchema(chat_message="Test input")
+ mock_input = BasicChatInputSchema(chat_message="Test input")
result = agent.run(mock_input)
@@ -290,17 +290,17 @@ def test_run(agent, mock_history):
def test_run_stream(mock_instructor, mock_history):
- # Create a BaseAgentConfig with system_role set to None
- config = BaseAgentConfig(
+ # Create a AgentConfig with system_role set to None
+ config = AgentConfig(
client=mock_instructor,
model="gpt-4o-mini",
history=mock_history,
system_prompt_generator=None, # No system prompt generator
)
- agent = BaseAgent[BaseAgentInputSchema, BaseAgentOutputSchema](config)
+ agent = AtomicAgent[BasicChatInputSchema, BasicChatOutputSchema](config)
- mock_input = BaseAgentInputSchema(chat_message="Test input")
- mock_output = BaseAgentOutputSchema(chat_message="Test output")
+ mock_input = BasicChatInputSchema(chat_message="Test input")
+ mock_output = BasicChatOutputSchema(chat_message="Test output")
for result in agent.run_stream(mock_input):
pass
@@ -314,8 +314,8 @@ def test_run_stream(mock_instructor, mock_history):
@pytest.mark.asyncio
async def test_run_async(agent_async, mock_history):
# Create a mock input
- mock_input = BaseAgentInputSchema(chat_message="Test input")
- mock_output = BaseAgentOutputSchema(chat_message="Test output")
+ mock_input = BasicChatInputSchema(chat_message="Test input")
+ mock_output = BasicChatOutputSchema(chat_message="Test output")
# Get response from run_async method
response = await agent_async.run_async(mock_input)
@@ -329,8 +329,8 @@ async def test_run_async(agent_async, mock_history):
@pytest.mark.asyncio
async def test_run_async_stream(agent_async, mock_history):
# Create a mock input
- mock_input = BaseAgentInputSchema(chat_message="Test input")
- mock_output = BaseAgentOutputSchema(chat_message="Test output")
+ mock_input = BasicChatInputSchema(chat_message="Test input")
+ mock_output = BasicChatOutputSchema(chat_message="Test output")
responses = []
# Get response from run_async_stream method
diff --git a/atomic-examples/basic-multimodal/basic_multimodal/main.py b/atomic-examples/basic-multimodal/basic_multimodal/main.py
index 6f2a0ed..0a53ae3 100644
--- a/atomic-examples/basic-multimodal/basic_multimodal/main.py
+++ b/atomic-examples/basic-multimodal/basic_multimodal/main.py
@@ -1,4 +1,4 @@
-from atomic_agents import BaseAgent, BaseAgentConfig, BaseIOSchema
+from atomic_agents import AtomicAgent, AgentConfig, BaseIOSchema
from atomic_agents.context import SystemPromptGenerator
import instructor
import openai
@@ -59,8 +59,8 @@ class NutritionAnalysisOutput(BaseIOSchema):
# Configure the nutrition analysis system
-nutrition_analyzer = BaseAgent[NutritionAnalysisInput, NutritionAnalysisOutput](
- config=BaseAgentConfig(
+nutrition_analyzer = AtomicAgent[NutritionAnalysisInput, NutritionAnalysisOutput](
+ config=AgentConfig(
client=instructor.from_openai(openai.OpenAI(api_key=API_KEY)),
model="gpt-4o-mini",
system_prompt_generator=SystemPromptGenerator(
diff --git a/atomic-examples/basic-pdf-analysis/basic_pdf_analysis/main.py b/atomic-examples/basic-pdf-analysis/basic_pdf_analysis/main.py
index e7b8611..f564d9e 100644
--- a/atomic-examples/basic-pdf-analysis/basic_pdf_analysis/main.py
+++ b/atomic-examples/basic-pdf-analysis/basic_pdf_analysis/main.py
@@ -1,7 +1,7 @@
import os
import instructor
-from atomic_agents import BaseAgent, BaseAgentConfig, BaseIOSchema
+from atomic_agents import AtomicAgent, AgentConfig, BaseIOSchema
from atomic_agents.context import SystemPromptGenerator
from dotenv import load_dotenv
from google import genai
@@ -40,8 +40,8 @@ system_prompt_generator = SystemPromptGenerator(
)
# Define the agent
-agent = BaseAgent[InputSchema, ExtractionResult](
- config=BaseAgentConfig(
+agent = AtomicAgent[InputSchema, ExtractionResult](
+ config=AgentConfig(
client=client,
model="gemini-2.0-flash",
system_prompt_generator=system_prompt_generator,
diff --git a/atomic-examples/deep-research/deep_research/agents/choice_agent.py b/atomic-examples/deep-research/deep_research/agents/choice_agent.py
index 565bebc..0d51a84 100644
--- a/atomic-examples/deep-research/deep_research/agents/choice_agent.py
+++ b/atomic-examples/deep-research/deep_research/agents/choice_agent.py
@@ -1,7 +1,7 @@
import instructor
import openai
from pydantic import Field
-from atomic_agents import BaseIOSchema, BaseAgent, BaseAgentConfig
+from atomic_agents import BaseIOSchema, AtomicAgent, AgentConfig
from atomic_agents.context import SystemPromptGenerator
from deep_research.config import ChatConfig
@@ -21,8 +21,8 @@ class ChoiceAgentOutputSchema(BaseIOSchema):
decision: bool = Field(..., description="The final decision based on the analysis")
-choice_agent = BaseAgent[ChoiceAgentInputSchema, ChoiceAgentOutputSchema](
- BaseAgentConfig(
+choice_agent = AtomicAgent[ChoiceAgentInputSchema, ChoiceAgentOutputSchema](
+ AgentConfig(
client=instructor.from_openai(openai.OpenAI(api_key=ChatConfig.api_key)),
model=ChatConfig.model,
system_prompt_generator=SystemPromptGenerator(
diff --git a/atomic-examples/deep-research/deep_research/agents/qa_agent.py b/atomic-examples/deep-research/deep_research/agents/qa_agent.py
index 9c209db..d83483c 100644
--- a/atomic-examples/deep-research/deep_research/agents/qa_agent.py
+++ b/atomic-examples/deep-research/deep_research/agents/qa_agent.py
@@ -1,7 +1,7 @@
import instructor
import openai
from pydantic import Field
-from atomic_agents import BaseIOSchema, BaseAgent, BaseAgentConfig
+from atomic_agents import BaseIOSchema, AtomicAgent, AgentConfig
from atomic_agents.context import SystemPromptGenerator
from deep_research.config import ChatConfig
@@ -27,8 +27,8 @@ class QuestionAnsweringAgentOutputSchema(BaseIOSchema):
)
-question_answering_agent = BaseAgent[QuestionAnsweringAgentInputSchema, QuestionAnsweringAgentOutputSchema](
- BaseAgentConfig(
+question_answering_agent = AtomicAgent[QuestionAnsweringAgentInputSchema, QuestionAnsweringAgentOutputSchema](
+ AgentConfig(
client=instructor.from_openai(openai.OpenAI(api_key=ChatConfig.api_key)),
model=ChatConfig.model,
system_prompt_generator=SystemPromptGenerator(
diff --git a/atomic-examples/deep-research/deep_research/agents/query_agent.py b/atomic-examples/deep-research/deep_research/agents/query_agent.py
index 1ec2f47..3029c11 100644
--- a/atomic-examples/deep-research/deep_research/agents/query_agent.py
+++ b/atomic-examples/deep-research/deep_research/agents/query_agent.py
@@ -2,7 +2,7 @@ from deep_research.config import ChatConfig
import instructor
import openai
from pydantic import Field
-from atomic_agents import BaseIOSchema, BaseAgent, BaseAgentConfig
+from atomic_agents import BaseIOSchema, AtomicAgent, AgentConfig
from atomic_agents.context import SystemPromptGenerator
from deep_research.tools.searxng_search import SearXNGSearchToolInputSchema
@@ -15,8 +15,8 @@ class QueryAgentInputSchema(BaseIOSchema):
num_queries: int = Field(..., description="The number of search queries to generate.")
-query_agent = BaseAgent[QueryAgentInputSchema, SearXNGSearchToolInputSchema](
- BaseAgentConfig(
+query_agent = AtomicAgent[QueryAgentInputSchema, SearXNGSearchToolInputSchema](
+ AgentConfig(
client=instructor.from_openai(openai.OpenAI(api_key=ChatConfig.api_key)),
model=ChatConfig.model,
system_prompt_generator=SystemPromptGenerator(
diff --git a/atomic-examples/mcp-agent/example-client/example_client/main_fastapi.py b/atomic-examples/mcp-agent/example-client/example_client/main_fastapi.py
index 52e61ca..9239671 100644
--- a/atomic-examples/mcp-agent/example-client/example_client/main_fastapi.py
+++ b/atomic-examples/mcp-agent/example-client/example_client/main_fastapi.py
@@ -10,7 +10,7 @@ from pydantic import BaseModel, Field
from atomic_agents.connectors.mcp import fetch_mcp_tools_async, MCPTransportType
from atomic_agents.context import ChatHistory, SystemPromptGenerator
-from atomic_agents import BaseIOSchema, BaseAgent, BaseAgentConfig
+from atomic_agents import BaseIOSchema, AtomicAgent, AgentConfig
import openai
import instructor
@@ -148,8 +148,8 @@ async def execute_with_orchestrator_async(query: str) -> tuple[str, list[str]]:
reasoning: str
action: ActionUnion
- orchestrator_agent = BaseAgent[MCPOrchestratorInputSchema, OrchestratorOutputSchema](
- BaseAgentConfig(
+ orchestrator_agent = AtomicAgent[MCPOrchestratorInputSchema, OrchestratorOutputSchema](
+ AgentConfig(
client=globals()["client"],
model=config.openai_model,
history=ChatHistory(),
diff --git a/atomic-examples/mcp-agent/example-client/example_client/main_http.py b/atomic-examples/mcp-agent/example-client/example_client/main_http.py
index 09a8e6d..43948ef 100644
--- a/atomic-examples/mcp-agent/example-client/example_client/main_http.py
+++ b/atomic-examples/mcp-agent/example-client/example_client/main_http.py
@@ -5,7 +5,7 @@ Communicates with the server_http.py `/mcp` endpoint using HTTP GET/POST/DELETE
from atomic_agents.connectors.mcp import fetch_mcp_tools, MCPTransportType
from atomic_agents.context import ChatHistory, SystemPromptGenerator
-from atomic_agents import BaseIOSchema, BaseAgent, BaseAgentConfig
+from atomic_agents import BaseIOSchema, AtomicAgent, AgentConfig
import sys
from rich.console import Console
from rich.table import Table
@@ -78,8 +78,8 @@ def main():
action: ActionUnion
history = ChatHistory()
- orchestrator_agent = BaseAgent[MCPOrchestratorInputSchema, OrchestratorOutputSchema](
- BaseAgentConfig(
+ orchestrator_agent = AtomicAgent[MCPOrchestratorInputSchema, OrchestratorOutputSchema](
+ AgentConfig(
client=client,
model=config.openai_model,
history=history,
@@ -126,7 +126,7 @@ def main():
# Handle the output similar to SSE version
if hasattr(orchestrator_output, "chat_message") and not hasattr(orchestrator_output, "action"):
- # Convert BaseAgentOutputSchema to FinalResponseSchema
+ # Convert BasicChatOutputSchema to FinalResponseSchema
action_instance = FinalResponseSchema(response_text=orchestrator_output.chat_message)
reasoning = "Response generated directly from chat model"
elif hasattr(orchestrator_output, "action"):
diff --git a/atomic-examples/mcp-agent/example-client/example_client/main_sse.py b/atomic-examples/mcp-agent/example-client/example_client/main_sse.py
index 7d5cf55..8b96e89 100644
--- a/atomic-examples/mcp-agent/example-client/example_client/main_sse.py
+++ b/atomic-examples/mcp-agent/example-client/example_client/main_sse.py
@@ -1,6 +1,6 @@
# pyright: reportInvalidTypeForm=false
from atomic_agents.connectors.mcp import fetch_mcp_tools, MCPTransportType
-from atomic_agents import BaseIOSchema, BaseAgent, BaseAgentConfig
+from atomic_agents import BaseIOSchema, AtomicAgent, AgentConfig
from atomic_agents.context import ChatHistory, SystemPromptGenerator
from rich.console import Console
from rich.table import Table
@@ -53,7 +53,7 @@ if not tools:
raise RuntimeError("No MCP tools found. Please ensure the MCP server is running and accessible.")
# Build mapping from input_schema to ToolClass
-tool_schema_to_class_map: Dict[Type[BaseIOSchema], Type[BaseAgent]] = {
+tool_schema_to_class_map: Dict[Type[BaseIOSchema], Type[AtomicAgent]] = {
ToolClass.input_schema: ToolClass for ToolClass in tools if hasattr(ToolClass, "input_schema")
}
# Collect all tool input schemas
@@ -140,8 +140,8 @@ def main():
# Create and initialize orchestrator agent
console.print("[dim]β€’ Creating orchestrator agent...[/dim]")
history = ChatHistory()
- orchestrator_agent = BaseAgent[MCPOrchestratorInputSchema, OrchestratorOutputSchema](
- BaseAgentConfig(
+ orchestrator_agent = AtomicAgent[MCPOrchestratorInputSchema, OrchestratorOutputSchema](
+ AgentConfig(
client=client,
model=config.openai_model,
history=history,
@@ -187,10 +187,10 @@ def main():
f"[dim]Debug - orchestrator_output type: {type(orchestrator_output)}, fields: {orchestrator_output.model_dump()}"
)
- # The model is returning a BaseAgentOutputSchema instead of OrchestratorOutputSchema
+ # The model is returning a BasicChatOutputSchema instead of OrchestratorOutputSchema
# We need to handle this case by creating a FinalResponseSchema directly
if hasattr(orchestrator_output, "chat_message") and not hasattr(orchestrator_output, "action"):
- console.print("[yellow]Note: Converting BaseAgentOutputSchema to FinalResponseSchema[/yellow]")
+ console.print("[yellow]Note: Converting BasicChatOutputSchema to FinalResponseSchema[/yellow]")
action_instance = FinalResponseSchema(response_text=orchestrator_output.chat_message)
reasoning = "Response generated directly from chat model"
# Handle the original expected format if it exists
@@ -393,7 +393,7 @@ def main():
# Handle different response formats
if hasattr(orchestrator_output, "chat_message") and not hasattr(orchestrator_output, "action"):
- console.print("[yellow]Note: Converting BaseAgentOutputSchema to FinalResponseSchema[/yellow]")
+ console.print("[yellow]Note: Converting BasicChatOutputSchema to FinalResponseSchema[/yellow]")
action_instance = FinalResponseSchema(response_text=orchestrator_output.chat_message)
reasoning = "Response generated directly from chat model"
elif hasattr(orchestrator_output, "action"):
diff --git a/atomic-examples/mcp-agent/example-client/example_client/main_stdio.py b/atomic-examples/mcp-agent/example-client/example_client/main_stdio.py
index e4923c3..2530d50 100644
--- a/atomic-examples/mcp-agent/example-client/example_client/main_stdio.py
+++ b/atomic-examples/mcp-agent/example-client/example_client/main_stdio.py
@@ -1,6 +1,6 @@
# pyright: reportInvalidTypeForm=false
from atomic_agents.connectors.mcp import fetch_mcp_tools, MCPTransportType
-from atomic_agents import BaseIOSchema, BaseAgent, BaseAgentConfig
+from atomic_agents import BaseIOSchema, AtomicAgent, AgentConfig
from atomic_agents.context import ChatHistory, SystemPromptGenerator
from rich.console import Console
from rich.table import Table
@@ -84,7 +84,7 @@ if not tools:
raise RuntimeError("No MCP tools found. Please ensure the MCP server is running and accessible.")
# Build mapping from input_schema to ToolClass
-tool_schema_to_class_map: Dict[Type[BaseIOSchema], Type[BaseAgent]] = {
+tool_schema_to_class_map: Dict[Type[BaseIOSchema], Type[AtomicAgent]] = {
ToolClass.input_schema: ToolClass for ToolClass in tools if hasattr(ToolClass, "input_schema")
}
# Collect all tool input schemas
@@ -133,8 +133,8 @@ def main():
# Create and initialize orchestrator agent
console.print("[dim]β€’ Creating orchestrator agent...[/dim]")
history = ChatHistory()
- orchestrator_agent = BaseAgent[MCPOrchestratorInputSchema, OrchestratorOutputSchema](
- BaseAgentConfig(
+ orchestrator_agent = AtomicAgent[MCPOrchestratorInputSchema, OrchestratorOutputSchema](
+ AgentConfig(
client=client,
model=config.openai_model,
history=history,
diff --git a/atomic-examples/mcp-agent/example-client/example_client/main_stdio_async.py b/atomic-examples/mcp-agent/example-client/example_client/main_stdio_async.py
index c3227d5..8e11501 100644
--- a/atomic-examples/mcp-agent/example-client/example_client/main_stdio_async.py
+++ b/atomic-examples/mcp-agent/example-client/example_client/main_stdio_async.py
@@ -1,6 +1,6 @@
# pyright: reportInvalidTypeForm=false
from atomic_agents.connectors.mcp import fetch_mcp_tools_async, MCPToolOutputSchema, MCPTransportType
-from atomic_agents import BaseAgent, BaseAgentConfig, BaseIOSchema
+from atomic_agents import AtomicAgent, AgentConfig, BaseIOSchema
from atomic_agents.context import ChatHistory, SystemPromptGenerator
from rich.console import Console
from rich.table import Table
@@ -70,7 +70,7 @@ async def main():
raise RuntimeError("No MCP tools found. Please ensure the MCP server is running and accessible.")
# Build mapping from input_schema to ToolClass
- tool_schema_to_class_map: Dict[Type[BaseIOSchema], Type[BaseAgent]] = {
+ tool_schema_to_class_map: Dict[Type[BaseIOSchema], Type[AtomicAgent]] = {
ToolClass.input_schema: ToolClass for ToolClass in tools if hasattr(ToolClass, "input_schema")
}
# Collect all tool input schemas
@@ -117,8 +117,8 @@ async def main():
# Create and initialize orchestrator agent
console.print("[dim]β€’ Creating orchestrator agent...[/dim]")
history = ChatHistory()
- orchestrator_agent = BaseAgent[MCPOrchestratorInputSchema, OrchestratorOutputSchema](
- BaseAgentConfig(
+ orchestrator_agent = AtomicAgent[MCPOrchestratorInputSchema, OrchestratorOutputSchema](
+ AgentConfig(
client=client,
model=config.openai_model,
history=history,
diff --git a/atomic-examples/orchestration-agent/orchestration_agent/orchestrator.py b/atomic-examples/orchestration-agent/orchestration_agent/orchestrator.py
index 953ee0d..a15e7f8 100644
--- a/atomic-examples/orchestration-agent/orchestration_agent/orchestrator.py
+++ b/atomic-examples/orchestration-agent/orchestration_agent/orchestrator.py
@@ -1,7 +1,7 @@
from typing import Union
import openai
from pydantic import Field
-from atomic_agents import BaseAgent, BaseAgentConfig, BaseIOSchema
+from atomic_agents import AtomicAgent, AgentConfig, BaseIOSchema
from atomic_agents.context import SystemPromptGenerator, BaseDynamicContextProvider
from orchestration_agent.tools.searxng_search import (
@@ -48,7 +48,7 @@ class FinalAnswerSchema(BaseIOSchema):
#######################
# AGENT CONFIGURATION #
#######################
-class OrchestratorAgentConfig(BaseAgentConfig):
+class OrchestratorAgentConfig(AgentConfig):
"""Configuration for the Orchestrator Agent."""
searxng_config: SearXNGSearchToolConfig
@@ -70,7 +70,7 @@ class CurrentDateProvider(BaseDynamicContextProvider):
######################
# ORCHESTRATOR AGENT #
######################
-orchestrator_agent_config = BaseAgentConfig(
+orchestrator_agent_config = AgentConfig(
client=instructor.from_openai(openai.OpenAI()),
model="gpt-4o-mini",
system_prompt_generator=SystemPromptGenerator(
@@ -88,8 +88,8 @@ orchestrator_agent_config = BaseAgentConfig(
],
),
)
-orchestrator_agent = BaseAgent[OrchestratorInputSchema, OrchestratorOutputSchema](config=orchestrator_agent_config)
-orchestrator_agent_final = BaseAgent[OrchestratorInputSchema, FinalAnswerSchema](config=orchestrator_agent_config)
+orchestrator_agent = AtomicAgent[OrchestratorInputSchema, OrchestratorOutputSchema](config=orchestrator_agent_config)
+orchestrator_agent_final = AtomicAgent[OrchestratorInputSchema, FinalAnswerSchema](config=orchestrator_agent_config)
# Register the current date provider
orchestrator_agent.register_context_provider("current_date", CurrentDateProvider("Current Date"))
@@ -178,4 +178,4 @@ if __name__ == "__main__":
final_answer = orchestrator_agent.run(input_schema)
console.print(f"\n[bold blue]Final Answer:[/bold blue] {final_answer.final_answer}")
# Reset the agent to the original
- orchestrator_agent = BaseAgent[OrchestratorInputSchema, OrchestratorOutputSchema](config=orchestrator_agent_config)
+ orchestrator_agent = AtomicAgent[OrchestratorInputSchema, OrchestratorOutputSchema](config=orchestrator_agent_config)
diff --git a/atomic-examples/quickstart/quickstart/1_0_basic_chatbot.py b/atomic-examples/quickstart/quickstart/1_0_basic_chatbot.py
index 7c30604..d0e0ffd 100644
--- a/atomic-examples/quickstart/quickstart/1_0_basic_chatbot.py
+++ b/atomic-examples/quickstart/quickstart/1_0_basic_chatbot.py
@@ -5,7 +5,7 @@ from rich.console import Console
from rich.panel import Panel
from rich.text import Text
from atomic_agents.context import ChatHistory
-from atomic_agents import BaseAgent, BaseAgentConfig, BaseAgentInputSchema, BaseAgentOutputSchema
+from atomic_agents import AtomicAgent, AgentConfig, BasicChatInputSchema, BasicChatOutputSchema
# API Key setup
API_KEY = ""
@@ -24,15 +24,15 @@ console = Console()
history = ChatHistory()
# Initialize history with an initial message from the assistant
-initial_message = BaseAgentOutputSchema(chat_message="Hello! How can I assist you today?")
+initial_message = BasicChatOutputSchema(chat_message="Hello! How can I assist you today?")
history.add_message("assistant", initial_message)
# OpenAI client setup using the Instructor library
client = instructor.from_openai(openai.OpenAI(api_key=API_KEY))
# Agent setup with specified configuration
-agent = BaseAgent[BaseAgentInputSchema, BaseAgentOutputSchema](
- config=BaseAgentConfig(
+agent = AtomicAgent[BasicChatInputSchema, BasicChatOutputSchema](
+ config=AgentConfig(
client=client,
model="gpt-4o-mini",
history=history,
@@ -58,7 +58,7 @@ while True:
break
# Process the user's input through the agent and get the response
- input_schema = BaseAgentInputSchema(chat_message=user_input)
+ input_schema = BasicChatInputSchema(chat_message=user_input)
response = agent.run(input_schema)
agent_message = Text(response.chat_message, style="bold green")
diff --git a/atomic-examples/quickstart/quickstart/1_1_basic_chatbot_streaming.py b/atomic-examples/quickstart/quickstart/1_1_basic_chatbot_streaming.py
index 132df9a..ab603a1 100644
--- a/atomic-examples/quickstart/quickstart/1_1_basic_chatbot_streaming.py
+++ b/atomic-examples/quickstart/quickstart/1_1_basic_chatbot_streaming.py
@@ -5,7 +5,7 @@ from rich.console import Console
from rich.panel import Panel
from rich.text import Text
from atomic_agents.context import ChatHistory
-from atomic_agents import BaseAgent, BaseAgentConfig, BaseAgentInputSchema, BaseAgentOutputSchema
+from atomic_agents import AtomicAgent, AgentConfig, BasicChatInputSchema, BasicChatOutputSchema
# API Key setup
API_KEY = ""
@@ -24,15 +24,15 @@ console = Console()
history = ChatHistory()
# Initialize history with an initial message from the assistant
-initial_message = BaseAgentOutputSchema(chat_message="Hello! How can I assist you today?")
+initial_message = BasicChatOutputSchema(chat_message="Hello! How can I assist you today?")
history.add_message("assistant", initial_message)
# OpenAI client setup using the Instructor library for synchronous operations
client = instructor.from_openai(openai.OpenAI(api_key=API_KEY))
# Agent setup with specified configuration
-agent = BaseAgent[BaseAgentInputSchema, BaseAgentOutputSchema](
- config=BaseAgentConfig(
+agent = AtomicAgent[BasicChatInputSchema, BasicChatOutputSchema](
+ config=AgentConfig(
client=client,
model="gpt-4o-mini",
history=history,
@@ -52,7 +52,7 @@ console.print(Text(initial_message.chat_message, style="green"))
def main():
"""
Main function to handle the chat loop using synchronous streaming.
- This demonstrates how to use BaseAgent.run_stream() instead of the async version.
+ This demonstrates how to use AtomicAgent.run_stream() instead of the async version.
"""
# Start an infinite loop to handle user inputs and agent responses
while True:
@@ -64,7 +64,7 @@ def main():
break
# Process the user's input through the agent
- input_schema = BaseAgentInputSchema(chat_message=user_input)
+ input_schema = BasicChatInputSchema(chat_message=user_input)
console.print() # Add newline before response
console.print(Text("Agent: ", style="bold green"), end="")
diff --git a/atomic-examples/quickstart/quickstart/1_2_basic_chatbot_async_streaming.py b/atomic-examples/quickstart/quickstart/1_2_basic_chatbot_async_streaming.py
index ae556ed..d489a56 100644
--- a/atomic-examples/quickstart/quickstart/1_2_basic_chatbot_async_streaming.py
+++ b/atomic-examples/quickstart/quickstart/1_2_basic_chatbot_async_streaming.py
@@ -6,7 +6,7 @@ from rich.panel import Panel
from rich.text import Text
from rich.live import Live
from atomic_agents.context import ChatHistory
-from atomic_agents import BaseAgent, BaseAgentConfig, BaseAgentInputSchema, BaseAgentOutputSchema
+from atomic_agents import AtomicAgent, AgentConfig, BasicChatInputSchema, BasicChatOutputSchema
# API Key setup
API_KEY = ""
@@ -25,15 +25,15 @@ console = Console()
history = ChatHistory()
# Initialize history with an initial message from the assistant
-initial_message = BaseAgentOutputSchema(chat_message="Hello! How can I assist you today?")
+initial_message = BasicChatOutputSchema(chat_message="Hello! How can I assist you today?")
history.add_message("assistant", initial_message)
# OpenAI client setup using the Instructor library for async operations
client = instructor.from_openai(openai.AsyncOpenAI(api_key=API_KEY))
# Agent setup with specified configuration
-agent = BaseAgent[BaseAgentInputSchema, BaseAgentOutputSchema](
- config=BaseAgentConfig(
+agent = AtomicAgent[BasicChatInputSchema, BasicChatOutputSchema](
+ config=AgentConfig(
client=client,
model="gpt-4o-mini",
history=history,
@@ -61,7 +61,7 @@ async def main():
break
# Process the user's input through the agent and get the streaming response
- input_schema = BaseAgentInputSchema(chat_message=user_input)
+ input_schema = BasicChatInputSchema(chat_message=user_input)
console.print() # Add newline before response
# Use Live display to show streaming response
diff --git a/atomic-examples/quickstart/quickstart/2_basic_custom_chatbot.py b/atomic-examples/quickstart/quickstart/2_basic_custom_chatbot.py
index 7354c1c..1f2b310 100644
--- a/atomic-examples/quickstart/quickstart/2_basic_custom_chatbot.py
+++ b/atomic-examples/quickstart/quickstart/2_basic_custom_chatbot.py
@@ -5,7 +5,7 @@ from rich.console import Console
from rich.panel import Panel
from rich.text import Text
from atomic_agents.context import SystemPromptGenerator, ChatHistory
-from atomic_agents import BaseAgent, BaseAgentConfig, BaseAgentInputSchema, BaseAgentOutputSchema
+from atomic_agents import AtomicAgent, AgentConfig, BasicChatInputSchema, BasicChatOutputSchema
# API Key setup
API_KEY = ""
@@ -24,7 +24,7 @@ console = Console()
history = ChatHistory()
# Initialize history with an initial message from the assistant
-initial_message = BaseAgentOutputSchema(
+initial_message = BasicChatOutputSchema(
chat_message="How do you do? What can I do for you? Tell me, pray, what is your need today?"
)
history.add_message("assistant", initial_message)
@@ -49,8 +49,8 @@ system_prompt_generator = SystemPromptGenerator(
console.print(Panel(system_prompt_generator.generate_prompt(), width=console.width, style="bold cyan"), style="bold cyan")
# Agent setup with specified configuration
-agent = BaseAgent[BaseAgentInputSchema, BaseAgentOutputSchema](
- config=BaseAgentConfig(
+agent = AtomicAgent[BasicChatInputSchema, BasicChatOutputSchema](
+ config=AgentConfig(
client=client,
model="gpt-4o-mini",
system_prompt_generator=system_prompt_generator,
diff --git a/atomic-examples/quickstart/quickstart/3_0_basic_custom_chatbot_with_custom_schema.py b/atomic-examples/quickstart/quickstart/3_0_basic_custom_chatbot_with_custom_schema.py
index ada8fb8..8cde784 100644
--- a/atomic-examples/quickstart/quickstart/3_0_basic_custom_chatbot_with_custom_schema.py
+++ b/atomic-examples/quickstart/quickstart/3_0_basic_custom_chatbot_with_custom_schema.py
@@ -7,7 +7,7 @@ from rich.text import Text
from typing import List
from pydantic import Field
from atomic_agents.context import SystemPromptGenerator, ChatHistory
-from atomic_agents import BaseAgent, BaseAgentConfig, BaseAgentInputSchema, BaseIOSchema
+from atomic_agents import AtomicAgent, AgentConfig, BasicChatInputSchema, BaseIOSchema
# API Key setup
API_KEY = ""
@@ -72,8 +72,8 @@ system_prompt_generator = SystemPromptGenerator(
console.print(Panel(system_prompt_generator.generate_prompt(), width=console.width, style="bold cyan"), style="bold cyan")
# Agent setup with specified configuration and custom output schema
-agent = BaseAgent[BaseAgentInputSchema, CustomOutputSchema](
- config=BaseAgentConfig(
+agent = AtomicAgent[BasicChatInputSchema, CustomOutputSchema](
+ config=AgentConfig(
client=client,
model="gpt-4o-mini",
system_prompt_generator=system_prompt_generator,
@@ -101,7 +101,7 @@ while True:
break
# Process the user's input through the agent and get the response
- response = agent.run(BaseAgentInputSchema(chat_message=user_input))
+ response = agent.run(BasicChatInputSchema(chat_message=user_input))
# Display the agent's response
agent_message = Text(response.chat_message, style="bold green")
diff --git a/atomic-examples/quickstart/quickstart/3_1_basic_custom_chatbot_with_custom_schema_streaming.py b/atomic-examples/quickstart/quickstart/3_1_basic_custom_chatbot_with_custom_schema_streaming.py
index c01e97c..3589aa5 100644
--- a/atomic-examples/quickstart/quickstart/3_1_basic_custom_chatbot_with_custom_schema_streaming.py
+++ b/atomic-examples/quickstart/quickstart/3_1_basic_custom_chatbot_with_custom_schema_streaming.py
@@ -8,7 +8,7 @@ from rich.live import Live
from typing import List
from pydantic import Field
from atomic_agents.context import SystemPromptGenerator, ChatHistory
-from atomic_agents import BaseAgent, BaseAgentConfig, BaseAgentInputSchema, BaseIOSchema
+from atomic_agents import AtomicAgent, AgentConfig, BasicChatInputSchema, BaseIOSchema
# API Key setup
API_KEY = ""
@@ -74,8 +74,8 @@ system_prompt_generator = SystemPromptGenerator(
console.print(Panel(system_prompt_generator.generate_prompt(), width=console.width, style="bold cyan"), style="bold cyan")
# Agent setup with specified configuration and custom output schema
-agent = BaseAgent[BaseAgentInputSchema, CustomOutputSchema](
- config=BaseAgentConfig(
+agent = AtomicAgent[BasicChatInputSchema, CustomOutputSchema](
+ config=AgentConfig(
client=client,
model="gpt-4o-mini",
system_prompt_generator=system_prompt_generator,
@@ -105,7 +105,7 @@ async def main():
break
# Process the user's input through the agent and get the streaming response
- input_schema = BaseAgentInputSchema(chat_message=user_input)
+ input_schema = BasicChatInputSchema(chat_message=user_input)
console.print() # Add newline before response
# Use Live display to show streaming response
diff --git a/atomic-examples/quickstart/quickstart/4_basic_chatbot_different_providers.py b/atomic-examples/quickstart/quickstart/4_basic_chatbot_different_providers.py
index d143e6a..796cbfa 100644
--- a/atomic-examples/quickstart/quickstart/4_basic_chatbot_different_providers.py
+++ b/atomic-examples/quickstart/quickstart/4_basic_chatbot_different_providers.py
@@ -4,7 +4,7 @@ from rich.console import Console
from rich.panel import Panel
from rich.text import Text
from atomic_agents.context import ChatHistory
-from atomic_agents import BaseAgent, BaseAgentConfig, BaseAgentInputSchema, BaseAgentOutputSchema
+from atomic_agents import AtomicAgent, AgentConfig, BasicChatInputSchema, BasicChatOutputSchema
from dotenv import load_dotenv
load_dotenv()
@@ -16,7 +16,7 @@ console = Console()
history = ChatHistory()
# Initialize history with an initial message from the assistant
-initial_message = BaseAgentOutputSchema(chat_message="Hello! How can I assist you today?")
+initial_message = BasicChatOutputSchema(chat_message="Hello! How can I assist you today?")
history.add_message("assistant", initial_message)
@@ -85,8 +85,8 @@ provider = console.input(providers_str).lower()
client, model = setup_client(provider)
# Agent setup with specified configuration
-agent = BaseAgent[BaseAgentInputSchema, BaseAgentOutputSchema](
- config=BaseAgentConfig(client=client, model=model, history=history, model_api_parameters={"max_tokens": 2048})
+agent = AtomicAgent[BasicChatInputSchema, BasicChatOutputSchema](
+ config=AgentConfig(client=client, model=model, history=history, model_api_parameters={"max_tokens": 2048})
)
# Generate the default system prompt for the agent
@@ -108,7 +108,7 @@ while True:
break
# Process the user's input through the agent and get the response
- input_schema = BaseAgentInputSchema(chat_message=user_input)
+ input_schema = BasicChatInputSchema(chat_message=user_input)
response = agent.run(input_schema)
agent_message = Text(response.chat_message, style="bold green")
diff --git a/atomic-examples/quickstart/quickstart/5_custom_system_role_for_reasoning_models.py b/atomic-examples/quickstart/quickstart/5_custom_system_role_for_reasoning_models.py
index 8ad5ba9..9dd2382 100644
--- a/atomic-examples/quickstart/quickstart/5_custom_system_role_for_reasoning_models.py
+++ b/atomic-examples/quickstart/quickstart/5_custom_system_role_for_reasoning_models.py
@@ -3,7 +3,7 @@ import instructor
import openai
from rich.console import Console
from rich.text import Text
-from atomic_agents import BaseAgent, BaseAgentConfig, BaseAgentInputSchema, BaseAgentOutputSchema
+from atomic_agents import AtomicAgent, AgentConfig, BasicChatInputSchema, BasicChatOutputSchema
from atomic_agents.context import SystemPromptGenerator
# API Key setup
@@ -29,8 +29,8 @@ system_prompt_generator = SystemPromptGenerator(
output_instructions=["Answer in plain English plus formulas."],
)
# Agent setup with specified configuration
-agent = BaseAgent[BaseAgentInputSchema, BaseAgentOutputSchema](
- config=BaseAgentConfig(
+agent = AtomicAgent[BasicChatInputSchema, BasicChatOutputSchema](
+ config=AgentConfig(
client=client,
model="o3-mini",
system_prompt_generator=system_prompt_generator,
@@ -46,7 +46,7 @@ console.print(Text("User:", style="bold green"), end=" ")
console.print(user_input)
# Process the user's input through the agent and get the response
-input_schema = BaseAgentInputSchema(chat_message=user_input)
+input_schema = BasicChatInputSchema(chat_message=user_input)
response = agent.run(input_schema)
agent_message = Text(response.chat_message, style="bold green")
diff --git a/atomic-examples/quickstart/quickstart/6_0_asynchronous_processing.py b/atomic-examples/quickstart/quickstart/6_0_asynchronous_processing.py
index 1ca5583..5870b13 100644
--- a/atomic-examples/quickstart/quickstart/6_0_asynchronous_processing.py
+++ b/atomic-examples/quickstart/quickstart/6_0_asynchronous_processing.py
@@ -3,7 +3,7 @@ import asyncio
import instructor
import openai
from rich.console import Console
-from atomic_agents import BaseIOSchema, BaseAgent, BaseAgentConfig, BaseAgentInputSchema
+from atomic_agents import BaseIOSchema, AtomicAgent, AgentConfig, BasicChatInputSchema
from atomic_agents.context import SystemPromptGenerator
# API Key setup
@@ -52,14 +52,14 @@ dataset = [
sem = asyncio.Semaphore(2)
# Agent setup with specified configuration
-agent = BaseAgent[BaseAgentInputSchema, PersonSchema](
- config=BaseAgentConfig(client=client, model="gpt-4o-mini", sysyem_prompt_generator=sysyem_prompt_generator)
+agent = AtomicAgent[BasicChatInputSchema, PersonSchema](
+ config=AgentConfig(client=client, model="gpt-4o-mini", sysyem_prompt_generator=sysyem_prompt_generator)
)
async def exec_agent(message: str):
"""Execute the agent with the provided message."""
- user_input = BaseAgentInputSchema(chat_message=message)
+ user_input = BasicChatInputSchema(chat_message=message)
agent.reset_history()
response = await agent.run_async(user_input)
return response
diff --git a/atomic-examples/quickstart/quickstart/6_1_asynchronous_processing_streaming.py b/atomic-examples/quickstart/quickstart/6_1_asynchronous_processing_streaming.py
index 2564d2d..c93b70d 100644
--- a/atomic-examples/quickstart/quickstart/6_1_asynchronous_processing_streaming.py
+++ b/atomic-examples/quickstart/quickstart/6_1_asynchronous_processing_streaming.py
@@ -6,7 +6,7 @@ from rich.console import Console
from rich.live import Live
from rich.table import Table
from rich.text import Text
-from atomic_agents import BaseIOSchema, BaseAgent, BaseAgentConfig, BaseAgentInputSchema
+from atomic_agents import BaseIOSchema, AtomicAgent, AgentConfig, BasicChatInputSchema
from atomic_agents.context import SystemPromptGenerator
# API Key setup
@@ -57,8 +57,8 @@ MAX_CONCURRENT = 3
sem = asyncio.Semaphore(MAX_CONCURRENT)
# Agent setup with specified configuration
-agent = BaseAgent[BaseAgentInputSchema, PersonSchema](
- config=BaseAgentConfig(client=client, model="gpt-4o-mini", system_prompt_generator=system_prompt_generator)
+agent = AtomicAgent[BasicChatInputSchema, PersonSchema](
+ config=AgentConfig(client=client, model="gpt-4o-mini", system_prompt_generator=system_prompt_generator)
)
@@ -66,7 +66,7 @@ async def exec_agent(message: str, idx: int, progress_dict: dict):
"""Execute the agent with the provided message and update progress in real-time."""
# Acquire the semaphore to limit concurrent executions
async with sem:
- user_input = BaseAgentInputSchema(chat_message=message)
+ user_input = BasicChatInputSchema(chat_message=message)
agent.reset_history()
# Track streaming progress
diff --git a/atomic-examples/rag-chatbot/rag_chatbot/agents/qa_agent.py b/atomic-examples/rag-chatbot/rag_chatbot/agents/qa_agent.py
index 95dc93b..1e5de07 100644
--- a/atomic-examples/rag-chatbot/rag_chatbot/agents/qa_agent.py
+++ b/atomic-examples/rag-chatbot/rag_chatbot/agents/qa_agent.py
@@ -1,7 +1,7 @@
import instructor
import openai
from pydantic import Field
-from atomic_agents import BaseIOSchema, BaseAgent, BaseAgentConfig
+from atomic_agents import BaseIOSchema, AtomicAgent, AgentConfig
from atomic_agents.context import SystemPromptGenerator
from rag_chatbot.config import ChatConfig
@@ -20,8 +20,8 @@ class RAGQuestionAnsweringAgentOutputSchema(BaseIOSchema):
answer: str = Field(..., description="The answer to the user's question based on the retrieved context")
-qa_agent = BaseAgent[RAGQuestionAnsweringAgentInputSchema, RAGQuestionAnsweringAgentOutputSchema](
- BaseAgentConfig(
+qa_agent = AtomicAgent[RAGQuestionAnsweringAgentInputSchema, RAGQuestionAnsweringAgentOutputSchema](
+ AgentConfig(
client=instructor.from_openai(openai.OpenAI(api_key=ChatConfig.api_key)),
model=ChatConfig.model,
system_prompt_generator=SystemPromptGenerator(
diff --git a/atomic-examples/rag-chatbot/rag_chatbot/agents/query_agent.py b/atomic-examples/rag-chatbot/rag_chatbot/agents/query_agent.py
index bf404fa..33e51a5 100644
--- a/atomic-examples/rag-chatbot/rag_chatbot/agents/query_agent.py
+++ b/atomic-examples/rag-chatbot/rag_chatbot/agents/query_agent.py
@@ -1,7 +1,7 @@
import instructor
import openai
from pydantic import Field
-from atomic_agents import BaseIOSchema, BaseAgent, BaseAgentConfig
+from atomic_agents import BaseIOSchema, AtomicAgent, AgentConfig
from atomic_agents.context import SystemPromptGenerator
from rag_chatbot.config import ChatConfig
@@ -20,8 +20,8 @@ class RAGQueryAgentOutputSchema(BaseIOSchema):
query: str = Field(..., description="The semantic search query to use for retrieving relevant chunks")
-query_agent = BaseAgent[RAGQueryAgentInputSchema, RAGQueryAgentOutputSchema](
- BaseAgentConfig(
+query_agent = AtomicAgent[RAGQueryAgentInputSchema, RAGQueryAgentOutputSchema](
+ AgentConfig(
client=instructor.from_openai(openai.OpenAI(api_key=ChatConfig.api_key)),
model=ChatConfig.model,
system_prompt_generator=SystemPromptGenerator(
diff --git a/atomic-examples/web-search-agent/web_search_agent/agents/query_agent.py b/atomic-examples/web-search-agent/web_search_agent/agents/query_agent.py
index c7b0c53..871713f 100644
--- a/atomic-examples/web-search-agent/web_search_agent/agents/query_agent.py
+++ b/atomic-examples/web-search-agent/web_search_agent/agents/query_agent.py
@@ -2,7 +2,7 @@ import instructor
import openai
from pydantic import Field
from typing import List
-from atomic_agents import BaseIOSchema, BaseAgent, BaseAgentConfig
+from atomic_agents import BaseIOSchema, AtomicAgent, AgentConfig
from atomic_agents.context import SystemPromptGenerator
@@ -19,8 +19,8 @@ class QueryAgentOutputSchema(BaseIOSchema):
queries: List[str] = Field(..., description="A list of search queries.")
-query_agent = BaseAgent[QueryAgentInputSchema, QueryAgentOutputSchema](
- BaseAgentConfig(
+query_agent = AtomicAgent[QueryAgentInputSchema, QueryAgentOutputSchema](
+ AgentConfig(
client=instructor.from_openai(openai.OpenAI()),
model="gpt-4o-mini",
system_prompt_generator=SystemPromptGenerator(
diff --git a/atomic-examples/web-search-agent/web_search_agent/agents/question_answering_agent.py b/atomic-examples/web-search-agent/web_search_agent/agents/question_answering_agent.py
index 33136d7..d4626b5 100644
--- a/atomic-examples/web-search-agent/web_search_agent/agents/question_answering_agent.py
+++ b/atomic-examples/web-search-agent/web_search_agent/agents/question_answering_agent.py
@@ -2,7 +2,7 @@ import instructor
import openai
from pydantic import Field, HttpUrl
from typing import List
-from atomic_agents import BaseIOSchema, BaseAgent, BaseAgentConfig
+from atomic_agents import BaseIOSchema, AtomicAgent, AgentConfig
from atomic_agents.context import SystemPromptGenerator
@@ -25,8 +25,8 @@ class QuestionAnsweringAgentOutputSchema(BaseIOSchema):
# Create the question answering agent
-question_answering_agent = BaseAgent[QuestionAnsweringAgentInputSchema, QuestionAnsweringAgentOutputSchema](
- BaseAgentConfig(
+question_answering_agent = AtomicAgent[QuestionAnsweringAgentInputSchema, QuestionAnsweringAgentOutputSchema](
+ AgentConfig(
client=instructor.from_openai(openai.OpenAI()),
model="gpt-4o-mini",
system_prompt_generator=SystemPromptGenerator(
diff --git a/atomic-examples/youtube-summarizer/youtube_summarizer/agent.py b/atomic-examples/youtube-summarizer/youtube_summarizer/agent.py
index b9b9443..4f7c0aa 100644
--- a/atomic-examples/youtube-summarizer/youtube_summarizer/agent.py
+++ b/atomic-examples/youtube-summarizer/youtube_summarizer/agent.py
@@ -3,7 +3,7 @@ import openai
from pydantic import Field
from typing import List, Optional
-from atomic_agents import BaseAgent, BaseAgentConfig, BaseIOSchema
+from atomic_agents import AtomicAgent, AgentConfig, BaseIOSchema
from atomic_agents.context import BaseDynamicContextProvider, SystemPromptGenerator
@@ -68,8 +68,8 @@ class YouTubeKnowledgeExtractionOutputSchema(BaseIOSchema):
transcript_provider = YtTranscriptProvider(title="YouTube Transcript")
-youtube_knowledge_extraction_agent = BaseAgent[YouTubeKnowledgeExtractionInputSchema, YouTubeKnowledgeExtractionOutputSchema](
- config=BaseAgentConfig(
+youtube_knowledge_extraction_agent = AtomicAgent[YouTubeKnowledgeExtractionInputSchema, YouTubeKnowledgeExtractionOutputSchema](
+ config=AgentConfig(
client=instructor.from_openai(openai.OpenAI()),
model="gpt-4o-mini",
system_prompt_generator=SystemPromptGenerator(
diff --git a/atomic-examples/youtube-to-recipe/youtube_to_recipe/agent.py b/atomic-examples/youtube-to-recipe/youtube_to_recipe/agent.py
index 880b1b9..2d341c6 100644
--- a/atomic-examples/youtube-to-recipe/youtube_to_recipe/agent.py
+++ b/atomic-examples/youtube-to-recipe/youtube_to_recipe/agent.py
@@ -3,7 +3,7 @@ import openai
from pydantic import BaseModel, Field
from typing import List, Optional
-from atomic_agents import BaseAgent, BaseAgentConfig, BaseIOSchema
+from atomic_agents import AtomicAgent, AgentConfig, BaseIOSchema
from atomic_agents.context import BaseDynamicContextProvider, SystemPromptGenerator
@@ -64,8 +64,8 @@ class YouTubeRecipeExtractionOutputSchema(BaseIOSchema):
transcript_provider = YtTranscriptProvider(title="YouTube Recipe Transcript")
-youtube_recipe_extraction_agent = BaseAgent[YouTubeRecipeExtractionInputSchema, YouTubeRecipeExtractionOutputSchema](
- config=BaseAgentConfig(
+youtube_recipe_extraction_agent = AtomicAgent[YouTubeRecipeExtractionInputSchema, YouTubeRecipeExtractionOutputSchema](
+ config=AgentConfig(
client=instructor.from_openai(openai.OpenAI()),
model="gpt-4o-mini",
system_prompt_generator=SystemPromptGenerator(
diff --git a/docs/api/agents.md b/docs/api/agents.md
index 001c1c1..0cc5c89 100644
--- a/docs/api/agents.md
+++ b/docs/api/agents.md
@@ -7,8 +7,8 @@ The Atomic Agents framework uses Pydantic for schema validation and serializatio
```PlainText
pydantic.BaseModel
└── BaseIOSchema
- β”œβ”€β”€ BaseAgentInputSchema
- └── BaseAgentOutputSchema
+ β”œβ”€β”€ BasicChatInputSchema
+ └── BasicChatOutputSchema
```
### BaseIOSchema
@@ -26,12 +26,12 @@ The base schema class that all agent input/output schemas inherit from.
- :class:`pydantic.BaseModel`
```
-### BaseAgentInputSchema
+### BasicChatInputSchema
The default input schema for agents.
```{eval-rst}
-.. py:class:: BaseAgentInputSchema
+.. py:class:: BasicChatInputSchema
Default input schema for agent interactions.
@@ -44,16 +44,16 @@ The default input schema for agents.
The message to send to the agent.
Example:
- >>> input_schema = BaseAgentInputSchema(chat_message="Hello, agent!")
+ >>> input_schema = BasicChatInputSchema(chat_message="Hello, agent!")
>>> agent.run(input_schema)
```
-### BaseAgentOutputSchema
+### BasicChatOutputSchema
The default output schema for agents.
```{eval-rst}
-.. py:class:: BaseAgentOutputSchema
+.. py:class:: BasicChatOutputSchema
Default output schema for agent responses.
@@ -99,15 +99,15 @@ class CustomOutputSchema(BaseIOSchema):
## Base Agent
-The `BaseAgent` class is the foundation for building AI agents in the Atomic Agents framework. It handles chat interactions, history management, system prompts, and responses from language models.
+The `AtomicAgent` class is the foundation for building AI agents in the Atomic Agents framework. It handles chat interactions, history management, system prompts, and responses from language models.
```python
-from atomic_agents import BaseAgent, BaseAgentConfig
+from atomic_agents import AtomicAgent, AgentConfig
from atomic_agents.context import ChatHistory, SystemPromptGenerator
# Create agent with basic configuration
-agent = BaseAgent[BaseAgentInputSchema, BaseAgentOutputSchema](
- config=BaseAgentConfig(
+agent = AtomicAgent[BasicChatInputSchema, BasicChatOutputSchema](
+ config=AgentConfig(
client=instructor.from_openai(OpenAI()),
model="gpt-4-turbo-preview",
history=ChatHistory(),
@@ -125,10 +125,10 @@ async for partial_response in agent.run_async(user_input):
### Configuration
-The `BaseAgentConfig` class provides configuration options:
+The `AgentConfig` class provides configuration options:
```python
-class BaseAgentConfig:
+class AgentConfig:
client: instructor.Instructor # Client for interacting with the language model
model: str = "gpt-4-turbo-preview" # Model to use
history: Optional[ChatHistory] = None # History component
@@ -143,14 +143,14 @@ class BaseAgentConfig:
Default schemas for basic chat interactions:
```python
-class BaseAgentInputSchema(BaseIOSchema):
+class BasicChatInputSchema(BaseIOSchema):
"""Input from the user to the AI agent."""
chat_message: str = Field(
...,
description="The chat message sent by the user."
)
-class BaseAgentOutputSchema(BaseIOSchema):
+class BasicChatOutputSchema(BaseIOSchema):
"""Response generated by the chat agent."""
chat_message: str = Field(
...,
@@ -239,8 +239,8 @@ class CustomOutput(BaseIOSchema):
sources: List[str] = Field(..., description="Source references")
# Create agent with custom schemas
-agent = BaseAgent[CustomInput, CustomOutput](
- config=BaseAgentConfig(
+agent = AtomicAgent[CustomInput, CustomOutput](
+ config=AgentConfig(
client=client,
model=model,
)
@@ -249,7 +249,7 @@ agent = BaseAgent[CustomInput, CustomOutput](
For full API details:
```{eval-rst}
-.. automodule:: atomic_agents.agents.base_agent
+.. automodule:: atomic_agents.agents.atomic_agent
:members:
:undoc-members:
:show-inheritance:
diff --git a/docs/api/index.md b/docs/api/index.md
index 91ea7f9..a2d76c5 100644
--- a/docs/api/index.md
+++ b/docs/api/index.md
@@ -7,7 +7,7 @@ This section contains the API reference for all public modules and classes in At
:caption: API Reference
agents
-components
+context
utils
```
@@ -19,16 +19,16 @@ The Atomic Agents framework is built around several core components that work to
The agents module provides the base classes for creating AI agents:
-- `BaseAgent`: The foundational agent class that handles interactions with LLMs
-- `BaseAgentConfig`: Configuration class for customizing agent behavior
-- `BaseAgentInputSchema`: Standard input schema for agent interactions
-- `BaseAgentOutputSchema`: Standard output schema for agent responses
+- `AtomicAgent`: The foundational agent class that handles interactions with LLMs
+- `AgentConfig`: Configuration class for customizing agent behavior
+- `BasicChatInputSchema`: Standard input schema for agent interactions
+- `BasicChatOutputSchema`: Standard output schema for agent responses
[Learn more about agents](agents.md)
-### Components
+### Context Components
-The components module contains essential building blocks:
+The context module contains essential building blocks:
- `ChatHistory`: Manages conversation history and state with support for:
- Message history with role-based messages
@@ -45,7 +45,7 @@ The components module contains essential building blocks:
- `BaseDynamicContextProvider`: Base class for creating custom context providers that can inject dynamic information into system prompts
-[Learn more about components](components.md)
+[Learn more about context components](context.md)
### Utils
diff --git a/docs/guides/quickstart.md b/docs/guides/quickstart.md
index e01c447..5e5e9fe 100644
--- a/docs/guides/quickstart.md
+++ b/docs/guides/quickstart.md
@@ -25,7 +25,7 @@ import instructor
import openai
from rich.console import Console
from atomic_agents.context import ChatHistory
-from atomic_agents import BaseAgent, BaseAgentConfig, BaseAgentInputSchema, BaseAgentOutputSchema
+from atomic_agents import AtomicAgent, AgentConfig, BasicChatInputSchema, BasicChatOutputSchema
# Initialize console for pretty outputs
console = Console()
@@ -34,15 +34,15 @@ console = Console()
history = ChatHistory()
# Initialize history with an initial message from the assistant
-initial_message = BaseAgentOutputSchema(chat_message="Hello! How can I assist you today?")
+initial_message = BasicChatOutputSchema(chat_message="Hello! How can I assist you today?")
history.add_message("assistant", initial_message)
# OpenAI client setup using the Instructor library
client = instructor.from_openai(openai.OpenAI(api_key=os.getenv("OPENAI_API_KEY")))
# Create agent with type parameters
-agent = BaseAgent[BaseAgentInputSchema, BaseAgentOutputSchema](
- config=BaseAgentConfig(
+agent = AtomicAgent[BasicChatInputSchema, BasicChatOutputSchema](
+ config=AgentConfig(
client=client,
model="gpt-4o-mini", # Using the latest model
history=history,
@@ -60,7 +60,7 @@ while True:
break
# Process the user's input through the agent and get the response
- input_schema = BaseAgentInputSchema(chat_message=user_input)
+ input_schema = BasicChatInputSchema(chat_message=user_input)
response = agent.run(input_schema)
# Display the agent's response
@@ -81,7 +81,7 @@ from rich.panel import Panel
from rich.text import Text
from rich.live import Live
from atomic_agents.context import ChatHistory
-from atomic_agents import BaseAgent, BaseAgentConfig, BaseAgentInputSchema, BaseAgentOutputSchema
+from atomic_agents import AtomicAgent, AgentConfig, BasicChatInputSchema, BasicChatOutputSchema
# Initialize console for pretty outputs
console = Console()
@@ -90,15 +90,15 @@ console = Console()
history = ChatHistory()
# Initialize history with an initial message from the assistant
-initial_message = BaseAgentOutputSchema(chat_message="Hello! How can I assist you today?")
+initial_message = BasicChatOutputSchema(chat_message="Hello! How can I assist you today?")
history.add_message("assistant", initial_message)
# OpenAI client setup using the Instructor library for async operations
client = instructor.from_openai(openai.AsyncOpenAI(api_key=os.getenv("OPENAI_API_KEY")))
# Agent setup with specified configuration
-agent = BaseAgent(
- config=BaseAgentConfig(
+agent = AtomicAgent(
+ config=AgentConfig(
client=client,
model="gpt-4o-mini",
history=history,
@@ -120,7 +120,7 @@ async def main():
break
# Process the user's input through the agent and get the streaming response
- input_schema = BaseAgentInputSchema(chat_message=user_input)
+ input_schema = BasicChatInputSchema(chat_message=user_input)
console.print() # Add newline before response
# Use Live display to show streaming response
@@ -152,7 +152,7 @@ from rich.console import Console
from typing import List
from pydantic import Field
from atomic_agents.context import ChatHistory, SystemPromptGenerator
-from atomic_agents import BaseAgent, BaseAgentConfig, BaseAgentInputSchema, BaseIOSchema
+from atomic_agents import AtomicAgent, AgentConfig, BasicChatInputSchema, BaseIOSchema
# Initialize console for pretty outputs
console = Console()
@@ -202,13 +202,12 @@ system_prompt_generator = SystemPromptGenerator(
)
# Agent setup with specified configuration and custom output schema
-agent = BaseAgent[BaseAgentInputSchema, BaseAgentOutputSchema](
- config=BaseAgentConfig(
+agent = AtomicAgent[BasicChatInputSchema, CustomOutputSchema](
+ config=AgentConfig(
client=client,
model="gpt-4o-mini",
system_prompt_generator=system_prompt_generator,
history=history,
- output_schema=CustomOutputSchema,
)
)
@@ -222,7 +221,7 @@ while True:
break
# Process the user's input through the agent
- input_schema = BaseAgentInputSchema(chat_message=user_input)
+ input_schema = BasicChatInputSchema(chat_message=user_input)
response = agent.run(input_schema)
# Display the agent's response
@@ -233,6 +232,7 @@ while True:
for i, question in enumerate(response.suggested_user_questions, 1):
console.print(f"[cyan]{i}. {question}[/cyan]")
console.print() # Add an empty line for better readability
+```
## Multiple AI Providers Support
@@ -257,7 +257,7 @@ import instructor
from rich.console import Console
from rich.text import Text
from atomic_agents.context import ChatHistory
-from atomic_agents import BaseAgent, BaseAgentConfig, BaseAgentInputSchema, BaseAgentOutputSchema
+from atomic_agents import AtomicAgent, AgentConfig, BasicChatInputSchema, BasicChatOutputSchema
from dotenv import load_dotenv
load_dotenv()
@@ -269,7 +269,7 @@ console = Console()
history = ChatHistory()
# Initialize history with an initial message from the assistant
-initial_message = BaseAgentOutputSchema(chat_message="Hello! How can I assist you today?")
+initial_message = BasicChatOutputSchema(chat_message="Hello! How can I assist you today?")
history.add_message("assistant", initial_message)
# Function to set up the client based on the chosen provider
@@ -341,8 +341,8 @@ provider = console.input("Choose a provider (openai/anthropic/groq/ollama/gemini
client, model = setup_client(provider)
# Create agent with chosen provider
-agent = BaseAgent[BaseAgentInputSchema, BaseAgentOutputSchema](
- config=BaseAgentConfig(
+agent = AtomicAgent[BasicChatInputSchema, BasicChatOutputSchema](
+ config=AgentConfig(
client=client,
model=model,
history=history,
diff --git a/docs/index.md b/docs/index.md
index 4682435..62b69ec 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -62,7 +62,7 @@ Here's a glimpse of how easy it is to create an agent:
import instructor
import openai
from atomic_agents.context import ChatHistory
-from atomic_agents import BaseAgent, BaseAgentConfig, BaseAgentInputSchema, BaseAgentOutputSchema
+from atomic_agents import AtomicAgent, AgentConfig, BasicChatInputSchema, BasicChatOutputSchema
# Set up your API key (either in environment or pass directly)
@@ -76,8 +76,8 @@ history = ChatHistory()
client = instructor.from_openai(openai.OpenAI()) # Pass your API key here if not in environment
# Create an agent
-agent = BaseAgent[BaseAgentInputSchema, BaseAgentOutputSchema](
- config=BaseAgentConfig(
+agent = AtomicAgent[BasicChatInputSchema, BasicChatOutputSchema](
+ config=AgentConfig(
client=client,
model="gpt-4o-mini", # Use your provider's model
history=history
@@ -89,7 +89,7 @@ response = agent.run(agent.input_schema(chat_message="Tell me about quantum comp
# Or more explicitly:
response = agent.run(
- BaseAgentInputSchema(chat_message="Tell me about quantum computing")
+ BasicChatInputSchema(chat_message="Tell me about quantum computing")
)
print(response)