Skip to content

Commit

Permalink
feat(node): Add run trigger to bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjcsmith committed Oct 31, 2024
1 parent d60a31d commit 526daf7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
8 changes: 4 additions & 4 deletions bootstrap-node/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bootstrap-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"dependencies": {
"dotenv": "^16.4.5",
"inferable": "^0.30.32",
"inferable": "^0.30.34",
"tsx": "^4.16.2",
"zod": "^3.23.8"
},
Expand Down
29 changes: 22 additions & 7 deletions bootstrap-node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { z } from 'zod';
import * as demo from './demo';

// Instantiate the Inferable client.
const i = new Inferable({
const client = new Inferable({
// To get a new key, run:
// npx @inferable/cli auth keys create 'My New Machine Key' --type='cluster_machine'
apiSecret: process.env.INFERABLE_API_SECRET
})

// Register some demo functions
i.default.register({
client.default.register({
name: "searchInventory",
func: demo.searchInventory,
description: "Searches the inventory",
Expand All @@ -23,7 +23,7 @@ i.default.register({
},
});

i.default.register({
client.default.register({
name: "getInventoryItem",
func: demo.getInventoryItem,
description: "Gets an inventory item",
Expand All @@ -34,7 +34,7 @@ i.default.register({
},
});

i.default.register({
client.default.register({
name: "listOrders",
func: demo.listOrders,
description: "Lists all orders",
Expand All @@ -43,7 +43,7 @@ i.default.register({
},
});

i.default.register({
client.default.register({
name: "totalOrderValue",
func: demo.totalOrderValue,
description: "Calculates the total value of all orders",
Expand All @@ -52,7 +52,7 @@ i.default.register({
},
});

i.default.register({
client.default.register({
name: "makeOrder",
func: demo.makeOrder,
description: "Makes an order",
Expand All @@ -71,6 +71,21 @@ i.default.register({
},
});

i.default.start().then(() => {
client.default.start().then(() => {
console.log("Inferable demo service started");
})

// Trigger a Run programmatically
// https://docs.inferable.ai/pages/runs
// client.run({
// message: "Can you make an order for 2 lightsabers?",
// // Optional: Explicitly attach the functions (All functions attached by default)
// //attachedFunctions: [],
// // Optional: Specify the schema of the result
// //resultSchema: z.object({}),
// }).then(async (run) => {
// console.log("Run result", {
// result: await run.poll(),
// });
// });

0 comments on commit 526daf7

Please sign in to comment.