An intelligent research assistant that uses LangGraph to clarify research queries, fetch relevant papers from Google Scholar, and save results to markdown files.
- Query Clarification: Uses OpenAI with structured output parsing to refine and structure research queries
- Google Scholar Integration: Fetches relevant research papers using the Scholarly library
- LangGraph Workflow: Implements a multi-step agent workflow with state management
- FastAPI Server: Provides a REST API for easy interaction
- Markdown Output: Saves research results with paper names and links to markdown files
- Install Dependencies
pip install -r requirements.txt- Configure Environment Variables
Choose your LLM provider (OpenAI, DeepSeek, OpenRouter, or Gemini):
cp .env.example .env
# Edit .env and set:
# - LLM_PROVIDER=openai, deepseek, openrouter, or gemini
# - Add the corresponding API keyFor OpenAI:
LLM_PROVIDER=openai
OPENAI_API_KEY=sk-your-key-here
For DeepSeek:
LLM_PROVIDER=deepseek
DEEPSEEK_API_KEY=your-key-here
For OpenRouter:
LLM_PROVIDER=openrouter
OPENROUTER_API_KEY=sk-or-your-key-here
For Gemini:
LLM_PROVIDER=gemini
GOOGLE_API_KEY=your-google-api-key-here
- Run the Agent
python agent.py "your research query here"python api_server.pyThen make a POST request:
curl -X POST "http://localhost:8000/research" \
-H "Content-Type: application/json" \
-d '{"query": "machine learning for climate change"}'agent.py- Main LangGraph agent implementationquery_clarifier.py- OpenAI-based query clarification with structured outputscholar_fetcher.py- Google Scholar API integrationapi_server.py- FastAPI server for the research agentmodels.py- Pydantic models for structured dataresults/- Directory where markdown results are saved
- Query Input: User provides a research query
- Clarification: Agent uses OpenAI to clarify and structure the query
- Paper Fetching: Searches Google Scholar for relevant papers
- Result Writing: Saves paper names and links to a markdown file
The agent creates markdown files in the results/ directory with content like:
# Research Results: PerFed Personalized Fedeated Learning
**Clarified Query**: Personalized Federated Learning, PerFed (Personalized Federated), Federated Learning Personalization, Client-Specific Model Adaptation
## Papers Found
1. [PerFED-GAN: Personalized federated learning via generative adversarial networks](https://ieeexplore.ieee.org/abstract/document/9766407/)
2. [Perfedmask: Personalized federated learning with optimized masking vectors](https://openreview.net/forum?id=hxEIgUXLFF)
...- Python 3.9+
- API key for one of: OpenAI, DeepSeek, OpenRouter, or Gemini
- Scholarly - for Google Scholar Feed Crawlng