Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(js/flows): consolidated defineFlow and defineStreamingFlow #1401

Merged
merged 6 commits into from
Dec 4, 2024

Conversation

pavelgj
Copy link
Collaborator

@pavelgj pavelgj commented Nov 26, 2024

Deprecated defineStreamingFlow (not removed, still works). Streaming and non-streaming flows can be defined using defineFlow

    const streamingBananaFlow = ai.defineFlow(
      {
        name: 'banana',
        streamSchema: z.string(),
      },
      (input, sendChunk) => {
        for (let i = 0; i < input.length; i++) {
          sendChunk(input.charAt(i));
        }
        return input;
      }
    );

Also made it so that streaming callback (see sendChunk in the example above) is always defined. If flow is invoked in non-streaming mode a no-op callback is passed in.

Checklist (if applicable):

  • Tested (manually, unit tested, etc.)

@pavelgj pavelgj requested review from apascal07 and mbleigh November 26, 2024 00:34
@pavelgj pavelgj changed the title feat(flows) consolidated defineFlow and defineStreamingFlow feat(flows): consolidated defineFlow and defineStreamingFlow Nov 26, 2024
@pavelgj pavelgj changed the title feat(flows): consolidated defineFlow and defineStreamingFlow feat(js/flows): consolidated defineFlow and defineStreamingFlow Nov 26, 2024
@pavelgj pavelgj merged commit f69dac3 into main Dec 4, 2024
4 checks passed
@pavelgj pavelgj deleted the pj/consolidateDefineFlow branch December 4, 2024 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants