firebase / genkit

An open source framework for building AI-powered apps with familiar code-centric patterns. Genkit makes it easy to integrate, test, and deploy sophisticated AI features to Firebase or Google Cloud.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[JS] Simplify syntax to call flows

chrisraygill opened this issue · comments

Is your feature request related to a problem? Please describe.

Current syntax to call flows does not feel ergonomic const response = await runFlow(menuSuggestionFlow, "French");. Flows are just special functions, so I want them to be able to call them more like regular functions.

Describe the solution you'd like

const myFlow = defineFlow() -> await myFlow()
const myFlow = defineStreamingFlow() -> const {stream, result} = await myFlow()

Being able to call flows like normal functions is a huge ergonomic win - it's qualitatively different than the alternatives because you get all the observability benefits but you use it like you just defined a normal function.

Describe alternatives you've considered

Some alternative ideas

Alternate 1

myFlow.run(...)
myFlow.stream(...)

Alternate 2

myFlow(...)
myFlow.stream(...)

Alternate 3

myFlow().run()
myFlow().runWithStreaming()

Additional context

N/A