Files
8.-samopisnyy-poiskovyy-age…/README.md
T
kuzakhmetovartur 35b6e514a8
CI / build (3.1) (push) Has been cancelled
CI / build (3.11) (push) Has been cancelled
CI / build (3.8) (push) Has been cancelled
CI / build (3.9) (push) Has been cancelled
feat: solution for '8. Самописный поисковый агент на основе deep agents from scratch'
2026-07-01 13:13:44 +03:00

87 lines
2.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Deep Agents from Scratch Search Agent
This project implements a simple websearch agent using the **LangChain** framework, following the “Deep Agents from Scratch” template.
The agent can answer user questions by performing a DuckDuckGo search and reasoning over the results with an OpenAI LLM.
## Features
- **Zeroshot React** agent powered by LangChain.
- Uses **DuckDuckGo** for web search (no API key required).
- Powered by **OpenAI** (requires an API key).
- Conversation memory to keep context across turns.
- Simple commandline interface.
## Prerequisites
- Python 3.10+
- An OpenAI API key (set in `OPENAI_API_KEY` environment variable).
## Installation
```bash
# Clone the repository
git clone https://git.brojs.ru/kuzakhmetovartur/8.-samopisnyy-poiskovyy-agent-na-osnove.git
cd 8.-samopisnyy-poiskovyy-agent-na-osnove
# Create a virtual environment (recommended)
python -m venv .venv
source .venv/bin/activate # On Windows use `.venv\Scripts\activate`
# Install dependencies
pip install -r requirements.txt
```
## Configuration
Create a `.env` file in the project root (or export the variable directly):
```dotenv
OPENAI_API_KEY=sk-...
```
> **Note**: The DuckDuckGo search tool does not require any API key.
## Usage
Run the agent from the command line:
```bash
python main.py "What is the capital of France?"
```
You should see the agent perform a search and return an answer.
## Example
```bash
$ python main.py "Who is the current CEO of Tesla?"
=== Agent Response ===
Elon Musk is the current CEO of Tesla. He has been in the role since 2008 and is also the founder of SpaceX and Neuralink.
```
## Project Structure
```
├── src
│ └── agent.py # Agent implementation
├── main.py # CLI entry point
├── requirements.txt # Dependencies
├── README.md # Documentation
└── .env # (Optional) Environment variables
```
## Extending the Agent
- **Add more tools**: Import additional tools from `langchain_community.tools` and add them to the `tools` list in `src/agent.py`.
- **Change the LLM**: Replace `ChatOpenAI` with another LLM provider (e.g., Anthropic, Gemini) by adjusting the import and initialization.
- **Adjust temperature**: Modify the `temperature` parameter in `ChatOpenAI` to control creativity.
## Troubleshooting
- **Missing OpenAI key**: Ensure `OPENAI_API_KEY` is set in your environment or `.env` file.
- **Network errors**: Check your internet connection and retry.
- **Agent hangs**: Increase the `timeout` in the DuckDuckGo tool or switch to a different search provider.
## License
MIT License.