feat: solution for 'Повторный экзамен #2: Сравнительный обзор 3 сущностей (Tavily)'
This commit is contained in:
@@ -1,64 +1,70 @@
|
||||
# LangGraph Comparative Review Agent
|
||||
# Research Brief Generator
|
||||
|
||||
This project implements a LangGraph agent that, given three entities (e.g., technologies, products, or approaches), produces a comparative review. The agent:
|
||||
This project builds a LangGraph agent that produces a cohesive research brief comparing three entities (e.g., vector databases).
|
||||
The agent:
|
||||
|
||||
1. Generates 3–5 comparison criteria using an LLM.
|
||||
2. Performs a web search for each entity‑criterion pair via Tavily and stores a short note.
|
||||
3. Builds a Markdown table with the findings.
|
||||
4. Produces a verdict recommending which entity suits which use case.
|
||||
1. Generates comparison criteria using an LLM.
|
||||
2. Performs iterative web searches with Tavily for each entity‑criterion pair.
|
||||
3. Aggregates findings into a concise research brief.
|
||||
4. Provides a recommendation verdict.
|
||||
|
||||
## Features
|
||||
## Prerequisites
|
||||
|
||||
- **LLM powered**: Uses OpenAI’s GPT model to generate criteria and verdicts.
|
||||
- **Web search**: Uses Tavily to fetch up-to-date information for each pair.
|
||||
- **CLI**: Run from the command line with default or custom entities.
|
||||
- **Modular**: Separate files for state, nodes, graph, and CLI.
|
||||
- Python 3.10+
|
||||
- An OpenAI API key (set in `OPENAI_API_KEY` environment variable).
|
||||
- A Tavily API key (set in `TAVILY_API_KEY` environment variable).
|
||||
|
||||
## Setup
|
||||
|
||||
```bash
|
||||
# Create a virtual environment (optional but recommended)
|
||||
# Clone the repository
|
||||
git clone https://github.com/yourusername/research-brief.git
|
||||
cd research-brief
|
||||
|
||||
# Create a virtual environment
|
||||
python -m venv .venv
|
||||
source .venv/bin/activate # On Windows use `.venv\Scripts\activate`
|
||||
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
||||
|
||||
# Install dependencies
|
||||
pip install -r requirements.txt
|
||||
|
||||
# Create a .env file with your API keys
|
||||
cp .env.example .env
|
||||
# Edit .env and fill in your keys
|
||||
echo "OPENAI_API_KEY=your_openai_key" >> .env
|
||||
echo "TAVILY_API_KEY=your_tavily_key" >> .env
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
python src/main.py
|
||||
```
|
||||
|
||||
The script will compare the default entities: **Chroma, FAISS, Qdrant**.
|
||||
You can also provide custom entities:
|
||||
Run the CLI with default entities (Chroma, FAISS, Qdrant):
|
||||
|
||||
```bash
|
||||
python src/main.py --entities "TensorFlow, PyTorch, JAX"
|
||||
python -m src.main
|
||||
```
|
||||
|
||||
The output will display:
|
||||
Provide custom entities:
|
||||
|
||||
1. Generated comparison criteria.
|
||||
2. The Markdown table of findings.
|
||||
3. The final verdict.
|
||||
```bash
|
||||
python -m src.main --entities "EntityA, EntityB, EntityC"
|
||||
```
|
||||
|
||||
The output will display the research brief followed by the verdict.
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
src/
|
||||
├── cli.py # CLI entry point
|
||||
├── graph.py # LangGraph definition
|
||||
├── main.py # Script to run the graph
|
||||
├── graph.py # LangGraph workflow
|
||||
├── main.py # Package entry
|
||||
├── nodes.py # Node implementations
|
||||
└── state.py # TypedDict for state
|
||||
└── state.py # State schema
|
||||
```
|
||||
|
||||
## Extending
|
||||
|
||||
- Replace the LLM with a local model (e.g., Ollama) by adjusting the `llm` initialization in `nodes.py`.
|
||||
- Add more sophisticated parsing or error handling as needed.
|
||||
|
||||
## License
|
||||
|
||||
MIT License
|
||||
Reference in New Issue
Block a user