Skip to content

eddieogola/ai-agent-deploy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI Agent Deploy

A FastAPI-based application that deploys AI agents for email management and research tasks using LangChain and LangGraph frameworks. The application features a supervisor agent that coordinates between specialized agents to handle complex multi-step tasks.

πŸ—οΈ Architecture Overview

This project implements a multi-agent system with the following components:

  • Supervisor Agent: Orchestrates work between specialized agents
  • Email Agent: Manages email operations (send, receive, manage inbox)
  • Research Agent: Handles research tasks and data preparation
  • FastAPI Backend: RESTful API for agent interactions
  • PostgreSQL Database: Persistent storage for chat messages
  • Docker Compose: Container orchestration for development

πŸ“ Project Structure

ai-agent-deploy/
β”œβ”€β”€ server/                     # Backend FastAPI application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”‚   β”œβ”€β”€ ai/            # AI agents and tools
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ agents.py  # Agent definitions
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ llms.py    # Language model configurations
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ tools.py   # Agent tools and functions
β”‚   β”‚   β”‚   β”‚   └── schemas.py # Pydantic schemas
β”‚   β”‚   β”‚   β”œβ”€β”€ chat/          # Chat functionality
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ models.py  # Database models
β”‚   β”‚   β”‚   β”‚   └── routing.py # API endpoints
β”‚   β”‚   β”‚   └── db.py          # Database configuration
β”‚   β”‚   └── main.py            # FastAPI application entry point
β”‚   β”œβ”€β”€ Dockerfile             # Server container configuration
β”‚   β”œβ”€β”€ requirements.txt       # Python dependencies
β”‚   └── railway.json           # Railway deployment config
β”œβ”€β”€ client/                    # Frontend client (currently commented out)
β”‚   β”œβ”€β”€ src/
β”‚   └── Dockerfile
β”œβ”€β”€ compose.yaml               # Docker Compose configuration
└── README.md                  # This file

πŸ€– AI Agents

Agent Types

Agent Purpose Tools Description
Supervisor Orchestration N/A Manages and coordinates work between specialized agents
Email Agent Email Management send_me_email, get_unread_emails Handles email operations and inbox management
Research Agent Research Tasks research_email Prepares and researches email-related data

Agent Workflow

  1. User sends a message through the API
  2. Supervisor agent analyzes the request
  3. Supervisor delegates tasks to appropriate specialized agents
  4. Agents execute their tasks using available tools
  5. Results are coordinated and returned to the user

πŸ› οΈ Technology Stack

Backend

  • FastAPI: Modern Python web framework
  • SQLModel: SQL database modeling with Pydantic integration
  • PostgreSQL: Primary database for persistent storage
  • LangChain: Framework for building language model applications
  • LangGraph: Graph-based agent orchestration
  • OpenAI: Language model provider
  • Uvicorn: ASGI server for production

Infrastructure

  • Docker: Containerization
  • Docker Compose: Multi-container orchestration
  • Railway: Cloud deployment platform

πŸ“Š Database Schema

ChatMessage Table

Column Type Description
id Integer (PK) Unique message identifier
message String User message content
created_at DateTime (UTC) Message creation timestamp

πŸš€ Getting Started

Prerequisites

  • Docker and Docker Compose
  • OpenAI API key
  • Environment variables configured

Environment Setup

  1. Create a .env file in the root directory:
OPENAI_API_KEY=your_openai_api_key_here
DATABASE_URL=postgresql://admin:admin@db:5432/app_db
PORT=8000
MY_PROJECT=AI Agent Deploy

Development Setup

  1. Clone the repository
git clone <repository-url>
cd ai-agent-deploy
  1. Start the development environment
docker compose up --build
  1. Access the application

Production Deployment

The application is configured for Railway deployment:

# Deploy to Railway
railway deploy

πŸ“‘ API Endpoints

Chat Endpoints

Method Endpoint Description Request Body Response
GET /api/chats/ Health check None {"status": "ok"}
GET /api/chats/recent/ Get recent messages None Array of ChatMessageListItem
POST /api/chats/ Send message to agents ChatMessagePayload SupervisorMessageSchema

Example Usage

Send a message to the AI agents:

curl -X POST http://localhost:8080/api/chats/ \
  -H "Content-Type: application/json" \
  -d '{"message": "Find out how to create a latte then email me the results"}'

Get recent chat messages:

curl http://localhost:8080/api/chats/recent/

πŸ”§ Configuration

Docker Compose Services

Service Purpose Port Dependencies
server FastAPI application 8080:8000 PostgreSQL
db PostgreSQL database 5432:5432 None

Development Features

  • Hot Reload: Automatic restart on code changes
  • Volume Mounting: Live code updates without rebuilds
  • Database Persistence: Data persists across container restarts

πŸ” Monitoring and Debugging

Health Checks

  • API Health: GET /api/chats/
  • Application Root: GET /

Logging

  • Container logs: docker compose logs -f server
  • Database logs: docker compose logs -f db

Development Watch Mode

The compose file includes watch configurations for:

  • Requirements changes (triggers rebuild)
  • Dockerfile changes (triggers rebuild)
  • Source code changes (triggers restart)

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

πŸ“„ License

This project is part of a learning exercise for Docker and AI agent deployment.

πŸ”— External Dependencies

  • OpenAI API for language model functionality
  • PostgreSQL for data persistence
  • Docker for containerization
  • Railway for cloud deployment

For more detailed information about specific components, refer to the inline documentation in the respective source files.

About

A docker containerized agentic AI chat bot using langchain framework primarily written in Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages