A service is a collection of functions that can be executed by an agent.

The Inferable SDKs provides a default service which can be used to register services.

Explicitly registering services is only required if you have multiple hosts with different functions available.

client.default.register({
  name: "greetUser",
  description: "Greets a user by name",
  schema: {
    input: z.object({
      name: z.string(),
    }),
  },
  func: async (input: { name: string }) => {
    return `Hello, ${input.name}! Welcome to Inferable.`;
  },
});

Creating a new service

inferable/support.ts
import { Inferable } from 'inferable';
import { z } from "zod";


// Setup a the Inferable client
const client = new Inferable()

// Register a new service "SupportService" with the client
const service = client.service({ name: "SupportService" })

service.register(...)
service.register(...)

// Start listening for work
service.start();

// Stop listening for work
service.stop();

Functions

service.start()

Starts listening for work on the service, allowing agents to invoke the functions.

service.stop()

Stops listening for work on the service, preventing agents from invoking the functions.

service.register()

Registers a new function with the service. Please see the functions documentation for more details.