Table of Contents

Class TokensInfo

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

Tokens info with a list of tokens and the corresponding list of token ids.

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

Properties

Role

Optional fields for the role from the corresponding Content.

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

Property Value

string

TokenIds

A list of token ids from the input.

[JsonPropertyName("tokenIds")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[JsonConverter(typeof(StringToNullableLongListConverter))]
public List<long>? TokenIds { get; set; }

Property Value

List<long>

Tokens

A list of tokens from the input.

[JsonPropertyName("tokens")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<byte[]>? Tokens { get; set; }

Property Value

List<byte[]>

Methods

FromJson(string, JsonSerializerOptions?)

Deserializes a JSON string to a TokensInfo object.

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

Parameters

jsonString string

The JSON string to deserialize.

options JsonSerializerOptions

Optional JsonSerializerOptions.

Returns

TokensInfo

The deserialized TokensInfo object, or null if deserialization fails.