Skip to main content

Module semantic

Module semantic 

Source
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

CategoryRepresentative keywordsDefault 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§

ClassificationResult
Detailed result of a SemanticRouter::classify_detailed call.
SemanticRouter
Routes prompts to specialised workers using keyword-based heuristics.
SemanticRouterConfig
Configuration for the semantic router.

Enums§

RoutingCategory
Semantic category assigned to an incoming prompt.