Extending services
Learn how to extend your services with new functions
Setting up
If you haven’t already, set up a cluster and project scaffolding by following the quick start.
In Inferable, services are a collection of functions that are connected to a cluster. runs are then created by connecting services together.
We will now extend the quickstart project with a new service.
Connecting a service with TypeScript
Create a service file
Start by creating a delivery.service.ts
inside the src/services
directory.
Write service functions
Let’s create a toy delivery service with two main functions:
makeDelivery
: Places a delivery for a given order id.checkDeliveryStatus
: Checks the status of a delivery by order id.
Inferable functions are just plain TypeScript functions and can contain any side-effects.
Connect functions to Inferable
Wire up the functions so AI can execute them alongside other services. Append this code to delivery.service.ts
:
Start the service
Start the service with:
You can verify that the services are running by doing:
Test the new function
Try out your new functions via the Assistant UI with this command:
Can you make an order for two lightsabers, and deliver them to 742 Evergreen Terrace, Springfield?
Inferable should execute multiple steps:
- Check the inventory
- Make the order
- Register a delivery for the order (using our new code)
Was this page helpful?