51 lines
1.3 KiB
Markdown
51 lines
1.3 KiB
Markdown
# Deep Search Agent
|
||
|
||
A minimal implementation of a deep search agent built from scratch using the LangChain framework and OpenAI API.
|
||
The agent decides whether to answer a query directly or perform a web search using SerpAPI.
|
||
|
||
## Prerequisites
|
||
|
||
- Node.js 18+ (ESM support)
|
||
- An OpenAI API key
|
||
- A SerpAPI key (free tier available)
|
||
|
||
## Setup
|
||
|
||
```bash
|
||
# Clone the repository
|
||
git clone https://github.com/your-username/deep-search-agent.git
|
||
cd deep-search-agent
|
||
|
||
# Install dependencies
|
||
npm install
|
||
|
||
# Create a .env file with your API keys
|
||
cp .env.example .env
|
||
# Edit .env and replace the placeholders with your actual keys
|
||
```
|
||
|
||
## Usage
|
||
|
||
Run the agent with a query:
|
||
|
||
```bash
|
||
npm start -- "What is the capital of France?"
|
||
```
|
||
|
||
The agent will output either a direct answer or the results of a web search.
|
||
|
||
## How It Works
|
||
|
||
1. **Planner** – Uses an LLM to decide if the query requires a web search or can be answered directly.
|
||
2. **Executor** – If a search is needed, the agent calls the SerpAPI tool and returns the results.
|
||
3. **Memory** – Stores conversation context (optional for future extensions).
|
||
|
||
## Extending
|
||
|
||
- Add more tools (e.g., Wikipedia, Calculator) and update the planner prompt accordingly.
|
||
- Replace the planner with a more sophisticated planner (e.g., chain of thought).
|
||
- Persist memory to a database for long‑term context.
|
||
|
||
## License
|
||
|
||
MIT License |