Skip to content

[JS] Simplify syntax to call flows #391

@chrisraygill

Description

@chrisraygill

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

Metadata

Metadata

Assignees

Labels

featureNew feature or requestjs

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions