A comprehensive AI agent framework with memory, tool integration, and visible reasoning capabilities.
Project description
AI Agent System
Installation
pip install ai_agent_system
A comprehensive AI agent framework with memory capabilities, tool integration, and visible reasoning processes. This system implements the orchestrator-worker pattern with advanced memory management and a rich set of tools for various tasks.
🌟 Features
- Memory Management: Long-term memory using vector embeddings and RAG (Retrieval-Augmented Generation)
- Tool Integration: Comprehensive set of tools including Python execution, web browsing, file operations, and more
- Visible Reasoning: Step-by-step reasoning display with timestamps and detailed explanations
- Typographic Output: Beautiful, formatted output with color coding and structured display
- Modular Architecture: Extensible design allowing easy addition of new tools and capabilities
🛠️ Available Tools
- Python Tool: Execute Python code and perform calculations
- Web Browser Tool: Navigate websites and extract content
- File System Tool: Read, write, and manage files and directories
- Screenshot Tool: Capture screenshots of web pages (requires browser automation)
- Web Scraper Tool: Extract structured data from websites
- Diff Checker Tool: Compare files and text content
- Content Generator Tool: Generate books, articles, and documents
🏗️ Architecture
The system follows an orchestrator-worker pattern:
- Agent Core: Central orchestrator that manages reasoning, tool selection, and response generation
- Memory Manager: Handles both short-term and long-term memory using vector embeddings
- Tool Registry: Manages available tools and provides a unified interface
- Output Formatter: Formats responses in a clear, typographic format
📦 Installation
- Clone or download the AI agent system
- Install required dependencies:
pip install -r requirements.txt
- Set up your OpenAI API key:
export OPENAI_API_KEY="your-api-key-here"
🚀 Quick Start
Basic Usage
from core.agent import AIAgent
# Initialize the agent
agent = AIAgent(
model_name="gpt-4",
memory_persist_path="./agent_memory",
enable_reasoning_display=True
)
# Process a query
response = agent.process_query("Calculate the factorial of 5 using Python")
# Get formatted output
formatted_response = agent.get_formatted_response(response)
print(formatted_response)
Interactive Mode
Run the demonstration script in interactive mode:
cd ai_agent_system
python examples/demo.py interactive
Demo Mode
Run the full demonstration:
cd ai_agent_system
python examples/demo.py
🧠 Memory System
The agent uses a sophisticated memory system with:
- Conversational Memory: Recent interactions stored in memory
- Knowledge Base: Long-term storage using ChromaDB vector database
- Semantic Search: Retrieve relevant information using embeddings
- Memory Types: Interactions, knowledge, and observations
Memory Operations
# Store knowledge
memory_id = agent.memory_manager.store_knowledge(
content="Python is a programming language",
source="user_input"
)
# Retrieve relevant context
relevant_items = agent.memory_manager.retrieve_relevant_context(
"Tell me about Python"
)
# Get memory statistics
stats = agent.get_memory_stats()
🔧 Tool Development
Create custom tools by extending the BaseTool class:
from tools.tool_registry import BaseTool
class CustomTool(BaseTool):
def __init__(self):
super().__init__(
name="custom_tool",
description="Description of what this tool does"
)
def execute(self, query: str, context: Dict[str, Any]) -> Any:
# Implement tool logic here
return {"success": True, "result": "Tool output"}
def get_capabilities(self) -> List[str]:
return ["custom_capability"]
# Register the tool
agent.tool_registry.register_tool(CustomTool())
📊 Output Format
The agent provides detailed, formatted output including:
- Execution Summary: Time taken, tools used, reasoning steps
- Reasoning Process: Step-by-step breakdown of decision making
- Tool Output: Detailed results from tool execution
- Final Response: Synthesized answer to the user's query
- Memory Updates: Information stored for future reference
🎯 Example Queries
"Calculate the sum of 25 and 37 using Python""Browse to https://example.com and extract the title""List all Python files in the current directory""Write a short article about machine learning""Compare the differences between file1.txt and file2.txt""Scrape product information from an e-commerce website"
🔍 Advanced Features
Memory Export/Import
# Export memory to JSON
agent.memory_manager.export_memory("memory_backup.json")
# Clear all memory
agent.clear_memory()
Tool Information
# Get available tools
tools = agent.tool_registry.get_available_tools()
# Get tool descriptions
descriptions = agent.tool_registry.get_tool_descriptions()
# Get tools by capability
web_tools = agent.tool_registry.get_tools_by_capability("web_navigation")
Custom Formatting
from utils.formatter import OutputFormatter
formatter = OutputFormatter()
# Format error messages
error_output = formatter.format_error("Something went wrong", context)
# Format memory statistics
stats_output = formatter.format_memory_stats(agent.get_memory_stats())
# Format tool list
tools_output = formatter.format_tool_list(agent.tool_registry.get_tool_info())
🛡️ Safety and Limitations
- Python code execution has basic safety checks to prevent dangerous operations
- File operations are limited to prevent accidental deletion
- Web browsing respects robots.txt and rate limiting
- Memory storage is local and persistent
🤝 Contributing
To add new tools or improve the system:
- Create new tool classes in the
tools/directory - Follow the
BaseToolinterface - Register tools in the
ToolRegistry - Add appropriate tests and documentation
📄 License
This project is licensed under the MIT License. See the LICENSE file for details.
🆘 Support
For issues or questions:
- Check the demonstration examples
- Review the tool implementations
- Examine the memory management system
- Test with simple queries first
Built with ❤️ by Paul Gedeon
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ai_agent_system-1.0.0.tar.gz.
File metadata
- Download URL: ai_agent_system-1.0.0.tar.gz
- Upload date:
- Size: 36.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ced84deda232e8b6750ab5d7cbd95f6a1a8c4cf4becf8944106d7c8e87497907
|
|
| MD5 |
3f78b61165a92f05b9d60b2bb02b3248
|
|
| BLAKE2b-256 |
8323089d1e07c25dcf28477eb8738462438166728bbb869eb95e9b4c14c59371
|
File details
Details for the file ai_agent_system-1.0.0-py3-none-any.whl.
File metadata
- Download URL: ai_agent_system-1.0.0-py3-none-any.whl
- Upload date:
- Size: 44.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c77b23994c2e75beac38f233e7450c4c9212c4ecaa06af47c81ac972fc30a04
|
|
| MD5 |
b727f99b23860711a84a0d0c576950f4
|
|
| BLAKE2b-256 |
84849ad640e7b8aed857f1c3dd488edaa4fdb0fa85f6a0735f0b78f28ba9fef7
|