70 lines
1.3 KiB
Markdown
70 lines
1.3 KiB
Markdown
# Deep Agent Search
|
||
|
||
This project demonstrates a simple search agent built with **LangChain**'s `DeepAgent` and the **OpenAI** language model. The agent can answer user queries and perform web searches when needed.
|
||
|
||
## Prerequisites
|
||
|
||
- Node.js 18+ (ES modules support)
|
||
- An OpenAI API key. Set it in your environment:
|
||
|
||
```bash
|
||
export OPENAI_API_KEY="your-api-key-here"
|
||
```
|
||
|
||
## Installation
|
||
|
||
```bash
|
||
npm install
|
||
```
|
||
|
||
## Usage
|
||
|
||
### CLI
|
||
|
||
Run the agent interactively:
|
||
|
||
```bash
|
||
npm start
|
||
```
|
||
|
||
You will be prompted to enter a question. The agent will respond.
|
||
|
||
### Programmatic
|
||
|
||
```js
|
||
import { ask } from "./src/index.js";
|
||
|
||
async function main() {
|
||
const answer = await ask("Who wrote 'Pride and Prejudice'?");
|
||
console.log(answer);
|
||
}
|
||
|
||
main();
|
||
```
|
||
|
||
## Testing
|
||
|
||
A simple test script is provided:
|
||
|
||
```bash
|
||
npm test
|
||
```
|
||
|
||
It queries the agent with a sample question and prints the answer.
|
||
|
||
## Project Structure
|
||
|
||
- `src/agent.js` – Configures the `DeepAgent` with OpenAI LLM and the search tool.
|
||
- `src/index.js` – Exposes the `ask` function and a CLI demo.
|
||
- `test.js` – Quick test script.
|
||
- `package.json` – Project metadata and dependencies.
|
||
|
||
## Dependencies
|
||
|
||
- `langchain` – Core LangChain library.
|
||
- `langchain-openai` – OpenAI wrapper for LangChain.
|
||
- `langchain-community` – Community tools, including the web search tool.
|
||
|
||
## License
|
||
|
||
MIT |