Ask Lusat is in betaRequest access
Powered by Lusat
This page covers the API reference for the cloud platform, which is currently available only to private testers. If you're interested in using it, please request access and reach out via Twitter/X.
You can create a client with lusat/ai
's RysanaAI
class and your platform API key (either using the RYSANA_API_KEY
environment variable or the apiKey
option).
import { RysanaAI } from 'lusat/ai'
const ai = new RysanaAI()
Workflows are the first core primitive of the Lusat API - in short, they are structured intents. They are minimal, serialized programs that are ran safely within your application and generated by reasoning engines on the Lusat AI platform.
To create a workflow, you need to include an App
object, which is used to understand the actions and other context of your application. You also need a natural language prompt, as either text or voice.
const workflow = await ai.workflows.create({
app: musicApp,
text: 'play dj crazy times'
})
In order to use voice input, you'll need a way to record audio, like the voice components and tools provided by lusat
.
const workflow = await ai.workflows.create({
app: musicApp,
audio: fs.createReadStream('audio.mp3')
})
You can use run
from lusat
core to run a workflow against your app
.
import { run } from 'lusat'
run(musicApp, workflow)
Translation is a simple API, but can be useful. It uses a mixture of language models and heuristics to translate between natural languages, programming languages, writing styles, data formats, and more.
const translation = await ai.translations.create({
text: 'const add = (a, b) => a + b',
pipeline: ['javascript', 'typescript']
})
Voice input is also supported for translations. Try out Rysana Translate to see them in action.
You can use the structured completion API to generate structured data from unstructured text. This is useful for things like extracting dates, times, locations, and other entities from natural language text.
Structured completions are parsed and validated against the provided schema upon return and are almost guaranteed to be valid (against the schema, but note that natural language sections like strings are still prone to the same errors as any other language model call).
const completion = await ai.completions.create({
text: 'meet me at 5pm at the park',
schema: z.object({
location: z.string(),
time: z.coerce.date()
})
})
completion.location // 'the park'
completion.time // 12/4/2023, 5:00:00 PM
Voice input is also supported for structured completions.
Now that you have an API client ready to go, it's time to start using it! The Lusat AI API gives you direct access to some very powerful intent translation and reasoning primitives, but it is easiest and optimized for use alongside all of the server-side and client-side tools the lusat
open source library provides for your applications.
See the Action
page for more information on how to use the lusat
library to build powerful natural language interfaces.
Join our newsletter to stay up to date on our progress!