From 9250ff030499fc7cbc9527b7a846bfbc69f5ff33 Mon Sep 17 00:00:00 2001 From: John Smith Date: Fri, 1 Nov 2024 11:21:58 +1030 Subject: [PATCH] feat(go): Add run start to bootstrap (#24) * feat(go): Add run start to bootstrap * [skip ci] Update bootstrap project archives --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- archives/bootstrap-dotnet.zip | Bin 4922 -> 4922 bytes archives/bootstrap-go.zip | Bin 5995761 -> 5996075 bytes archives/bootstrap-node.zip | Bin 6963 -> 6963 bytes bootstrap-go/go.mod | 4 +-- bootstrap-go/go.sum | 6 ++-- bootstrap-go/main.go | 55 ++++++++++++++++++++++++++-------- sdk-go/README.md | 3 +- 7 files changed, 48 insertions(+), 20 deletions(-) diff --git a/archives/bootstrap-dotnet.zip b/archives/bootstrap-dotnet.zip index e381bd3248317503f9c67a95ed30fac5bf393af2..4149b8d3c8d49144dac5879453bdef10b37a2917 100644 GIT binary patch delta 342 zcmdm`wo8pSz?+$civa}k*b*o5s2M+jK>Jckij7{%tv zs+_JcGYdFNA$Gsuf;nfiJa;tb9gx+;3I!u`F9|`d6P~OlECK*(4otZK delta 342 zcmdm`wo8pSz?+$civa{0_QX%*RcA{OQAtk_nan6CJkghf86+5C2o>DeZ@>r=nS6** z4=S|z8{=(eu-Fw=JD8XR8&sV)yEDwZDeQS*Wvm?L2qCk{6&xX8;qx3uFkytvlT|rg zVP+O^mO|`)!3A^9W_j*v7O?KQ{H9D`H_L*#U-<2jxuF6!$lT2WKFC}}!9Zm06hT)A eSDX_bER%l=Iv}fw6$(b?UJ`;@Cp=kASOfqIR$)j0 diff --git a/archives/bootstrap-go.zip b/archives/bootstrap-go.zip index a96ae5d20eca530aa439de53eef0476baa0cb406..f39a18ac50bd3fdae977da0a0cb4a3a05654b633 100644 GIT binary patch delta 3241 zcmZ`+2{hDQA0B2%)qD@F7l1ibF zhGdIm$x@lb8+p-(^Y(tbA;w^qKe@;KR{F`TH4 z5yXDtcODsbK6z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C)8*$!xw?o8Rp?sTXjcp9rw;Q?kY}Nj7iA2CoM?vPiowMF8Rz=Y>t~8 zb#LmJ^4z$E^}uYe|Luz{oW2c=>*6kTTKXkev${oxee$UwY?D2uKkN2Z(8p|rYb`bPY9m^98O_c8eZEa)!p{S^b#M-HgI+{-J6WtSS+t`rpM_AeB`Kg-e<|V_MWpL#L*FF z%ahj1gA1c7WY_E<|eOmv3WJy9w+kE zx}_0)*J^3@z$xY>^T&rVYx3XymqX*&jtreYNaTvngmaJk%?q@j-?a@M_V3}Zdnxtk zH|x`)MW-E{s?AupT$ti&(H*88%ZurfW>*U@VH%`;SjVY!jN&!YXk=^zLE&1TvI?o_0D^BwcbLpk>9H<2W5s zl>Wc2l2#FeS4IBmDMfxvQDiJ$?`MGhU(Si<8;e)`3F+-Zf4c_+f(L=#@l6N>-OetI z$N1q9?ty_}p9hl*@o z#+bnf787JPgNgYvKi~z683<~knKijq&;X`vv!Ek0SlM?Gm<5~lMAIN*(L tDGOHeM#3JM>nmxC%v~et0^y2t!u>H>NXi^pO}3OBGWWC;*gzg>bpR)~N|pcs 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",