Warning If wanting to use a fully local version of semantic router you can useHuggingFaceEncoder
andLlamaCppLLM
(pip install -qU "semantic-router[local]"
, see here). To use theHybridRouteLayer
you mustpip install -qU "semantic-router[hybrid]"
.
Route
objects. A Route represents a specific topic or intent that you want to detect in user input. Each Route is defined by example utterances that serve as a semantic reference point.
Let’s try two simple routes for now — one for talk on politics and another for chitchat:
CohereEncoder
and OpenAIEncoder
— more encoders will be added soon.
To initialize them:
routes
and encoder
defined we now create a SemanticRouter
. The SemanticRouter is the decision-making engine that compares incoming text against your routes to find the best semantic match.
None
! This feature is useful for creating fallback behavior or passthroughs in your applications when no intent is clearly matched.