Skip to content

Conversation

cynthiajoan
Copy link
Collaborator

Description

Replace this paragraph with a description of what this PR is doing. If you're modifying existing behavior, describe the existing behavior, how this PR is changing it, and what motivated the change.

Related Issues

Replace this paragraph with a list of issues related to this PR from the issue database. Indicate, which of these issues are resolved or fixed by this PR. Note that you'll have to prefix the issue numbers with flutter/flutter#.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (melos run analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

@cynthiajoan
Copy link
Collaborator Author

/gemini summary

Copy link

Summary of Changes

This pull request introduces a significant refactoring of the Firebase AI package's bidirectional input API. The core objective is to enhance the clarity and maintainability of real-time data transmission by replacing generic media chunk handling with distinct, type-specific methods for audio, video, and text. This change streamlines how developers interact with the AI service for different input modalities, making the API more intuitive and less prone to errors. The accompanying example application has been updated to demonstrate the correct usage of these new API patterns.

Highlights

  • API Refactoring for Bidi Input: The bidirectional (Bidi) input API has been refactored to provide more specific methods for sending audio, video, and text data, moving away from a generic 'media chunks' approach.
  • New Dedicated Send Methods: The LiveSession class now includes dedicated sendAudio, sendVideo, and sendText methods, improving clarity and type safety for real-time input.
  • Deprecated Generic Methods: The previous sendMediaChunks and sendMediaStream methods have been deprecated in favor of the new, more granular send functions.
  • Updated LiveClientRealtimeInput: The LiveClientRealtimeInput class has been updated with new fields (audio, video, text) and named constructors to support the new API, with the mediaChunks field now deprecated.
  • Example Application Updates: The bidi_page.dart example has been updated to utilize the new sendText and sendAudio methods and includes a more robust image display logic.
Changelog
  • packages/firebase_ai/firebase_ai/example/lib/pages/bidi_page.dart
    • Changed ResponseModalities.audio to ResponseModalities.text in LiveGenerationConfig.
    • Implemented a null check for _messages[idx].imageBytes before displaying images to prevent potential runtime errors.
    • Refactored the audio stream sending logic to use the new _session.sendAudio method within a for await loop.
    • Updated text prompt submission to use the new _session.sendText(textPrompt) method.
  • packages/firebase_ai/firebase_ai/lib/src/live_api.dart
    • Added new named constructors: LiveClientRealtimeInput.audio, LiveClientRealtimeInput.video, and LiveClientRealtimeInput.text.
    • Introduced audio, video, and text fields to LiveClientRealtimeInput for direct media type handling.
    • Deprecated the mediaChunks field and its corresponding toJson() logic, encouraging the use of the new specific fields.
  • packages/firebase_ai/firebase_ai/lib/src/live_session.dart
    • Added new public methods: sendAudio(InlineDataPart audio), sendVideo(InlineDataPart video), and sendText(String text).
    • Deprecated the sendMediaChunks and sendMediaStream methods, guiding users towards the new, more specific API functions.
Activity
  • The author cynthiajoan requested a summary of the pull request using the /gemini summary command.

@cynthiajoan cynthiajoan marked this pull request as ready for review October 1, 2025 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant