1.6 KiB
1.6 KiB
Deep Search Agent – LangChain Implementation
This repository contains a minimal implementation of a search agent built with LangChain, following the “Deep Agents from Scratch” template.
The agent can answer arbitrary questions by performing a web search and reasoning over the results.
Features
- Uses OpenAI GPT‑4o‑mini as the language model.
- Performs web searches via SerpAPI (Google/SerpAPI).
- Maintains conversation context with a memory buffer.
- Implements the Zero‑Shot React agent pattern.
- Simple command‑line interface for interactive use.
Prerequisites
- Python 3.10+
- An OpenAI API key.
- A SerpAPI key (free tier available).
Setup
# Clone the repository
git clone https://git.brojs.ru/kuzakhmetovartur/8.-samopisnyy-poiskovyy-agent-na-osnove-<repo>.git
cd <repo>
# 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 with your credentials:
OPENAI_API_KEY=sk-...
SERPAPI_KEY=your-serpapi-key
Usage
Run the agent interactively:
python -m src.agent
You will be prompted to enter a question. The agent will search the web and return a concise answer.
Example
Enter your question: What is the capital of France?
Processing...
=== Answer ===
The capital of France is Paris.
Testing
The agent can be tested programmatically by importing create_search_agent from src.agent and calling agent.run("your question").
License
MIT License