Add Firebase AI Logic to the shared model client API - #86
Merged
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Firebase AI Logic can now join every
ModelClientconsumerApplications that already use Firebase can now adapt a caller-constructed Firebase AI Logic
GenerativeModelinto the shared@inbrowser/modelcontract:The returned client streams the same
text,thinking,tool_call,usage, anderrorevents as the other providers. Existing agent and model-call code can consume Firebase AI Logic without learning a second provider-specific event vocabulary.The optional
idgives the client a stable metrics and provenance name. An optional construction-timetemperaturesupplies a default, while a temperature on an individualModelRequesttakes precedence.A configured Firebase model becomes a streaming client in one step
The host initializes Firebase, selects the Google AI or Vertex AI backend, configures App Check, and constructs the model. The new adapter starts at that model boundary:
The package does not depend on Firebase itself. It accepts the narrow structural surface used from
GenerativeModel, so applications keep control of their Firebase version, app lifecycle, authentication, backend, and location.Gemini tool calls keep the existing conversation loop
ToolSpecdeclarations are translated into Firebase function declarations. Streamed calls are assembled into onetool_callevent with their ids, arguments, and Gemini thought signatures intact.After the application executes a tool, it appends the assistant call and a
role: "tool"result to the message history, then callsclient.chat()again. The adapter translates that full history back into Firebasemodelandfunctioncontent, including the thought signature Gemini needs to continue tool-assisted reasoning.Sampling and reasoning settings also stay in the shared request shape: temperature, top-p, top-k, and
ReasoningEffortare mapped to the matching Gemini generation and thinking configuration.The provider stays focused on the common Gemini path
This API covers streamed Gemini text, thinking, caller-executed custom functions, usage accounting, cancellation, and Firebase error normalization. Live API sessions, Imagen, server prompt templates, built-in or automatically executed tools, and multimodal lifecycle APIs remain outside this adapter because they require contracts beyond the current text-and-tool-oriented
ModelClient.The Firebase-specific reference documents the model seam, request mapping, event behavior, and deliberate boundaries alongside the other provider APIs.