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

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

# 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):

OPENAI_API_KEY=sk-...

Note

: The DuckDuckGo search tool does not require any API key.

Usage

Run the agent from the command line:

python main.py "What is the capital of France?"

You should see the agent perform a search and return an answer.

Example

$ 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.

S
Description
BroJS: 8. Самописный поисковый агент на основе deep agents from scratch
Readme MIT 102 KiB
Languages
Python 80.3%
JavaScript 19.7%