Skip to content

ram-cs7/Research_Agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔬 Autonomous Research Agent

A fully autonomous research agent built with OpenAI-Compatible LLMs + LangGraph that:

  • Plans research tasks automatically
  • Searches the web (Tavily / DuckDuckGo)
  • Retrieves from uploaded documents (RAG via ChromaDB)
  • Summarises content with map-reduce
  • Maintains memory across tasks
  • Generates structured Markdown / HTML reports

All free resources — can run entirely locally using Ollama or using free tier cloud APIs like Groq.

Example Output

Streamlit UI Output


Architecture

User Query
    │
    ▼
┌─────────────┐
│   Planner   │  LLM decomposes query → ordered task list
└──────┬──────┘
       │
       ▼
┌─────────────┐         ┌───────────────┐   ┌──────────────┐
│  Executor   │◄────────│  Web Search   │   │ Doc Retrieval│
│  (ReAct     │────────►│ Tavily / DDG  │   │ ChromaDB RAG │
│   loop)     │         └───────────────┘   └──────────────┘
└──────┬──────┘         ┌───────────────┐   ┌──────────────┐
       │                │  Summariser   │   │    Memory    │
       │                │  (Map-Reduce) │   │  (ChromaDB)  │
       ▼                └───────────────┘   └──────────────┘
┌─────────────┐
│  Summariser │  Section-level synthesis
└──────┬──────┘
       ▼
┌─────────────┐
│  Reporter   │  Jinja2 → Markdown + HTML report
└─────────────┘

Quick Start

1 — Clone & install

git clone <this-repo>
cd autonomous_research_agent
python -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install -r requirements.txt

2 — Configure

cp .env.example .env
# Open .env and set LLM_API_KEY and LLM_BASE_URL
# Optionally set TAVILY_API_KEY for better search quality

3a — Streamlit UI

streamlit run app.py
# Open http://localhost:8501

3b — CLI

# Simple query
python main.py "What are the latest breakthroughs in quantum computing?"

# With local documents
python main.py "Summarise the key arguments in the attached papers" \
    --docs paper1.pdf notes.txt

# Save report to custom path
python main.py "AI regulation in the EU" --output my_report.md

Project Structure

autonomous_research_agent/
├── agents/
│   ├── state.py          # ResearchState TypedDict
│   ├── planner.py        # Planner LangGraph node
│   ├── executor.py       # Executor ReAct loop node
│   └── graph.py          # Full LangGraph workflow
├── tools/
│   ├── web_search.py     # Tavily + DuckDuckGo
│   ├── doc_loader.py     # PDF / URL / text ingestion + chunking
│   └── summarizer.py     # Map-Reduce summarisation
├── memory/
│   ├── vector_store.py   # ChromaDB + sentence-transformers
│   └── agent_memory.py   # Agent memory add/query layer
├── report/
│   ├── generator.py      # Jinja2 report rendering + save
│   └── templates/
│       └── report_template.md
├── data/                 # Auto-created at runtime
│   ├── chroma_db/        # Persistent vector store
│   ├── reports/          # Generated reports
│   └── uploads/          # Saved uploads
├── app.py                # Streamlit UI
├── main.py               # CLI entry point
├── config.py             # Centralised settings
├── requirements.txt
└── .env.example

Free Resources Used

Component Tool Cost
LLM Generic OpenAI / Groq / Ollama Free / Low Cost
Web Search DuckDuckGo Free
Web Search+ Tavily API 1K/mo free
Vector DB ChromaDB (local) Free
Embeddings sentence-transformers Free (local)
Agent framework LangGraph (OSS) Free
RAG pipeline Custom (LlamaIndex-free) Free
Report Jinja2 + Markdown Free
UI Streamlit Free

Configuration Reference

Variable Default Description
LLM_API_KEY empty Your API key (optional if using Ollama)
LLM_BASE_URL empty Base URL (e.g., https://api.groq.com/openai/v1)
TAVILY_API_KEY empty (uses DuckDuckGo) Optional – better search
PLANNER_MODEL llama-3.1-8b-instant Model for planning
EXECUTOR_MODEL llama-3.1-8b-instant Model for execution
REPORTER_MODEL llama-3.1-8b-instant Model for report generation
MAX_TASKS_PER_PLAN 8 Max sub-tasks per research run
MAX_SEARCH_RESULTS 5 Results per web search
CHUNK_SIZE 500 Words per document chunk
CHUNK_OVERLAP 50 Overlap between chunks

Extending the Agent

Add a new tool

  1. Create tools/my_tool.py with a function that returns str.
  2. In agents/executor.py, add a new elif task["type"] == "my_tool": branch.
  3. In agents/planner.py, add "my_tool" to the valid types in the system prompt.

Change the LLM

Set PLANNER_MODEL, EXECUTOR_MODEL, or REPORTER_MODEL in .env to any supported model string (e.g. llama-3.3-70b-versatile for Groq, or llama3 for Ollama).

Use a remote vector database

Replace the chromadb.PersistentClient in memory/vector_store.py with chromadb.HttpClient(host=..., port=...) or swap in Pinecone / Weaviate.


License

MIT — use freely.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors