diff --git a/sdk-dotnet/src/Inferable.cs b/sdk-dotnet/src/Inferable.cs
index 07c1c7cb..01768437 100644
--- a/sdk-dotnet/src/Inferable.cs
+++ b/sdk-dotnet/src/Inferable.cs
@@ -54,7 +54,6 @@ public class RunReference
///
/// The Inferable client. This is the main entry point for using Inferable.
- ///
/// Basic usage:
///
/// // create a new Inferable instance
@@ -62,7 +61,6 @@ public class RunReference
/// ApiSecret = "API_SECRET"
/// });
///
- ///
///
public class InferableClient
{
@@ -79,7 +77,6 @@ public class InferableClient
///
/// Convenience reference to a service with the name 'default'.
- ///
///
/// // Create a new Inferable instance with an API secret
/// var client = new InferableClient(new InferableOptions {
@@ -102,7 +99,6 @@ public class InferableClient
/// // Stop the service on shutdown
/// await client.Default.StopAsync();
///
- ///
///
public RegisteredService Default
{
@@ -114,7 +110,6 @@ public RegisteredService Default
///
/// Initializes a new instance of the InferableClient class.
- ///
/// Basic usage:
///
/// // Create a new Inferable instance with an API secret
@@ -127,7 +122,6 @@ public RegisteredService Default
/// Environment.SetEnvironmentVariable("INFERABLE_API_SECRET", "API_SECRET");
/// var client = new InferableClient();
///
- ///
///
public InferableClient(InferableOptions? options = null, ILogger? logger = null)
{
@@ -158,7 +152,6 @@ public InferableClient(InferableOptions? options = null, ILogger
/// Registers a service with Inferable.
- ///
///
/// // Create a new Inferable instance with an API secret
/// var client = new Inferable(new InferableOptions {
@@ -184,12 +177,29 @@ public InferableClient(InferableOptions? options = null, ILogger
- ///
///
public RegisteredService RegisterService(string name)
{ return new RegisteredService(name, this);
}
+ ///
+ /// Creates a run and returns a reference to it.
+ ///
+ /// // Create a new Inferable instance with an API secret
+ /// var client = new InferableClient(new InferableOptions {
+ /// ApiSecret = "API_SECRET"
+ /// });
+ ///
+ /// var run = client.CreateRun(new CreateRunInput {
+ /// Message = "Hello world"
+ /// });
+ ///
+ /// Console.WriteLine("Started run with ID: " + run.ID);
+ ///
+ /// var result = await run.PollAsync();
+ /// Console.WriteLine("Run result: " + result);
+ ///
+ ///
async public Task CreateRunAsync(CreateRunInput input)
{
if (this._clusterId == null) {
@@ -312,7 +322,6 @@ internal RegisteredService(string name, InferableClient inferable) {
///
/// Registers a function against the Service.
- ///
///
/// service.RegisterFunction(new FunctionRegistration
/// {
@@ -324,7 +333,6 @@ internal RegisteredService(string name, InferableClient inferable) {
/// }),
/// });
///
- ///
///
public FunctionReference RegisterFunction(FunctionRegistration function) where T : struct {
this._inferable.RegisterFunction(this._name, function);
diff --git a/sdk-go/inferable.go b/sdk-go/inferable.go
index d4fb5d45..af25a345 100644
--- a/sdk-go/inferable.go
+++ b/sdk-go/inferable.go
@@ -30,7 +30,33 @@ type Inferable struct {
functionRegistry functionRegistry
machineID string
clusterID string
- Default *service
+ // Convenience reference to a service with the name 'default'.
+ //
+ // Returns:
+ // A registered service instance.
+ //
+ // Example:
+ //
+ // // Create a new Inferable instance with an API secret
+ // client := inferable.New(InferableOptions{
+ // ApiSecret: "API_SECRET",
+ // })
+ //
+ // client.Default.RegisterFunc(Function{
+ // Func: func(input EchoInput) string {
+ // didCallSayHello = true
+ // return "Hello " + input.Input
+ // },
+ // Name: "SayHello",
+ // Description: "A simple greeting function",
+ // })
+ //
+ // // Start the service
+ // client.Default.Start()
+ //
+ // // Stop the service on shutdown
+ // defer client.Default.Stop()
+ Default *service
}
type InferableOptions struct {
@@ -114,6 +140,38 @@ func New(options InferableOptions) (*Inferable, error) {
return inferable, nil
}
+// Registers a service with Inferable. This will register all functions on the service.
+//
+// Parameters:
+// - input: The service definition.
+//
+// Returns:
+// A registered service instance.
+//
+// Example:
+//
+// // Create a new Inferable instance with an API secret
+// client := inferable.New(InferableOptions{
+// ApiSecret: "API_SECRET",
+// })
+//
+// // Define and register the service
+// service := client.Service("MyService")
+//
+// sayHello, err := service.RegisterFunc(Function{
+// Func: func(input EchoInput) string {
+// didCallSayHello = true
+// return "Hello " + input.Input
+// },
+// Name: "SayHello",
+// Description: "A simple greeting function",
+// })
+//
+// // Start the service
+// service.Start()
+//
+// // Stop the service on shutdown
+// defer service.Stop()
func (i *Inferable) RegisterService(serviceName string) (*service, error) {
if _, exists := i.functionRegistry.services[serviceName]; exists {
return nil, fmt.Errorf("service with name '%s' already registered", serviceName)
@@ -158,6 +216,37 @@ func (i *Inferable) getRun(runID string) (*runResult, error) {
return &result, nil
}
+// Creates a run and returns a reference to it.
+//
+// Parameters:
+// - input: The run definition.
+//
+// Returns:
+// A run reference.
+//
+// Example:
+//
+// // Create a new Inferable instance with an API secret
+// client := inferable.New(InferableOptions{
+// ApiSecret: "API_SECRET",
+// })
+//
+// run, err := client.Run(CreateRunInput{
+// Message: "Hello world",
+// })
+//
+// if err != nil {
+// log.Fatal("Failed to create run:", err)
+// }
+//
+// fmt.Println("Started run with ID:", run.ID)
+//
+// result, err := run.Poll()
+// if err != nil {
+// log.Fatal("Failed to poll run result:", err)
+// }
+//
+// fmt.Println("Run result:", result)
func (i *Inferable) CreateRun(input CreateRunInput) (*runReference, error) {
if i.clusterID == "" {
return nil, fmt.Errorf("cluster ID must be provided to manage runs")
diff --git a/sdk-go/service.go b/sdk-go/service.go
index 0cdf3c93..6c002f10 100644
--- a/sdk-go/service.go
+++ b/sdk-go/service.go
@@ -59,6 +59,38 @@ type FunctionReference struct {
Function string `json:"function"`
}
+// Registers a function against the service.
+//
+// Parameters:
+// - input: The function definition.
+//
+// Returns:
+// A function reference.
+//
+// Example:
+//
+// // Create a new Inferable instance with an API secret
+// client := inferable.New(InferableOptions{
+// ApiSecret: "API_SECRET",
+// })
+//
+// // Define and register the service
+// service := client.Service("MyService")
+//
+// sayHello, err := service.RegisterFunc(Function{
+// Func: func(input EchoInput) string {
+// didCallSayHello = true
+// return "Hello " + input.Input
+// },
+// Name: "SayHello",
+// Description: "A simple greeting function",
+// })
+//
+// // Start the service
+// service.Start()
+//
+// // Stop the service on shutdown
+// defer service.Stop()
func (s *service) RegisterFunc(fn Function) (*FunctionReference, error) {
if s.isPolling() {
return nil, fmt.Errorf("functions must be registered before starting the service.")