@horribleprogram/sdk 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,97 +1,109 @@
1
- # @botcierge/sdk
2
-
3
- [![npm version](https://img.shields.io/npm/v/@botcierge/sdk.svg)](https://www.npmjs.com/package/@botcierge/sdk)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
-
6
- Official JavaScript/TypeScript SDK for the **Botcierge Intent Classification API**.
7
-
8
- ## Features
9
-
10
- - **TypeScript Native**: Full type definitions for all API responses.
11
- - **Lightweight**: Zero dependencies (uses native `fetch`).
12
- - **Flexible**: Easy to use for both simple scripts and complex applications.
13
- - **Cross-platform**: Works in Node.js, Browsers, and Edge environments.
14
-
15
- ## Installation
16
-
17
- ```bash
18
- npm install @botcierge/sdk
19
- ```
20
-
21
- ## Quick Start
22
-
23
- ```typescript
24
- import { query_intent } from '@botcierge/sdk';
25
-
26
- try {
27
- const result = await query_intent("I'd like to share some food");
28
-
29
- console.log(`Domain: ${result.domain}`); // foodshare
30
- console.log(`Intent: ${result.intent}`); // share_food
31
- console.log(`Confidence: ${result.confidence}`); // high
32
- } catch (error) {
33
- console.error("Classification failed:", error.message);
34
- }
35
- ```
36
-
37
- ## API Reference
38
-
39
- ### `query_intent(utterance: string): Promise<IntentResult>`
40
-
41
- A helper function for quick classification using the default configuration (connecting to `http://localhost:8000`).
42
-
43
- ### `class Botcierge`
44
-
45
- The main class for interacting with the Botcierge API.
46
-
47
- #### `constructor(config?: BotciergeConfig)`
48
-
49
- - `config.baseUrl`: The base URL of your Botcierge API (default: `http://localhost:8000`).
50
-
51
- #### `query_intent(utterance: string): Promise<IntentResult>`
52
-
53
- Classifies a string into a specific domain and intent.
54
-
55
- ### Types
56
-
57
- #### `IntentResult`
58
- ```typescript
59
- interface IntentResult {
60
- domain: string; // The high-level category (e.g., 'moneyshare')
61
- intent: string; // The specific action (e.g., 'request_loan')
62
- confidence: "high" | "medium" | "low";
63
- scores: Record<string, number>; // Raw similarity scores for all intents
64
- }
65
- ```
66
-
67
- ## Error Handling
68
-
69
- The SDK throws standard `Error` objects if the network request fails or if the API returns a non-2xx status code.
70
-
71
- ```typescript
72
- import { Botcierge } from '@botcierge/sdk';
73
-
74
- const client = new Botcierge({ baseUrl: 'https://invalid-api.com' });
75
-
76
- try {
77
- await client.query_intent("hello");
78
- } catch (e) {
79
- console.log(e.message); // "Botcierge API error: ..."
80
- }
81
- ```
82
-
83
- ## Development
84
-
85
- ### Running Tests
86
- ```bash
87
- npm test
88
- ```
89
-
90
- ### Building
91
- ```bash
92
- npm run build
93
- ```
94
-
95
- ## License
96
-
97
- MIT © [horribleprogram](https://npmjs.com/~horribleprogram)
1
+ # @horribleprogram/sdk
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@horribleprogram/sdk.svg)](https://www.npmjs.com/package/@horribleprogram/sdk)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ Official JavaScript/TypeScript SDK for the **Botcierge Intent Classification API**.
7
+
8
+ ## Features
9
+
10
+ - **TypeScript Native**: Full type definitions for all API responses.
11
+ - **Lightweight**: Zero dependencies (uses native `fetch`).
12
+ - **Flexible**: Easy to use for both simple scripts and complex applications.
13
+ - **Cross-platform**: Works in Node.js, Browsers, and Edge environments.
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @horribleprogram/sdk
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ```typescript
24
+ import { query_intent } from '@horribleprogram/sdk';
25
+
26
+ const result = await query_intent("I'd like to share some food");
27
+
28
+ console.log(result.domain); // FOODLINK
29
+ console.log(result.intent); // share_food
30
+ console.log(result.confidence); // high
31
+ ```
32
+
33
+ No configuration needed — the SDK points to the hosted API at `https://horribleprogram-intentapi.hf.space` by default.
34
+
35
+ ## Try it in Node
36
+
37
+ Create a file `demo.mjs` and run it with `node demo.mjs`:
38
+
39
+ ```js
40
+ import { Botcierge, query_intent } from '@horribleprogram/sdk'
41
+
42
+ // Zero-config — hits the hosted API by default
43
+ console.log(await query_intent("I'm hungry"))
44
+ console.log(await query_intent("I need help with a bill"))
45
+
46
+ // Or with an explicit client
47
+ const client = new Botcierge()
48
+ console.log(await client.query_intent("I want to add milk to my list"))
49
+ ```
50
+
51
+ Example output:
52
+ ```json
53
+ { "domain": "FOODLINK", "intent": "request_food", "confidence": "high" }
54
+ { "domain": "BILLBRIDGE", "intent": "request_bill_help", "confidence": "high" }
55
+ { "domain": "SHOP_SAVVY", "intent": "add_item", "confidence": "high" }
56
+ ```
57
+
58
+ ## API Reference
59
+
60
+ ### `query_intent(utterance: string): Promise<IntentResult>`
61
+
62
+ Classifies a string using the default client (hosted API).
63
+
64
+ ### `class Botcierge`
65
+
66
+ #### `constructor(config?: BotciergeConfig)`
67
+
68
+ - `config.baseUrl`: Override the API base URL (default: `https://horribleprogram-intentapi.hf.space`).
69
+
70
+ #### `query_intent(utterance: string): Promise<IntentResult>`
71
+
72
+ Classifies a string into a specific domain and intent.
73
+
74
+ ### Types
75
+
76
+ #### `IntentResult`
77
+ ```typescript
78
+ interface IntentResult {
79
+ domain: string;
80
+ intent: string;
81
+ confidence: "high" | "medium" | "low";
82
+ scores?: Record<string, number>;
83
+ }
84
+ ```
85
+
86
+ ## Error Handling
87
+
88
+ ```typescript
89
+ import { Botcierge } from '@horribleprogram/sdk';
90
+
91
+ const client = new Botcierge({ baseUrl: 'https://my-own-instance.com' });
92
+
93
+ try {
94
+ await client.query_intent("hello");
95
+ } catch (e) {
96
+ console.log(e.message); // "Botcierge API error: ..."
97
+ }
98
+ ```
99
+
100
+ ## Development
101
+
102
+ ```bash
103
+ npm test
104
+ npm run build
105
+ ```
106
+
107
+ ## License
108
+
109
+ MIT © [horribleprogram](https://npmjs.com/~horribleprogram)
@@ -2,7 +2,7 @@
2
2
  var Botcierge = class {
3
3
  baseUrl;
4
4
  constructor(config = {}) {
5
- this.baseUrl = config.baseUrl || "http://localhost:8000";
5
+ this.baseUrl = config.baseUrl || "https://horribleprogram-intentapi.hf.space";
6
6
  }
7
7
  async query_intent(utterance) {
8
8
  const response = await fetch(`${this.baseUrl}/classify`, {
package/dist/index.cjs CHANGED
@@ -27,7 +27,7 @@ module.exports = __toCommonJS(index_exports);
27
27
  var Botcierge = class {
28
28
  baseUrl;
29
29
  constructor(config = {}) {
30
- this.baseUrl = config.baseUrl || "http://localhost:8000";
30
+ this.baseUrl = config.baseUrl || "https://horribleprogram-intentapi.hf.space";
31
31
  }
32
32
  async query_intent(utterance) {
33
33
  const response = await fetch(`${this.baseUrl}/classify`, {
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Botcierge,
3
3
  query_intent
4
- } from "./chunk-AOE6JLKC.js";
4
+ } from "./chunk-EWLGKE65.js";
5
5
  export {
6
6
  Botcierge,
7
7
  query_intent
package/dist/main.cjs CHANGED
@@ -29,7 +29,7 @@ var readline = __toESM(require("readline"), 1);
29
29
  var Botcierge = class {
30
30
  baseUrl;
31
31
  constructor(config = {}) {
32
- this.baseUrl = config.baseUrl || "http://localhost:8000";
32
+ this.baseUrl = config.baseUrl || "https://horribleprogram-intentapi.hf.space";
33
33
  }
34
34
  async query_intent(utterance) {
35
35
  const response = await fetch(`${this.baseUrl}/classify`, {
package/dist/main.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  query_intent
3
- } from "./chunk-AOE6JLKC.js";
3
+ } from "./chunk-EWLGKE65.js";
4
4
 
5
5
  // src/main.ts
6
6
  import * as readline from "readline";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@horribleprogram/sdk",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "SDK for Botcierge Intent Classification",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",