@horribleprogram/sdk
v0.1.3
Published
SDK for Botcierge Intent Classification
Downloads
383
Maintainers
Readme
@horribleprogram/sdk
Official JavaScript/TypeScript SDK for the Botcierge Intent Classification API.
Features
- TypeScript Native: Full type definitions for all API responses.
- Lightweight: Zero dependencies (uses native
fetch). - Flexible: Easy to use for both simple scripts and complex applications.
- Cross-platform: Works in Node.js, Browsers, and Edge environments.
Installation
npm install @horribleprogram/sdkQuick Start
import { query_intent } from '@horribleprogram/sdk';
const result = await query_intent("I'd like to share some food");
console.log(result.domain); // FOODLINK
console.log(result.intent); // share_food
console.log(result.confidence); // highNo configuration needed — the SDK points to the hosted API at https://horribleprogram-intentapi.hf.space by default.
Try it in Node
Create a file demo.mjs and run it with node demo.mjs:
import { Botcierge, query_intent } from '@horribleprogram/sdk'
// Zero-config — hits the hosted API by default
console.log(await query_intent("I'm hungry"))
console.log(await query_intent("I need help with a bill"))
// Or with an explicit client
const client = new Botcierge()
console.log(await client.query_intent("I want to add milk to my list"))Example output:
{ "domain": "FOODLINK", "intent": "request_food", "confidence": "high" }
{ "domain": "BILLBRIDGE", "intent": "request_bill_help", "confidence": "high" }
{ "domain": "SHOP_SAVVY", "intent": "add_item", "confidence": "high" }API Reference
query_intent(utterance: string): Promise<IntentResult>
Classifies a string using the default client (hosted API).
class Botcierge
constructor(config?: BotciergeConfig)
config.baseUrl: Override the API base URL (default:https://horribleprogram-intentapi.hf.space).
query_intent(utterance: string): Promise<IntentResult>
Classifies a string into a specific domain and intent.
Types
IntentResult
interface IntentResult {
domain: string;
intent: string;
confidence: "high" | "medium" | "low";
scores?: Record<string, number>;
}Error Handling
import { Botcierge } from '@horribleprogram/sdk';
const client = new Botcierge({ baseUrl: 'https://my-own-instance.com' });
try {
await client.query_intent("hello");
} catch (e) {
console.log(e.message); // "Botcierge API error: ..."
}Development
npm test
npm run buildLicense
MIT © horribleprogram
