A free and opensource (MIT) client to compose and invoke fully typed Generative AI pipelines.
Check out the documentation at https://client.aigur.dev
This simple pipeline accepts a subject
and returns a joke
about that subject.
import {
createClient,
replaceString,
gpt3Prediction
} from '@aigur/client';
export const aigur = createClient({
apiKeys: {
openai: process.env.OPENAI_KEY!,
},
});
export const jokeGptPipeline = aigur.pipeline
.create<{ subject: string }, { joke: string }>({
id: 'jokegpt',
flow: (flow) =>
flow
.node(replaceString, ({ input }) => ({
text: input.subject,
modifier: 'tell me a joke about $(text)$',
}))
.node(gpt3Prediction, ({ prev }) => ({
prompt: prev.text,
}))
.output(({ prev }) => ({
joke: prev.text,
})
});
const { joke } = await jokeGptPipeline.invoke({
subject: 'a car'
});
Check out this next example in the docs site.