queryIntentRouter
Workspace API / services/queryIntentRouter
services/queryIntentRouter
Interfaces
HistoryMessage
Defined in: services/queryIntentRouter.ts:30
Simplified history message for intent classification
Properties
role
role:
"user"|"assistant"
Defined in: services/queryIntentRouter.ts:31
content
content:
string
Defined in: services/queryIntentRouter.ts:32
chunks?
optionalchunks:RAGChunk[]
Defined in: services/queryIntentRouter.ts:33
timestamp?
optionaltimestamp:Date
Defined in: services/queryIntentRouter.ts:34
TargetReference
Defined in: services/queryIntentRouter.ts:40
Target reference for TARGETED intent
Properties
documentFilename?
optionaldocumentFilename:string
Defined in: services/queryIntentRouter.ts:41
pageNumbers?
optionalpageNumbers:number[]
Defined in: services/queryIntentRouter.ts:42
chunkId?
optionalchunkId:string
Defined in: services/queryIntentRouter.ts:43
IntentClassification
Defined in: services/queryIntentRouter.ts:49
Intent classification result
Properties
intent
intent:
QueryIntent
Defined in: services/queryIntentRouter.ts:50
confidence
confidence:
"high"|"medium"|"low"
Defined in: services/queryIntentRouter.ts:51
reasoning?
optionalreasoning:string
Defined in: services/queryIntentRouter.ts:52
targetReference?
optionaltargetReference:TargetReference
Defined in: services/queryIntentRouter.ts:54
For TARGETED intent: which document/chunk to expand on
method
method:
"heuristic"|"llm"
Defined in: services/queryIntentRouter.ts:56
Classification method used
latencyMs
latencyMs:
number
Defined in: services/queryIntentRouter.ts:58
Time taken for classification (ms)
ClassifyIntentOptions
Defined in: services/queryIntentRouter.ts:64
Options for intent classification
Properties
heuristicsOnly?
optionalheuristicsOnly:boolean
Defined in: services/queryIntentRouter.ts:66
Skip LLM and use heuristics only (for testing/fallback)
timeoutMs?
optionaltimeoutMs:number
Defined in: services/queryIntentRouter.ts:68
Timeout for LLM classification (default: 3000ms)
Type Aliases
QueryIntent
QueryIntent =
"RETRIEVE"|"HISTORY_ONLY"|"TARGETED"|"HYBRID"
Defined in: services/queryIntentRouter.ts:25
Query intent classification result
Functions
classifyQueryIntent()
classifyQueryIntent(
query,history,options?):Promise<IntentClassification>
Defined in: services/queryIntentRouter.ts:374
Classify query intent using hybrid approach (LLM-heavy)
Strategy:
- Fast heuristic check for DEFINITE new topics only (~20% of queries)
- Everything else goes to LLM classification (~80% of queries)
This ensures nuanced follow-ups are handled correctly at the cost of ~100-150ms latency for most queries.
Parameters
query
string
User's query
history
Conversation history (messages)
options?
Classification options
Returns
Promise<IntentClassification>
Intent classification result
messagesToHistory()
messagesToHistory(
messages):HistoryMessage[]
Defined in: services/queryIntentRouter.ts:416
Convert database messages to history format for classification
Parameters
messages
Message[]