Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
706 changes: 706 additions & 0 deletions docs/user_guide/13_llm_router.ipynb
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

Large diffs are not rendered by default.

27 changes: 24 additions & 3 deletions redisvl/extensions/router/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
from redisvl.extensions.router.schema import Route, RoutingConfig
from redisvl.extensions.router.semantic import SemanticRouter
from redisvl.extensions.router.schema import (
DistanceAggregationMethod,
PretrainedReference,
PretrainedRoute,
PretrainedRouterConfig,
Route,
RouteMatch,
RoutingConfig,
)
from redisvl.extensions.router.semantic import AsyncSemanticRouter, SemanticRouter

__all__ = ["SemanticRouter", "Route", "RoutingConfig"]
__all__ = [
# Main router classes
"SemanticRouter",
"AsyncSemanticRouter",
# Schema classes
"Route",
"RouteMatch",
"RoutingConfig",
"DistanceAggregationMethod",
# Pretrained classes
"PretrainedReference",
"PretrainedRoute",
"PretrainedRouterConfig",
]
30 changes: 30 additions & 0 deletions redisvl/extensions/router/pretrained/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""Pretrained router configurations.

This module provides pre-built router configurations that can be loaded
without needing to re-embed references.
"""

from pathlib import Path

PRETRAINED_DIR = Path(__file__).parent


def get_pretrained_path(name: str) -> Path:
"""Get path to a pretrained configuration.

Args:
name: Pretrained config name (e.g., "default", "cost_optimized")

Returns:
Path to the pretrained JSON file.
"""
path = PRETRAINED_DIR / f"{name}.json"
if not path.exists():
available = [f.stem for f in PRETRAINED_DIR.glob("*.json")]
raise ValueError(
f"Pretrained config '{name}' not found. " f"Available: {available}"
)
return path


__all__ = ["get_pretrained_path", "PRETRAINED_DIR"]
Loading
Loading