Represents a UsageMetadata.
Package
@google-ai/generativelanguageConstructors
(constructor)(properties)
constructor(properties?: google.ai.generativelanguage.v1beta.GenerateContentResponse.IUsageMetadata);
Constructs a new UsageMetadata.
Parameter | |
---|---|
Name | Description |
properties |
IUsageMetadata
Properties to set |
Properties
cachedContentTokenCount
public cachedContentTokenCount: number;
UsageMetadata cachedContentTokenCount.
candidatesTokenCount
public candidatesTokenCount: number;
UsageMetadata candidatesTokenCount.
promptTokenCount
public promptTokenCount: number;
UsageMetadata promptTokenCount.
totalTokenCount
public totalTokenCount: number;
UsageMetadata totalTokenCount.
Methods
create(properties)
public static create(properties?: google.ai.generativelanguage.v1beta.GenerateContentResponse.IUsageMetadata): google.ai.generativelanguage.v1beta.GenerateContentResponse.UsageMetadata;
Creates a new UsageMetadata instance using the specified properties.
Parameter | |
---|---|
Name | Description |
properties |
IUsageMetadata
Properties to set |
Returns | |
---|---|
Type | Description |
UsageMetadata |
UsageMetadata instance |
decode(reader, length)
public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.ai.generativelanguage.v1beta.GenerateContentResponse.UsageMetadata;
Decodes a UsageMetadata message from the specified reader or buffer.
Parameters | |
---|---|
Name | Description |
reader |
(Reader|Uint8Array)
Reader or buffer to decode from |
length |
number
Message length if known beforehand |
Returns | |
---|---|
Type | Description |
UsageMetadata |
UsageMetadata |
decodeDelimited(reader)
public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.ai.generativelanguage.v1beta.GenerateContentResponse.UsageMetadata;
Decodes a UsageMetadata message from the specified reader or buffer, length delimited.
Parameter | |
---|---|
Name | Description |
reader |
(Reader|Uint8Array)
Reader or buffer to decode from |
Returns | |
---|---|
Type | Description |
UsageMetadata |
UsageMetadata |
encode(message, writer)
public static encode(message: google.ai.generativelanguage.v1beta.GenerateContentResponse.IUsageMetadata, writer?: $protobuf.Writer): $protobuf.Writer;
Encodes the specified UsageMetadata message. Does not implicitly messages.
Parameters | |
---|---|
Name | Description |
message |
IUsageMetadata
UsageMetadata message or plain object to encode |
writer |
$protobuf.Writer
Writer to encode to |
Returns | |
---|---|
Type | Description |
$protobuf.Writer |
Writer |
encodeDelimited(message, writer)
public static encodeDelimited(message: google.ai.generativelanguage.v1beta.GenerateContentResponse.IUsageMetadata, writer?: $protobuf.Writer): $protobuf.Writer;
Encodes the specified UsageMetadata message, length delimited. Does not implicitly messages.
Parameters | |
---|---|
Name | Description |
message |
IUsageMetadata
UsageMetadata message or plain object to encode |
writer |
$protobuf.Writer
Writer to encode to |
Returns | |
---|---|
Type | Description |
$protobuf.Writer |
Writer |
fromObject(object)
public static fromObject(object: { [k: string]: any }): google.ai.generativelanguage.v1beta.GenerateContentResponse.UsageMetadata;
Creates a UsageMetadata message from a plain object. Also converts values to their respective internal types.
Parameter | |
---|---|
Name | Description |
object |
{ [k: string]: any }
Plain object |
Returns | |
---|---|
Type | Description |
UsageMetadata |
UsageMetadata |
getTypeUrl(typeUrlPrefix)
public static getTypeUrl(typeUrlPrefix?: string): string;
Gets the default type url for UsageMetadata
Parameter | |
---|---|
Name | Description |
typeUrlPrefix |
string
your custom typeUrlPrefix(default "type.googleapis.com") |
Returns | |
---|---|
Type | Description |
string |
The default type url |
toJSON()
public toJSON(): { [k: string]: any };
Converts this UsageMetadata to JSON.
Returns | |
---|---|
Type | Description |
{ [k: string]: any } |
JSON object |
toObject(message, options)
public static toObject(message: google.ai.generativelanguage.v1beta.GenerateContentResponse.UsageMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any };
Creates a plain object from a UsageMetadata message. Also converts values to other types if specified.
Parameters | |
---|---|
Name | Description |
message |
UsageMetadata
UsageMetadata |
options |
$protobuf.IConversionOptions
Conversion options |
Returns | |
---|---|
Type | Description |
{ [k: string]: any } |
Plain object |
verify(message)
public static verify(message: { [k: string]: any }): (string|null);
Verifies a UsageMetadata message.
Parameter | |
---|---|
Name | Description |
message |
{ [k: string]: any }
Plain object to verify |
Returns | |
---|---|
Type | Description |
(string|null) |
|