Deep Research in a Pipeline with Routing

Overview

This guide shows how to perform deep research using the Deep Researcher Component placed inside a Pipeline when you need additional logic such as context preparation or routing decisions. The Pipeline orchestrates when and under what conditions deep research is invoked, but does not define how deep research itself works internally.

See complete code in GitHub

You can either:

  1. You can refer to the guide whenever you need explanation or want to clarify how each part works.

  2. Follow along with each step to recreate the files yourself while learning about the components and how to integrate them.

Both options will work—choose based on whether you prefer speed or learning by doing!

chevron-rightPrerequisiteshashtag

This example specifically requires:

  1. Completion of all setup steps listed on the Prerequisites page

You should be familiar with these:

  1. Pipeline and orchestration:

  2. Event emitting: Event Emitter

Installation

# you can use a Conda environment
pip install --extra-index-url "https://oauth2accesstoken:$(gcloud auth print-access-token)@glsdk.gdplabs.id/gen-ai-internal/simple/" python-dotenv gllm-core gllm-generation gllm-inference gllm-pipeline

Project Setup

1

Clone the repository

git clone https://github.com/gl-sdk/gen-ai-sdk-cookbook.git
cd gen-ai-sdk-cookbook/deep-research
2

Set UV authentication and install dependencies

Unix-based systems (Linux, macOS):

./setup.sh

For Windows:

setup.bat
3

Prepare .env file

OPENAI_API_KEY="..."

Implementation

In this example, DeepResearcher Component is used as one step within a Pipeline. The Pipeline handles routing logic and context preparation, while deep research itself remains a standalone invocation.

Run the script

How it works:

  1. The Pipeline evaluates the user query and determines the appropriate execution path.

  2. If deep research is required, the Pipeline invokes the deep research step.

  3. Otherwise, the Pipeline routes the request to a simpler response path.

  4. The Pipeline returns the final result produced by the selected path.

circle-info

The deep research step is treated as an encapsulated unit; the Pipeline does not break down or modify its internal execution.

See more examples on GitHub

That’s it! You've just successfully used the deep researcher module!

Next Step

  1. Combine in an end-to-end RAG pipeline by following the guides in Your First RAG Pipeline

  2. Explore more about deep researcher subclasses and features in API reference pagearrow-up-right

Last updated

Was this helpful?