Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ Support

Release Notes
-------------
### Upcoming
- Changes
- Firebase AI: Add the AgentPlatform backend, and deprecate the VertexAI one,
to reflect the renaming of Vertex AI to Gemini Enterprise Agent Platform.
Note that the default location is different between the two.

### 13.14.0
- Changes
- General: Update to Firebase C++ SDK version 13.10.0.
Expand Down
1 change: 1 addition & 0 deletions firebaseai/src/Citation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ internal static CitationMetadata FromJson(Dictionary<string, object> jsonDict,
{
FirebaseAI.Backend.InternalProvider.GoogleAI => "citationSources",
FirebaseAI.Backend.InternalProvider.VertexAI => "citations",
FirebaseAI.Backend.InternalProvider.AgentPlatform => "citations",
_ => throw new ArgumentOutOfRangeException(nameof(backend), backend,
"Unsupported or unhandled backend provider encountered.")
};
Expand Down
29 changes: 24 additions & 5 deletions firebaseai/src/FirebaseAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public readonly struct Backend
internal enum InternalProvider
{
GoogleAI,
VertexAI
VertexAI,
AgentPlatform,
Comment thread
a-maurice marked this conversation as resolved.
}

/// <summary>
Expand All @@ -47,7 +48,7 @@ internal enum InternalProvider
internal InternalProvider Provider { get; }
/// <summary>
/// Intended for internal use only.
/// The region identifier used by the Vertex AI backend.
/// The region identifier used by the Vertex AI and Gemini Enterprise Agent Platform backends.
/// </summary>
internal string Location { get; }

Expand All @@ -68,9 +69,12 @@ public static Backend GoogleAI()
/// <summary>
/// The Vertex AI backend service configuration.
/// </summary>
/// <param name="location">The region identifier, defaulting to `us-central1`; see [Vertex AI
/// regions](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/locations#available-regions)
/// for a list of supported regions.</param>
/// <param name="location">The region identifier, defaulting to `us-central1`</param>
/// <remarks>
/// Deprecated: Use AgentPlatform instead. Note that the default location changes to 'global'.
/// </remarks>
/// @deprecated Use AgentPlatform instead. Note that the default location changes to 'global'.
[Obsolete("Use AgentPlatform instead. Note that the default location changes to 'global'.")]
public static Backend VertexAI(string location = "us-central1")
{
if (string.IsNullOrWhiteSpace(location) || location.Contains("/"))
Expand All @@ -82,6 +86,21 @@ public static Backend VertexAI(string location = "us-central1")
return new Backend(InternalProvider.VertexAI, location);
}

/// <summary>
/// The Gemini Enterprise Agent Platform backend service configuration.
/// </summary>
/// <param name="location">The region identifier, defaulting to `global`</param>
public static Backend AgentPlatform(string location = "global")
{
if (string.IsNullOrWhiteSpace(location) || location.Contains("/"))
{
throw new ArgumentException(
$"The location argument must be non-empty, and not contain special characters like '/'");
}

return new Backend(InternalProvider.AgentPlatform, location);
}

public override readonly string ToString()
{
return $"FirebaseAIBackend|{Provider}|{Location}";
Expand Down
1 change: 1 addition & 0 deletions firebaseai/src/GenerativeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ private string MakeCountTokensRequest(IEnumerable<ModelContent> contents)
$"models/{_modelName}";
break;
case FirebaseAI.Backend.InternalProvider.VertexAI:
case FirebaseAI.Backend.InternalProvider.AgentPlatform:
jsonDict = new()
{
// Convert the Contents into a list of Json dictionaries
Expand Down
6 changes: 4 additions & 2 deletions firebaseai/src/Internal/HttpHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ internal static class HttpHelpers
internal static string GetURL(FirebaseApp firebaseApp,
FirebaseAI.Backend backend, string modelName)
{
if (backend.Provider == FirebaseAI.Backend.InternalProvider.VertexAI)
if (backend.Provider == FirebaseAI.Backend.InternalProvider.VertexAI ||
backend.Provider == FirebaseAI.Backend.InternalProvider.AgentPlatform)
{
return "https://firebasevertexai.googleapis.com/v1beta" +
"/projects/" + firebaseApp.Options.ProjectId +
Expand All @@ -54,7 +55,8 @@ internal static string GetTemplateURL(FirebaseApp firebaseApp,
{
var projectUrl = "https://firebasevertexai.googleapis.com/v1beta" +
$"/projects/{firebaseApp.Options.ProjectId}";
if (backend.Provider == FirebaseAI.Backend.InternalProvider.VertexAI)
if (backend.Provider == FirebaseAI.Backend.InternalProvider.VertexAI ||
backend.Provider == FirebaseAI.Backend.InternalProvider.AgentPlatform)
{
return $"{projectUrl}/locations/{backend.Location}/templates/{templateId}";
}
Expand Down
6 changes: 4 additions & 2 deletions firebaseai/src/LiveGenerativeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ internal LiveGenerativeModel(FirebaseApp firebaseApp,

private string GetURL()
{
if (_backend.Provider == FirebaseAI.Backend.InternalProvider.VertexAI)
if (_backend.Provider == FirebaseAI.Backend.InternalProvider.VertexAI ||
_backend.Provider == FirebaseAI.Backend.InternalProvider.AgentPlatform)
{
return "wss://firebasevertexai.googleapis.com/ws" +
"/google.firebase.vertexai.v1beta.LlmBidiService/BidiGenerateContent" +
Expand All @@ -97,7 +98,8 @@ private string GetURL()

private string GetModelName()
{
if (_backend.Provider == FirebaseAI.Backend.InternalProvider.VertexAI)
if (_backend.Provider == FirebaseAI.Backend.InternalProvider.VertexAI ||
_backend.Provider == FirebaseAI.Backend.InternalProvider.AgentPlatform)
{
return $"projects/{_firebaseApp.Options.ProjectId}/locations/{_backend.Location}" +
$"/publishers/google/models/{_modelName}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class UIHandler : MonoBehaviour {

private string appCheckDebugToken = "REPLACE_WITH_APP_CHECK_TOKEN";

protected void InitializeAppCheck() {
protected virtual void InitializeAppCheck() {
DebugLog("Initializing App Check directly in manual UIHandler");
DebugAppCheckProviderFactory.Instance.SetDebugToken(appCheckDebugToken);
FirebaseAppCheck.SetAppCheckProviderFactory(DebugAppCheckProviderFactory.Instance);
Expand Down Expand Up @@ -76,11 +76,11 @@ protected void InitializeFirebase() {
public string ModelName = "gemini-3.1-flash-lite";

private int backendSelection = 0;
private string[] backendChoices = new string[] { "Google AI Backend", "Vertex AI Backend" };
private string[] backendChoices = new string[] { "Google AI Backend", "Agent Platform Backend" };
private GenerativeModel GetModel() {
var backend = backendSelection == 0
? FirebaseAI.Backend.GoogleAI()
: FirebaseAI.Backend.VertexAI();
: FirebaseAI.Backend.AgentPlatform();

return FirebaseAI.GetInstance(backend, useLimitedUseAppCheckTokens: true).GetGenerativeModel(ModelName);
}
Expand Down
Loading