Skip to content

Latest commit

Β 

History

19 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ResearchPilot-Agent-REST-API

Live Demo AI-powered research system with modular architecture, multi-agent collaboration, and real tool integration.

🌟 Features

  • Multi-Agent System: 3 specialized AI agents working together
    • Researcher: Searches web for current information
    • Fact-Checker: Verifies claims and cross-checks sources
    • Summarizer: Creates professional reports
  • Real Tool Access: Web search, webpage scraping, calculations
  • JWT Authentication: Secure user authentication and authorization
  • Database Storage: SQLite for research history and user management
  • Modular Architecture: Clean separation of concerns
  • RESTful API: FastAPI with automatic OpenAPI documentation
  • Fully Tested: Unit tests with pytest

πŸ“ Project Structure

research_assistant/
β”œβ”€β”€ agent/              # AI agents and workflow logic
β”‚   β”œβ”€β”€ tools.py        # Research tools (search, scrape, calculate)
β”‚   β”œβ”€β”€ state.py        # Workflow state definition
β”‚   β”œβ”€β”€ agents.py       # Agent classes
β”‚   β”œβ”€β”€ router.py       # Routing logic
β”‚   └── graph.py        # LangGraph workflow builder
β”œβ”€β”€ api/                # FastAPI application
β”‚   β”œβ”€β”€ main.py         # App entry point
β”‚   β”œβ”€β”€ models.py       # Pydantic models
β”‚   β”œβ”€β”€ auth_routes.py  # Authentication endpoints
β”‚   └── research_routes.py # Research endpoints
β”œβ”€β”€ database/           # Database layer
β”‚   β”œβ”€β”€ db.py           # Database setup
β”‚   └── models.py       # SQLAlchemy models
β”œβ”€β”€ auth/               # Authentication
β”‚   β”œβ”€β”€ security.py     # Password hashing, JWT
β”‚   └── dependencies.py # Auth middleware
β”œβ”€β”€ config/             # Configuration
β”‚   └── settings.py     # Settings management
β”œβ”€β”€ tests/              # Unit tests
β”‚   └── test_agents.py  # Agent tests
β”œβ”€β”€ requirements.txt    # Python dependencies
β”œβ”€β”€ .env                # Environment variables
└── README.md          # This file

πŸš€ Quick Start

1. Clone and Setup

# Clone repository
git clone <your-repo-url>
cd research_assistant

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

2. Configure Environment

Create .env file:

# API Keys
GOOGLE_API_KEY=your_google_gemini_api_key

# JWT Secret (generate with: openssl rand -hex 32)
SECRET_KEY=your_super_secret_jwt_key_here

# Database
DATABASE_URL=sqlite:///./research_assistant.db

# Agent Settings
MAX_RESEARCH_ITERATIONS=2
DEFAULT_LLM_TEMPERATURE=0.7

3. Run Application

# Start server
uvicorn api.main:app --reload

# Server will start at: http://localhost:8000

4. Access API Documentation

πŸ“š API Usage

Register User

curl -X POST http://localhost:8000/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "username": "testuser",
    "email": "test@example.com",
    "password": "password123"
  }'

Login

curl -X POST http://localhost:8000/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "username": "testuser",
    "password": "password123"
  }'

Response:

{
  "access_token": "eyJhbGc...",
  "token_type": "bearer",
  "username": "testuser",
  "email": "test@example.com"
}

Create Research

curl -X POST http://localhost:8000/research/ \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -d '{
    "query": "What are the latest AI developments in 2024?",
    "max_iterations": 2
  }'

Get Research History

curl -X GET http://localhost:8000/research/history \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Get Specific Research

curl -X GET http://localhost:8000/research/1 \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

πŸ§ͺ Testing

# Run all tests
pytest tests/ -v

# Run specific test file
pytest tests/test_agents.py -v

# Run with coverage
pytest tests/ --cov=agent --cov-report=html

# View coverage report
open htmlcov/index.html

πŸ”§ Configuration

Environment Variables

Variable Description Default
GOOGLE_API_KEY Google AI API key Required
SECRET_KEY JWT secret key Required
DATABASE_URL Database connection sqlite:///./research_assistant.db
MAX_RESEARCH_ITERATIONS Max research cycles 2
ACCESS_TOKEN_EXPIRE_MINUTES Token expiration 1440 (24h)

Agent Configuration

Edit config/settings.py:

MAX_RESEARCH_ITERATIONS: int = 2  # 1-5 iterations
DEFAULT_LLM_TEMPERATURE: float = 0.7  # 0.0-1.0

πŸ—οΈ Architecture

Multi-Agent Workflow

User Query
    ↓
Researcher Agent (with tools)
    ↓ (searches web, scrapes pages)
Fact-Checker Agent (with tools)
    ↓ (verifies claims)
Summarizer Agent
    ↓ (creates report)
Final Report

Tools Available

  1. Web Search: DuckDuckGo search for current information
  2. Web Scraper: Extract content from URLs
  3. Calculator: Perform mathematical calculations

Database Schema

Users Table:

  • id, username, email, hashed_password, is_active, created_at

ResearchSessions Table:

  • id, user_id, query, research_data, verified_facts, final_report
  • status, agent_iterations, processing_time, created_at

πŸ“Š Project Stats

  • Lines of Code: ~1,500+
  • Modules: 10
  • API Endpoints: 8
  • Test Coverage: 80%+
  • Tools Integrated: 3

🎯 Key Features for Portfolio

  1. βœ… Modular Design: Clean separation of concerns
  2. βœ… Multi-Agent System: LangGraph orchestration
  3. βœ… Tool Integration: Real web search capabilities
  4. βœ… Production Ready: Auth, DB, error handling
  5. βœ… Well Tested: Unit tests with pytest
  6. βœ… Documented: Comprehensive API docs
  7. βœ… Scalable: Easy to extend with new agents/tools

πŸš€ Future Enhancements

  • Add streaming responses
  • Implement caching with Redis
  • Add more tools (Wikipedia, arXiv, GitHub)
  • Create admin dashboard
  • Add usage analytics
  • Implement rate limiting
  • Deploy to cloud (AWS/GCP)

πŸ“ License

MIT License

πŸ‘€ Author

[Asadullah Shebaz]

πŸ™ Acknowledgments

  • LangChain & LangGraph
  • FastAPI
  • GROQ API Key

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages