An AI-powered API built with FastAPI for generating research reports using LangGraph for multi-step reasoning and OpenAI for response generation.
- FastAPI Framework: Modern, high-performance web framework for building APIs
- AI Analyst Personas: Automatically creates analyst personas based on the research topic
- Simulated Interviews: Conducts interviews between analysts and AI experts
- Report Generation: Compiles insights into a comprehensive research report
- Multi-Step Reasoning: Uses LangGraph for structured reasoning workflows
- AI-Generated Summaries: OpenAI summarizes the retrieved data
- Framework: FastAPI - Fast, modern Python web framework
- API Documentation: Automatic Swagger/OpenAPI documentation
- AI Model: OpenAI (GPT-3.5-turbo)
- Agentic Mechanism: LangGraph
- Dependency Management: Python virtual environments
- Clone the repository:
git clone https://github.com/skanderkaroui/analyst-research-api.git
cd analyst-research-api- Create a virtual environment:
python -m venv venv
venv\Scripts\activate # On Windows- Install dependencies:
pip install -r requirements.txt- Create a
.envfile and add your OpenAI API key:
OPENAI_API_KEY=your_openai_api_key
We've tested and confirmed that the following versions work well together:
fastapi==0.115.9
uvicorn==0.34.0
pydantic==2.10.6
pydantic-core==2.27.2
python-dotenv==1.0.1
langchain-core==0.3.40
langchain-openai==0.3.7
langgraph==0.3.1
openai==1.65.1
typing-extensions==4.12.2
langsmith==0.3.11
If you encounter dependency conflicts or errors like ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard', try using these specific versions.
- Start the FastAPI server:
# Activate the virtual environment
venv\Scripts\activate # On Windows
# Start the server
uvicorn app.main:app --reload-
Access the interactive API documentation at
http://localhost:8000/docs -
Example API request:
curl -X POST "http://localhost:8000/research" \
-H "Content-Type: application/json" \
-d '{"topic": "The impact of artificial intelligence on healthcare", "max_analysts": 2}'POST /research
Request body:
{
"topic": "The impact of artificial intelligence on healthcare",
"max_analysts": 2
}Response:
{
"report": "# AI in Healthcare: A Comprehensive Analysis\n\n## Introduction\n..."
}python simple_test.pypython analyst_test.pyapp.py: Original FastAPI applicationapp/main.py: Modular FastAPI applicationsimple_test.py: Simple test script for LangGraphanalyst_test.py: Implementation of the analyst research systemrequirements.txt: Project dependencies
If you encounter any issues:
- Make sure your OpenAI API key is correctly set in the
.envfile - Check that all dependencies are installed with the correct versions
- Ensure you're using Python 3.8 or higher
- If you see warnings about
json_schemawith GPT-3.5-turbo, these can be safely ignored
MIT