Repository navigation
feat: Google live audio output - #4280
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
There is another interesting aspect to think about. I see in your OpenAI audio example that the transcript is moved in the text field which allows to run llm rubric on it. Transcript is for me in context.providerResponse.audio.transcript. a) Transcript could be copied over to text. Which makes sense |
|
Good points @adelmuursepp!. We should use the model graded metrics just like how the openai models work. Re thinking processes - how about putting them in metadata instead (feel free to disagree). Thank you so much! |
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
This comment was marked as duplicate.
This comment was marked as duplicate.
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (10)
examples/google-live-audio/promptfooconfig.yaml (1)
30-36: 🧹 Nitpick (assertive)Consider using optional chaining for cleaner code.
The null checks can be simplified using the optional chaining operator (
?.) as suggested in past reviews. While verbose examples are educational, modern JavaScript syntax would also be a good learning example.- if (context.providerResponse && context.providerResponse.audio && context.providerResponse.audio.transcript) { - return context.providerResponse.audio && - context.providerResponse.audio.data && - context.providerResponse.audio.transcript && - context.providerResponse.audio.transcript.length > 0; - } + return context.providerResponse?.audio?.transcript?.length > 0 && + context.providerResponse?.audio?.data;examples/google-live-audio/promptfooconfig.audio-affective.yaml (1)
7-14: 🧹 Nitpick (assertive)Consider using variables for prompts to improve reusability.
As suggested in past reviews, using variables instead of hardcoded prompts would make the configuration more flexible and demonstrate better practices.
prompts: - - label: 'Positive input' - raw: It's a new dawn, it's a new day, and I'm feeling good. - - - label: 'Negative Input' - raw: | - I looked in the fridge and I found nothing. - I think someone ate my sandwich + - label: 'Positive input' + raw: '{{positive_statement}}' + - label: 'Negative Input' + raw: '{{negative_statement}}'Then add test cases with the variables defined:
tests: - vars: positive_statement: "It's a new dawn, it's a new day, and I'm feeling good." negative_statement: | I looked in the fridge and I found nothing. I think someone ate my sandwich assert: # existing assertionsexamples/google-live-audio/promptfooconfig.audio-voices.yaml (1)
7-8: 🧹 Nitpick (assertive)Consider using a variable for the prompt to improve flexibility.
As suggested in past reviews, using a variable instead of a hardcoded prompt would make the configuration more flexible and reusable.
prompts: - - 'Why was Gemini model by Google named Gemini?' + - '{{question}}'Then define the variable in test cases:
tests: - vars: question: 'Why was Gemini model by Google named Gemini?' assert: # existing assertionsexamples/google-live-audio/README.md (3)
16-22: 🛠️ Refactor suggestionAdd the standard initialization command.
As discussed in past reviews, the standard
npx promptfoo@latest init --example google-live-audiocommand should be added now that it will work after merging to main.## Running the Examples +First, initialize the example: + +```bash +npx promptfoo@latest init --example google-live-audio +``` + After running any evaluation, you can view the results by running:
73-73:⚠️ Potential issueFix the relative link to use absolute URL.
The relative link may not resolve correctly as noted in past reviews. Use an absolute URL to the documentation.
-For more information about the Google Live API and audio capabilities, see the [Google AI documentation](/docs/providers/google). +For more information about the Google Live API and audio capabilities, see the [Google AI documentation](https://promptfoo.dev/docs/providers/google).
12-12: 🧹 Nitpick (assertive)Clarify environment variable specification.
As suggested in past reviews, specify 'environment variable' for clarity.
-- Google AI Studio API key set as the environment variable `GOOGLE_API_KEY` +- Google AI Studio API key set as the environment variable `GOOGLE_API_KEY`src/providers/google/live.ts (4)
57-86: Manual WAV header creation remains fragile.The manual construction of WAV headers could lead to subtle bugs. Consider using a dedicated audio library for more robust WAV encoding.
134-136: Fixed startup delay for Python API remains fragile.Using a fixed 1-second delay could cause race conditions or unnecessary waiting. Implement a health check endpoint as previously suggested.
485-487: Warning suggests incomplete implementation.The warning message indicates that HTTP client functionality was removed but the configuration option remains.
600-613: Promise may remain unresolved on unexpected close.The close handler should resolve or reject the promise if finalizeResponse hasn't executed to prevent hanging promises.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (7)
examples/google-live-audio/README.md(1 hunks)examples/google-live-audio/promptfooconfig.audio-affective.yaml(1 hunks)examples/google-live-audio/promptfooconfig.audio-voices.yaml(1 hunks)examples/google-live-audio/promptfooconfig.yaml(1 hunks)src/providers/google/live.ts(5 hunks)src/providers/google/types.ts(2 hunks)test/providers/google/live.test.ts(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
test/providers/google/live.test.ts (1)
src/providers/google/live.ts (1)
GoogleLiveProvider(40-616)
src/providers/google/live.ts (4)
src/logger.ts (1)
logger(191-203)examples/google-live/promptfooconfig.callback.js (1)
JSON(33-33)src/providers/google/types.ts (1)
FunctionCall(8-11)src/providers/google/util.ts (1)
loadFile(370-397)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Test on Node 18.x and windows-latest
🔇 Additional comments (4)
src/providers/google/types.ts (2)
135-155: LGTM! Comprehensive audio configuration types added.The new type definitions for speech configuration, transcription, affective dialog, and proactive audio features are well-structured and comprehensive. They properly support the new Google Live Audio API capabilities demonstrated in the example configurations.
99-99: Good clarification on apiVersion values.The updated comment clearly specifies the accepted values and default, which helps developers understand the API versioning for Live API features.
test/providers/google/live.test.ts (2)
620-620: Good addition to verify the final state retrieval endpoint.This assertion ensures that the last GET request is made to the correct endpoint for retrieving the final state of the stateful API, which aligns with the implementation in
src/providers/google/live.tslines 195-196.
859-1047: Well-structured and comprehensive test suite for audio configurations.The tests thoroughly cover all audio-related configuration options including proactivity, affective dialog, and transcription settings. The test cases properly verify:
- Correct transformation of configuration property names (camelCase to snake_case)
- Proper placement of configurations (generation_config vs setup level)
- Behavior when configurations are present vs absent
- All configurations working together
I like how Bedrock shows extra fields in the metadata, it is cleaner. But the other providers generally show fields like function and tool calls in the output directly. I think it is better to be consistent in showing extra fields. I am not going to change how other Live provider examples work, so I would rather place it in the output for now. And refactor all into text and metadata in Live provider later. For quick reference, metadata: @mldangelo you will know how to be consistent and organize thinking better in the other providers too going forward probably? |
| @@ -0,0 +1,2 @@ | |||
| - role: user | |||
There was a problem hiding this comment.
nit, for a simple prompt, consider defining it inline in examples/google-live-audio/promptfooconfig.yaml instead of a different file


Overview
Implemented audio output support for Google's Live API, enabling audio generation, transcription, and advanced features like affective dialog and voice customization. Yet to cover coercing the model to speak in specific language, turn coverage, proactive audio and features involving audio as input.
Key Features Added
Audio Output Support in Google Live Provider
New Audio Examples (
examples/google-live-audio/)Created three examples demonstrating audio capabilities:
a) Simple Audio Generation (
promptfooconfig.yaml)b) Affective Dialog (
promptfooconfig.audio-affective.yaml)c) Voice Customization (
promptfooconfig.audio-voices.yaml)UI Enhancements for Audio Display
EvalOutputCell.tsxto properly display audio outputs. Added download audio button (decided not to generate files in the folder)Testing
test/providers/google/live.test.tsAmazon Bedrock Nova speech to speech:

OpenAI audio:
