horriblecpp Claude Sonnet 4.6 commited on
Commit
87996a7
·
1 Parent(s): 715f465

Add SDK usage examples

Browse files

Four runnable TypeScript examples covering basic usage, custom client
configuration, error handling, and batch classification.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

sdk-js/examples/basic.ts ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ import { query_intent } from "@botcierge/sdk";
2
+
3
+ const result = await query_intent("I have food to share");
4
+ console.log(`Domain: ${result.domain}`);
5
+ console.log(`Intent: ${result.intent}`);
6
+ console.log(`Confidence: ${result.confidence}`);
sdk-js/examples/batch.ts ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Botcierge } from "@botcierge/sdk";
2
+
3
+ const client = new Botcierge();
4
+
5
+ const utterances = [
6
+ "I'm hungry",
7
+ "I want to remember something",
8
+ "I want to buy a package",
9
+ "Create a flow plan for tomorrow",
10
+ ];
11
+
12
+ const results = await Promise.all(utterances.map(u => client.query_intent(u)));
13
+
14
+ results.forEach((r, i) => {
15
+ console.log(`"${utterances[i]}"`);
16
+ console.log(` → ${r.domain} / ${r.intent} [${r.confidence}]`);
17
+ console.log();
18
+ });
sdk-js/examples/custom-client.ts ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ import { Botcierge } from "@botcierge/sdk";
2
+
3
+ const client = new Botcierge({ baseUrl: "http://staging.botcierge.com:8000" });
4
+
5
+ const result = await client.query_intent("I need a small loan");
6
+ console.log(result);
sdk-js/examples/error-handling.ts ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ import { query_intent } from "@botcierge/sdk";
2
+
3
+ try {
4
+ const result = await query_intent("I want to add an item to my shopping list");
5
+ console.log(`${result.intent} (${result.confidence})`);
6
+ } catch (err) {
7
+ console.error("Classification failed:", (err as Error).message);
8
+ }