genkit icon indicating copy to clipboard operation
genkit copied to clipboard

[JS] Simplify syntax to call flows

Open chrisraygill opened this issue 1 year ago • 0 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

chrisraygill avatar Jun 12 '24 02:06 chrisraygill