2.2 KiB
2.2 KiB
LangGraph Research Brief Agent
This project demonstrates how to build a LangGraph agent that generates a short research brief for a given topic.
The agent:
- Creates an outline of 4‑5 research steps.
- For each step, performs a web search (via Tavily) and writes a concise note.
- Synthesizes all notes into a coherent brief.
Prerequisites
- Python 3.10+
- A Tavily API key (free tier available).
- An OpenAI API key (or any compatible LLM provider).
Setup
# Clone the repository
git clone https://github.com/your-username/langgraph-research-brief.git
cd langgraph-research-brief
# Create a virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
Create a .env file in the project root based on the example:
cp .env.example .env
Edit .env and replace the placeholders with your actual keys:
OPENAI_API_KEY=sk-...
TAVILY_API_KEY=your_tavily_key
Running the Agent
python src/main.py
You should see output similar to:
=== Outline ===
1. Identify the security requirements for MCP integration
2. Review LangChain's authentication mechanisms
3. Evaluate secure communication protocols
4. Test the integration in a sandbox environment
5. Document best practices and compliance checks
=== Notes ===
[Step 1] ... (5‑8 sentence note)
[Step 2] ... (5‑8 sentence note)
...
=== Final Brief ===
...
Project Structure
src/
├── main.py # Entry point
├── graph.py # LangGraph definition
├── nodes.py # Node implementations
├── state.py # TypedDict for state
├── .env.example # Environment variable template
requirements.txt
README.md
Customization
- Topic: Change the
default_topicvariable insrc/main.pyto generate a brief on a different subject. - LLM: Swap
ChatOpenAIfor another provider (e.g., Ollama) by adjusting the imports and initialization insrc/nodes.py. - Search: Replace
TavilySearchResultswith another search tool if desired.
License
MIT License