Routing
gllm-pipeline | 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 Reference
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.
Prerequisites
This tutorial requires familiarity with these concepts:
Embedding Model (EM) Invoker - For embedding-based routers
Language Model (LM) Invoker - For LM-based routers
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:
Similarity-Based Router - Uses embedding similarity with configurable thresholds for simple semantic routing
Semantic Router - Advanced semantic similarity with pluggable backends (Native, Aurelio) for flexible routing
LM-Based Router - Leverages language models for intelligent, context-aware routing decisions
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 selectdefault_route: A fallback route used when no match is found (must be invalid_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?