-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce transcript newlines for function calls/responses (#499)
The TTS buffer only gets flushed when it sees content after a sentence. To ensure that it gets flushed after any pre-function-call filler text, this change: - Adds the `batchFrames` render option to ai-jsx to coalesce updates from different parts of the render tree. (This delays surfacing frames until further rendering is blocked on I/O.) - Adds message-level state tracking (`"in-progress" | "done"`) in `fixie-sdk` to text messages - Changes the fixie backend in the voice demo to emit newlines after `"done"` text messages - Stops appending text after `"in-progress"` text messages --------- Co-authored-by: Justin Uberti <justin@fixie.ai>
- Loading branch information
1 parent
574f2f8
commit 83627e8
Showing
10 changed files
with
120 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import * as AI from 'ai-jsx'; | ||
|
||
it('ensures that synchronous updates are not batched when batchFrames is false', async () => { | ||
async function* MyComponent() { | ||
yield '1'; | ||
yield '2'; | ||
return '3'; | ||
} | ||
|
||
const ctx = AI.createRenderContext(); | ||
const renderResult = ctx.render(<MyComponent />, { batchFrames: false }); | ||
const frames: string[] = []; | ||
for await (const frame of renderResult) { | ||
frames.push(frame); | ||
} | ||
expect(frames).toEqual(['1', '2']); | ||
expect(await renderResult).toBe('3'); | ||
}); | ||
|
||
it('ensures that synchronous updates are batched when batchFrames is true', async () => { | ||
async function* MyComponent() { | ||
yield '1'; | ||
yield '2'; | ||
return '3'; | ||
} | ||
|
||
const ctx = AI.createRenderContext(); | ||
const renderResult = ctx.render(<MyComponent />, { batchFrames: true }); | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
for await (const _ of renderResult) { | ||
throw new Error('Render updates should be batched'); | ||
} | ||
expect(await renderResult).toBe('3'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83627e8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
ai-jsx-voice – ./packages/voice
ai-jsx-voice-fixie-ai.vercel.app
voice.fixie.ai
ai-jsx-voice.vercel.app
ai-jsx-voice-git-main-fixie-ai.vercel.app
83627e8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
ai-jsx-docs – ./packages/docs
ai-jsx-docs.vercel.app
ai-jsx-docs-git-main-fixie-ai.vercel.app
ai-jsx-docs-fixie-ai.vercel.app
docs.ai-jsx.com
83627e8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
ai-jsx-nextjs-demo – ./packages/nextjs-demo
ai-jsx-nextjs-demo.vercel.app
ai-jsx-nextjs-demo-git-main-fixie-ai.vercel.app
ai-jsx-nextjs-demo-fixie-ai.vercel.app
83627e8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
ai-jsx-tutorial-nextjs – ./packages/tutorial-nextjs
ai-jsx-tutorial-nextjs.vercel.app
ai-jsx-tutorial-nextjs-git-main-fixie-ai.vercel.app
ai-jsx-tutorial-nextjs-fixie-ai.vercel.app