How himanshu00singhal/agent works
Project Type and Purpose
• This is a lightweight AI‐agent orchestration service with both an HTTP API (FastAPI) and an optional Streamlit UI.
• Purpose: accept POST requests at /process/, route tasks (“internet”, “query”, “summarize”) through a manager to specialized agent modules, and return AI‐driven results.
File‐Structure Analysis
• Top‐level:
• .env – environment variables (e.g., API keys)
• Dockerfile – containerizes the FastAPI app
• requirements.txt – Python dependencies (FastAPI, Uvicorn, python‐dotenv, Streamlit, etc.)
• app.py – FastAPI entrypoint defining /process/ endpoint and connecting to manager
• ui.py – Streamlit app for an interactive UI layer
• agents/ – core business logic modules:
– agent_1.py, agent_2.py, agent_3.py: implement “internet”, “query”, “summarize” behaviors
– manager.py: orchestrates which agent to invoke based on task_type
README Insights
• The service runs on port 8000, exposes Swagger UI at /docs.
• Can be consumed directly via Swagger or via the Streamlit front‐end.
• Uses Docker for deployment and .env for configuration.
a. Main Components
• Clients:
• Swagger UI (FastAPI auto‐docs)
• Streamlit UI (ui.py)
• API Backend: FastAPI server (app.py)
• Orchestration Layer: AgentManager (agents/manager.py)
• Agent Modules: agents/agent_1.py, agent_2.py, agent_3.py
• External Services:
• LLM API (OpenAI or similar)
• (For “internet” tasks) Web search API or crawling service
• Infrastructure: Docker container, .env config
b. Relationships & Data Flow
1. Client → HTTP POST /process/ (input_text, task_type, document_text)
2. FastAPI Controller (app.py) → AgentManager
3. AgentManager → selects agent_X.py based on task_type
4. Agent Module → calls external LLM or web‐search API
5. AgentModule returns response → AgentManager → FastAPI → Client
c. Architectural Patterns & Principles
• Single responsibility: each agent file handles one task type.
• Orchestration vs. execution: manager decouples routing logic from agent logic.
• 12-factor app: config via .env, containerized.
d. Key Technologies & Frameworks
• FastAPI + Uvicorn
• Python‐dotenv for config
• Streamlit for UI
• Docker for packaging
• External AI APIs (e.g., OpenAI)
Detailed Capture of Architecture
• Docker as an outer container boundary.
• .env feeding into FastAPI and Manager (config injection).
• Agent with its task_type (“internet”, “query”, “summarize”).
• Two UIs separately, indicating they both consume the same API endpoint.