A Python-based multi-agent research pipeline that uses LangChain, a web search tool, and a web scraper to gather information, generate a structured report, and critique the final output.
This repository implements a small multi-agent system with two primary execution modes:
- CLI pipeline via
pipeline.py - Streamlit web app via
app.py
The system uses:
- a search agent to gather recent web content using Tavily
- a reader agent to scrape and extract deeper page content from selected URLs
- a writer chain to draft a polished research report
- a critic chain to review the report and provide feedback
app.py— Streamlit interface for running the research pipeline in a browser.pipeline.py— console-based orchestration of the full pipeline with printed progress.agents.py— agent and chain builder for search, reader, writer, and critic workflows.tools.py— custom LangChain tools for web search and scraping.main.py— simple placeholder entry point.requirements.txt— Python dependencies.pyproject.toml— project metadata and Python version requirements..env— environment variables (not committed; used for API keys).
agents.py defines:
build_search_agent()— LangChain agent withweb_search_toolbuild_reader_agent()— LangChain agent withweb_scraping_toolwriter_chain— prompt chain for generating a structured research reportcritic_chain— prompt chain for evaluating the report and producing feedback
tools.py implements two LangChain tools:
web_search_tool(query: str)— performs web search via the Tavily API and returns titles, URLs, and snippetsweb_scraping_tool(url: str)— fetches page HTML and extracts visible text using BeautifulSoup
pipeline.py coordinates the full flow:
- search for topic-related results
- choose and scrape a top resource
- combine findings and generate a report
- critique the final report
app.py provides a polished UI with a four-step progress indicator, result cards, and download support.
- Create and activate a virtual environment:
python -m venv .venv
.\.venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Create a
.envfile with your Tavily API key:
TAVILY_API_KEY=your_api_key_here
MISTRAL_API_KEY=your_api_key_herepython pipeline.pyEnter a research topic when prompted.
streamlit run app.pyOpen the local Streamlit URL shown in the terminal to use the browser UI.
- The current implementation uses
mistral-small-2506viaChatMistralAI. - The web scraper trims content to approximately 3000 characters to avoid overly large outputs.
app.pyincludes custom styling and a stepper UI for a better user experience.
- Python 3.12+
langchainlangchain-corelangchain-communitylangchain-mistralaitavilybs4requestsstreamlit