Skip to content

abdulsamad00529/research-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔬 Autonomous Research Agent

An AI agent that autonomously searches the web, reads sources, and generates full research reports — powered by LangChain, Groq LLaMA-3, and Tavily Search.

Python LangChain Groq Tavily Streamlit License


What Is An AI Agent?

An AI agent is a program that can decide what to do next on its own, rather than following a fixed script. It loops through thinking, acting, and observing results until it has enough information to answer. Unlike a simple chatbot that answers from memory, an agent actively goes out and finds information in real time. This one searches the web, reads webpages, and synthesises everything into a structured report — all without human guidance.


How It Works

The agent follows the ReAct (Reasoning + Acting) loop:

┌─────────────────────────────────────────────────────────┐
│                     ReAct Loop                          │
│                                                         │
│   User Topic                                            │
│       │                                                 │
│       ▼                                                 │
│   💭 Think ──► What should I search for?               │
│       │                                                 │
│       ▼                                                 │
│   🔍 Search ──► Tavily queries live web                 │
│       │                                                 │
│       ▼                                                 │
│   📄 Read ──► Fetch full page content                   │
│       │                                                 │
│       ▼                                                 │
│   💭 Think ──► Do I have enough? What's missing?       │
│       │                                                 │
│       ├─── No ──► 🔍 Search again (new angle)          │
│       │                                                 │
│       └─── Yes ──► ✅ Generate final report             │
└─────────────────────────────────────────────────────────┘

Each loop: Think → Search → Read → Think → Search → ... → Answer


Features

  • 🤖 Autonomous multi-step research — the agent decides what to search and when to stop
  • Powered by Groq — blazing fast LLaMA-3 inference (free tier)
  • 🌐 Real-time web search — Tavily finds current, accurate sources
  • 📖 Deep reading — agent fetches and reads full webpage content
  • 🎬 Live streaming UI — watch the agent think and act in real time
  • 📄 Structured reports — summary, key findings, analysis, citations
  • 💾 Export to PDF and TXT — download professional reports instantly
  • 🔒 100% free APIs — no OpenAI, no paid services

Quick Start

1. Get your free API keys

Service URL Free Tier
Groq (LLM) https://console.groq.com Unlimited (rate-limited)
Tavily (Search) https://tavily.com 1000 searches/month

2. Clone and install

git clone <your-repo-url>
cd research-agent
pip install -r requirements.txt

3. Configure environment (optional)

cp .env.example .env
# Edit .env and add your API keys

Or enter them directly in the app sidebar — no .env file required.

4. Run the app

streamlit run app.py

Open your browser to http://localhost:8501


Example Research Topics

Try these prompts for impressive demos:

  1. "Latest breakthroughs in fusion energy and nuclear power 2024"
    → Pulls recent ITER/NIF news, power generation data, timeline predictions

  2. "How is AI changing drug discovery and pharmaceutical research?"
    → AlphaFold, ML molecular design, FDA approvals, company case studies

  3. "State of electric vehicle adoption globally in 2024"
    → Sales figures, country comparisons, infrastructure stats, manufacturer data

  4. "Best practices for building production-grade RAG systems"
    → Chunking strategies, embedding models, retrieval techniques, benchmarks

  5. "Impact of the 2024 US election on global markets and trade policy"
    → Economic analysis, sector impacts, expert predictions, historical parallels


Architecture

ReAct Pattern

ReAct (Yao et al., 2022) combines Reasoning and Acting in an interleaved loop. At each step the LLM:

  1. Emits a Thought — natural language reasoning about the situation
  2. Selects an Action — which tool to call and with what input
  3. Receives an Observation — the tool's return value
  4. Uses the observation to inform the next thought

This lets the model correct itself mid-task — if a search returns poor results, it immediately rethinks the query.

Component Map

app.py              ← Streamlit UI, live streaming, download buttons
agent.py            ← ReAct AgentExecutor (LangChain + Groq LLaMA-3)
tools/
  search.py         ← Tavily web search → formatted results
  reader.py         ← requests + BeautifulSoup → clean text
report_gen.py       ← section parser, Markdown formatter, FPDF2 PDF generator

Demo

[Add a GIF or screenshot of the app here]


Project Structure

research-agent/
├── app.py              # Main Streamlit application
├── agent.py            # LangChain ReAct agent
├── report_gen.py       # Report parsing and PDF generation
├── tools/
│   ├── __init__.py
│   ├── search.py       # Tavily search tool
│   └── reader.py       # URL content reader tool
├── requirements.txt
├── .env.example
└── README.md

License

MIT © 2024 — free to use, modify, and distribute.


Day 7 of a 7-day AI portfolio sprint. Built with LangChain, Groq, Tavily, and Streamlit.

About

Autonomous AI research agent that searches the web, reads sources, and generates structured PDF reports. Built with LangChain ReAct, Groq LLaMA3, Tavily Search, and Streamlit.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages