deep-research

repository·main·Indexed 26 days ago

https://github.com/u14app/deep-research

A research report generator using 'Thinking' and 'Task' AI models with web search capabilities. Version 0.11.1 supports various LLM providers, SSE API for real-time research monitoring, and MCP server integration via StreamableHTTP and SSE transports. It offers flexible deployment options including Vercel, Cloudflare Pages, and Docker, with a privacy-first approach allowing for local data storage.

Tokens
9.2K
Snippets
9
Records
57
Agent score
87%

What's inside deep-research

  1. Deploy deep-research to Cloudflare Pages

    main

    Follow these steps to deploy your project using the Cloudflare dashboard:

    1. Log in to the Cloudflare dashboard and select your account.
    2. Navigate to Compute(Workers) > Create > Pages.
    3. Click Connect to Git, select the deep-research repository, and click Begin Setup.
    4. In the Framework preset dropdown, select Next.js.
    5. (Optional) Configure any required Environment Variables.
    6. Click Save and Deploy.
    7. Once the initial build is complete, click Deploy > Redeploy if necessary to ensure the latest version is running.
  2. Build a Static Deployment

    main

    You can generate a static version of the application by building it with the export command. The resulting files in the out directory can be uploaded to any static hosting service like GitHub Pages, Cloudflare Pages, or Vercel.

    pnpm build:export
  3. Deploy using Docker

    main

    Deep Research can be deployed using Docker. Note that the Docker image may lag behind the latest version by 1-2 days.

    Run with a single command:

    docker run -d --name deep-research -p 3333:3000 xiangfa/deep-research

    Run with environment variables (e.g., password and Gemini key):

    docker run -d --name deep-research \
       -p 3333:3000 \
       -e ACCESS_PASSWORD=your-password \
       -e GOOGLE_GENERATIVE_AI_API_KEY=AIzaSy... \
       xiangfa/deep-research

    Deploy using Docker Compose: Create a docker-compose.yml file with the following content:

    version: '3.9'
    services:
       deep-research:
          image: xiangfa/deep-research
          container_name: deep-research
          environment:
             - ACCESS_PASSWORD=your-password
             - GOOGLE_GENERATIVE_AI_API_KEY=AIzaSy...
          ports:
             - 3333:3000

    Then run:

    docker compose -f docker-compose.yml build
  4. Connect to the Deep Research API via SSE

    main

    The Deep Research API uses Server-Sent Events (SSE) over HTTP to stream real-time updates. To consume the API, establish a POST connection to the /api/sse endpoint and keep it open to receive a continuous stream of events. It is highly recommended to use the @microsoft/fetch-event-source library to handle the connection and event parsing.

    import { fetchEventSource } from "@microsoft/fetch-event-source";
    
    const ctrl = new AbortController();
    
    fetchEventSource("/api/sse", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        // Authorization: "Bearer YOUR_ACCESS_PASSWORD",
      },
      body: JSON.stringify({
        query: "AI trends for this year",
        provider: "google",
        thinkingModel: "gemini-2.0-flash-thinking-exp",
        taskModel: "gemini-2.0-flash-exp",
        searchProvider: "model",
        language: "en-US",
        maxResult: 5,
        enableCitationImage: true,
        enableReferences: true,
        promptOverrides: {
          systemInstruction: "You are an expert researcher. Keep answers concise and evidence-driven.",
        },
      }),
      signal: ctrl.signal,
      onmessage(msg) {
        const msgData = JSON.parse(msg.data);
        // Handle events based on msg.event type
      },
      onclose() {
        console.log("Stream closed");
      },
    });
  5. Install Deep Research for Local Development

    main

    To run Deep Research locally for development, ensure you have Node.js (v18.18.0+) and a package manager (pnpm, npm, or yarn) installed.

    1. Clone the repository:
      git clone https://github.com/u14app/deep-research.git
      cd deep-research
    2. Install dependencies:
      pnpm install
    3. Set up Environment Variables: Create a .env.local file for development by copying the template:
      cp env.tpl .env.local
    4. Run the development server:
      pnpm dev
      Access the app at http://localhost:3000.
    git clone https://github.com/u14app/deep-research.git
    cd deep-research
    pnpm install
    cp env.tpl .env.local
    pnpm dev
  6. Configure Custom Model List

    main

    You can customize the available models in the UI, but this feature only works in proxy mode.

    Add the NEXT_PUBLIC_MODEL_LIST environment variable to your .env file or your hosting provider's environment settings. Use commas (,) to separate models.

    • To disable a model: Use a minus sign before the name (e.g., -model-name).
    • To allow only specific models: Use -all,+model-name to disable everything except the specified model.
  7. Configure the Deep Research API request

    main

    When making a POST request to /api/sse, provide a JSON body following the Config interface.

    Required Fields:

    • query: The research topic string.
    • provider: AI provider (e.g., google, openai, anthropic, deepseek, xai, mistral, azure, openrouter, openaicompatible, pollinations, ollama).
    • thinkingModel: ID of the model used for thinking.
    • taskModel: ID of the model used for tasks.
    • searchProvider: Search provider (e.g., model, tavily, firecrawl, crw, exa, bocha, searxng).

    Optional Fields:

    • language: Response and search language (e.g., en-US).
    • maxResult: Maximum number of search results (default: 5).
    • enableCitationImage: Include content-related images in the report (default: true).
    • enableReferences: Include citation links (default: true).
    • promptOverrides: A partial object to override built-in prompt templates (e.g., systemInstruction, reportPlanPrompt, finalReportPrompt, etc.).
  8. Handle real-time updates with onMessage

    main

    The onMessage callback allows you to monitor the research process. Common event types include:

    • progress: Indicates lifecycle steps like report-plan, serp-query, search-task, and final-report with statuses start and end.
    • message: Streams the actual text content being generated (e.g., the report plan or search task results).
    • reasoning: Streams the internal 'thinking' or reasoning process of the model.
    • error: Emits when a step in the research process fails.
  9. Run deep-research using Docker Compose

    main
    You can deploy the deep-research service using Docker Compose. The configuration maps the internal container port 3000 to host port 3333. Environment variables required for the service must be defined in a .env file located in the same directory as the docker-compose.yml file.