inferable
TypeScript icon, indicating that this package has built-in type declarations

0.30.6 • Public • Published

Typescript SDK

This is the official Inferable AI SDK for Typescript.

Installation

npm

npm install inferable

yarn

yarn add inferable

pnpm

pnpm add inferable

Quick Start

1. Initializing Inferable

Create a file named i.ts which will be used to initialize Inferable. This file will export the Inferable instance.

// d.ts

import { Inferable } from "inferable";

// Initialize the Inferable client with your API secret.
// Get yours at https://console.inferable.ai.
export const d = new Inferable({
  apiSecret: "YOUR_API_SECRET",
});

2. Hello World Service

In a separate file, create the "Hello World" service. This file will import the Inferable instance from i.ts and define the service.

// service.ts

import { i } from "./i";

// Define a simple function that returns "Hello, World!"
const sayHello = async ({ to }: { to: string }) => {
  return `Hello, ${to}!`;
};

// Create the service
export const helloWorldService = d.service({
  name: "helloWorld",
});

helloWorldService.register({
  name: "sayHello",
  func: sayHello,
  schema: {
    input: z.object({
      to: z.string(),
    }),
  },
});

3. Running the Service

To run the service, simply run the file with the service definition. This will start the service and make it available to your Inferable agent.

tsx service.ts

Documentation

Dependencies (12)

Dev Dependencies (13)

Package Sidebar

Install

npm i inferable

Weekly Downloads

771

Version

0.30.6

License

MIT

Unpacked Size

728 kB

Total Files

79

Last publish

Collaborators

  • ft4x
  • johnjcsmith