Table of Contents

Class GroundingChunkRetrievedContext

Namespace
Google.GenAI.Types
Assembly
Google.GenAI.dll

Context retrieved from a data source to ground the model's response. This is used when a retrieval tool fetches information from a user-provided corpus or a public dataset.

public record GroundingChunkRetrievedContext : IEquatable<GroundingChunkRetrievedContext>
Inheritance
GroundingChunkRetrievedContext
Implements
Inherited Members

Properties

CustomMetadata

Optional. User-provided metadata about the retrieved context. This field is not supported in Vertex AI.

[JsonPropertyName("customMetadata")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<GroundingChunkCustomMetadata>? CustomMetadata { get; set; }

Property Value

List<GroundingChunkCustomMetadata>

DocumentName

Output only. The full resource name of the referenced Vertex AI Search document. This is used to identify the specific document that was retrieved. The format is projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document}. This field is not supported in Gemini API.

[JsonPropertyName("documentName")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? DocumentName { get; set; }

Property Value

string

FileSearchStore

Optional. Name of the FileSearchStore containing the document. Example: fileSearchStores/123. This field is not supported in Vertex AI.

[JsonPropertyName("fileSearchStore")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? FileSearchStore { get; set; }

Property Value

string

MediaId

Optional. The media blob resource name for multimodal file search results. Format: fileSearchStores/{file_search_store_id}/media/{blob_id}. This field is not supported in Vertex AI.

[JsonPropertyName("mediaId")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? MediaId { get; set; }

Property Value

string

PageNumber

Optional. Page number of the retrieved context, if applicable. This field is not supported in Vertex AI.

[JsonPropertyName("pageNumber")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? PageNumber { get; set; }

Property Value

int?

RagChunk

Additional context for a Retrieval-Augmented Generation (RAG) retrieval result. This is populated only when the RAG retrieval tool is used. This field is not supported in Gemini API.

[JsonPropertyName("ragChunk")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public RagChunk? RagChunk { get; set; }

Property Value

RagChunk

Text

The content of the retrieved data source.

[JsonPropertyName("text")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Text { get; set; }

Property Value

string

Title

The title of the retrieved data source.

[JsonPropertyName("title")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Title { get; set; }

Property Value

string

Uri

The URI of the retrieved data source.

[JsonPropertyName("uri")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Uri { get; set; }

Property Value

string

Methods

FromJson(string, JsonSerializerOptions?)

Deserializes a JSON string to a GroundingChunkRetrievedContext object.

public static GroundingChunkRetrievedContext? FromJson(string jsonString, JsonSerializerOptions? options = null)

Parameters

jsonString string

The JSON string to deserialize.

options JsonSerializerOptions

Optional JsonSerializerOptions.

Returns

GroundingChunkRetrievedContext

The deserialized GroundingChunkRetrievedContext object, or null if deserialization fails.