# Deep Agent from Scratch This repository demonstrates a **Deep Agent** implementation using the **LangChain** library. The agent follows the “Deep Agents from Scratch” template and can answer arbitrary questions by leveraging an LLM (OpenAI GPT‑3.5‑Turbo by default). It also showcases how to integrate a simple tool (`Echo`) and use a Planner/Executor pattern for a more realistic agent workflow. ## Features - Implements the **Planner** and **Executor** pattern from the Deep Agents from Scratch template. - Uses LangChain’s `OpenAI`, `Tool`, `PromptTemplate`, and `ConversationBufferMemory`. - Configurable LLM model, temperature, and token limits. - Simple command‑line interface for quick testing. - Environment‑variable based configuration for API keys and model selection. - Demonstrates tool integration (Echo tool) and the full agent template. ## Prerequisites - Node.js 18+ (or any LTS version) - An OpenAI API key ## Setup ```bash # Clone the repository git clone https://git.brojs.ru/kuzakhmetovartur/8.-samopisnyy-poiskovyy-agent-na-osnove- cd 8.-samopisnyy-poiskovyy-agent-na-osnove- # Install dependencies npm install ``` Create a `.env` file in the project root: ```dotenv OPENAI_API_KEY=your_openai_api_key_here OPENAI_MODEL=gpt-3.5-turbo # optional, defaults to gpt-3.5-turbo ``` > **Tip:** Keep your `.env` file out of version control. Add it to `.gitignore` if you plan to push the repo. ## Usage Run the agent with a question: ```bash npm start -- "What is the tallest mountain in the world?" ``` Or simply: ```bash node src/index.js "Your question here" ``` The agent will output the answer to the console. ## Project Structure ``` ├── package.json # Project metadata and dependencies ├── src/ │ ├── deepAgent.js # Core DeepAgent implementation (Planner/Executor) │ └── index.js # CLI entry point └── README.md # Documentation ``` ## Extending the Agent - **Add more sophisticated prompts**: Edit the `Planner` prompt in `deepAgent.js`. - **Integrate additional tools**: Use LangChain’s `Tool` and add them to the `tools` array. - **Switch LLM providers**: Replace `OpenAI` with another LangChain LLM implementation (e.g., `AzureOpenAI`, `Anthropic`). ## License MIT © 2026 ---