From 77f27e0cc48af808fb045c0efc75be5a097f7fd5 Mon Sep 17 00:00:00 2001 From: a-maurice Date: Fri, 9 May 2025 15:53:31 -0700 Subject: [PATCH 1/3] [FirebaseAI] Fix minor issues with reference docs --- firebaseai/CMakeLists.txt | 1 + firebaseai/src/Candidate.cs | 7 ++++-- firebaseai/src/Chat.cs | 6 ++++- firebaseai/src/Citation.cs | 7 ++++-- firebaseai/src/CountTokensResponse.cs | 7 ++++-- firebaseai/src/FirebaseAI.cs | 6 ++++- firebaseai/src/GenerateContentResponse.cs | 28 ++++++++++++++++------- firebaseai/src/LiveSessionResponse.cs | 14 ++++++++---- firebaseai/src/ModelContent.cs | 12 ++++++++-- firebaseai/src/Schema.cs | 8 +++---- 10 files changed, 70 insertions(+), 26 deletions(-) diff --git a/firebaseai/CMakeLists.txt b/firebaseai/CMakeLists.txt index 6a9ea769..21341be2 100644 --- a/firebaseai/CMakeLists.txt +++ b/firebaseai/CMakeLists.txt @@ -26,6 +26,7 @@ unity_pack_folder( # For documentation, get only the C# files at the top level, # which make up the public API. file(GLOB firebase_firebaseai_doc_src "src/*.cs") +list(FILTER firebase_firebaseai_doc_src EXCLUDE REGEX "src/Internal/.*") unity_pack_documentation_sources(firebaseai DOCUMENTATION_SOURCES ${firebase_firebaseai_doc_src} diff --git a/firebaseai/src/Candidate.cs b/firebaseai/src/Candidate.cs index 44ae4986..b607c864 100644 --- a/firebaseai/src/Candidate.cs +++ b/firebaseai/src/Candidate.cs @@ -83,8 +83,11 @@ public readonly struct Candidate { /// /// The safety rating of the response content. /// - public IEnumerable SafetyRatings => - _safetyRatings ?? new ReadOnlyCollection(new List()); + public IEnumerable SafetyRatings { + get { + return _safetyRatings ?? new ReadOnlyCollection(new List()); + } + } /// /// The reason the model stopped generating content, if it exists; diff --git a/firebaseai/src/Chat.cs b/firebaseai/src/Chat.cs index fed264cc..241da1f2 100644 --- a/firebaseai/src/Chat.cs +++ b/firebaseai/src/Chat.cs @@ -36,7 +36,11 @@ public class Chat { /// The previous content from the chat that has been successfully sent and received from the /// model. This will be provided to the model for each message sent as context for the discussion. /// - public IEnumerable History => new ReadOnlyCollection(chatHistory); + public IEnumerable History { + get { + return new ReadOnlyCollection(chatHistory); + } + } // Note: No public constructor, get one through GenerativeModel.StartChat private Chat(GenerativeModel model, IEnumerable initialHistory) { diff --git a/firebaseai/src/Citation.cs b/firebaseai/src/Citation.cs index 01ee3ff2..907104c0 100644 --- a/firebaseai/src/Citation.cs +++ b/firebaseai/src/Citation.cs @@ -30,8 +30,11 @@ public readonly struct CitationMetadata { /// /// A list of individual cited sources and the parts of the content to which they apply. /// - public IEnumerable Citations => - _citations ?? new ReadOnlyCollection(new List()); + public IEnumerable Citations { + get { + return _citations ?? new ReadOnlyCollection(new List()); + } + } // Hidden constructor, users don't need to make this. private CitationMetadata(List citations) { diff --git a/firebaseai/src/CountTokensResponse.cs b/firebaseai/src/CountTokensResponse.cs index 516633fa..f00a23ee 100644 --- a/firebaseai/src/CountTokensResponse.cs +++ b/firebaseai/src/CountTokensResponse.cs @@ -41,8 +41,11 @@ public readonly struct CountTokensResponse { /// /// The breakdown, by modality, of how many tokens are consumed by the prompt. /// - public IEnumerable PromptTokensDetails => - _promptTokensDetails ?? new ReadOnlyCollection(new List()); + public IEnumerable PromptTokensDetails { + get { + return _promptTokensDetails ?? new ReadOnlyCollection(new List()); + } + } // Hidden constructor, users don't need to make this private CountTokensResponse(int totalTokens, diff --git a/firebaseai/src/FirebaseAI.cs b/firebaseai/src/FirebaseAI.cs index c0d48b72..eb5c6986 100644 --- a/firebaseai/src/FirebaseAI.cs +++ b/firebaseai/src/FirebaseAI.cs @@ -93,7 +93,11 @@ private FirebaseAI(FirebaseApp firebaseApp, Backend backend) { /// /// Returns a `FirebaseAI` instance with the default `FirebaseApp` and GoogleAI Backend. /// - public static FirebaseAI DefaultInstance => GetInstance(); + public static FirebaseAI DefaultInstance { + get { + return GetInstance(); + } + } /// /// Returns a `FirebaseAI` instance with the default `FirebaseApp` and the given Backend. diff --git a/firebaseai/src/GenerateContentResponse.cs b/firebaseai/src/GenerateContentResponse.cs index 2056f367..17ac497c 100644 --- a/firebaseai/src/GenerateContentResponse.cs +++ b/firebaseai/src/GenerateContentResponse.cs @@ -31,8 +31,11 @@ public readonly struct GenerateContentResponse { /// /// A list of candidate response content, ordered from best to worst. /// - public IEnumerable Candidates => - _candidates ?? new ReadOnlyCollection(new List()); + public IEnumerable Candidates { + get { + return _candidates ?? new ReadOnlyCollection(new List()); + } + } /// /// A value containing the safety ratings for the response, or, @@ -141,8 +144,11 @@ public readonly struct PromptFeedback { /// /// The safety ratings of the prompt. /// - public IEnumerable SafetyRatings => - _safetyRatings ?? new ReadOnlyCollection(new List()); + public IEnumerable SafetyRatings { + get { + return _safetyRatings ?? new ReadOnlyCollection(new List()); + } + } // Hidden constructor, users don't need to make this. private PromptFeedback(BlockReason? blockReason, string blockReasonMessage, @@ -192,12 +198,18 @@ public readonly struct UsageMetadata { public int TotalTokenCount { get; } private readonly ReadOnlyCollection _promptTokensDetails; - public IEnumerable PromptTokensDetails => - _promptTokensDetails ?? new ReadOnlyCollection(new List()); + public IEnumerable PromptTokensDetails { + get { + return _promptTokensDetails ?? new ReadOnlyCollection(new List()); + } + } private readonly ReadOnlyCollection _candidatesTokensDetails; - public IEnumerable CandidatesTokensDetails => - _candidatesTokensDetails ?? new ReadOnlyCollection(new List()); + public IEnumerable CandidatesTokensDetails { + get { + return _candidatesTokensDetails ?? new ReadOnlyCollection(new List()); + } + } // Hidden constructor, users don't need to make this. private UsageMetadata(int promptTC, int candidatesTC, int totalTC, diff --git a/firebaseai/src/LiveSessionResponse.cs b/firebaseai/src/LiveSessionResponse.cs index 80f01a7f..24ce1fdc 100644 --- a/firebaseai/src/LiveSessionResponse.cs +++ b/firebaseai/src/LiveSessionResponse.cs @@ -183,9 +183,12 @@ internal static LiveSessionContent FromJson(Dictionary jsonDict) /// /// This will be empty if no function calls are present. /// - public IEnumerable FunctionCalls => - _functionCalls ?? new ReadOnlyCollection( + public IEnumerable FunctionCalls { + get { + return _functionCalls ?? new ReadOnlyCollection( new List()); + } + } private LiveSessionToolCall(List functionCalls) { _functionCalls = new ReadOnlyCollection( @@ -211,8 +214,11 @@ internal static LiveSessionToolCall FromJson(Dictionary jsonDict /// /// The list of Function IDs to cancel. /// - public IEnumerable FunctionIds => - _functionIds ?? new ReadOnlyCollection(new List()); + public IEnumerable FunctionIds { + get { + return _functionIds ?? new ReadOnlyCollection(new List()); + } + } private LiveSessionToolCallCancellation(List functionIds) { _functionIds = new ReadOnlyCollection( diff --git a/firebaseai/src/ModelContent.cs b/firebaseai/src/ModelContent.cs index 90f1d1b4..cd462c47 100644 --- a/firebaseai/src/ModelContent.cs +++ b/firebaseai/src/ModelContent.cs @@ -35,12 +35,20 @@ public readonly struct ModelContent { /// The role of the entity creating the `ModelContent`. For user-generated client requests, /// for example, the role is `user`. /// - public string Role => string.IsNullOrWhiteSpace(_role) ? "user" : _role; + public string Role { + get { + return string.IsNullOrWhiteSpace(_role) ? "user" : _role; + } + } /// /// The data parts comprising this `ModelContent` value. /// - public IEnumerable Parts => _parts ?? new ReadOnlyCollection(new List()); + public IEnumerable Parts { + get { + return _parts ?? new ReadOnlyCollection(new List()); + } + } /// /// Creates a `ModelContent` with the given `Part`s, using the default `user` role. diff --git a/firebaseai/src/Schema.cs b/firebaseai/src/Schema.cs index 48c3ce75..7b5ab501 100644 --- a/firebaseai/src/Schema.cs +++ b/firebaseai/src/Schema.cs @@ -100,7 +100,7 @@ public static StringFormat Custom(string format) { /// /// Possible values of the element of type "String" with "enum" format. /// - public IEnumerable EnumValues => _enumValues; + public IEnumerable EnumValues { get { return _enumValues; } } /// /// Schema of the elements of type "Array". /// @@ -132,7 +132,7 @@ public static StringFormat Custom(string format) { /// /// Required properties of type "Object". /// - public IEnumerable RequiredProperties => _requiredProperties; + public IEnumerable RequiredProperties { get { return _requiredProperties; } } private readonly ReadOnlyCollection _propertyOrdering; /// @@ -143,7 +143,7 @@ public static StringFormat Custom(string format) { /// not preserve this order. This parameter primarily affects the raw JSON string /// serialization. /// - public IEnumerable PropertyOrdering => _propertyOrdering; + public IEnumerable PropertyOrdering { get { return _propertyOrdering; } } private readonly ReadOnlyCollection _anyOf; /// @@ -156,7 +156,7 @@ public static StringFormat Custom(string format) { /// Schema.AnyOf(new [] { Schema.String(), Schema.Int() }) /// ``` /// - public IEnumerable AnyOfSchemas => _anyOf; + public IEnumerable AnyOfSchemas { get { return _anyOf; } } private Schema( SchemaType? type, From 04cf460885f51850cfafb7e70f4bdce242dff73b Mon Sep 17 00:00:00 2001 From: a-maurice Date: Fri, 9 May 2025 17:50:04 -0700 Subject: [PATCH 2/3] Update ResponseModality.cs --- firebaseai/src/ResponseModality.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/firebaseai/src/ResponseModality.cs b/firebaseai/src/ResponseModality.cs index 89de0a9b..65f4eccb 100644 --- a/firebaseai/src/ResponseModality.cs +++ b/firebaseai/src/ResponseModality.cs @@ -20,8 +20,32 @@ namespace Firebase.AI { /// The response type the model should return with. /// public enum ResponseModality { + /// + /// Specifies that the model should generate textual content. + /// + /// Use this modality when you need the model to produce written language, such as answers to + /// questions, summaries, creative writing, code snippets, or structured data formats like JSON. + /// Text, + /// + /// **Public Experimental**: Specifies that the model should generate image data. + /// + /// Use this modality when you want the model to create visual content based on the provided input + /// or prompts. The response might contain one or more generated images. See the [image + /// generation](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal-response-generation#image-generation) + /// documentation for more details. + /// + /// > Warning: Image generation using Gemini 2.0 Flash is a **Public Experimental** feature, which + /// > means that it is not subject to any SLA or deprecation policy and could change in + /// > backwards-incompatible ways. + /// Image, + /// + /// **Public Experimental**: Specifies that the model should generate audio data. + /// + /// Use this modality with a `LiveGenerationConfig` to create audio content based on the + /// provided input or prompts with a `LiveGenerativeModel`. + /// Audio, } From d763ee321e1542416e1962322023fad913cc60d1 Mon Sep 17 00:00:00 2001 From: a-maurice Date: Fri, 9 May 2025 17:53:33 -0700 Subject: [PATCH 3/3] Update CMakeLists.txt --- firebaseai/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/firebaseai/CMakeLists.txt b/firebaseai/CMakeLists.txt index 21341be2..6a9ea769 100644 --- a/firebaseai/CMakeLists.txt +++ b/firebaseai/CMakeLists.txt @@ -26,7 +26,6 @@ unity_pack_folder( # For documentation, get only the C# files at the top level, # which make up the public API. file(GLOB firebase_firebaseai_doc_src "src/*.cs") -list(FILTER firebase_firebaseai_doc_src EXCLUDE REGEX "src/Internal/.*") unity_pack_documentation_sources(firebaseai DOCUMENTATION_SOURCES ${firebase_firebaseai_doc_src}