Expand description
Semantic prompt router using keyword-based heuristics.
Routes prompts to specialised worker labels based on the prompt’s semantic category. Categories are identified via keyword matching — no external embedding API is required, keeping the hot path zero-I/O.
§Categories
| Category | Representative keywords | Default worker label |
|---|---|---|
Code | “function”, “debug”, “compile”, … | "code-specialist" |
Math | “equation”, “integral”, “derivative”, … | "math-specialist" |
Creative | “poem”, “story”, “imagine”, … | "creative-specialist" |
Data | “csv”, “dataframe”, “sql”, “query”, … | "data-specialist" |
General | (catch-all) | "general-worker" |
§Usage
use tokio_prompt_orchestrator::routing::semantic::{SemanticRouter, RoutingCategory};
let router = SemanticRouter::default();
let category = router.classify("Write a Python function to sort a list");
assert_eq!(category, RoutingCategory::Code);
let target = router.route("Calculate the integral of x^2");
assert_eq!(target, "math-specialist");Structs§
- Classification
Result - Detailed result of a
SemanticRouter::classify_detailedcall. - Semantic
Router - Routes prompts to specialised workers using keyword-based heuristics.
- Semantic
Router Config - Configuration for the semantic router.
Enums§
- Routing
Category - Semantic category assigned to an incoming prompt.