This project implements a modular, multi-stage deep research pipeline using TypeScript and LangChain. The system is designed to take a user query and autonomously:
- Route the query for clarification or research.
- Extract a precise research topic.
- Supervise and decompose the research into sub-topics.
- Generate targeted web search queries.
- Filter and summarize web results.
- Synthesize a comprehensive, well-cited answer.
- Router: Determines if the user query is ready for research or needs clarification.
- User Question Handler: Asks clarifying questions if needed.
- Topic Extractor: Converts conversation into a standalone research topic.
- Research Supervisor: Decomposes the main topic, tracks confidence, and orchestrates sub-research.
- Topic Research Supervisor: Generates web search queries for each research gap.
- Web Search & Filter: Executes searches and selects the most relevant results.
- Summarizer: Produces concise, data-rich summaries from web content.
- Answer Generator: Synthesizes a final, well-structured, and cited answer.
deep_researcher.ts— Main pipeline logic and orchestration.prompts.ts— All prompt templates and few-shot examples for each node.utils.ts— Utility functions for parsing, formatting, and web scraping.config.ts— LLM and embedding model configuration, and the main research query.package.json— Dependencies and scripts.tsconfig.json— TypeScript configuration.assets/graph.png— Visual graph of the pipeline.answer.txt— The final answer is saved here after each run.
- Change LLM and Embedding Providers:
- You can fully customize which LLM (large language model) or LLM provider, and which embedding model or embedding provider to use in
config.ts. - Update the model names, providers, or endpoints as needed for your environment.
- You can fully customize which LLM (large language model) or LLM provider, and which embedding model or embedding provider to use in
- Change the Research Query:
- You can set what the pipeline will perform deep research for by editing the initial query in
config.ts(see themainfunction indeep_researcher.tsfor usage).
- You can set what the pipeline will perform deep research for by editing the initial query in
- Edit Prompts:
- Edit
prompts.tsto refine the behavior and instructions for each pipeline node.
- Edit
-
Install dependencies
yarn
-
Build the project
yarn build
-
Start the pipeline
yarn start
- The answer to your research query will be saved in
answer.txt.
- The answer to your research query will be saved in
-
Development mode
yarn dev
- The final answer is always written to
answer.txtin the project root. - The answer is well-structured, cited, and suitable for professional use.
- Node.js
- Yarn
