diff --git a/archives/bootstrap-dotnet.zip b/archives/bootstrap-dotnet.zip index e381bd32..4149b8d3 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 a96ae5d2..f39a18ac 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 c1270f93..aff3aa80 100644 Binary files a/archives/bootstrap-node.zip and b/archives/bootstrap-node.zip differ diff --git a/bootstrap-go/go.mod b/bootstrap-go/go.mod index 806f12d5..a2fd5972 100644 --- a/bootstrap-go/go.mod +++ b/bootstrap-go/go.mod @@ -1,9 +1,9 @@ -module github.com/inferablehq/bootstrap-go +module github.com/inferablehq/inferable/bootstrap-go go 1.23.2 require ( - github.com/inferablehq/inferable-go v0.1.13 + github.com/inferablehq/inferable/sdk-go v0.1.20 github.com/joho/godotenv v1.5.1 ) diff --git a/bootstrap-go/go.sum b/bootstrap-go/go.sum index c8b8fd29..29e5bf0a 100644 --- a/bootstrap-go/go.sum +++ b/bootstrap-go/go.sum @@ -4,10 +4,8 @@ github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMU github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/inferablehq/inferable-go v0.1.8 h1:0FMmdquUck1ubQNuwHc4jeVGm3i1lRxKO07plKOzuBw= -github.com/inferablehq/inferable-go v0.1.8/go.mod h1:KCREH8SMnNBtVb5+FUFsj3m4gWQMJ6yB+V6EEmQmg+c= -github.com/inferablehq/inferable-go v0.1.13 h1:yTk+ulhZtwEip1GZFGro35VplxVD+AHEJ9Z1i96Lhb8= -github.com/inferablehq/inferable-go v0.1.13/go.mod h1:KCREH8SMnNBtVb5+FUFsj3m4gWQMJ6yB+V6EEmQmg+c= +github.com/inferablehq/inferable/sdk-go v0.1.20 h1:YF2vg9+nlxBVCuWXsJHulm+ZZuyRQ9BEceh+RL8O35w= +github.com/inferablehq/inferable/sdk-go v0.1.20/go.mod h1:MNuRqSw8/28SGdk5dHreAcSDkKK4BenNXOp4QDkAbPw= github.com/invopop/jsonschema v0.12.0 h1:6ovsNSuvn9wEQVOyc72aycBMVQFKz7cPdMJn10CvzRI= github.com/invopop/jsonschema v0.12.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= diff --git a/bootstrap-go/main.go b/bootstrap-go/main.go index 5b0c6451..6ad88c80 100644 --- a/bootstrap-go/main.go +++ b/bootstrap-go/main.go @@ -1,10 +1,11 @@ package main import ( - "os" + "fmt" + "os" - "github.com/inferablehq/inferable-go" - "github.com/joho/godotenv" + "github.com/inferablehq/inferable/sdk-go" + "github.com/joho/godotenv" ) func main() { @@ -15,11 +16,12 @@ func main() { } // Instantiate the Inferable client. - i, err := inferable.New(inferable.InferableOptions{ + client, err := inferable.New(inferable.InferableOptions{ // To get a new key, run: // npx @inferable/cli auth keys create 'My New Machine Key' --type='cluster_machine' - APISecret: os.Getenv("INFERABLE_API_SECRET"), - APIEndpoint: os.Getenv("INFERABLE_API_ENDPOINT"), + APISecret: os.Getenv("INFERABLE_API_SECRET"), + APIEndpoint: os.Getenv("INFERABLE_API_ENDPOINT"), + ClusterID: os.Getenv("INFERABLE_CLUSTER_ID"), }) if err != nil { @@ -27,7 +29,7 @@ func main() { } // Register demo functions (Defined in ./src/demo.go) - err = i.Default.RegisterFunc(inferable.Function{ + _, err = client.Default.RegisterFunc(inferable.Function{ Func: SearchInventory, Name: "searchInventory", Description: "Searches the inventory", @@ -36,7 +38,7 @@ func main() { panic(err) } - err = i.Default.RegisterFunc(inferable.Function{ + _, err = client.Default.RegisterFunc(inferable.Function{ Func: GetInventoryItem, Name: "getInventoryItem", Description: "Gets an inventory item", @@ -45,7 +47,7 @@ func main() { panic(err) } - err = i.Default.RegisterFunc(inferable.Function{ + _, err = client.Default.RegisterFunc(inferable.Function{ Func: ListOrders, Name: "listOrders", Description: "Lists all orders", @@ -54,7 +56,7 @@ func main() { panic(err) } - err = i.Default.RegisterFunc(inferable.Function{ + _, err = client.Default.RegisterFunc(inferable.Function{ Func: TotalOrderValue, Name: "totalOrderValue", Description: "Calculates the total value of all orders", @@ -67,7 +69,7 @@ func main() { RequiresApproval bool } - err = i.Default.RegisterFunc(inferable.Function{ + _, err = client.Default.RegisterFunc(inferable.Function{ Func: MakeOrder, Name: "makeOrder", Description: "Makes an order", @@ -77,12 +79,39 @@ func main() { panic(err) } - err = i.Default.Start() + err = client.Default.Start() if err != nil { panic(err) } - defer i.Default.Stop() + defer client.Default.Stop() + + // Trigger a Run programmatically + // run, err := client.CreateRun(inferable.CreateRunInput{ + // Message: "Can you make an order for 2 lightsabers?", + // // Optional: Explicitly attach the functions (All functions attached by default) + // // AttachedFunctions: []*inferable.FunctionReference{ + // // inferable.FunctionReference{ + // // Function: "SayHello", + // // Service: "default", + // // } + // // }, + // // Optional: Subscribe an Inferable function to receive notifications when the run status changes + // //OnStatusChange: &inferable.OnStatusChange{ + // // Function: OnStatusChangeFunction + // //} + // }) + // + // if err != nil { + // panic(err) + // } + // + // fmt.Println("Run started: ", run.ID) + // result, err := run.Poll(nil) + // if err != nil { + // panic(err) + // } + // fmt.Println("Run Result: ", result) // Wait for CTRL+C <-make(chan struct{}) diff --git a/sdk-go/README.md b/sdk-go/README.md index 0931c869..8e23dc42 100644 --- a/sdk-go/README.md +++ b/sdk-go/README.md @@ -125,8 +125,9 @@ 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` ```go - run, err := i.CreateRun(inferable.CreateRunInput{ + run, err := client.CreateRun(inferable.CreateRunInput{ Message: "Say hello to John Smith", + // Optional: Explicitly attach the functions (All functions attached by default) AttachedFunctions: []*inferable.FunctionReference{ inferable.FunctionReference{ Function: "SayHello",