From 526daf7513c5177269222a5844811299c53d80b2 Mon Sep 17 00:00:00 2001 From: John Smith Date: Fri, 1 Nov 2024 09:37:19 +1030 Subject: [PATCH] feat(node): Add run trigger to bootstrap --- bootstrap-node/package-lock.json | 8 ++++---- bootstrap-node/package.json | 2 +- bootstrap-node/src/index.ts | 29 ++++++++++++++++++++++------- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/bootstrap-node/package-lock.json b/bootstrap-node/package-lock.json index ae3329da..ff0d78cd 100644 --- a/bootstrap-node/package-lock.json +++ b/bootstrap-node/package-lock.json @@ -7,7 +7,7 @@ "name": "@inferable/node-bootstrap", "dependencies": { "dotenv": "^16.4.5", - "inferable": "^0.30.32", + "inferable": "^0.30.34", "tsx": "^4.16.2", "zod": "^3.23.8" }, @@ -223,9 +223,9 @@ } }, "node_modules/inferable": { - "version": "0.30.32", - "resolved": "https://registry.npmjs.org/inferable/-/inferable-0.30.32.tgz", - "integrity": "sha512-5Fja4i7soDELmz8vW+F7eC31v0IHq5mINHzEbRAs8xwpSxfyVShpkNh5PbmpqsmgoG59npdVEFL6jWyshTpBNg==", + "version": "0.30.34", + "resolved": "https://registry.npmjs.org/inferable/-/inferable-0.30.34.tgz", + "integrity": "sha512-vCoju67bxrSXbEYyWocwvxbo1O3At019dL7t8mBcW8MtQAoffOfYTBvLJ1Cfgp5oXV577hgojlINFU2YlR0nNQ==", "license": "MIT", "dependencies": { "@ts-rest/core": "^3.28.0", diff --git a/bootstrap-node/package.json b/bootstrap-node/package.json index dcae0cd5..e9e9b590 100644 --- a/bootstrap-node/package.json +++ b/bootstrap-node/package.json @@ -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" }, diff --git a/bootstrap-node/src/index.ts b/bootstrap-node/src/index.ts index 27fdafd2..aca375e2 100644 --- a/bootstrap-node/src/index.ts +++ b/bootstrap-node/src/index.ts @@ -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", @@ -23,7 +23,7 @@ i.default.register({ }, }); -i.default.register({ +client.default.register({ name: "getInventoryItem", func: demo.getInventoryItem, description: "Gets an inventory item", @@ -34,7 +34,7 @@ i.default.register({ }, }); -i.default.register({ +client.default.register({ name: "listOrders", func: demo.listOrders, description: "Lists all orders", @@ -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", @@ -52,7 +52,7 @@ i.default.register({ }, }); -i.default.register({ +client.default.register({ name: "makeOrder", func: demo.makeOrder, description: "Makes an order", @@ -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(), +// }); +// }); +