@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 +109 -97
- package/dist/{chunk-AOE6JLKC.js → chunk-EWLGKE65.js} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/main.cjs +1 -1
- package/dist/main.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,97 +1,109 @@
|
|
|
1
|
-
# @
|
|
2
|
-
|
|
3
|
-
[](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 @
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Quick Start
|
|
22
|
-
|
|
23
|
-
```typescript
|
|
24
|
-
import { query_intent } from '@
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
1
|
+
# @horribleprogram/sdk
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@horribleprogram/sdk)
|
|
4
|
+
[](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 || "
|
|
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 || "
|
|
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
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 || "
|
|
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