@o-lang/intent-classifier
v1.0.4
Published
O-Lang intent classifier resolver — topic gating for governed chatbots
Downloads
361
Maintainers
Readme
@o-lang/intent-classifier
O-Lang intent classifier resolver — topic gating for governed chatbots.
Classifies user messages against a list of allowed topics. Blocks off-topic messages before they reach the LLM. Works for any domain — topics are defined at runtime.
Install
npm install @o-lang/intent-classifierActions
intent_classifier — classify and gate
Step 1: Ask intent-classifier "{user_message}" "{allowed_topics}"
Save as intentReturns:
{
"intent": "ask_refund",
"topic": "refunds",
"is_allowed": true,
"confidence": 0.92
}Use in a workflow
Workflow "My Chatbot" with session_id, user_message, allowed_topics
Allow resolvers:
- @o-lang/intent-classifier
- @o-lang/llm-groq
Step 1: Ask @o-lang/intent-classifier "{user_message}" "{allowed_topics}"
Save as intent
Step 2: Ask @o-lang/llm-groq "Answer this: {user_message}"
Save as reply
Return replyWorks for any domain
# Banking
allowed_topics: "accounts,savings,loans,transfers"
# E-commerce
allowed_topics: "orders,refunds,shipping,products"
# Healthcare
allowed_topics: "appointments,prescriptions,billing"
# HR
allowed_topics: "leave,payroll,benefits,onboarding"LLM vs keyword fallback
| Condition | Behaviour |
|---|---|
| GROQ_API_KEY set | Uses llama-3.1-8b-instant for accurate classification |
| No API key | Falls back to keyword matching — works offline |
| LLM error | Automatically falls back to keyword matching |
Environment variables
GROQ_API_KEY=your_key # optional — enables LLM classification
INTENT_MODEL=llama-3.1-8b-instant # optional model overrideRunning tests
npm test # Jest suite — no API key required
node test-local-resolver.js # Live smoke test