compassRouting

gllm-pipelinearrow-up-right | Involves LM | Involves EM | Tutorial: Routing | Use Case: https://github.com/GDP-ADMIN/gl-sdk/blob/docs/gitbook-sync/gitbook/gen-ai-sdk/tutorials/guides/build-end-to-end-rag-pipeline/implement-semantic-routing.md | API Referencearrow-up-right

What's a Router?

A router selects which downstream path (tool, retriever, prompt, agent) to use for a given input. This helps ensure that each query is handled by the most suitable component.

Routers are essential for building intelligent pipelines that can dynamically route queries to different components based on their content, complexity, or other criteria. Whether you need simple keyword-based routing or sophisticated semantic understanding, GL SDK provides multiple router implementations to fit your needs.

chevron-rightPrerequisiteshashtag

This tutorial requires familiarity with these concepts:

  1. Embedding Model (EM) Invoker - For embedding-based routers

  2. Language Model (LM) Invoker - For LM-based routers

  3. LM Request Processor (LMRP) - For LM request configuration

Supported Router Types

GL SDK provides several router types, each designed for specific use cases and routing strategies:

  1. Similarity-Based Router - Uses embedding similarity with configurable thresholds for simple semantic routing

  2. Semantic Router - Advanced semantic similarity with pluggable backends (Native, Aurelio) for flexible routing

  3. LM-Based Router - Leverages language models for intelligent, context-aware routing decisions

  4. Rule-Based Router - Deterministic keyword and pattern matching for explicit control over routing logic

All routers share a common interface and support features like route filtering and fallback handling, making it easy to switch between different routing strategies in your application.

Installation

Core Concepts

Routes and Valid Routes

Every router requires:

  • valid_routes: A set of all possible route names the router can select

  • default_route: A fallback route used when no match is found (must be in valid_routes)

Route Filtering

All routers support restricting available routes at runtime:

The route_filter must include the default_route and only contain valid routes.

Last updated

Was this helpful?