Skip to content

[FirebaseAI] Fix minor issues with reference docs #1251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 12, 2025
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
7 changes: 5 additions & 2 deletions firebaseai/src/Candidate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,11 @@ public readonly struct Candidate {
/// <summary>
/// The safety rating of the response content.
/// </summary>
public IEnumerable<SafetyRating> SafetyRatings =>
_safetyRatings ?? new ReadOnlyCollection<SafetyRating>(new List<SafetyRating>());
public IEnumerable<SafetyRating> SafetyRatings {
get {
return _safetyRatings ?? new ReadOnlyCollection<SafetyRating>(new List<SafetyRating>());
}
}

/// <summary>
/// The reason the model stopped generating content, if it exists;
Expand Down
6 changes: 5 additions & 1 deletion firebaseai/src/Chat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// </summary>
public IEnumerable<ModelContent> History => new ReadOnlyCollection<ModelContent>(chatHistory);
public IEnumerable<ModelContent> History {
get {
return new ReadOnlyCollection<ModelContent>(chatHistory);
}
}

// Note: No public constructor, get one through GenerativeModel.StartChat
private Chat(GenerativeModel model, IEnumerable<ModelContent> initialHistory) {
Expand Down
7 changes: 5 additions & 2 deletions firebaseai/src/Citation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ public readonly struct CitationMetadata {
/// <summary>
/// A list of individual cited sources and the parts of the content to which they apply.
/// </summary>
public IEnumerable<Citation> Citations =>
_citations ?? new ReadOnlyCollection<Citation>(new List<Citation>());
public IEnumerable<Citation> Citations {
get {
return _citations ?? new ReadOnlyCollection<Citation>(new List<Citation>());
}
}

// Hidden constructor, users don't need to make this.
private CitationMetadata(List<Citation> citations) {
Expand Down
7 changes: 5 additions & 2 deletions firebaseai/src/CountTokensResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ public readonly struct CountTokensResponse {
/// <summary>
/// The breakdown, by modality, of how many tokens are consumed by the prompt.
/// </summary>
public IEnumerable<ModalityTokenCount> PromptTokensDetails =>
_promptTokensDetails ?? new ReadOnlyCollection<ModalityTokenCount>(new List<ModalityTokenCount>());
public IEnumerable<ModalityTokenCount> PromptTokensDetails {
get {
return _promptTokensDetails ?? new ReadOnlyCollection<ModalityTokenCount>(new List<ModalityTokenCount>());
}
}

// Hidden constructor, users don't need to make this
private CountTokensResponse(int totalTokens,
Expand Down
6 changes: 5 additions & 1 deletion firebaseai/src/FirebaseAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ private FirebaseAI(FirebaseApp firebaseApp, Backend backend) {
/// <summary>
/// Returns a `FirebaseAI` instance with the default `FirebaseApp` and GoogleAI Backend.
/// </summary>
public static FirebaseAI DefaultInstance => GetInstance();
public static FirebaseAI DefaultInstance {
get {
return GetInstance();
}
}

/// <summary>
/// Returns a `FirebaseAI` instance with the default `FirebaseApp` and the given Backend.
Expand Down
28 changes: 20 additions & 8 deletions firebaseai/src/GenerateContentResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ public readonly struct GenerateContentResponse {
/// <summary>
/// A list of candidate response content, ordered from best to worst.
/// </summary>
public IEnumerable<Candidate> Candidates =>
_candidates ?? new ReadOnlyCollection<Candidate>(new List<Candidate>());
public IEnumerable<Candidate> Candidates {
get {
return _candidates ?? new ReadOnlyCollection<Candidate>(new List<Candidate>());
}
}

/// <summary>
/// A value containing the safety ratings for the response, or,
Expand Down Expand Up @@ -141,8 +144,11 @@ public readonly struct PromptFeedback {
/// <summary>
/// The safety ratings of the prompt.
/// </summary>
public IEnumerable<SafetyRating> SafetyRatings =>
_safetyRatings ?? new ReadOnlyCollection<SafetyRating>(new List<SafetyRating>());
public IEnumerable<SafetyRating> SafetyRatings {
get {
return _safetyRatings ?? new ReadOnlyCollection<SafetyRating>(new List<SafetyRating>());
}
}

// Hidden constructor, users don't need to make this.
private PromptFeedback(BlockReason? blockReason, string blockReasonMessage,
Expand Down Expand Up @@ -192,12 +198,18 @@ public readonly struct UsageMetadata {
public int TotalTokenCount { get; }

private readonly ReadOnlyCollection<ModalityTokenCount> _promptTokensDetails;
public IEnumerable<ModalityTokenCount> PromptTokensDetails =>
_promptTokensDetails ?? new ReadOnlyCollection<ModalityTokenCount>(new List<ModalityTokenCount>());
public IEnumerable<ModalityTokenCount> PromptTokensDetails {
get {
return _promptTokensDetails ?? new ReadOnlyCollection<ModalityTokenCount>(new List<ModalityTokenCount>());
}
}

private readonly ReadOnlyCollection<ModalityTokenCount> _candidatesTokensDetails;
public IEnumerable<ModalityTokenCount> CandidatesTokensDetails =>
_candidatesTokensDetails ?? new ReadOnlyCollection<ModalityTokenCount>(new List<ModalityTokenCount>());
public IEnumerable<ModalityTokenCount> CandidatesTokensDetails {
get {
return _candidatesTokensDetails ?? new ReadOnlyCollection<ModalityTokenCount>(new List<ModalityTokenCount>());
}
}

// Hidden constructor, users don't need to make this.
private UsageMetadata(int promptTC, int candidatesTC, int totalTC,
Expand Down
14 changes: 10 additions & 4 deletions firebaseai/src/LiveSessionResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,12 @@ internal static LiveSessionContent FromJson(Dictionary<string, object> jsonDict)
///
/// This will be empty if no function calls are present.
/// </summary>
public IEnumerable<ModelContent.FunctionCallPart> FunctionCalls =>
_functionCalls ?? new ReadOnlyCollection<ModelContent.FunctionCallPart>(
public IEnumerable<ModelContent.FunctionCallPart> FunctionCalls {
get {
return _functionCalls ?? new ReadOnlyCollection<ModelContent.FunctionCallPart>(
new List<ModelContent.FunctionCallPart>());
}
}

private LiveSessionToolCall(List<ModelContent.FunctionCallPart> functionCalls) {
_functionCalls = new ReadOnlyCollection<ModelContent.FunctionCallPart>(
Expand All @@ -211,8 +214,11 @@ internal static LiveSessionToolCall FromJson(Dictionary<string, object> jsonDict
/// <summary>
/// The list of Function IDs to cancel.
/// </summary>
public IEnumerable<string> FunctionIds =>
_functionIds ?? new ReadOnlyCollection<string>(new List<string>());
public IEnumerable<string> FunctionIds {
get {
return _functionIds ?? new ReadOnlyCollection<string>(new List<string>());
}
}

private LiveSessionToolCallCancellation(List<string> functionIds) {
_functionIds = new ReadOnlyCollection<string>(
Expand Down
12 changes: 10 additions & 2 deletions firebaseai/src/ModelContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
/// </summary>
public string Role => string.IsNullOrWhiteSpace(_role) ? "user" : _role;
public string Role {
get {
return string.IsNullOrWhiteSpace(_role) ? "user" : _role;
}
}

/// <summary>
/// The data parts comprising this `ModelContent` value.
/// </summary>
public IEnumerable<Part> Parts => _parts ?? new ReadOnlyCollection<Part>(new List<Part>());
public IEnumerable<Part> Parts {
get {
return _parts ?? new ReadOnlyCollection<Part>(new List<Part>());
}
}

/// <summary>
/// Creates a `ModelContent` with the given `Part`s, using the default `user` role.
Expand Down
24 changes: 24 additions & 0 deletions firebaseai/src/ResponseModality.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,32 @@ namespace Firebase.AI {
/// The response type the model should return with.
/// </summary>
public enum ResponseModality {
/// <summary>
/// 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.
/// </summary>
Text,
/// <summary>
/// **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.
/// </summary>
Image,
/// <summary>
/// **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`.
/// </summary>
Audio,
}

Expand Down
8 changes: 4 additions & 4 deletions firebaseai/src/Schema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static StringFormat Custom(string format) {
/// <summary>
/// Possible values of the element of type "String" with "enum" format.
/// </summary>
public IEnumerable<string> EnumValues => _enumValues;
public IEnumerable<string> EnumValues { get { return _enumValues; } }
/// <summary>
/// Schema of the elements of type "Array".
/// </summary>
Expand Down Expand Up @@ -132,7 +132,7 @@ public static StringFormat Custom(string format) {
/// <summary>
/// Required properties of type "Object".
/// </summary>
public IEnumerable<string> RequiredProperties => _requiredProperties;
public IEnumerable<string> RequiredProperties { get { return _requiredProperties; } }

private readonly ReadOnlyCollection<string> _propertyOrdering;
/// <summary>
Expand All @@ -143,7 +143,7 @@ public static StringFormat Custom(string format) {
/// not preserve this order. This parameter primarily affects the raw JSON string
/// serialization.
/// </summary>
public IEnumerable<string> PropertyOrdering => _propertyOrdering;
public IEnumerable<string> PropertyOrdering { get { return _propertyOrdering; } }

private readonly ReadOnlyCollection<Schema> _anyOf;
/// <summary>
Expand All @@ -156,7 +156,7 @@ public static StringFormat Custom(string format) {
/// Schema.AnyOf(new [] { Schema.String(), Schema.Int() })
/// ```
/// </summary>
public IEnumerable<Schema> AnyOfSchemas => _anyOf;
public IEnumerable<Schema> AnyOfSchemas { get { return _anyOf; } }

private Schema(
SchemaType? type,
Expand Down