Skip to content

ZenWayne/AgentFusion

Repository files navigation

AgentFusion

A comprehensive AI agent management platform that provides multi-agent orchestration, agent building tools, prompt version management, and real-time chat interface. AgentFusion enables you to create, configure, and deploy AI agents through individual agents, group chats, and graph flows with a complete backend infrastructure.

🌟 Features

  • Multi-Agent Orchestration: Deploy individual agents, group chats, or complex graph flows
  • Database Infrastructure: PostgreSQL with SQLAlchemy ORM for persistent data storage
  • User Authentication: Complete user management with bcrypt password hashing and activity logging
  • Web Interface: Chainlit-powered real-time chat interface with WebSocket support
  • MCP Integration: Model Context Protocol support for external tool integration
  • Advanced Memory System: Configurable memory models and intelligent context initialization
  • Prompt Management: Version-controlled prompt system with built-in optimization agents
  • Activity Logging: Comprehensive audit trail for all user actions and system events
  • Flexible Configuration: JSON-based configuration system for agents, workflows, and integrations

πŸš€ Quick Start

1. Installation

# Create and activate virtual environment using uv
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies
uv pip install -r requirements.txt

# Install the package in development mode
cd python/packages/agent_fusion
uv pip install -e .

2. Database Setup

# Set up PostgreSQL database (production)
# Or use SQLite for testing - automatically configured

# Run database migrations if needed
# Database schema is located in sql/progresdb.sql

3. Environment Setup

Create a .env file in the project root with your API keys:

DEEPSEEK_API_KEY=your_deepseek_api_key_here
DASHSCOPE_API_KEY=your_aliyun_api_key_here
GEMINI_API_KEY=your_google_api_key_here

# Database configuration (optional - defaults to SQLite for testing)
DATABASE_URL=postgresql://user:password@localhost/agentfusion

4. Launch Web Interface

chainlit run python/packages/agent_fusion/src/chainlit_web/run.py

The web interface will be available at http://localhost:8000

πŸ“‹ Project Structure

AgentFusion/
β”œβ”€β”€ config/                          # Configuration files
β”‚   β”œβ”€β”€ prompt/                      # Agent prompts organized by type
β”‚   β”‚   β”œβ”€β”€ agent/                   # Individual agent prompts
β”‚   β”‚   β”œβ”€β”€ group_chat/              # Group chat selectors
β”‚   β”‚   └── ui_design/               # UI design prompts
β”‚   └── mem/                         # Memory configurations
β”œβ”€β”€ python/packages/agent_fusion/    # Main Python package
β”‚   └── src/
β”‚       β”œβ”€β”€ data_layer/              # Database layer with SQLAlchemy ORM
β”‚       β”‚   β”œβ”€β”€ models/              # Business logic models
β”‚       β”‚   └── tables/              # Database table definitions
β”‚       β”œβ”€β”€ schemas/                 # Pydantic data models
β”‚       β”œβ”€β”€ builders/                # Core builders for agents/workflows
β”‚       β”œβ”€β”€ chainlit_web/            # Web interface with user authentication
β”‚       β”‚   β”œβ”€β”€ user/                # User management and authentication
β”‚       β”‚   └── ui_hook/             # UI integration hooks
β”‚       β”œβ”€β”€ model_client/            # Model client implementations
β”‚       β”œβ”€β”€ base/                    # Base utilities and MCP support
β”‚       β”œβ”€β”€ tools/                   # Agent tools and utilities
β”‚       └── dump/                    # Configuration export utilities
β”œβ”€β”€ sql/                            # Database schema and migration scripts
β”œβ”€β”€ config.json                     # Main configuration file
β”œβ”€β”€ dumped_config/                  # Exported configurations
β”œβ”€β”€ CLAUDE.md                       # Project memory and guidelines
└── requirements.txt                # Python dependencies

πŸ—οΈ Architecture

Technology Stack

  • Backend: Python 3.11+ with FastAPI + Chainlit
  • Database: PostgreSQL (production) / SQLite (testing)
  • ORM: SQLAlchemy 2.0 with async support
  • Authentication: Custom user authentication with bcrypt
  • Agent Framework: AutoGen AgentChat
  • Frontend: Chainlit with real-time WebSocket connections

Database Architecture

  • User Management: User accounts, authentication, and activity logging
  • Agent System: Agent configurations and model clients
  • Chat System: Threads, steps, elements, and feedback
  • Prompt Management: Prompts with version control
  • Audit Trail: Comprehensive activity logging with JSONB metadata

πŸ€– Agent Types

Individual Agents

  • file_system: File and directory operations via MCP
  • product_manager: Product requirement documentation
  • prompt_refiner: Prompt optimization and refinement
  • executor: Task execution specialist
  • template_extractor: Extract parameters from prompt templates
  • prompt_specialization: Interactive prompt customization

Group Chats

  • prompt_flow: Collaborative prompt development workflow
  • hil: Human-in-the-loop product management

Graph Flows

  • prompt_specialization: Template extraction β†’ customization β†’ execution workflow

βš™οΈ Configuration

Agent Configuration

Agents are defined in config.json under the agents section:

{
  "agents": {
    "your_agent": {
      "name": "your_agent",
      "description": "Agent description",
      "labels": ["tag1", "tag2"],
      "type": "assistant_agent",
      "prompt_path": "agent/your_prompt.md",
      "model_client": "deepseek-chat_DeepSeek",
      "memory_model_client": "gemini-2.5-flash-preview-04-17_Google",
      "mcp_tools": ["file_system"]
    }
  }
}

Group Chat Configuration

{
  "group_chats": {
    "your_group": {
      "name": "your_group",
      "description": "Group description",
      "type": "selector_group_chat",
      "selector_prompt": "group_chat/your_selector.md",
      "model_client": "deepseek-chat_DeepSeek",
      "participants": ["agent1", "agent2", "human_proxy"]
    }
  }
}

Graph Flow Configuration

{
  "graph_flows": {
    "your_flow": {
      "name": "your_flow",
      "description": "Workflow description",
      "type": "graph_flow",
      "participants": ["agent1", "agent2"],
      "nodes": [
        ["agent1", "agent2"],
        ["agent2", {"condition": "agent1"}]
      ],
      "start_node": "agent1"
    }
  }
}

πŸ”§ Usage Examples

Export Configuration

Use the dump utilities to export your configuration:

from dump import dump_agents, dump_group_chats

# Export specific components
dump_agents(["file_system"], "dumped_config")
dump_group_chats(["prompt_flow"], "dumped_config")

πŸ› οΈ Development

Database Development

# Run tests
python -m pytest python/packages/agent_fusion/tests/ -v

# Test specific model
python -m pytest python/packages/agent_fusion/tests/test_user_model.py -v

Adding New Agents

  1. Create a prompt file in config/prompt/agent/
  2. Add agent configuration to config.json
  3. Update database models if needed (data_layer/models/)
  4. Add tests for new functionality
  5. Test via the web interface

Database Migrations

  1. Update SQL schema in sql/progresdb.sql
  2. Update SQLAlchemy models in data_layer/models/tables/
  3. Update business logic models in data_layer/models/
  4. Add comprehensive tests

Custom MCP Tools

Define MCP servers in the mcpServers section of config.json:

{
  "mcpServers": {
    "your_tool": {
      "command": "your_command",
      "args": ["arg1", "arg2"],
      "env": {},
      "read_timeout_seconds": 30
    }
  }
}

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/your-feature
  3. Make your changes
  4. Update tests and documentation
  5. Submit a pull request

πŸ“„ License

MIT License - see LICENSE file for details

πŸ™ Acknowledgments

Built on top of AutoGen - a powerful framework for multi-agent AI applications. Special thanks to the AutoGen team for their pioneering work in multi-agent orchestration.

πŸ“ž Support

  • Create an issue for bug reports or feature requests
  • Check the documentation in the config/prompt/ directory for prompt examples
  • Review config.json for configuration patterns

About

autogen with chainlit

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages