1.3 KiB
1.3 KiB
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:
export OPENAI_API_KEY="your-api-key-here"
Installation
npm install
Usage
CLI
Run the agent interactively:
npm start
You will be prompted to enter a question. The agent will respond.
Programmatic
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:
npm test
It queries the agent with a sample question and prints the answer.
Project Structure
src/agent.js– Configures theDeepAgentwith OpenAI LLM and the search tool.src/index.js– Exposes theaskfunction 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