diff --git a/.github/workflows/create-archives.yml b/.github/workflows/create-archives.yml index 91759ad7..e43487e1 100644 --- a/.github/workflows/create-archives.yml +++ b/.github/workflows/create-archives.yml @@ -32,6 +32,7 @@ jobs: create-archives: runs-on: ubuntu-latest + needs: check_changes if: ${{ needs.check_changes.outputs.bootstrap == 'true' }} permissions: contents: write diff --git a/archives/bootstrap-dotnet.zip b/archives/bootstrap-dotnet.zip index 27e6cfd1..e381bd32 100644 Binary files a/archives/bootstrap-dotnet.zip and b/archives/bootstrap-dotnet.zip differ diff --git a/archives/bootstrap-go.zip b/archives/bootstrap-go.zip index 488ef866..a96ae5d2 100644 Binary files a/archives/bootstrap-go.zip and b/archives/bootstrap-go.zip differ diff --git a/archives/bootstrap-node.zip b/archives/bootstrap-node.zip index 284f0f80..c1270f93 100644 Binary files a/archives/bootstrap-node.zip and b/archives/bootstrap-node.zip differ diff --git a/bootstrap-dotnet/Program.cs b/bootstrap-dotnet/Program.cs index be9622ca..f29fae56 100644 --- a/bootstrap-dotnet/Program.cs +++ b/bootstrap-dotnet/Program.cs @@ -24,43 +24,72 @@ Env.Load(); } -var inferable = app.Services.GetService(); +var client = app.Services.GetService(); -if (inferable == null) +if (client == null) { throw new Exception("Could not get InferableClient"); } -inferable.Default.RegisterFunction(new FunctionRegistration { +client.Default.RegisterFunction(new FunctionRegistration { Name = "SearchInventory", Description = "Searches the inventory", Func = new Func(input => InventorySystem.SearchInventory(input)) }); -inferable.Default.RegisterFunction(new FunctionRegistration { +client.Default.RegisterFunction(new FunctionRegistration { Name = "GetInventoryItem", Description = "Gets an inventory item", Func = new Func(input => InventorySystem.GetInventoryItem(input)) }); -inferable.Default.RegisterFunction(new FunctionRegistration { +client.Default.RegisterFunction(new FunctionRegistration { Name = "ListOrders", Description = "Lists all orders", Func = new Func(input => InventorySystem.ListOrders()) }); -inferable.Default.RegisterFunction(new FunctionRegistration { +client.Default.RegisterFunction(new FunctionRegistration { Name = "TotalOrderValue", Description = "Calculates the total value of all orders", Func = new Func(input => InventorySystem.TotalOrderValue()) }); -inferable.Default.RegisterFunction(new FunctionRegistration { +client.Default.RegisterFunction(new FunctionRegistration { Name = "MakeOrder", Description = "Makes an order", Func = new Func(input => InventorySystem.MakeOrder(input)) }); -await inferable.Default.Start(); +_ = client.Default.StartAsync(); + +// Trigger a Run programmatically +// var run = await client.CreateRunAsync(new Inferable.API.CreateRunInput +// { +// Message = "Can you make an order for 2 lightsabers?", +// // Optional: Explicitly attach the `sayHello` function (All functions attached by default) +// // AttachedFunctions = new List +// // { +// // new FunctionReference { +// // Function = "SayHello", +// // Service = "default" +// // } +// // }, +// // Optional: Define a schema for the result to conform to +// //ResultSchema = JsonSchema.FromType(); +// // Optional: Subscribe an Inferable function to receive notifications when the run status changes +// //OnStatusChange = new OnStatusChange +// //{ +// // Function = OnStatusChangeFunction +// //} +// }); +// +// Console.WriteLine($"Run started: {run.ID}"); +// +// // Wait for the run to complete and log +// var result = await run.PollAsync(null); +// +// Console.WriteLine($"Run result: {result}"); app.Run(); + diff --git a/bootstrap-dotnet/bootstrap-dotnet.csproj b/bootstrap-dotnet/bootstrap-dotnet.csproj index dda36059..a6558b42 100644 --- a/bootstrap-dotnet/bootstrap-dotnet.csproj +++ b/bootstrap-dotnet/bootstrap-dotnet.csproj @@ -9,7 +9,7 @@ - + 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(), +// }); +// }); + diff --git a/sdk-dotnet/README.md b/sdk-dotnet/README.md index 7e9a613a..68b39729 100644 --- a/sdk-dotnet/README.md +++ b/sdk-dotnet/README.md @@ -60,7 +60,7 @@ client.Default.RegisterFunction(new FunctionRegistration }), }); -await client.Default.Start(); +_ = client.Default.Start(); ```
@@ -81,7 +81,7 @@ The following code will create an [Inferable run](https://docs.inferable.ai/page > - in the [CLI](https://www.npmjs.com/package/@inferable/cli) via `inf runs list` ```csharp -var run = await inferable.CreateRun(new CreateRunInput +var run = await inferable.CreateRunAsync(new CreateRunInput { Message = "Say hello to John", // Optional: Explicitly attach the `sayHello` function (All functions attached by default) @@ -101,10 +101,10 @@ var run = await inferable.CreateRun(new CreateRunInput //} }); -Console.WriteLine($"Run started: {run.Id}"); +Console.WriteLine($"Run started: {run.ID}"); // Wait for the run to complete and log -var result = await run.Poll(null); +var result = await run.PollAsync(null); Console.WriteLine($"Run result: {result}"); ```