diff --git a/packages/ai/google/src/Generated.ts b/packages/ai/google/src/Generated.ts index 1a977320b2a..d19542538d4 100644 --- a/packages/ai/google/src/Generated.ts +++ b/packages/ai/google/src/Generated.ts @@ -10,117 +10,6 @@ import * as Effect from "effect/Effect" import type { ParseError } from "effect/ParseResult" import * as S from "effect/Schema" -export class ListOperationsParams extends S.Struct({ - "filter": S.optionalWith(S.String, { nullable: true }), - "pageSize": S.optionalWith(S.Int, { nullable: true }), - "pageToken": S.optionalWith(S.String, { nullable: true }) -}) {} - -/** - * The `Status` type defines a logical error model that is suitable for - * different programming environments, including REST APIs and RPC APIs. It is - * used by [gRPC](https://github.com/grpc). Each `Status` message contains - * three pieces of data: error code, error message, and error details. - * - * You can find out more about this error model and how to work with it in the - * [API Design Guide](https://cloud.google.com/apis/design/errors). - */ -export class Status extends S.Class("Status")({ - /** - * The status code, which should be an enum value of google.rpc.Code. - */ - "code": S.optionalWith(S.Int, { nullable: true }), - /** - * A developer-facing error message, which should be in English. Any - * user-facing error message should be localized and sent in the - * google.rpc.Status.details field, or localized by the client. - */ - "message": S.optionalWith(S.String, { nullable: true }), - /** - * A list of messages that carry the error details. There is a common set of - * message types for APIs to use. - */ - "details": S.optionalWith(S.Array(S.Record({ key: S.String, value: S.Unknown })), { nullable: true }) -}) {} - -/** - * This resource represents a long-running operation that is the result of a - * network API call. - */ -export class Operation extends S.Class("Operation")({ - /** - * Service-specific metadata associated with the operation. It typically - * contains progress information and common metadata such as create time. - * Some services might not provide such metadata. Any method that returns a - * long-running operation should document the metadata type, if any. - */ - "metadata": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true }), - /** - * The normal, successful response of the operation. If the original - * method returns no data on success, such as `Delete`, the response is - * `google.protobuf.Empty`. If the original method is standard - * `Get`/`Create`/`Update`, the response should be the resource. For other - * methods, the response should have the type `XxxResponse`, where `Xxx` - * is the original method name. For example, if the original method name - * is `TakeSnapshot()`, the inferred response type is - * `TakeSnapshotResponse`. - */ - "response": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true }), - /** - * The server-assigned name, which is only unique within the same service that - * originally returns it. If you use the default HTTP mapping, the - * `name` should be a resource name ending with `operations/{unique_id}`. - */ - "name": S.optionalWith(S.String, { nullable: true }), - /** - * If the value is `false`, it means the operation is still in progress. - * If `true`, the operation is completed, and either `error` or `response` is - * available. - */ - "done": S.optionalWith(S.Boolean, { nullable: true }), - /** - * The error result of the operation in case of failure or cancellation. - */ - "error": S.optionalWith(Status, { nullable: true }) -}) {} - -/** - * The response message for Operations.ListOperations. - */ -export class ListOperationsResponse extends S.Class("ListOperationsResponse")({ - /** - * A list of operations that matches the specified filter in the request. - */ - "operations": S.optionalWith(S.Array(Operation), { nullable: true }), - /** - * The standard List next-page token. - */ - "nextPageToken": S.optionalWith(S.String, { nullable: true }) -}) {} - -export class ListOperationsByParams extends S.Struct({ - "filter": S.optionalWith(S.String, { nullable: true }), - "pageSize": S.optionalWith(S.Int, { nullable: true }), - "pageToken": S.optionalWith(S.String, { nullable: true }) -}) {} - -export class ListOperationsByModelParams extends S.Struct({ - "filter": S.optionalWith(S.String, { nullable: true }), - "pageSize": S.optionalWith(S.Int, { nullable: true }), - "pageToken": S.optionalWith(S.String, { nullable: true }) -}) {} - -/** - * A generic empty message that you can re-use to avoid defining duplicated - * empty messages in your APIs. A typical example is to use it as the request - * or the response type of an API method. For instance: - * - * service Foo { - * rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); - * } - */ -export class Empty extends S.Record({ key: S.String, value: S.Unknown }) {} - /** * Raw media bytes. * @@ -143,6 +32,20 @@ export class Blob extends S.Class("Blob")({ "data": S.optionalWith(S.String, { nullable: true }) }) {} +/** + * URI based data. + */ +export class FileData extends S.Class("FileData")({ + /** + * Required. URI. + */ + "fileUri": S.String, + /** + * Optional. The IANA standard MIME type of the source data. + */ + "mimeType": S.optionalWith(S.String, { nullable: true }) +}) {} + /** * A predicted `FunctionCall` returned from the model that contains * a string representing the `FunctionDeclaration.name` with the @@ -150,10 +53,9 @@ export class Blob extends S.Class("Blob")({ */ export class FunctionCall extends S.Class("FunctionCall")({ /** - * Optional. The unique id of the function call. If populated, the client to execute the - * `function_call` and return the response with the matching `id`. + * Optional. The function parameters and values in JSON object format. */ - "id": S.optionalWith(S.String, { nullable: true }), + "args": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true }), /** * Required. The name of the function to call. * Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum @@ -161,78 +63,55 @@ export class FunctionCall extends S.Class("FunctionCall")({ */ "name": S.String, /** - * Optional. The function parameters and values in JSON object format. + * Optional. The unique id of the function call. If populated, the client to execute the + * `function_call` and return the response with the matching `id`. */ - "args": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true }) + "id": S.optionalWith(S.String, { nullable: true }) }) {} /** - * Optional. Specifies how the response should be scheduled in the conversation. - * Only applicable to NON_BLOCKING function calls, is ignored otherwise. - * Defaults to WHEN_IDLE. + * Required. Outcome of the code execution. */ -export class FunctionResponseScheduling - extends S.Literal("SCHEDULING_UNSPECIFIED", "SILENT", "WHEN_IDLE", "INTERRUPT") +export class CodeExecutionResultOutcome + extends S.Literal("OUTCOME_UNSPECIFIED", "OUTCOME_OK", "OUTCOME_FAILED", "OUTCOME_DEADLINE_EXCEEDED") {} /** - * The result output from a `FunctionCall` that contains a string - * representing the `FunctionDeclaration.name` and a structured JSON - * object containing any output from the function is used as context to - * the model. This should contain the result of a`FunctionCall` made - * based on model prediction. + * Result of executing the `ExecutableCode`. + * + * Only generated when using the `CodeExecution`, and always follows a `part` + * containing the `ExecutableCode`. */ -export class FunctionResponse extends S.Class("FunctionResponse")({ - /** - * Optional. The id of the function call this response is for. Populated by the client - * to match the corresponding function call `id`. - */ - "id": S.optionalWith(S.String, { nullable: true }), - /** - * Required. The name of the function to call. - * Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum - * length of 64. - */ - "name": S.String, - /** - * Required. The function response in JSON object format. - * Callers can use any keys of their choice that fit the function's syntax - * to return the function output, e.g. "output", "result", etc. - * In particular, if the function call failed to execute, the response can - * have an "error" key to return error details to the model. - */ - "response": S.Record({ key: S.String, value: S.Unknown }), +export class CodeExecutionResult extends S.Class("CodeExecutionResult")({ /** - * Optional. Signals that function call continues, and more responses will be - * returned, turning the function call into a generator. - * Is only applicable to NON_BLOCKING function calls, is ignored otherwise. - * If set to false, future responses will not be considered. - * It is allowed to return empty `response` with `will_continue=False` to - * signal that the function call is finished. This may still trigger the model - * generation. To avoid triggering the generation and finish the function - * call, additionally set `scheduling` to `SILENT`. + * Required. Outcome of the code execution. */ - "willContinue": S.optionalWith(S.Boolean, { nullable: true }), + "outcome": CodeExecutionResultOutcome, /** - * Optional. Specifies how the response should be scheduled in the conversation. - * Only applicable to NON_BLOCKING function calls, is ignored otherwise. - * Defaults to WHEN_IDLE. + * Optional. Contains stdout when code execution is successful, stderr or other + * description otherwise. */ - "scheduling": S.optionalWith(FunctionResponseScheduling, { nullable: true }) + "output": S.optionalWith(S.String, { nullable: true }) }) {} /** - * URI based data. + * Metadata describes the input video content. */ -export class FileData extends S.Class("FileData")({ +export class VideoMetadata extends S.Class("VideoMetadata")({ /** - * Optional. The IANA standard MIME type of the source data. + * Optional. The end offset of the video. */ - "mimeType": S.optionalWith(S.String, { nullable: true }), + "endOffset": S.optionalWith(S.String, { nullable: true }), /** - * Required. URI. + * Optional. The start offset of the video. */ - "fileUri": S.String + "startOffset": S.optionalWith(S.String, { nullable: true }), + /** + * Optional. The frame rate of the video sent to the model. If not specified, the + * default value will be 1.0. + * The fps range is (0.0, 24.0]. + */ + "fps": S.optionalWith(S.Number, { nullable: true }) }) {} /** @@ -260,89 +139,150 @@ export class ExecutableCode extends S.Class("ExecutableCode")({ }) {} /** - * Required. Outcome of the code execution. + * Optional. Specifies how the response should be scheduled in the conversation. + * Only applicable to NON_BLOCKING function calls, is ignored otherwise. + * Defaults to WHEN_IDLE. */ -export class CodeExecutionResultOutcome - extends S.Literal("OUTCOME_UNSPECIFIED", "OUTCOME_OK", "OUTCOME_FAILED", "OUTCOME_DEADLINE_EXCEEDED") +export class FunctionResponseScheduling + extends S.Literal("SCHEDULING_UNSPECIFIED", "SILENT", "WHEN_IDLE", "INTERRUPT") {} /** - * Result of executing the `ExecutableCode`. + * Raw media bytes for function response. * - * Only generated when using the `CodeExecution`, and always follows a `part` - * containing the `ExecutableCode`. + * Text should not be sent as raw bytes, use the 'FunctionResponse.response' + * field. */ -export class CodeExecutionResult extends S.Class("CodeExecutionResult")({ +export class FunctionResponseBlob extends S.Class("FunctionResponseBlob")({ /** - * Required. Outcome of the code execution. + * The IANA standard MIME type of the source data. + * Examples: + * - image/png + * - image/jpeg + * If an unsupported MIME type is provided, an error will be returned. For a + * complete list of supported types, see [Supported file + * formats](https://ai.google.dev/gemini-api/docs/prompting_with_media#supported_file_formats). */ - "outcome": CodeExecutionResultOutcome, + "mimeType": S.optionalWith(S.String, { nullable: true }), /** - * Optional. Contains stdout when code execution is successful, stderr or other - * description otherwise. + * Raw bytes for media formats. */ - "output": S.optionalWith(S.String, { nullable: true }) + "data": S.optionalWith(S.String, { nullable: true }) }) {} /** - * Metadata describes the input video content. + * A datatype containing media that is part of a `FunctionResponse` message. + * + * A `FunctionResponsePart` consists of data which has an associated datatype. A + * `FunctionResponsePart` can only contain one of the accepted types in + * `FunctionResponsePart.data`. + * + * A `FunctionResponsePart` must have a fixed IANA MIME type identifying the + * type and subtype of the media if the `inline_data` field is filled with raw + * bytes. */ -export class VideoMetadata extends S.Class("VideoMetadata")({ - /** - * Optional. The start offset of the video. - */ - "startOffset": S.optionalWith(S.String, { nullable: true }), - /** - * Optional. The end offset of the video. - */ - "endOffset": S.optionalWith(S.String, { nullable: true }), +export class FunctionResponsePart extends S.Class("FunctionResponsePart")({ /** - * Optional. The frame rate of the video sent to the model. If not specified, the - * default value will be 1.0. - * The fps range is (0.0, 24.0]. + * Inline media bytes. */ - "fps": S.optionalWith(S.Number, { nullable: true }) + "inlineData": S.optionalWith(FunctionResponseBlob, { nullable: true }) }) {} /** - * A datatype containing media that is part of a multi-part `Content` message. - * - * A `Part` consists of data which has an associated datatype. A `Part` can only - * contain one of the accepted types in `Part.data`. - * - * A `Part` must have a fixed IANA MIME type identifying the type and subtype - * of the media if the `inline_data` field is filled with raw bytes. + * The result output from a `FunctionCall` that contains a string + * representing the `FunctionDeclaration.name` and a structured JSON + * object containing any output from the function is used as context to + * the model. This should contain the result of a`FunctionCall` made + * based on model prediction. */ -export class Part extends S.Class("Part")({ +export class FunctionResponse extends S.Class("FunctionResponse")({ /** - * Inline text. + * Optional. Specifies how the response should be scheduled in the conversation. + * Only applicable to NON_BLOCKING function calls, is ignored otherwise. + * Defaults to WHEN_IDLE. */ - "text": S.optionalWith(S.String, { nullable: true }), + "scheduling": S.optionalWith(FunctionResponseScheduling, { nullable: true }), + /** + * Optional. Ordered `Parts` that constitute a function response. Parts may have + * different IANA MIME types. + */ + "parts": S.optionalWith(S.Array(FunctionResponsePart), { nullable: true }), + /** + * Optional. Signals that function call continues, and more responses will be + * returned, turning the function call into a generator. + * Is only applicable to NON_BLOCKING function calls, is ignored otherwise. + * If set to false, future responses will not be considered. + * It is allowed to return empty `response` with `will_continue=False` to + * signal that the function call is finished. This may still trigger the model + * generation. To avoid triggering the generation and finish the function + * call, additionally set `scheduling` to `SILENT`. + */ + "willContinue": S.optionalWith(S.Boolean, { nullable: true }), + /** + * Optional. The id of the function call this response is for. Populated by the client + * to match the corresponding function call `id`. + */ + "id": S.optionalWith(S.String, { nullable: true }), + /** + * Required. The name of the function to call. + * Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum + * length of 64. + */ + "name": S.String, + /** + * Required. The function response in JSON object format. + * Callers can use any keys of their choice that fit the function's syntax + * to return the function output, e.g. "output", "result", etc. + * In particular, if the function call failed to execute, the response can + * have an "error" key to return error details to the model. + */ + "response": S.Record({ key: S.String, value: S.Unknown }) +}) {} + +/** + * A datatype containing media that is part of a multi-part `Content` message. + * + * A `Part` consists of data which has an associated datatype. A `Part` can only + * contain one of the accepted types in `Part.data`. + * + * A `Part` must have a fixed IANA MIME type identifying the type and subtype + * of the media if the `inline_data` field is filled with raw bytes. + */ +export class Part extends S.Class("Part")({ /** * Inline media bytes. */ "inlineData": S.optionalWith(Blob, { nullable: true }), /** - * A predicted `FunctionCall` returned from the model that contains - * a string representing the `FunctionDeclaration.name` with the - * arguments and their values. + * Custom metadata associated with the Part. + * Agents using genai.Part as content representation may need to keep track + * of the additional information. For example it can be name of a file/source + * from which the Part originates or a way to multiplex multiple Part streams. */ - "functionCall": S.optionalWith(FunctionCall, { nullable: true }), + "partMetadata": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true }), /** - * The result output of a `FunctionCall` that contains a string - * representing the `FunctionDeclaration.name` and a structured JSON - * object containing any output from the function is used as context to - * the model. + * Optional. Indicates if the part is thought from the model. + */ + "thought": S.optionalWith(S.Boolean, { nullable: true }), + /** + * Inline text. */ - "functionResponse": S.optionalWith(FunctionResponse, { nullable: true }), + "text": S.optionalWith(S.String, { nullable: true }), /** * URI based data. */ "fileData": S.optionalWith(FileData, { nullable: true }), /** - * Code generated by the model that is meant to be executed. + * A predicted `FunctionCall` returned from the model that contains + * a string representing the `FunctionDeclaration.name` with the + * arguments and their values. */ - "executableCode": S.optionalWith(ExecutableCode, { nullable: true }), + "functionCall": S.optionalWith(FunctionCall, { nullable: true }), + /** + * Optional. An opaque signature for the thought so it can be reused in subsequent + * requests. + */ + "thoughtSignature": S.optionalWith(S.String, { nullable: true }), /** * Result of executing the `ExecutableCode`. */ @@ -353,14 +293,16 @@ export class Part extends S.Class("Part")({ */ "videoMetadata": S.optionalWith(VideoMetadata, { nullable: true }), /** - * Optional. Indicates if the part is thought from the model. + * Code generated by the model that is meant to be executed. */ - "thought": S.optionalWith(S.Boolean, { nullable: true }), + "executableCode": S.optionalWith(ExecutableCode, { nullable: true }), /** - * Optional. An opaque signature for the thought so it can be reused in subsequent - * requests. + * The result output of a `FunctionCall` that contains a string + * representing the `FunctionDeclaration.name` and a structured JSON + * object containing any output from the function is used as context to + * the model. */ - "thoughtSignature": S.optionalWith(S.String, { nullable: true }) + "functionResponse": S.optionalWith(FunctionResponse, { nullable: true }) }) {} /** @@ -385,6 +327,128 @@ export class Content extends S.Class("Content")({ "role": S.optionalWith(S.String, { nullable: true }) }) {} +export class HarmCategory extends S.Literal( + "HARM_CATEGORY_UNSPECIFIED", + "HARM_CATEGORY_DEROGATORY", + "HARM_CATEGORY_TOXICITY", + "HARM_CATEGORY_VIOLENCE", + "HARM_CATEGORY_SEXUAL", + "HARM_CATEGORY_MEDICAL", + "HARM_CATEGORY_DANGEROUS", + "HARM_CATEGORY_HARASSMENT", + "HARM_CATEGORY_HATE_SPEECH", + "HARM_CATEGORY_SEXUALLY_EXPLICIT", + "HARM_CATEGORY_DANGEROUS_CONTENT", + "HARM_CATEGORY_CIVIC_INTEGRITY" +) {} + +/** + * Required. Controls the probability threshold at which harm is blocked. + */ +export class SafetySettingThreshold extends S.Literal( + "HARM_BLOCK_THRESHOLD_UNSPECIFIED", + "BLOCK_LOW_AND_ABOVE", + "BLOCK_MEDIUM_AND_ABOVE", + "BLOCK_ONLY_HIGH", + "BLOCK_NONE", + "OFF" +) {} + +/** + * Safety setting, affecting the safety-blocking behavior. + * + * Passing a safety setting for a category changes the allowed probability that + * content is blocked. + */ +export class SafetySetting extends S.Class("SafetySetting")({ + /** + * Required. The category for this setting. + */ + "category": HarmCategory, + /** + * Required. Controls the probability threshold at which harm is blocked. + */ + "threshold": SafetySettingThreshold +}) {} + +/** + * The mode of the predictor to be used in dynamic retrieval. + */ +export class DynamicRetrievalConfigMode extends S.Literal("MODE_UNSPECIFIED", "MODE_DYNAMIC") {} + +/** + * Describes the options to customize dynamic retrieval. + */ +export class DynamicRetrievalConfig extends S.Class("DynamicRetrievalConfig")({ + /** + * The threshold to be used in dynamic retrieval. + * If not set, a system default value is used. + */ + "dynamicThreshold": S.optionalWith(S.Number, { nullable: true }), + /** + * The mode of the predictor to be used in dynamic retrieval. + */ + "mode": S.optionalWith(DynamicRetrievalConfigMode, { nullable: true }) +}) {} + +/** + * Tool to retrieve public web data for grounding, powered by Google. + */ +export class GoogleSearchRetrieval extends S.Class("GoogleSearchRetrieval")({ + /** + * Specifies the dynamic retrieval configuration for the given source. + */ + "dynamicRetrievalConfig": S.optionalWith(DynamicRetrievalConfig, { nullable: true }) +}) {} + +/** + * Tool that executes code generated by the model, and automatically returns + * the result to the model. + * + * See also `ExecutableCode` and `CodeExecutionResult` which are only generated + * when using this tool. + */ +export class CodeExecution extends S.Record({ key: S.String, value: S.Unknown }) {} + +/** + * The GoogleMaps Tool that provides geospatial context for the user's query. + */ +export class GoogleMaps extends S.Class("GoogleMaps")({ + /** + * Optional. Whether to return a widget context token in the GroundingMetadata of the + * response. Developers can use the widget context token to render a Google + * Maps widget with geospatial context related to the places that the model + * references in the response. + */ + "enableWidget": S.optionalWith(S.Boolean, { nullable: true }) +}) {} + +/** + * The FileSearch tool that retrieves knowledge from Semantic Retrieval corpora. + * Files are imported to Semantic Retrieval corpora using the ImportFile API. + */ +export class FileSearch extends S.Class("FileSearch")({ + /** + * Required. The names of the file_search_stores to retrieve from. + * Example: `fileSearchStores/my-file-search-store-123` + */ + "fileSearchStoreNames": S.Array(S.String), + /** + * Optional. Metadata filter to apply to the semantic retrieval documents and chunks. + */ + "metadataFilter": S.optionalWith(S.String, { nullable: true }), + /** + * Optional. The number of semantic retrieval chunks to retrieve. + */ + "topK": S.optionalWith(S.Int, { nullable: true }) +}) {} + +/** + * Optional. Specifies the function Behavior. + * Currently only supported by the BidiGenerateContent method. + */ +export class FunctionDeclarationBehavior extends S.Literal("UNSPECIFIED", "BLOCKING", "NON_BLOCKING") {} + export class Type extends S.Literal("TYPE_UNSPECIFIED", "STRING", "NUMBER", "INTEGER", "BOOLEAN", "ARRAY", "OBJECT", "NULL") {} @@ -476,7 +540,7 @@ const schemaFields = { } /** - * The \`Schema\` object allows the definition of input and output data types. + * The `Schema` object allows the definition of input and output data types. * These types can be objects, but also primitives and arrays. * Represents a select subset of an [OpenAPI 3.0 schema * object](https://spec.openapis.org/oas/v3.0.3#schema). @@ -501,19 +565,9 @@ export interface SchemaEncoded extends S.Struct.Encoded { */ export class Schema extends S.Class("Schema")({ ...schemaFields, - "anyOf": S.optionalWith(S.Array(S.suspend((): S.Schema => Schema)), { nullable: true }), - /** - * Optional. Schema of the elements of Type.ARRAY. - */ - "items": S.optionalWith(S.suspend((): S.Schema => Schema), { nullable: true }) + "anyOf": S.optionalWith(S.Array(S.suspend((): S.Schema => Schema)), { nullable: true }) }) {} -/** - * Optional. Specifies the function Behavior. - * Currently only supported by the BidiGenerateContent method. - */ -export class FunctionDeclarationBehavior extends S.Literal("UNSPECIFIED", "BLOCKING", "NON_BLOCKING") {} - /** * Structured representation of a function declaration as defined by the * [OpenAPI 3.03 specification](https://spec.openapis.org/oas/v3.0.3). Included @@ -522,6 +576,10 @@ export class FunctionDeclarationBehavior extends S.Literal("UNSPECIFIED", "BLOCK * as a `Tool` by the model and executed by the client. */ export class FunctionDeclaration extends S.Class("FunctionDeclaration")({ + /** + * Required. A brief description of the function. + */ + "description": S.String, /** * Required. The name of the function. * Must be a-z, A-Z, 0-9, or contain underscores, colons, dots, and dashes, @@ -529,16 +587,10 @@ export class FunctionDeclaration extends S.Class("FunctionD */ "name": S.String, /** - * Required. A brief description of the function. - */ - "description": S.String, - /** - * Optional. Describes the parameters to this function. Reflects the Open API 3.03 - * Parameter Object string Key: the name of the parameter. Parameter names are - * case sensitive. Schema Value: the Schema defining the type used for the - * parameter. + * Optional. Specifies the function Behavior. + * Currently only supported by the BidiGenerateContent method. */ - "parameters": S.optionalWith(Schema, { nullable: true }), + "behavior": S.optionalWith(FunctionDeclarationBehavior, { nullable: true }), /** * Optional. Describes the output from this function in JSON Schema format. Reflects the * Open API 3.03 Response Object. The Schema defines the type used for the @@ -546,94 +598,81 @@ export class FunctionDeclaration extends S.Class("FunctionD */ "response": S.optionalWith(Schema, { nullable: true }), /** - * Optional. Specifies the function Behavior. - * Currently only supported by the BidiGenerateContent method. + * Optional. Describes the parameters to this function. Reflects the Open API 3.03 + * Parameter Object string Key: the name of the parameter. Parameter names are + * case sensitive. Schema Value: the Schema defining the type used for the + * parameter. */ - "behavior": S.optionalWith(FunctionDeclarationBehavior, { nullable: true }) + "parameters": S.optionalWith(Schema, { nullable: true }) }) {} /** - * The mode of the predictor to be used in dynamic retrieval. + * Tool to support URL context retrieval. */ -export class DynamicRetrievalConfigMode extends S.Literal("MODE_UNSPECIFIED", "MODE_DYNAMIC") {} +export class UrlContext extends S.Record({ key: S.String, value: S.Unknown }) {} /** - * Describes the options to customize dynamic retrieval. + * Represents a time interval, encoded as a Timestamp start (inclusive) and a + * Timestamp end (exclusive). + * + * The start must be less than or equal to the end. + * When the start equals the end, the interval is empty (matches no time). + * When both start and end are unspecified, the interval matches any time. */ -export class DynamicRetrievalConfig extends S.Class("DynamicRetrievalConfig")({ +export class Interval extends S.Class("Interval")({ /** - * The mode of the predictor to be used in dynamic retrieval. + * Optional. Exclusive end of the interval. + * + * If specified, a Timestamp matching this interval will have to be before the + * end. */ - "mode": S.optionalWith(DynamicRetrievalConfigMode, { nullable: true }), + "endTime": S.optionalWith(S.String, { nullable: true }), /** - * The threshold to be used in dynamic retrieval. - * If not set, a system default value is used. + * Optional. Inclusive start of the interval. + * + * If specified, a Timestamp matching this interval will have to be the same + * or after the start. */ - "dynamicThreshold": S.optionalWith(S.Number, { nullable: true }) + "startTime": S.optionalWith(S.String, { nullable: true }) }) {} /** - * Tool to retrieve public web data for grounding, powered by Google. + * GoogleSearch tool type. + * Tool to support Google Search in Model. Powered by Google. */ -export class GoogleSearchRetrieval extends S.Class("GoogleSearchRetrieval")({ +export class GoogleSearch extends S.Class("GoogleSearch")({ /** - * Specifies the dynamic retrieval configuration for the given source. + * Optional. Filter search results to a specific time range. + * If customers set a start time, they must set an end time (and vice + * versa). */ - "dynamicRetrievalConfig": S.optionalWith(DynamicRetrievalConfig, { nullable: true }) + "timeRangeFilter": S.optionalWith(Interval, { nullable: true }) }) {} /** - * Tool that executes code generated by the model, and automatically returns - * the result to the model. - * - * See also `ExecutableCode` and `CodeExecutionResult` which are only generated - * when using this tool. + * Required. The environment being operated. */ -export class CodeExecution extends S.Record({ key: S.String, value: S.Unknown }) {} +export class ComputerUseEnvironment extends S.Literal("ENVIRONMENT_UNSPECIFIED", "ENVIRONMENT_BROWSER") {} /** - * Represents a time interval, encoded as a Timestamp start (inclusive) and a - * Timestamp end (exclusive). - * - * The start must be less than or equal to the end. - * When the start equals the end, the interval is empty (matches no time). - * When both start and end are unspecified, the interval matches any time. + * Computer Use tool type. */ -export class Interval extends S.Class("Interval")({ - /** - * Optional. Inclusive start of the interval. - * - * If specified, a Timestamp matching this interval will have to be the same - * or after the start. - */ - "startTime": S.optionalWith(S.String, { nullable: true }), +export class ComputerUse extends S.Class("ComputerUse")({ /** - * Optional. Exclusive end of the interval. - * - * If specified, a Timestamp matching this interval will have to be before the - * end. + * Required. The environment being operated. */ - "endTime": S.optionalWith(S.String, { nullable: true }) -}) {} - -/** - * GoogleSearch tool type. - * Tool to support Google Search in Model. Powered by Google. - */ -export class GoogleSearch extends S.Class("GoogleSearch")({ + "environment": ComputerUseEnvironment, /** - * Optional. Filter search results to a specific time range. - * If customers set a start time, they must set an end time (and vice - * versa). + * Optional. By default, predefined functions are included in the final model + * call. + * Some of them can be explicitly excluded from being automatically + * included. This can serve two purposes: + * 1. Using a more restricted / different action space. + * 2. Improving the definitions / instructions of predefined functions. */ - "timeRangeFilter": S.optionalWith(Interval, { nullable: true }) + "excludedPredefinedFunctions": S.optionalWith(S.Array(S.String), { nullable: true }) }) {} -/** - * Tool to support URL context retrieval. - */ -export class UrlContext extends S.Record({ key: S.String, value: S.Unknown }) {} - /** * Tool details that the model may use to generate response. * @@ -641,9 +680,27 @@ export class UrlContext extends S.Record({ key: S.String, value: S.Unknown }) {} * external systems to perform an action, or set of actions, outside of * knowledge and scope of the model. * - * Next ID: 11 + * Next ID: 13 */ export class Tool extends S.Class("Tool")({ + /** + * Optional. Retrieval tool that is powered by Google search. + */ + "googleSearchRetrieval": S.optionalWith(GoogleSearchRetrieval, { nullable: true }), + /** + * Optional. Enables the model to execute code as part of generation. + */ + "codeExecution": S.optionalWith(CodeExecution, { nullable: true }), + /** + * Optional. Tool that allows grounding the model's response with geospatial context + * related to the user's query. + */ + "googleMaps": S.optionalWith(GoogleMaps, { nullable: true }), + /** + * Optional. FileSearch tool type. + * Tool to retrieve knowledge from Semantic Retrieval corpora. + */ + "fileSearch": S.optionalWith(FileSearch, { nullable: true }), /** * Optional. A list of `FunctionDeclarations` available to the model that can be used * for function calling. @@ -660,103 +717,20 @@ export class Tool extends S.Class("Tool")({ */ "functionDeclarations": S.optionalWith(S.Array(FunctionDeclaration), { nullable: true }), /** - * Optional. Retrieval tool that is powered by Google search. - */ - "googleSearchRetrieval": S.optionalWith(GoogleSearchRetrieval, { nullable: true }), - /** - * Optional. Enables the model to execute code as part of generation. + * Optional. Tool to support URL context retrieval. */ - "codeExecution": S.optionalWith(CodeExecution, { nullable: true }), + "urlContext": S.optionalWith(UrlContext, { nullable: true }), /** * Optional. GoogleSearch tool type. * Tool to support Google Search in Model. Powered by Google. */ "googleSearch": S.optionalWith(GoogleSearch, { nullable: true }), /** - * Optional. Tool to support URL context retrieval. - */ - "urlContext": S.optionalWith(UrlContext, { nullable: true }) -}) {} - -/** - * Optional. Specifies the mode in which function calling should execute. If - * unspecified, the default value will be set to AUTO. - */ -export class FunctionCallingConfigMode extends S.Literal("MODE_UNSPECIFIED", "AUTO", "ANY", "NONE", "VALIDATED") {} - -/** - * Configuration for specifying function calling behavior. - */ -export class FunctionCallingConfig extends S.Class("FunctionCallingConfig")({ - /** - * Optional. Specifies the mode in which function calling should execute. If - * unspecified, the default value will be set to AUTO. - */ - "mode": S.optionalWith(FunctionCallingConfigMode, { nullable: true }), - /** - * Optional. A set of function names that, when provided, limits the functions the model - * will call. - * - * This should only be set when the Mode is ANY or VALIDATED. Function names - * should match [FunctionDeclaration.name]. When set, model will - * predict a function call from only allowed function names. - */ - "allowedFunctionNames": S.optionalWith(S.Array(S.String), { nullable: true }) -}) {} - -/** - * The Tool configuration containing parameters for specifying `Tool` use - * in the request. - */ -export class ToolConfig extends S.Class("ToolConfig")({ - /** - * Optional. Function calling config. - */ - "functionCallingConfig": S.optionalWith(FunctionCallingConfig, { nullable: true }) -}) {} - -export class HarmCategory extends S.Literal( - "HARM_CATEGORY_UNSPECIFIED", - "HARM_CATEGORY_DEROGATORY", - "HARM_CATEGORY_TOXICITY", - "HARM_CATEGORY_VIOLENCE", - "HARM_CATEGORY_SEXUAL", - "HARM_CATEGORY_MEDICAL", - "HARM_CATEGORY_DANGEROUS", - "HARM_CATEGORY_HARASSMENT", - "HARM_CATEGORY_HATE_SPEECH", - "HARM_CATEGORY_SEXUALLY_EXPLICIT", - "HARM_CATEGORY_DANGEROUS_CONTENT", - "HARM_CATEGORY_CIVIC_INTEGRITY" -) {} - -/** - * Required. Controls the probability threshold at which harm is blocked. - */ -export class SafetySettingThreshold extends S.Literal( - "HARM_BLOCK_THRESHOLD_UNSPECIFIED", - "BLOCK_LOW_AND_ABOVE", - "BLOCK_MEDIUM_AND_ABOVE", - "BLOCK_ONLY_HIGH", - "BLOCK_NONE", - "OFF" -) {} - -/** - * Safety setting, affecting the safety-blocking behavior. - * - * Passing a safety setting for a category changes the allowed probability that - * content is blocked. - */ -export class SafetySetting extends S.Class("SafetySetting")({ - /** - * Required. The category for this setting. - */ - "category": HarmCategory, - /** - * Required. Controls the probability threshold at which harm is blocked. + * Optional. Tool to support the model interacting directly with the computer. + * If enabled, it automatically populates computer-use specific Function + * Declarations. */ - "threshold": SafetySettingThreshold + "computerUse": S.optionalWith(ComputerUse, { nullable: true }) }) {} /** @@ -807,15 +781,15 @@ export class MultiSpeakerVoiceConfig extends S.Class("M * The speech generation config. */ export class SpeechConfig extends S.Class("SpeechConfig")({ - /** - * The configuration in case of single-voice output. - */ - "voiceConfig": S.optionalWith(VoiceConfig, { nullable: true }), /** * Optional. The configuration for the multi-speaker setup. * It is mutually exclusive with the voice_config field. */ "multiSpeakerVoiceConfig": S.optionalWith(MultiSpeakerVoiceConfig, { nullable: true }), + /** + * The configuration in case of single-voice output. + */ + "voiceConfig": S.optionalWith(VoiceConfig, { nullable: true }), /** * Optional. Language code (in BCP 47 format, e.g. "en-US") for speech synthesis. * @@ -827,10 +801,23 @@ export class SpeechConfig extends S.Class("SpeechConfig")({ "languageCode": S.optionalWith(S.String, { nullable: true }) }) {} +/** + * Optional. Controls the maximum depth of the model's internal reasoning process before + * it produces a response. If not specified, the default is HIGH. Recommended + * for Gemini 3 or later models. Use with earlier models results in an error. + */ +export class ThinkingConfigThinkingLevel extends S.Literal("THINKING_LEVEL_UNSPECIFIED", "LOW", "HIGH") {} + /** * Config for thinking features. */ export class ThinkingConfig extends S.Class("ThinkingConfig")({ + /** + * Optional. Controls the maximum depth of the model's internal reasoning process before + * it produces a response. If not specified, the default is HIGH. Recommended + * for Gemini 3 or later models. Use with earlier models results in an error. + */ + "thinkingLevel": S.optionalWith(ThinkingConfigThinkingLevel, { nullable: true }), /** * Indicates whether to include thoughts in the response. * If true, thoughts are returned only when available. @@ -842,6 +829,25 @@ export class ThinkingConfig extends S.Class("ThinkingConfig")({ "thinkingBudget": S.optionalWith(S.Int, { nullable: true }) }) {} +/** + * Config for image generation features. + */ +export class ImageConfig extends S.Class("ImageConfig")({ + /** + * Optional. The aspect ratio of the image to generate. Supported aspect ratios: 1:1, + * 2:3, 3:2, 3:4, 4:3, 9:16, 16:9, 21:9. + * + * If not specified, the model will choose a default aspect ratio based on any + * reference images provided. + */ + "aspectRatio": S.optionalWith(S.String, { nullable: true }), + /** + * Optional. Specifies the size of generated images. Supported values are `1K`, `2K`, + * `4K`. If not specified, the model will use default value `1K`. + */ + "imageSize": S.optionalWith(S.String, { nullable: true }) +}) {} + /** * Optional. If specified, the media resolution specified will be used. */ @@ -855,22 +861,28 @@ export class GenerationConfigMediaResolution extends S.Literal( /** * Configuration options for model generation and outputs. Not all parameters * are configurable for every model. - * Next ID: 28 */ export class GenerationConfig extends S.Class("GenerationConfig")({ /** - * Optional. Number of generated responses to return. If unset, this will default - * to 1. Please note that this doesn't work for previous generation - * models (Gemini 1.0 family) + * Optional. The requested modalities of the response. Represents the set of modalities + * that the model can return, and should be expected in the response. This is + * an exact match to the modalities of the response. + * + * A model may have multiple combinations of supported modalities. If the + * requested modalities do not match any of the supported combinations, an + * error will be returned. + * + * An empty list is equivalent to requesting only text. */ - "candidateCount": S.optionalWith(S.Int, { nullable: true }), + "responseModalities": S.optionalWith(S.Array(S.Literal("MODALITY_UNSPECIFIED", "TEXT", "IMAGE", "AUDIO")), { + nullable: true + }), /** - * Optional. The set of character sequences (up to 5) that will stop output generation. - * If specified, the API will stop at the first appearance of a - * `stop_sequence`. The stop sequence will not be included as part of the - * response. + * Optional. Only valid if response_logprobs=True. + * This sets the number of top logprobs to return at each decoding step in the + * Candidate.logprobs_result. The number must be in the range of [0, 20]. */ - "stopSequences": S.optionalWith(S.Array(S.String), { nullable: true }), + "logprobs": S.optionalWith(S.Int, { nullable: true }), /** * Optional. The maximum number of tokens to include in a response candidate. * @@ -879,30 +891,9 @@ export class GenerationConfig extends S.Class("GenerationConfi */ "maxOutputTokens": S.optionalWith(S.Int, { nullable: true }), /** - * Optional. Controls the randomness of the output. - * - * Note: The default value varies by model, see the `Model.temperature` - * attribute of the `Model` returned from the `getModel` function. - * - * Values can range from [0.0, 2.0]. - */ - "temperature": S.optionalWith(S.Number, { nullable: true }), - /** - * Optional. The maximum cumulative probability of tokens to consider when sampling. - * - * The model uses combined Top-k and Top-p (nucleus) sampling. - * - * Tokens are sorted based on their assigned probabilities so that only the - * most likely tokens are considered. Top-k sampling directly limits the - * maximum number of tokens to consider, while Nucleus sampling limits the - * number of tokens based on the cumulative probability. - * - * Note: The default value varies by `Model` and is specified by - * the`Model.top_p` attribute returned from the `getModel` function. An empty - * `top_k` attribute indicates that the model doesn't apply top-k sampling - * and doesn't allow setting `top_k` on requests. + * Optional. The speech generation config. */ - "topP": S.optionalWith(S.Number, { nullable: true }), + "speechConfig": S.optionalWith(SpeechConfig, { nullable: true }), /** * Optional. The maximum number of tokens to consider when sampling. * @@ -916,22 +907,6 @@ export class GenerationConfig extends S.Class("GenerationConfi * and doesn't allow setting `top_k` on requests. */ "topK": S.optionalWith(S.Int, { nullable: true }), - /** - * Optional. Seed used in decoding. If not set, the request uses a randomly generated - * seed. - */ - "seed": S.optionalWith(S.Int, { nullable: true }), - /** - * Optional. MIME type of the generated candidate text. - * Supported MIME types are: - * `text/plain`: (default) Text output. - * `application/json`: JSON response in the response candidates. - * `text/x.enum`: ENUM as a string response in the response candidates. - * Refer to the - * [docs](https://ai.google.dev/gemini-api/docs/prompting_with_media#plain_text_formats) - * for a list of all supported text MIME types. - */ - "responseMimeType": S.optionalWith(S.String, { nullable: true }), /** * Optional. Output schema of the generated candidate text. Schemas must be a * subset of the [OpenAPI schema](https://spec.openapis.org/oas/v3.0.3#schema) @@ -961,83 +936,180 @@ export class GenerationConfig extends S.Class("GenerationConfi */ "presencePenalty": S.optionalWith(S.Number, { nullable: true }), /** - * Optional. Frequency penalty applied to the next token's logprobs, multiplied by the - * number of times each token has been seen in the respponse so far. - * - * A positive penalty will discourage the use of tokens that have already - * been used, proportional to the number of times the token has been used: - * The more a token is used, the more difficult it is for the model to use - * that token again increasing the vocabulary of responses. - * - * Caution: A _negative_ penalty will encourage the model to reuse tokens - * proportional to the number of times the token has been used. Small - * negative values will reduce the vocabulary of a response. Larger negative - * values will cause the model to start repeating a common token until it - * hits the max_output_tokens - * limit. + * Optional. Config for thinking features. + * An error will be returned if this field is set for models that don't + * support thinking. */ - "frequencyPenalty": S.optionalWith(S.Number, { nullable: true }), + "thinkingConfig": S.optionalWith(ThinkingConfig, { nullable: true }), /** - * Optional. If true, export the logprobs results in response. + * Optional. MIME type of the generated candidate text. + * Supported MIME types are: + * `text/plain`: (default) Text output. + * `application/json`: JSON response in the response candidates. + * `text/x.enum`: ENUM as a string response in the response candidates. + * Refer to the + * [docs](https://ai.google.dev/gemini-api/docs/prompting_with_media#plain_text_formats) + * for a list of all supported text MIME types. */ - "responseLogprobs": S.optionalWith(S.Boolean, { nullable: true }), + "responseMimeType": S.optionalWith(S.String, { nullable: true }), /** - * Optional. Only valid if response_logprobs=True. - * This sets the number of top logprobs to return at each decoding step in the - * Candidate.logprobs_result. The number must be in the range of [0, 20]. + * Optional. Config for image generation. + * An error will be returned if this field is set for models that don't + * support these config options. */ - "logprobs": S.optionalWith(S.Int, { nullable: true }), + "imageConfig": S.optionalWith(ImageConfig, { nullable: true }), + /** + * Optional. If specified, the media resolution specified will be used. + */ + "mediaResolution": S.optionalWith(GenerationConfigMediaResolution, { nullable: true }), + /** + * Optional. The set of character sequences (up to 5) that will stop output generation. + * If specified, the API will stop at the first appearance of a + * `stop_sequence`. The stop sequence will not be included as part of the + * response. + */ + "stopSequences": S.optionalWith(S.Array(S.String), { nullable: true }), + /** + * Optional. Number of generated responses to return. If unset, this will default + * to 1. Please note that this doesn't work for previous generation + * models (Gemini 1.0 family) + */ + "candidateCount": S.optionalWith(S.Int, { nullable: true }), + /** + * Optional. Seed used in decoding. If not set, the request uses a randomly generated + * seed. + */ + "seed": S.optionalWith(S.Int, { nullable: true }), /** * Optional. Enables enhanced civic answers. It may not be available for all models. */ "enableEnhancedCivicAnswers": S.optionalWith(S.Boolean, { nullable: true }), /** - * Optional. The requested modalities of the response. Represents the set of modalities - * that the model can return, and should be expected in the response. This is - * an exact match to the modalities of the response. + * Optional. Frequency penalty applied to the next token's logprobs, multiplied by the + * number of times each token has been seen in the respponse so far. * - * A model may have multiple combinations of supported modalities. If the - * requested modalities do not match any of the supported combinations, an - * error will be returned. + * A positive penalty will discourage the use of tokens that have already + * been used, proportional to the number of times the token has been used: + * The more a token is used, the more difficult it is for the model to use + * that token again increasing the vocabulary of responses. * - * An empty list is equivalent to requesting only text. + * Caution: A _negative_ penalty will encourage the model to reuse tokens + * proportional to the number of times the token has been used. Small + * negative values will reduce the vocabulary of a response. Larger negative + * values will cause the model to start repeating a common token until it + * hits the max_output_tokens + * limit. */ - "responseModalities": S.optionalWith(S.Array(S.Literal("MODALITY_UNSPECIFIED", "TEXT", "IMAGE", "AUDIO")), { - nullable: true - }), + "frequencyPenalty": S.optionalWith(S.Number, { nullable: true }), /** - * Optional. The speech generation config. + * Optional. If true, export the logprobs results in response. */ - "speechConfig": S.optionalWith(SpeechConfig, { nullable: true }), + "responseLogprobs": S.optionalWith(S.Boolean, { nullable: true }), /** - * Optional. Config for thinking features. - * An error will be returned if this field is set for models that don't - * support thinking. + * Optional. The maximum cumulative probability of tokens to consider when sampling. + * + * The model uses combined Top-k and Top-p (nucleus) sampling. + * + * Tokens are sorted based on their assigned probabilities so that only the + * most likely tokens are considered. Top-k sampling directly limits the + * maximum number of tokens to consider, while Nucleus sampling limits the + * number of tokens based on the cumulative probability. + * + * Note: The default value varies by `Model` and is specified by + * the`Model.top_p` attribute returned from the `getModel` function. An empty + * `top_k` attribute indicates that the model doesn't apply top-k sampling + * and doesn't allow setting `top_k` on requests. */ - "thinkingConfig": S.optionalWith(ThinkingConfig, { nullable: true }), + "topP": S.optionalWith(S.Number, { nullable: true }), /** - * Optional. If specified, the media resolution specified will be used. + * Optional. Controls the randomness of the output. + * + * Note: The default value varies by model, see the `Model.temperature` + * attribute of the `Model` returned from the `getModel` function. + * + * Values can range from [0.0, 2.0]. */ - "mediaResolution": S.optionalWith(GenerationConfigMediaResolution, { nullable: true }) + "temperature": S.optionalWith(S.Number, { nullable: true }) }) {} /** - * Request to generate a completion from the model. - * NEXT ID: 16 + * An object that represents a latitude/longitude pair. This is expressed as a + * pair of doubles to represent degrees latitude and degrees longitude. Unless + * specified otherwise, this object must conform to the + * WGS84 standard. Values must be within normalized ranges. */ -export class GenerateContentRequest extends S.Class("GenerateContentRequest")({ +export class LatLng extends S.Class("LatLng")({ /** - * Required. The name of the `Model` to use for generating the completion. + * The latitude in degrees. It must be in the range [-90.0, +90.0]. + */ + "latitude": S.optionalWith(S.Number, { nullable: true }), + /** + * The longitude in degrees. It must be in the range [-180.0, +180.0]. + */ + "longitude": S.optionalWith(S.Number, { nullable: true }) +}) {} + +/** + * Retrieval config. + */ +export class RetrievalConfig extends S.Class("RetrievalConfig")({ + /** + * Optional. The location of the user. + */ + "latLng": S.optionalWith(LatLng, { nullable: true }), + /** + * Optional. The language code of the user. + * Language code for content. Use language tags defined by + * [BCP47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt). + */ + "languageCode": S.optionalWith(S.String, { nullable: true }) +}) {} + +/** + * Optional. Specifies the mode in which function calling should execute. If + * unspecified, the default value will be set to AUTO. + */ +export class FunctionCallingConfigMode extends S.Literal("MODE_UNSPECIFIED", "AUTO", "ANY", "NONE", "VALIDATED") {} + +/** + * Configuration for specifying function calling behavior. + */ +export class FunctionCallingConfig extends S.Class("FunctionCallingConfig")({ + /** + * Optional. A set of function names that, when provided, limits the functions the model + * will call. * - * Format: `models/{model}`. + * This should only be set when the Mode is ANY or VALIDATED. Function names + * should match [FunctionDeclaration.name]. When set, model will + * predict a function call from only allowed function names. */ - "model": S.String, + "allowedFunctionNames": S.optionalWith(S.Array(S.String), { nullable: true }), /** - * Optional. Developer set [system - * instruction(s)](https://ai.google.dev/gemini-api/docs/system-instructions). - * Currently, text only. + * Optional. Specifies the mode in which function calling should execute. If + * unspecified, the default value will be set to AUTO. */ - "systemInstruction": S.optionalWith(Content, { nullable: true }), + "mode": S.optionalWith(FunctionCallingConfigMode, { nullable: true }) +}) {} + +/** + * The Tool configuration containing parameters for specifying `Tool` use + * in the request. + */ +export class ToolConfig extends S.Class("ToolConfig")({ + /** + * Optional. Retrieval config. + */ + "retrievalConfig": S.optionalWith(RetrievalConfig, { nullable: true }), + /** + * Optional. Function calling config. + */ + "functionCallingConfig": S.optionalWith(FunctionCallingConfig, { nullable: true }) +}) {} + +/** + * Request to generate a completion from the model. + */ +export class GenerateContentRequest extends S.Class("GenerateContentRequest")({ /** * Required. The content of the current conversation with the model. * @@ -1047,25 +1119,6 @@ export class GenerateContentRequest extends S.Class("Gen * latest request. */ "contents": S.Array(Content), - /** - * Optional. A list of `Tools` the `Model` may use to generate the next response. - * - * A `Tool` is a piece of code that enables the system to interact with - * external systems to perform an action, or set of actions, outside of - * knowledge and scope of the `Model`. Supported `Tool`s are `Function` and - * `code_execution`. Refer to the [Function - * calling](https://ai.google.dev/gemini-api/docs/function-calling) and the - * [Code execution](https://ai.google.dev/gemini-api/docs/code-execution) - * guides to learn more. - */ - "tools": S.optionalWith(S.Array(Tool), { nullable: true }), - /** - * Optional. Tool configuration for any `Tool` specified in the request. Refer to the - * [Function calling - * guide](https://ai.google.dev/gemini-api/docs/function-calling#function_calling_mode) - * for a usage example. - */ - "toolConfig": S.optionalWith(ToolConfig, { nullable: true }), /** * Optional. A list of unique `SafetySetting` instances for blocking unsafe content. * @@ -1086,39 +1139,48 @@ export class GenerateContentRequest extends S.Class("Gen */ "safetySettings": S.optionalWith(S.Array(SafetySetting), { nullable: true }), /** - * Optional. Configuration options for model generation and outputs. + * Required. The name of the `Model` to use for generating the completion. + * + * Format: `models/{model}`. */ - "generationConfig": S.optionalWith(GenerationConfig, { nullable: true }), + "model": S.String, /** * Optional. The name of the content * [cached](https://ai.google.dev/gemini-api/docs/caching) to use as context * to serve the prediction. Format: `cachedContents/{cachedContent}` */ - "cachedContent": S.optionalWith(S.String, { nullable: true }) + "cachedContent": S.optionalWith(S.String, { nullable: true }), + /** + * Optional. Developer set [system + * instruction(s)](https://ai.google.dev/gemini-api/docs/system-instructions). + * Currently, text only. + */ + "systemInstruction": S.optionalWith(Content, { nullable: true }), + /** + * Optional. A list of `Tools` the `Model` may use to generate the next response. + * + * A `Tool` is a piece of code that enables the system to interact with + * external systems to perform an action, or set of actions, outside of + * knowledge and scope of the `Model`. Supported `Tool`s are `Function` and + * `code_execution`. Refer to the [Function + * calling](https://ai.google.dev/gemini-api/docs/function-calling) and the + * [Code execution](https://ai.google.dev/gemini-api/docs/code-execution) + * guides to learn more. + */ + "tools": S.optionalWith(S.Array(Tool), { nullable: true }), + /** + * Optional. Configuration options for model generation and outputs. + */ + "generationConfig": S.optionalWith(GenerationConfig, { nullable: true }), + /** + * Optional. Tool configuration for any `Tool` specified in the request. Refer to the + * [Function calling + * guide](https://ai.google.dev/gemini-api/docs/function-calling#function_calling_mode) + * for a usage example. + */ + "toolConfig": S.optionalWith(ToolConfig, { nullable: true }) }) {} -/** - * Optional. Output only. The reason why the model stopped generating tokens. - * - * If empty, the model has not stopped generating tokens. - */ -export class CandidateFinishReason extends S.Literal( - "FINISH_REASON_UNSPECIFIED", - "STOP", - "MAX_TOKENS", - "SAFETY", - "RECITATION", - "LANGUAGE", - "OTHER", - "BLOCKLIST", - "PROHIBITED_CONTENT", - "SPII", - "MALFORMED_FUNCTION_CALL", - "IMAGE_SAFETY", - "UNEXPECTED_TOOL_CALL", - "TOO_MANY_TOOL_CALLS" -) {} - /** * Required. The probability of harm for this content. */ @@ -1137,17 +1199,52 @@ export class SafetyRatingProbability */ export class SafetyRating extends S.Class("SafetyRating")({ /** - * Required. The category for this rating. + * Was this content blocked because of this rating? */ - "category": HarmCategory, + "blocked": S.optionalWith(S.Boolean, { nullable: true }), /** * Required. The probability of harm for this content. */ "probability": SafetyRatingProbability, /** - * Was this content blocked because of this rating? + * Required. The category for this rating. + */ + "category": HarmCategory +}) {} + +/** + * Status of the url retrieval. + */ +export class UrlMetadataUrlRetrievalStatus extends S.Literal( + "URL_RETRIEVAL_STATUS_UNSPECIFIED", + "URL_RETRIEVAL_STATUS_SUCCESS", + "URL_RETRIEVAL_STATUS_ERROR", + "URL_RETRIEVAL_STATUS_PAYWALL", + "URL_RETRIEVAL_STATUS_UNSAFE" +) {} + +/** + * Context of the a single url retrieval. + */ +export class UrlMetadata extends S.Class("UrlMetadata")({ + /** + * Status of the url retrieval. + */ + "urlRetrievalStatus": S.optionalWith(UrlMetadataUrlRetrievalStatus, { nullable: true }), + /** + * Retrieved url by the tool. */ - "blocked": S.optionalWith(S.Boolean, { nullable: true }) + "retrievedUrl": S.optionalWith(S.String, { nullable: true }) +}) {} + +/** + * Metadata related to url context retrieval tool. + */ +export class UrlContextMetadata extends S.Class("UrlContextMetadata")({ + /** + * List of url context. + */ + "urlMetadata": S.optionalWith(S.Array(UrlMetadata), { nullable: true }) }) {} /** @@ -1160,10 +1257,6 @@ export class CitationSource extends S.Class("CitationSource")({ * Index indicates the start of the segment, measured in bytes. */ "startIndex": S.optionalWith(S.Int, { nullable: true }), - /** - * Optional. End of the attributed segment, exclusive. - */ - "endIndex": S.optionalWith(S.Int, { nullable: true }), /** * Optional. URI that is attributed as a source for a portion of the text. */ @@ -1173,9 +1266,13 @@ export class CitationSource extends S.Class("CitationSource")({ * * License info is required for code citations. */ - "license": S.optionalWith(S.String, { nullable: true }) -}) {} - + "license": S.optionalWith(S.String, { nullable: true }), + /** + * Optional. End of the attributed segment, exclusive. + */ + "endIndex": S.optionalWith(S.Int, { nullable: true }) +}) {} + /** * A collection of source attributions for a piece of content. */ @@ -1186,6 +1283,24 @@ export class CitationMetadata extends S.Class("CitationMetadat "citationSources": S.optionalWith(S.Array(CitationSource), { nullable: true }) }) {} +/** + * Identifier for a `Chunk` retrieved via Semantic Retriever specified in the + * `GenerateAnswerRequest` using `SemanticRetrieverConfig`. + */ +export class SemanticRetrieverChunk extends S.Class("SemanticRetrieverChunk")({ + /** + * Output only. Name of the `Chunk` containing the attributed text. + * Example: `corpora/123/documents/abc/chunks/xyz` + */ + "chunk": S.optionalWith(S.String, { nullable: true }), + /** + * Output only. Name of the source matching the request's + * `SemanticRetrieverConfig.source`. Example: `corpora/123` or + * `corpora/123/documents/abc` + */ + "source": S.optionalWith(S.String, { nullable: true }) +}) {} + /** * Identifier for a part within a `GroundingPassage`. */ @@ -1203,49 +1318,45 @@ export class GroundingPassageId extends S.Class("GroundingPa }) {} /** - * Identifier for a `Chunk` retrieved via Semantic Retriever specified in the - * `GenerateAnswerRequest` using `SemanticRetrieverConfig`. + * Identifier for the source contributing to this attribution. */ -export class SemanticRetrieverChunk extends S.Class("SemanticRetrieverChunk")({ +export class AttributionSourceId extends S.Class("AttributionSourceId")({ /** - * Output only. Name of the source matching the request's - * `SemanticRetrieverConfig.source`. Example: `corpora/123` or - * `corpora/123/documents/abc` + * Identifier for a `Chunk` fetched via Semantic Retriever. */ - "source": S.optionalWith(S.String, { nullable: true }), + "semanticRetrieverChunk": S.optionalWith(SemanticRetrieverChunk, { nullable: true }), /** - * Output only. Name of the `Chunk` containing the attributed text. - * Example: `corpora/123/documents/abc/chunks/xyz` + * Identifier for an inline passage. */ - "chunk": S.optionalWith(S.String, { nullable: true }) + "groundingPassage": S.optionalWith(GroundingPassageId, { nullable: true }) }) {} /** - * Identifier for the source contributing to this attribution. + * Attribution for a source that contributed to an answer. */ -export class AttributionSourceId extends S.Class("AttributionSourceId")({ +export class GroundingAttribution extends S.Class("GroundingAttribution")({ /** - * Identifier for an inline passage. + * Grounding source content that makes up this attribution. */ - "groundingPassage": S.optionalWith(GroundingPassageId, { nullable: true }), + "content": S.optionalWith(Content, { nullable: true }), /** - * Identifier for a `Chunk` fetched via Semantic Retriever. + * Output only. Identifier for the source contributing to this attribution. */ - "semanticRetrieverChunk": S.optionalWith(SemanticRetrieverChunk, { nullable: true }) + "sourceId": S.optionalWith(AttributionSourceId, { nullable: true }) }) {} /** - * Attribution for a source that contributed to an answer. + * Metadata related to retrieval in the grounding flow. */ -export class GroundingAttribution extends S.Class("GroundingAttribution")({ - /** - * Output only. Identifier for the source contributing to this attribution. - */ - "sourceId": S.optionalWith(AttributionSourceId, { nullable: true }), +export class RetrievalMetadata extends S.Class("RetrievalMetadata")({ /** - * Grounding source content that makes up this attribution. + * Optional. Score indicating how likely information from google search could help + * answer the prompt. The score is in the range [0, 1], where 0 is the least + * likely and 1 is the most likely. This score is only populated when + * google search grounding and dynamic retrieval is enabled. It will be + * compared to the threshold to determine whether to trigger google search. */ - "content": S.optionalWith(Content, { nullable: true }) + "googleSearchDynamicRetrievalScore": S.optionalWith(S.Number, { nullable: true }) }) {} /** @@ -1253,13 +1364,13 @@ export class GroundingAttribution extends S.Class("Groundi */ export class SearchEntryPoint extends S.Class("SearchEntryPoint")({ /** - * Optional. Web content snippet that can be embedded in a web page or an app webview. + * Optional. Base64 encoded JSON representing array of tuple. */ - "renderedContent": S.optionalWith(S.String, { nullable: true }), + "sdkBlob": S.optionalWith(S.String, { nullable: true }), /** - * Optional. Base64 encoded JSON representing array of tuple. + * Optional. Web content snippet that can be embedded in a web page or an app webview. */ - "sdkBlob": S.optionalWith(S.String, { nullable: true }) + "renderedContent": S.optionalWith(S.String, { nullable: true }) }) {} /** @@ -1276,6 +1387,93 @@ export class Web extends S.Class("Web")({ "title": S.optionalWith(S.String, { nullable: true }) }) {} +/** + * Chunk from context retrieved by the file search tool. + */ +export class RetrievedContext extends S.Class("RetrievedContext")({ + /** + * Optional. Name of the `FileSearchStore` containing the document. + * Example: `fileSearchStores/123` + */ + "fileSearchStore": S.optionalWith(S.String, { nullable: true }), + /** + * Optional. Title of the document. + */ + "title": S.optionalWith(S.String, { nullable: true }), + /** + * Optional. URI reference of the semantic retrieval document. + */ + "uri": S.optionalWith(S.String, { nullable: true }), + /** + * Optional. Text of the chunk. + */ + "text": S.optionalWith(S.String, { nullable: true }) +}) {} + +/** + * Encapsulates a snippet of a user review that answers a question about + * the features of a specific place in Google Maps. + */ +export class ReviewSnippet extends S.Class("ReviewSnippet")({ + /** + * The ID of the review snippet. + */ + "reviewId": S.optionalWith(S.String, { nullable: true }), + /** + * Title of the review. + */ + "title": S.optionalWith(S.String, { nullable: true }), + /** + * A link that corresponds to the user review on Google Maps. + */ + "googleMapsUri": S.optionalWith(S.String, { nullable: true }) +}) {} + +/** + * Collection of sources that provide answers about the features of a given + * place in Google Maps. Each PlaceAnswerSources message corresponds to a + * specific place in Google Maps. The Google Maps tool used these sources in + * order to answer questions about features of the place (e.g: "does Bar Foo + * have Wifi" or "is Foo Bar wheelchair accessible?"). Currently we only + * support review snippets as sources. + */ +export class PlaceAnswerSources extends S.Class("PlaceAnswerSources")({ + /** + * Snippets of reviews that are used to generate answers about the + * features of a given place in Google Maps. + */ + "reviewSnippets": S.optionalWith(S.Array(ReviewSnippet), { nullable: true }) +}) {} + +/** + * A grounding chunk from Google Maps. A Maps chunk corresponds to a single + * place. + */ +export class Maps extends S.Class("Maps")({ + /** + * Sources that provide answers about the features of a given place in + * Google Maps. + */ + "placeAnswerSources": S.optionalWith(PlaceAnswerSources, { nullable: true }), + /** + * Title of the place. + */ + "title": S.optionalWith(S.String, { nullable: true }), + /** + * Text description of the place answer. + */ + "text": S.optionalWith(S.String, { nullable: true }), + /** + * This ID of the place, in `places/{place_id}` format. A user can use this + * ID to look up that place. + */ + "placeId": S.optionalWith(S.String, { nullable: true }), + /** + * URI reference of the place. + */ + "uri": S.optionalWith(S.String, { nullable: true }) +}) {} + /** * Grounding chunk. */ @@ -1283,41 +1481,45 @@ export class GroundingChunk extends S.Class("GroundingChunk")({ /** * Grounding chunk from the web. */ - "web": S.optionalWith(Web, { nullable: true }) + "web": S.optionalWith(Web, { nullable: true }), + /** + * Optional. Grounding chunk from context retrieved by the file search tool. + */ + "retrievedContext": S.optionalWith(RetrievedContext, { nullable: true }), + /** + * Optional. Grounding chunk from Google Maps. + */ + "maps": S.optionalWith(Maps, { nullable: true }) }) {} /** * Segment of the content. */ export class Segment extends S.Class("Segment")({ - /** - * Output only. The index of a Part object within its parent Content object. - */ - "partIndex": S.optionalWith(S.Int, { nullable: true }), - /** - * Output only. Start index in the given Part, measured in bytes. Offset from the start of - * the Part, inclusive, starting at zero. - */ - "startIndex": S.optionalWith(S.Int, { nullable: true }), /** * Output only. End index in the given Part, measured in bytes. Offset from the start of * the Part, exclusive, starting at zero. */ "endIndex": S.optionalWith(S.Int, { nullable: true }), + /** + * Output only. The index of a Part object within its parent Content object. + */ + "partIndex": S.optionalWith(S.Int, { nullable: true }), /** * Output only. The text corresponding to the segment from the response. */ - "text": S.optionalWith(S.String, { nullable: true }) + "text": S.optionalWith(S.String, { nullable: true }), + /** + * Output only. Start index in the given Part, measured in bytes. Offset from the start of + * the Part, inclusive, starting at zero. + */ + "startIndex": S.optionalWith(S.Int, { nullable: true }) }) {} /** * Grounding support. */ export class GroundingSupport extends S.Class("GroundingSupport")({ - /** - * Segment of the content this support belongs to. - */ - "segment": S.optionalWith(Segment, { nullable: true }), /** * A list of indices (into 'grounding_chunk') specifying the * citations associated with the claim. For instance [1,3,4] means @@ -1330,31 +1532,35 @@ export class GroundingSupport extends S.Class("GroundingSuppor * most confident. This list must have the same size as the * grounding_chunk_indices. */ - "confidenceScores": S.optionalWith(S.Array(S.Number), { nullable: true }) -}) {} - -/** - * Metadata related to retrieval in the grounding flow. - */ -export class RetrievalMetadata extends S.Class("RetrievalMetadata")({ + "confidenceScores": S.optionalWith(S.Array(S.Number), { nullable: true }), /** - * Optional. Score indicating how likely information from google search could help - * answer the prompt. The score is in the range [0, 1], where 0 is the least - * likely and 1 is the most likely. This score is only populated when - * google search grounding and dynamic retrieval is enabled. It will be - * compared to the threshold to determine whether to trigger google search. + * Segment of the content this support belongs to. */ - "googleSearchDynamicRetrievalScore": S.optionalWith(S.Number, { nullable: true }) + "segment": S.optionalWith(Segment, { nullable: true }) }) {} /** * Metadata returned to client when grounding is enabled. */ export class GroundingMetadata extends S.Class("GroundingMetadata")({ + /** + * Metadata related to retrieval in the grounding flow. + */ + "retrievalMetadata": S.optionalWith(RetrievalMetadata, { nullable: true }), + /** + * Optional. Resource name of the Google Maps widget context token that can be used + * with the PlacesContextElement widget in order to render contextual data. + * Only populated in the case that grounding with Google Maps is enabled. + */ + "googleMapsWidgetContextToken": S.optionalWith(S.String, { nullable: true }), /** * Optional. Google search entry for the following-up web searches. */ "searchEntryPoint": S.optionalWith(SearchEntryPoint, { nullable: true }), + /** + * Web search queries for the following-up web search. + */ + "webSearchQueries": S.optionalWith(S.Array(S.String), { nullable: true }), /** * List of supporting references retrieved from specified grounding source. */ @@ -1362,21 +1568,44 @@ export class GroundingMetadata extends S.Class("GroundingMeta /** * List of grounding support. */ - "groundingSupports": S.optionalWith(S.Array(GroundingSupport), { nullable: true }), - /** - * Metadata related to retrieval in the grounding flow. - */ - "retrievalMetadata": S.optionalWith(RetrievalMetadata, { nullable: true }), - /** - * Web search queries for the following-up web search. - */ - "webSearchQueries": S.optionalWith(S.Array(S.String), { nullable: true }) + "groundingSupports": S.optionalWith(S.Array(GroundingSupport), { nullable: true }) }) {} +/** + * Optional. Output only. The reason why the model stopped generating tokens. + * + * If empty, the model has not stopped generating tokens. + */ +export class CandidateFinishReason extends S.Literal( + "FINISH_REASON_UNSPECIFIED", + "STOP", + "MAX_TOKENS", + "SAFETY", + "RECITATION", + "LANGUAGE", + "OTHER", + "BLOCKLIST", + "PROHIBITED_CONTENT", + "SPII", + "MALFORMED_FUNCTION_CALL", + "IMAGE_SAFETY", + "IMAGE_PROHIBITED_CONTENT", + "IMAGE_OTHER", + "NO_IMAGE", + "IMAGE_RECITATION", + "UNEXPECTED_TOOL_CALL", + "TOO_MANY_TOOL_CALLS", + "MISSING_THOUGHT_SIGNATURE" +) {} + /** * Candidate for the logprobs token and score. */ export class LogprobsResultCandidate extends S.Class("LogprobsResultCandidate")({ + /** + * The candidate's log probability. + */ + "logProbability": S.optionalWith(S.Number, { nullable: true }), /** * The candidate’s token string value. */ @@ -1384,11 +1613,7 @@ export class LogprobsResultCandidate extends S.Class("L /** * The candidate’s token id value. */ - "tokenId": S.optionalWith(S.Int, { nullable: true }), - /** - * The candidate's log probability. - */ - "logProbability": S.optionalWith(S.Number, { nullable: true }) + "tokenId": S.optionalWith(S.Int, { nullable: true }) }) {} /** @@ -1413,42 +1638,11 @@ export class LogprobsResult extends S.Class("LogprobsResult")({ * Length = total number of decoding steps. * The chosen candidates may or may not be in top_candidates. */ - "chosenCandidates": S.optionalWith(S.Array(LogprobsResultCandidate), { nullable: true }) -}) {} - -/** - * Status of the url retrieval. - */ -export class UrlMetadataUrlRetrievalStatus extends S.Literal( - "URL_RETRIEVAL_STATUS_UNSPECIFIED", - "URL_RETRIEVAL_STATUS_SUCCESS", - "URL_RETRIEVAL_STATUS_ERROR", - "URL_RETRIEVAL_STATUS_PAYWALL", - "URL_RETRIEVAL_STATUS_UNSAFE" -) {} - -/** - * Context of the a single url retrieval. - */ -export class UrlMetadata extends S.Class("UrlMetadata")({ - /** - * Retrieved url by the tool. - */ - "retrievedUrl": S.optionalWith(S.String, { nullable: true }), - /** - * Status of the url retrieval. - */ - "urlRetrievalStatus": S.optionalWith(UrlMetadataUrlRetrievalStatus, { nullable: true }) -}) {} - -/** - * Metadata related to url context retrieval tool. - */ -export class UrlContextMetadata extends S.Class("UrlContextMetadata")({ + "chosenCandidates": S.optionalWith(S.Array(LogprobsResultCandidate), { nullable: true }), /** - * List of url context. + * Sum of log probabilities for all tokens. */ - "urlMetadata": S.optionalWith(S.Array(UrlMetadata), { nullable: true }) + "logProbabilitySum": S.optionalWith(S.Number, { nullable: true }) }) {} /** @@ -1456,25 +1650,23 @@ export class UrlContextMetadata extends S.Class("UrlContextM */ export class Candidate extends S.Class("Candidate")({ /** - * Output only. Index of the candidate in the list of response candidates. + * List of ratings for the safety of a response candidate. + * + * There is at most one rating per category. */ - "index": S.optionalWith(S.Int, { nullable: true }), + "safetyRatings": S.optionalWith(S.Array(SafetyRating), { nullable: true }), /** - * Output only. Generated content returned from the model. + * Output only. Average log probability score of the candidate. */ - "content": S.optionalWith(Content, { nullable: true }), + "avgLogprobs": S.optionalWith(S.Number, { nullable: true }), /** - * Optional. Output only. The reason why the model stopped generating tokens. - * - * If empty, the model has not stopped generating tokens. + * Output only. Metadata related to url context retrieval tool. */ - "finishReason": S.optionalWith(CandidateFinishReason, { nullable: true }), + "urlContextMetadata": S.optionalWith(UrlContextMetadata, { nullable: true }), /** - * List of ratings for the safety of a response candidate. - * - * There is at most one rating per category. + * Output only. Index of the candidate in the list of response candidates. */ - "safetyRatings": S.optionalWith(S.Array(SafetyRating), { nullable: true }), + "index": S.optionalWith(S.Int, { nullable: true }), /** * Output only. Citation information for model-generated candidate. * @@ -1483,10 +1675,6 @@ export class Candidate extends S.Class("Candidate")({ * copyrighted material in the foundational LLM's training data. */ "citationMetadata": S.optionalWith(CitationMetadata, { nullable: true }), - /** - * Output only. Token count for this candidate. - */ - "tokenCount": S.optionalWith(S.Int, { nullable: true }), /** * Output only. Attribution information for sources that contributed to a grounded answer. * @@ -1500,42 +1688,28 @@ export class Candidate extends S.Class("Candidate")({ */ "groundingMetadata": S.optionalWith(GroundingMetadata, { nullable: true }), /** - * Output only. Average log probability score of the candidate. + * Optional. Output only. The reason why the model stopped generating tokens. + * + * If empty, the model has not stopped generating tokens. */ - "avgLogprobs": S.optionalWith(S.Number, { nullable: true }), + "finishReason": S.optionalWith(CandidateFinishReason, { nullable: true }), + /** + * Optional. Output only. Details the reason why the model stopped generating tokens. + * This is populated only when `finish_reason` is set. + */ + "finishMessage": S.optionalWith(S.String, { nullable: true }), /** * Output only. Log-likelihood scores for the response tokens and top tokens */ "logprobsResult": S.optionalWith(LogprobsResult, { nullable: true }), /** - * Output only. Metadata related to url context retrieval tool. - */ - "urlContextMetadata": S.optionalWith(UrlContextMetadata, { nullable: true }) -}) {} - -/** - * Optional. If set, the prompt was blocked and no candidates are returned. - * Rephrase the prompt. - */ -export class PromptFeedbackBlockReason - extends S.Literal("BLOCK_REASON_UNSPECIFIED", "SAFETY", "OTHER", "BLOCKLIST", "PROHIBITED_CONTENT", "IMAGE_SAFETY") -{} - -/** - * A set of the feedback metadata the prompt specified in - * `GenerateContentRequest.content`. - */ -export class PromptFeedback extends S.Class("PromptFeedback")({ - /** - * Optional. If set, the prompt was blocked and no candidates are returned. - * Rephrase the prompt. + * Output only. Generated content returned from the model. */ - "blockReason": S.optionalWith(PromptFeedbackBlockReason, { nullable: true }), + "content": S.optionalWith(Content, { nullable: true }), /** - * Ratings for safety of the prompt. - * There is at most one rating per category. + * Output only. Token count for this candidate. */ - "safetyRatings": S.optionalWith(S.Array(SafetyRating), { nullable: true }) + "tokenCount": S.optionalWith(S.Int, { nullable: true }) }) {} export class GenerativeLanguageModality @@ -1547,62 +1721,87 @@ export class GenerativeLanguageModality */ export class ModalityTokenCount extends S.Class("ModalityTokenCount")({ /** - * The modality associated with this token count. + * Number of tokens. */ - "modality": S.optionalWith(GenerativeLanguageModality, { nullable: true }), + "tokenCount": S.optionalWith(S.Int, { nullable: true }), /** - * Number of tokens. + * The modality associated with this token count. */ - "tokenCount": S.optionalWith(S.Int, { nullable: true }) + "modality": S.optionalWith(GenerativeLanguageModality, { nullable: true }) }) {} /** * Metadata on the generation request's token usage. */ export class UsageMetadata extends S.Class("UsageMetadata")({ - /** - * Number of tokens in the prompt. When `cached_content` is set, this is - * still the total effective prompt size meaning this includes the number of - * tokens in the cached content. - */ - "promptTokenCount": S.optionalWith(S.Int, { nullable: true }), /** * Number of tokens in the cached part of the prompt (the cached content) */ "cachedContentTokenCount": S.optionalWith(S.Int, { nullable: true }), /** - * Total number of tokens across all the generated response candidates. + * Output only. List of modalities that were processed in the request input. */ - "candidatesTokenCount": S.optionalWith(S.Int, { nullable: true }), + "promptTokensDetails": S.optionalWith(S.Array(ModalityTokenCount), { nullable: true }), /** - * Output only. Number of tokens present in tool-use prompt(s). + * Number of tokens in the prompt. When `cached_content` is set, this is + * still the total effective prompt size meaning this includes the number of + * tokens in the cached content. */ - "toolUsePromptTokenCount": S.optionalWith(S.Int, { nullable: true }), + "promptTokenCount": S.optionalWith(S.Int, { nullable: true }), /** - * Output only. Number of tokens of thoughts for thinking models. + * Total number of tokens across all the generated response candidates. */ - "thoughtsTokenCount": S.optionalWith(S.Int, { nullable: true }), + "candidatesTokenCount": S.optionalWith(S.Int, { nullable: true }), /** * Total token count for the generation request (prompt + response * candidates). */ "totalTokenCount": S.optionalWith(S.Int, { nullable: true }), /** - * Output only. List of modalities that were processed in the request input. + * Output only. Number of tokens present in tool-use prompt(s). */ - "promptTokensDetails": S.optionalWith(S.Array(ModalityTokenCount), { nullable: true }), + "toolUsePromptTokenCount": S.optionalWith(S.Int, { nullable: true }), + /** + * Output only. List of modalities that were processed for tool-use request inputs. + */ + "toolUsePromptTokensDetails": S.optionalWith(S.Array(ModalityTokenCount), { nullable: true }), /** * Output only. List of modalities of the cached content in the request input. */ "cacheTokensDetails": S.optionalWith(S.Array(ModalityTokenCount), { nullable: true }), + /** + * Output only. Number of tokens of thoughts for thinking models. + */ + "thoughtsTokenCount": S.optionalWith(S.Int, { nullable: true }), /** * Output only. List of modalities that were returned in the response. */ - "candidatesTokensDetails": S.optionalWith(S.Array(ModalityTokenCount), { nullable: true }), + "candidatesTokensDetails": S.optionalWith(S.Array(ModalityTokenCount), { nullable: true }) +}) {} + +/** + * Optional. If set, the prompt was blocked and no candidates are returned. + * Rephrase the prompt. + */ +export class PromptFeedbackBlockReason + extends S.Literal("BLOCK_REASON_UNSPECIFIED", "SAFETY", "OTHER", "BLOCKLIST", "PROHIBITED_CONTENT", "IMAGE_SAFETY") +{} + +/** + * A set of the feedback metadata the prompt specified in + * `GenerateContentRequest.content`. + */ +export class PromptFeedback extends S.Class("PromptFeedback")({ + /** + * Optional. If set, the prompt was blocked and no candidates are returned. + * Rephrase the prompt. + */ + "blockReason": S.optionalWith(PromptFeedbackBlockReason, { nullable: true }), /** - * Output only. List of modalities that were processed for tool-use request inputs. + * Ratings for safety of the prompt. + * There is at most one rating per category. */ - "toolUsePromptTokensDetails": S.optionalWith(S.Array(ModalityTokenCount), { nullable: true }) + "safetyRatings": S.optionalWith(S.Array(SafetyRating), { nullable: true }) }) {} /** @@ -1618,416 +1817,523 @@ export class UsageMetadata extends S.Class("UsageMetadata")({ * `safety_ratings`. */ export class GenerateContentResponse extends S.Class("GenerateContentResponse")({ + /** + * Output only. response_id is used to identify each response. + */ + "responseId": S.optionalWith(S.String, { nullable: true }), /** * Candidate responses from the model. */ "candidates": S.optionalWith(S.Array(Candidate), { nullable: true }), /** - * Returns the prompt's feedback related to the content filters. + * Output only. The model version used to generate the response. */ - "promptFeedback": S.optionalWith(PromptFeedback, { nullable: true }), + "modelVersion": S.optionalWith(S.String, { nullable: true }), /** * Output only. Metadata on the generation requests' token usage. */ "usageMetadata": S.optionalWith(UsageMetadata, { nullable: true }), /** - * Output only. The model version used to generate the response. - */ - "modelVersion": S.optionalWith(S.String, { nullable: true }), - /** - * Output only. response_id is used to identify each response. + * Returns the prompt's feedback related to the content filters. */ - "responseId": S.optionalWith(S.String, { nullable: true }) + "promptFeedback": S.optionalWith(PromptFeedback, { nullable: true }) }) {} /** - * Passage included inline with a grounding configuration. + * The `Status` type defines a logical error model that is suitable for + * different programming environments, including REST APIs and RPC APIs. It is + * used by [gRPC](https://github.com/grpc). Each `Status` message contains + * three pieces of data: error code, error message, and error details. + * + * You can find out more about this error model and how to work with it in the + * [API Design Guide](https://cloud.google.com/apis/design/errors). */ -export class GroundingPassage extends S.Class("GroundingPassage")({ +export class Status extends S.Class("Status")({ /** - * Identifier for the passage for attributing this passage in grounded - * answers. + * The status code, which should be an enum value of google.rpc.Code. */ - "id": S.optionalWith(S.String, { nullable: true }), + "code": S.optionalWith(S.Int, { nullable: true }), /** - * Content of the passage. + * A list of messages that carry the error details. There is a common set of + * message types for APIs to use. */ - "content": S.optionalWith(Content, { nullable: true }) -}) {} - -/** - * A repeated list of passages. - */ -export class GroundingPassages extends S.Class("GroundingPassages")({ + "details": S.optionalWith(S.Array(S.Record({ key: S.String, value: S.Unknown })), { nullable: true }), /** - * List of passages. + * A developer-facing error message, which should be in English. Any + * user-facing error message should be localized and sent in the + * google.rpc.Status.details field, or localized by the client. */ - "passages": S.optionalWith(S.Array(GroundingPassage), { nullable: true }) + "message": S.optionalWith(S.String, { nullable: true }) }) {} /** - * Required. Operator applied to the given key-value pair to trigger the condition. - */ -export class ConditionOperation extends S.Literal( - "OPERATOR_UNSPECIFIED", - "LESS", - "LESS_EQUAL", - "EQUAL", - "GREATER_EQUAL", - "GREATER", - "NOT_EQUAL", - "INCLUDES", - "EXCLUDES" -) {} - -/** - * Filter condition applicable to a single key. + * This resource represents a long-running operation that is the result of a + * network API call. */ -export class Condition extends S.Class("Condition")({ +export class Operation extends S.Class("Operation")({ /** - * The string value to filter the metadata on. + * The normal, successful response of the operation. If the original + * method returns no data on success, such as `Delete`, the response is + * `google.protobuf.Empty`. If the original method is standard + * `Get`/`Create`/`Update`, the response should be the resource. For other + * methods, the response should have the type `XxxResponse`, where `Xxx` + * is the original method name. For example, if the original method name + * is `TakeSnapshot()`, the inferred response type is + * `TakeSnapshotResponse`. */ - "stringValue": S.optionalWith(S.String, { nullable: true }), + "response": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true }), /** - * The numeric value to filter the metadata on. + * Service-specific metadata associated with the operation. It typically + * contains progress information and common metadata such as create time. + * Some services might not provide such metadata. Any method that returns a + * long-running operation should document the metadata type, if any. */ - "numericValue": S.optionalWith(S.Number, { nullable: true }), + "metadata": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true }), /** - * Required. Operator applied to the given key-value pair to trigger the condition. + * The error result of the operation in case of failure or cancellation. */ - "operation": ConditionOperation -}) {} - -/** - * User provided filter to limit retrieval based on `Chunk` or `Document` level - * metadata values. - * Example (genre = drama OR genre = action): - * key = "document.custom_metadata.genre" - * conditions = [{string_value = "drama", operation = EQUAL}, - * {string_value = "action", operation = EQUAL}] - */ -export class MetadataFilter extends S.Class("MetadataFilter")({ + "error": S.optionalWith(Status, { nullable: true }), /** - * Required. The key of the metadata to filter on. + * If the value is `false`, it means the operation is still in progress. + * If `true`, the operation is completed, and either `error` or `response` is + * available. */ - "key": S.String, + "done": S.optionalWith(S.Boolean, { nullable: true }), /** - * Required. The `Condition`s for the given key that will trigger this filter. Multiple - * `Condition`s are joined by logical ORs. + * The server-assigned name, which is only unique within the same service that + * originally returns it. If you use the default HTTP mapping, the + * `name` should be a resource name ending with `operations/{unique_id}`. */ - "conditions": S.Array(Condition) + "name": S.optionalWith(S.String, { nullable: true }) }) {} /** - * Configuration for retrieving grounding content from a `Corpus` or - * `Document` created using the Semantic Retriever API. + * A generic empty message that you can re-use to avoid defining duplicated + * empty messages in your APIs. A typical example is to use it as the request + * or the response type of an API method. For instance: + * + * service Foo { + * rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); + * } */ -export class SemanticRetrieverConfig extends S.Class("SemanticRetrieverConfig")({ - /** - * Required. Name of the resource for retrieval. Example: `corpora/123` or - * `corpora/123/documents/abc`. - */ - "source": S.String, - /** - * Required. Query to use for matching `Chunk`s in the given resource by similarity. - */ - "query": Content, - /** - * Optional. Filters for selecting `Document`s and/or `Chunk`s from the resource. - */ - "metadataFilters": S.optionalWith(S.Array(MetadataFilter), { nullable: true }), - /** - * Optional. Maximum number of relevant `Chunk`s to retrieve. - */ - "maxChunksCount": S.optionalWith(S.Int, { nullable: true }), - /** - * Optional. Minimum relevance score for retrieved relevant `Chunk`s. - */ - "minimumRelevanceScore": S.optionalWith(S.Number, { nullable: true }) -}) {} +export class Empty extends S.Record({ key: S.String, value: S.Unknown }) {} /** - * Required. Style in which answers should be returned. + * Text given to the model as a prompt. + * + * The Model will use this TextPrompt to Generate a text completion. */ -export class GenerateAnswerRequestAnswerStyle - extends S.Literal("ANSWER_STYLE_UNSPECIFIED", "ABSTRACTIVE", "EXTRACTIVE", "VERBOSE") -{} +export class TextPrompt extends S.Class("TextPrompt")({ + /** + * Required. The prompt text. + */ + "text": S.String +}) {} /** - * Request to generate a grounded answer from the `Model`. + * Request to generate a text completion response from the model. */ -export class GenerateAnswerRequest extends S.Class("GenerateAnswerRequest")({ - /** - * Passages provided inline with the request. - */ - "inlinePassages": S.optionalWith(GroundingPassages, { nullable: true }), +export class GenerateTextRequest extends S.Class("GenerateTextRequest")({ /** - * Content retrieved from resources created via the Semantic Retriever - * API. + * The set of character sequences (up to 5) that will stop output generation. + * If specified, the API will stop at the first appearance of a stop + * sequence. The stop sequence will not be included as part of the response. */ - "semanticRetriever": S.optionalWith(SemanticRetrieverConfig, { nullable: true }), + "stopSequences": S.optionalWith(S.Array(S.String), { nullable: true }), /** - * Required. The content of the current conversation with the `Model`. For single-turn - * queries, this is a single question to answer. For multi-turn queries, this - * is a repeated field that contains conversation history and the last - * `Content` in the list containing the question. + * Optional. The maximum number of tokens to consider when sampling. * - * Note: `GenerateAnswer` only supports queries in English. + * The model uses combined Top-k and nucleus sampling. + * + * Top-k sampling considers the set of `top_k` most probable tokens. + * Defaults to 40. + * + * Note: The default value varies by model, see the `Model.top_k` + * attribute of the `Model` returned the `getModel` function. */ - "contents": S.Array(Content), + "topK": S.optionalWith(S.Int, { nullable: true }), /** - * Required. Style in which answers should be returned. + * Optional. Number of generated responses to return. + * + * This value must be between [1, 8], inclusive. If unset, this will default + * to 1. */ - "answerStyle": GenerateAnswerRequestAnswerStyle, + "candidateCount": S.optionalWith(S.Int, { nullable: true }), /** * Optional. A list of unique `SafetySetting` instances for blocking unsafe content. * - * This will be enforced on the `GenerateAnswerRequest.contents` and - * `GenerateAnswerResponse.candidate`. There should not be more than one - * setting for each `SafetyCategory` type. The API will block any contents and + * that will be enforced on the `GenerateTextRequest.prompt` and + * `GenerateTextResponse.candidates`. There should not be more than one + * setting for each `SafetyCategory` type. The API will block any prompts and * responses that fail to meet the thresholds set by these settings. This list * overrides the default settings for each `SafetyCategory` specified in the * safety_settings. If there is no `SafetySetting` for a given * `SafetyCategory` provided in the list, the API will use the default safety - * setting for that category. Harm categories HARM_CATEGORY_HATE_SPEECH, - * HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT, - * HARM_CATEGORY_HARASSMENT are supported. - * Refer to the - * [guide](https://ai.google.dev/gemini-api/docs/safety-settings) - * for detailed information on available safety settings. Also refer to the - * [Safety guidance](https://ai.google.dev/gemini-api/docs/safety-guidance) to - * learn how to incorporate safety considerations in your AI applications. + * setting for that category. Harm categories HARM_CATEGORY_DEROGATORY, + * HARM_CATEGORY_TOXICITY, HARM_CATEGORY_VIOLENCE, HARM_CATEGORY_SEXUAL, + * HARM_CATEGORY_MEDICAL, HARM_CATEGORY_DANGEROUS are supported in text + * service. */ "safetySettings": S.optionalWith(S.Array(SafetySetting), { nullable: true }), + /** + * Optional. The maximum cumulative probability of tokens to consider when sampling. + * + * The model uses combined Top-k and nucleus sampling. + * + * Tokens are sorted based on their assigned probabilities so that only the + * most likely tokens are considered. Top-k sampling directly limits the + * maximum number of tokens to consider, while Nucleus sampling limits number + * of tokens based on the cumulative probability. + * + * Note: The default value varies by model, see the `Model.top_p` + * attribute of the `Model` returned the `getModel` function. + */ + "topP": S.optionalWith(S.Number, { nullable: true }), + /** + * Required. The free-form input text given to the model as a prompt. + * + * Given a prompt, the model will generate a TextCompletion response it + * predicts as the completion of the input text. + */ + "prompt": TextPrompt, + /** + * Optional. The maximum number of tokens to include in a candidate. + * + * If unset, this will default to output_token_limit specified in the `Model` + * specification. + */ + "maxOutputTokens": S.optionalWith(S.Int, { nullable: true }), /** * Optional. Controls the randomness of the output. + * Note: The default value varies by model, see the `Model.temperature` + * attribute of the `Model` returned the `getModel` function. * - * Values can range from [0.0,1.0], inclusive. A value closer to 1.0 will - * produce responses that are more varied and creative, while a value closer - * to 0.0 will typically result in more straightforward responses from the - * model. A low temperature (~0.2) is usually recommended for - * Attributed-Question-Answering use cases. + * Values can range from [0.0,1.0], + * inclusive. A value closer to 1.0 will produce responses that are more + * varied and creative, while a value closer to 0.0 will typically result in + * more straightforward responses from the model. */ "temperature": S.optionalWith(S.Number, { nullable: true }) }) {} /** - * Optional. If set, the input was blocked and no candidates are returned. - * Rephrase the input. + * Safety feedback for an entire request. + * + * This field is populated if content in the input and/or response is blocked + * due to safety settings. SafetyFeedback may not exist for every HarmCategory. + * Each SafetyFeedback will return the safety settings used by the request as + * well as the lowest HarmProbability that should be allowed in order to return + * a result. */ -export class InputFeedbackBlockReason extends S.Literal("BLOCK_REASON_UNSPECIFIED", "SAFETY", "OTHER") {} +export class SafetyFeedback extends S.Class("SafetyFeedback")({ + /** + * Safety rating evaluated from content. + */ + "rating": S.optionalWith(SafetyRating, { nullable: true }), + /** + * Safety settings applied to the request. + */ + "setting": S.optionalWith(SafetySetting, { nullable: true }) +}) {} /** - * Feedback related to the input data used to answer the question, as opposed - * to the model-generated response to the question. + * The reason content was blocked during request processing. */ -export class InputFeedback extends S.Class("InputFeedback")({ +export class ContentFilterReason extends S.Literal("BLOCKED_REASON_UNSPECIFIED", "SAFETY", "OTHER") {} + +/** + * Content filtering metadata associated with processing a single request. + * + * ContentFilter contains a reason and an optional supporting string. The reason + * may be unspecified. + */ +export class ContentFilter extends S.Class("ContentFilter")({ /** - * Optional. If set, the input was blocked and no candidates are returned. - * Rephrase the input. + * The reason content was blocked during request processing. */ - "blockReason": S.optionalWith(InputFeedbackBlockReason, { nullable: true }), + "reason": S.optionalWith(ContentFilterReason, { nullable: true }), /** - * Ratings for safety of the input. - * There is at most one rating per category. + * A string that describes the filtering behavior in more detail. */ - "safetyRatings": S.optionalWith(S.Array(SafetyRating), { nullable: true }) + "message": S.optionalWith(S.String, { nullable: true }) }) {} /** - * Response from the model for a grounded answer. + * Output text returned from a model. */ -export class GenerateAnswerResponse extends S.Class("GenerateAnswerResponse")({ +export class TextCompletion extends S.Class("TextCompletion")({ /** - * Candidate answer from the model. - * - * Note: The model *always* attempts to provide a grounded answer, even when - * the answer is unlikely to be answerable from the given passages. - * In that case, a low-quality or ungrounded answer may be provided, along - * with a low `answerable_probability`. + * Output only. The generated text returned from the model. */ - "answer": S.optionalWith(Candidate, { nullable: true }), + "output": S.optionalWith(S.String, { nullable: true }), /** - * Output only. The model's estimate of the probability that its answer is correct and - * grounded in the input passages. - * - * A low `answerable_probability` indicates that the answer might not be - * grounded in the sources. - * - * When `answerable_probability` is low, you may want to: + * Ratings for the safety of a response. * - * * Display a message to the effect of "We couldn’t answer that question" to - * the user. - * * Fall back to a general-purpose LLM that answers the question from world - * knowledge. The threshold and nature of such fallbacks will depend on - * individual use cases. `0.5` is a good starting threshold. + * There is at most one rating per category. */ - "answerableProbability": S.optionalWith(S.Number, { nullable: true }), + "safetyRatings": S.optionalWith(S.Array(SafetyRating), { nullable: true }), /** - * Output only. Feedback related to the input data used to answer the question, as opposed - * to the model-generated response to the question. - * - * The input data can be one or more of the following: + * Output only. Citation information for model-generated `output` in this + * `TextCompletion`. * - * - Question specified by the last entry in `GenerateAnswerRequest.content` - * - Conversation history specified by the other entries in - * `GenerateAnswerRequest.content` - * - Grounding sources (`GenerateAnswerRequest.semantic_retriever` or - * `GenerateAnswerRequest.inline_passages`) + * This field may be populated with attribution information for any text + * included in the `output`. */ - "inputFeedback": S.optionalWith(InputFeedback, { nullable: true }) + "citationMetadata": S.optionalWith(CitationMetadata, { nullable: true }) }) {} -export class TaskType extends S.Literal( - "TASK_TYPE_UNSPECIFIED", - "RETRIEVAL_QUERY", - "RETRIEVAL_DOCUMENT", - "SEMANTIC_SIMILARITY", - "CLASSIFICATION", - "CLUSTERING", - "QUESTION_ANSWERING", - "FACT_VERIFICATION", - "CODE_RETRIEVAL_QUERY" -) {} - /** - * Request containing the `Content` for the model to embed. + * The response from the model, including candidate completions. */ -export class EmbedContentRequest extends S.Class("EmbedContentRequest")({ - /** - * Required. The model's resource name. This serves as an ID for the Model to use. - * - * This name should match a model name returned by the `ListModels` method. - * - * Format: `models/{model}` - */ - "model": S.String, - /** - * Required. The content to embed. Only the `parts.text` fields will be counted. - */ - "content": Content, +export class GenerateTextResponse extends S.Class("GenerateTextResponse")({ /** - * Optional. Optional task type for which the embeddings will be used. Not supported on - * earlier models (`models/embedding-001`). + * Returns any safety feedback related to content filtering. */ - "taskType": S.optionalWith(TaskType, { nullable: true }), + "safetyFeedback": S.optionalWith(S.Array(SafetyFeedback), { nullable: true }), /** - * Optional. An optional title for the text. Only applicable when TaskType is - * `RETRIEVAL_DOCUMENT`. + * A set of content filtering metadata for the prompt and response + * text. * - * Note: Specifying a `title` for `RETRIEVAL_DOCUMENT` provides better quality - * embeddings for retrieval. + * This indicates which `SafetyCategory`(s) blocked a + * candidate from this response, the lowest `HarmProbability` + * that triggered a block, and the HarmThreshold setting for that category. + * This indicates the smallest change to the `SafetySettings` that would be + * necessary to unblock at least 1 response. + * + * The blocking is configured by the `SafetySettings` in the request (or the + * default `SafetySettings` of the API). */ - "title": S.optionalWith(S.String, { nullable: true }), + "filters": S.optionalWith(S.Array(ContentFilter), { nullable: true }), /** - * Optional. Optional reduced dimension for the output embedding. If set, excessive - * values in the output embedding are truncated from the end. Supported by - * newer models since 2024 only. You cannot set this value if using the - * earlier model (`models/embedding-001`). + * Candidate responses from the model. */ - "outputDimensionality": S.optionalWith(S.Int, { nullable: true }) + "candidates": S.optionalWith(S.Array(TextCompletion), { nullable: true }) }) {} /** - * A list of floats representing an embedding. + * Configuration for a white space chunking algorithm [white space delimited]. */ -export class ContentEmbedding extends S.Class("ContentEmbedding")({ +export class WhiteSpaceConfig extends S.Class("WhiteSpaceConfig")({ /** - * The embedding values. + * Maximum number of overlapping tokens between two adjacent chunks. + */ + "maxOverlapTokens": S.optionalWith(S.Int, { nullable: true }), + /** + * Maximum number of tokens per chunk. + * Tokens are defined as words for this chunking algorithm. + * Note: we are defining tokens as words split by whitespace as opposed to + * the output of a tokenizer. The context window of the latest gemini + * embedding model as of 2025-04-17 is currently 8192 tokens. We assume that + * the average word is 5 characters. Therefore, we set the upper limit to + * 2**9, which is 512 words, or 2560 tokens, assuming worst case a + * character per token. This is a conservative estimate meant to prevent + * context window overflow. */ - "values": S.optionalWith(S.Array(S.Number), { nullable: true }) + "maxTokensPerChunk": S.optionalWith(S.Int, { nullable: true }) }) {} /** - * The response to an `EmbedContentRequest`. + * Parameters for telling the service how to chunk the file. + * inspired by + * google3/cloud/ai/platform/extension/lib/retrieval/config/chunker_config.proto */ -export class EmbedContentResponse extends S.Class("EmbedContentResponse")({ +export class ChunkingConfig extends S.Class("ChunkingConfig")({ /** - * Output only. The embedding generated from the input content. + * White space chunking configuration. */ - "embedding": S.optionalWith(ContentEmbedding, { nullable: true }) + "whiteSpaceConfig": S.optionalWith(WhiteSpaceConfig, { nullable: true }) }) {} /** - * Batch request to get embeddings from the model for a list of prompts. + * User provided string values assigned to a single metadata key. */ -export class BatchEmbedContentsRequest extends S.Class("BatchEmbedContentsRequest")({ +export class StringList extends S.Class("StringList")({ /** - * Required. Embed requests for the batch. The model in each of these requests must - * match the model specified `BatchEmbedContentsRequest.model`. + * The string values of the metadata to store. */ - "requests": S.Array(EmbedContentRequest) + "values": S.optionalWith(S.Array(S.String), { nullable: true }) }) {} /** - * The response to a `BatchEmbedContentsRequest`. + * User provided metadata stored as key-value pairs. */ -export class BatchEmbedContentsResponse extends S.Class("BatchEmbedContentsResponse")({ +export class CustomMetadata extends S.Class("CustomMetadata")({ /** - * Output only. The embeddings for each request, in the same order as provided in the batch - * request. + * Required. The key of the metadata to store. */ - "embeddings": S.optionalWith(S.Array(ContentEmbedding), { nullable: true }) + "key": S.String, + /** + * The StringList value of the metadata to store. + */ + "stringListValue": S.optionalWith(StringList, { nullable: true }), + /** + * The string value of the metadata to store. + */ + "stringValue": S.optionalWith(S.String, { nullable: true }), + /** + * The numeric value of the metadata to store. + */ + "numericValue": S.optionalWith(S.Number, { nullable: true }) }) {} /** - * Counts the number of tokens in the `prompt` sent to a model. - * - * Models may tokenize text differently, so each model may return a different - * `token_count`. + * Request for `UploadToFileSearchStore`. */ -export class CountTokensRequest extends S.Class("CountTokensRequest")({ - /** - * Optional. The input given to the model as a prompt. This field is ignored when - * `generate_content_request` is set. - */ - "contents": S.optionalWith(S.Array(Content), { nullable: true }), - /** - * Optional. The overall input given to the `Model`. This includes the prompt as well as - * other model steering information like [system - * instructions](https://ai.google.dev/gemini-api/docs/system-instructions), - * and/or function declarations for [function - * calling](https://ai.google.dev/gemini-api/docs/function-calling). - * `Model`s/`Content`s and `generate_content_request`s are mutually - * exclusive. You can either send `Model` + `Content`s or a - * `generate_content_request`, but never both. - */ - "generateContentRequest": S.optionalWith(GenerateContentRequest, { nullable: true }) +export class UploadToFileSearchStoreRequest + extends S.Class("UploadToFileSearchStoreRequest")({ + /** + * Optional. Config for telling the service how to chunk the data. + * If not provided, the service will use default parameters. + */ + "chunkingConfig": S.optionalWith(ChunkingConfig, { nullable: true }), + /** + * Optional. Display name of the created document. + */ + "displayName": S.optionalWith(S.String, { nullable: true }), + /** + * Optional. MIME type of the data. If not provided, it will be inferred from the + * uploaded content. + */ + "mimeType": S.optionalWith(S.String, { nullable: true }), + /** + * Custom metadata to be associated with the data. + */ + "customMetadata": S.optionalWith(S.Array(CustomMetadata), { nullable: true }) + }) +{} + +/** + * Metadata for LongRunning UploadToFileSearchStore Operations. + */ +export class UploadToFileSearchStoreMetadata extends S.Record({ key: S.String, value: S.Unknown }) {} + +/** + * Response from UploadToFileSearchStore. + */ +export class UploadToFileSearchStoreResponse + extends S.Class("UploadToFileSearchStoreResponse")({ + /** + * Size of the file in bytes. + */ + "sizeBytes": S.optionalWith(S.String, { nullable: true }), + /** + * Immutable. Identifier. The identifier for the `Document` imported. + * Example: `fileSearchStores/my-file-search-store-123a456b789c` + */ + "documentName": S.optionalWith(S.String, { nullable: true }), + /** + * MIME type of the file. + */ + "mimeType": S.optionalWith(S.String, { nullable: true }), + /** + * The name of the `FileSearchStore` containing `Document`s. + * Example: `fileSearchStores/my-file-search-store-123` + */ + "parent": S.optionalWith(S.String, { nullable: true }) + }) +{} + +/** + * This resource represents a long-running operation that is the result of a + * network API call. + */ +export class UploadToFileSearchStoreOperation + extends S.Class("UploadToFileSearchStoreOperation")({ + "metadata": S.optionalWith(UploadToFileSearchStoreMetadata, { nullable: true }), + "response": S.optionalWith(UploadToFileSearchStoreResponse, { nullable: true }), + /** + * The error result of the operation in case of failure or cancellation. + */ + "error": S.optionalWith(Status, { nullable: true }), + /** + * If the value is `false`, it means the operation is still in progress. + * If `true`, the operation is completed, and either `error` or `response` is + * available. + */ + "done": S.optionalWith(S.Boolean, { nullable: true }), + /** + * The server-assigned name, which is only unique within the same service that + * originally returns it. If you use the default HTTP mapping, the + * `name` should be a resource name ending with `operations/{unique_id}`. + */ + "name": S.optionalWith(S.String, { nullable: true }) + }) +{} + +export class UpdateEmbedContentBatchParams extends S.Struct({ + "updateMask": S.optionalWith(S.String.pipe(S.pattern(new RegExp("^(\\s*[^,\\s.]+(\\s*[,.]\\s*[^,\\s.]+)*)?$"))), { + nullable: true + }) }) {} +export class BatchState extends S.Literal( + "BATCH_STATE_UNSPECIFIED", + "BATCH_STATE_PENDING", + "BATCH_STATE_RUNNING", + "BATCH_STATE_SUCCEEDED", + "BATCH_STATE_FAILED", + "BATCH_STATE_CANCELLED", + "BATCH_STATE_EXPIRED" +) {} + +export class TaskType extends S.Literal( + "TASK_TYPE_UNSPECIFIED", + "RETRIEVAL_QUERY", + "RETRIEVAL_DOCUMENT", + "SEMANTIC_SIMILARITY", + "CLASSIFICATION", + "CLUSTERING", + "QUESTION_ANSWERING", + "FACT_VERIFICATION", + "CODE_RETRIEVAL_QUERY" +) {} + /** - * A response from `CountTokens`. - * - * It returns the model's `token_count` for the `prompt`. + * Request containing the `Content` for the model to embed. */ -export class CountTokensResponse extends S.Class("CountTokensResponse")({ +export class EmbedContentRequest extends S.Class("EmbedContentRequest")({ /** - * The number of tokens that the `Model` tokenizes the `prompt` into. Always - * non-negative. + * Required. The model's resource name. This serves as an ID for the Model to use. + * + * This name should match a model name returned by the `ListModels` method. + * + * Format: `models/{model}` */ - "totalTokens": S.optionalWith(S.Int, { nullable: true }), + "model": S.String, /** - * Number of tokens in the cached part of the prompt (the cached content). + * Optional. Optional task type for which the embeddings will be used. Not supported on + * earlier models (`models/embedding-001`). */ - "cachedContentTokenCount": S.optionalWith(S.Int, { nullable: true }), + "taskType": S.optionalWith(TaskType, { nullable: true }), /** - * Output only. List of modalities that were processed in the request input. + * Optional. An optional title for the text. Only applicable when TaskType is + * `RETRIEVAL_DOCUMENT`. + * + * Note: Specifying a `title` for `RETRIEVAL_DOCUMENT` provides better quality + * embeddings for retrieval. */ - "promptTokensDetails": S.optionalWith(S.Array(ModalityTokenCount), { nullable: true }), + "title": S.optionalWith(S.String, { nullable: true }), /** - * Output only. List of modalities that were processed in the cached content. + * Optional. Optional reduced dimension for the output embedding. If set, excessive + * values in the output embedding are truncated from the end. Supported by + * newer models since 2024 only. You cannot set this value if using the + * earlier model (`models/embedding-001`). + */ + "outputDimensionality": S.optionalWith(S.Int, { nullable: true }), + /** + * Required. The content to embed. Only the `parts.text` fields will be counted. */ - "cacheTokensDetails": S.optionalWith(S.Array(ModalityTokenCount), { nullable: true }) + "content": Content }) {} /** * The request to be processed in the batch. */ -export class InlinedRequest extends S.Class("InlinedRequest")({ +export class InlinedEmbedContentRequest extends S.Class("InlinedEmbedContentRequest")({ /** * Required. The request to be processed in the batch. */ - "request": GenerateContentRequest, + "request": EmbedContentRequest, /** * Optional. The metadata to be associated with the request. */ @@ -2038,17 +2344,17 @@ export class InlinedRequest extends S.Class("InlinedRequest")({ * The requests to be processed in the batch if provided as part of the * batch creation request. */ -export class InlinedRequests extends S.Class("InlinedRequests")({ +export class InlinedEmbedContentRequests extends S.Class("InlinedEmbedContentRequests")({ /** * Required. The requests to be processed in the batch. */ - "requests": S.Array(InlinedRequest) + "requests": S.Array(InlinedEmbedContentRequest) }) {} /** * Configures the input to the batch request. */ -export class InputConfig extends S.Class("InputConfig")({ +export class InputEmbedContentConfig extends S.Class("InputEmbedContentConfig")({ /** * The name of the `File` containing the input requests. */ @@ -2056,166 +2362,257 @@ export class InputConfig extends S.Class("InputConfig")({ /** * The requests to be processed in the batch. */ - "requests": S.optionalWith(InlinedRequests, { nullable: true }) + "requests": S.optionalWith(InlinedEmbedContentRequests, { nullable: true }) }) {} /** - * The response to a single request in the batch. + * Stats about the batch. */ -export class InlinedResponse extends S.Class("InlinedResponse")({ +export class EmbedContentBatchStats extends S.Class("EmbedContentBatchStats")({ /** - * Output only. The error encountered while processing the request. + * Output only. The number of requests in the batch. */ - "error": S.optionalWith(Status, { nullable: true }), + "requestCount": S.optionalWith(S.String, { nullable: true }), /** - * Output only. The response to the request. + * Output only. The number of requests that failed to be processed. */ - "response": S.optionalWith(GenerateContentResponse, { nullable: true }), + "failedRequestCount": S.optionalWith(S.String, { nullable: true }), /** - * Output only. The metadata associated with the request. + * Output only. The number of requests that are still pending processing. */ - "metadata": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true }) + "pendingRequestCount": S.optionalWith(S.String, { nullable: true }), + /** + * Output only. The number of requests that were successfully processed. + */ + "successfulRequestCount": S.optionalWith(S.String, { nullable: true }) }) {} /** - * The responses to the requests in the batch. + * A list of floats representing an embedding. */ -export class InlinedResponses extends S.Class("InlinedResponses")({ +export class ContentEmbedding extends S.Class("ContentEmbedding")({ /** - * Output only. The responses to the requests in the batch. + * The embedding values. This is for 3P users only and will not be populated + * for 1P calls. */ - "inlinedResponses": S.optionalWith(S.Array(InlinedResponse), { nullable: true }) + "values": S.optionalWith(S.Array(S.Number), { nullable: true }), + /** + * This field stores the soft tokens tensor frame shape + * (e.g. [1, 1, 256, 2048]). + */ + "shape": S.optionalWith(S.Array(S.Int), { nullable: true }) }) {} /** - * The output of a batch request. This is returned in the - * `BatchGenerateContentResponse` or the `GenerateContentBatch.output` field. + * The response to an `EmbedContentRequest`. */ -export class GenerateContentBatchOutput extends S.Class("GenerateContentBatchOutput")({ - /** - * Output only. The file ID of the file containing the responses. - * The file will be a JSONL file with a single response per line. - * The responses will be `GenerateContentResponse` messages formatted as - * JSON. - * The responses will be written in the same order as the input requests. - */ - "responsesFile": S.optionalWith(S.String, { nullable: true }), +export class EmbedContentResponse extends S.Class("EmbedContentResponse")({ /** - * Output only. The responses to the requests in the batch. Returned when the batch was - * built using inlined requests. The responses will be in the same order as - * the input requests. + * Output only. The embedding generated from the input content. */ - "inlinedResponses": S.optionalWith(InlinedResponses, { nullable: true }) + "embedding": S.optionalWith(ContentEmbedding, { nullable: true }) }) {} /** - * Stats about the batch. + * The response to a single request in the batch. */ -export class BatchStats extends S.Class("BatchStats")({ +export class InlinedEmbedContentResponse extends S.Class("InlinedEmbedContentResponse")({ /** - * Output only. The number of requests in the batch. + * Output only. The metadata associated with the request. */ - "requestCount": S.optionalWith(S.String, { nullable: true }), + "metadata": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true }), /** - * Output only. The number of requests that were successfully processed. + * Output only. The response to the request. */ - "successfulRequestCount": S.optionalWith(S.String, { nullable: true }), + "response": S.optionalWith(EmbedContentResponse, { nullable: true }), /** - * Output only. The number of requests that failed to be processed. + * Output only. The error encountered while processing the request. */ - "failedRequestCount": S.optionalWith(S.String, { nullable: true }), + "error": S.optionalWith(Status, { nullable: true }) +}) {} + +/** + * The responses to the requests in the batch. + */ +export class InlinedEmbedContentResponses + extends S.Class("InlinedEmbedContentResponses")({ + /** + * Output only. The responses to the requests in the batch. + */ + "inlinedResponses": S.optionalWith(S.Array(InlinedEmbedContentResponse), { nullable: true }) + }) +{} + +/** + * The output of a batch request. This is returned in the + * `AsyncBatchEmbedContentResponse` or the `EmbedContentBatch.output` field. + */ +export class EmbedContentBatchOutput extends S.Class("EmbedContentBatchOutput")({ /** - * Output only. The number of requests that are still pending processing. + * Output only. The file ID of the file containing the responses. + * The file will be a JSONL file with a single response per line. + * The responses will be `EmbedContentResponse` messages formatted as JSON. + * The responses will be written in the same order as the input requests. + */ + "responsesFile": S.optionalWith(S.String, { nullable: true }), + /** + * Output only. The responses to the requests in the batch. Returned when the batch was + * built using inlined requests. The responses will be in the same order as + * the input requests. */ - "pendingRequestCount": S.optionalWith(S.String, { nullable: true }) + "inlinedResponses": S.optionalWith(InlinedEmbedContentResponses, { nullable: true }) }) {} -export class BatchState extends S.Literal( - "BATCH_STATE_UNSPECIFIED", - "BATCH_STATE_PENDING", - "BATCH_STATE_RUNNING", - "BATCH_STATE_SUCCEEDED", - "BATCH_STATE_FAILED", - "BATCH_STATE_CANCELLED", - "BATCH_STATE_EXPIRED" -) {} - /** - * A resource representing a batch of `GenerateContent` requests. + * A resource representing a batch of `EmbedContent` requests. */ -export class GenerateContentBatch extends S.Class("GenerateContentBatch")({ +export class EmbedContentBatch extends S.Class("EmbedContentBatch")({ /** - * Required. The name of the `Model` to use for generating the completion. - * - * Format: `models/{model}`. + * Optional. The priority of the batch. Batches with a higher priority value will be + * processed before batches with a lower priority value. Negative values are + * allowed. Default is 0. */ - "model": S.String, + "priority": S.optionalWith(S.String, { nullable: true }), + /** + * Output only. The state of the batch. + */ + "state": S.optionalWith(BatchState, { nullable: true }), /** * Output only. Identifier. Resource name of the batch. * * Format: `batches/{batch_id}`. */ "name": S.optionalWith(S.String, { nullable: true }), - /** - * Required. The user-defined name of this batch. - */ - "displayName": S.String, /** * Required. Input configuration of the instances on which batch processing * are performed. */ - "inputConfig": InputConfig, + "inputConfig": InputEmbedContentConfig, + /** + * Output only. Stats about the batch. + */ + "batchStats": S.optionalWith(EmbedContentBatchStats, { nullable: true }), /** * Output only. The output of the batch request. */ - "output": S.optionalWith(GenerateContentBatchOutput, { nullable: true }), + "output": S.optionalWith(EmbedContentBatchOutput, { nullable: true }), /** - * Output only. The time at which the batch was created. + * Output only. The time at which the batch was last updated. */ - "createTime": S.optionalWith(S.String, { nullable: true }), + "updateTime": S.optionalWith(S.String, { nullable: true }), + /** + * Required. The user-defined name of this batch. + */ + "displayName": S.String, /** * Output only. The time at which the batch processing completed. */ "endTime": S.optionalWith(S.String, { nullable: true }), /** - * Output only. The time at which the batch was last updated. + * Output only. The time at which the batch was created. */ - "updateTime": S.optionalWith(S.String, { nullable: true }), + "createTime": S.optionalWith(S.String, { nullable: true }), /** - * Output only. Stats about the batch. + * Required. The name of the `Model` to use for generating the completion. + * + * Format: `models/{model}`. */ - "batchStats": S.optionalWith(BatchStats, { nullable: true }), + "model": S.String +}) {} + +export class ListPermissionsParams extends S.Struct({ + "pageSize": S.optionalWith(S.Int, { nullable: true }), + "pageToken": S.optionalWith(S.String, { nullable: true }) +}) {} + +/** + * Required. The role granted by this permission. + */ +export class PermissionRole extends S.Literal("ROLE_UNSPECIFIED", "OWNER", "WRITER", "READER") {} + +/** + * Optional. Immutable. The type of the grantee. + */ +export class PermissionGranteeType extends S.Literal("GRANTEE_TYPE_UNSPECIFIED", "USER", "GROUP", "EVERYONE") {} + +/** + * Permission resource grants user, group or the rest of the world access to the + * PaLM API resource (e.g. a tuned model, corpus). + * + * A role is a collection of permitted operations that allows users to perform + * specific actions on PaLM API resources. To make them available to users, + * groups, or service accounts, you assign roles. When you assign a role, you + * grant permissions that the role contains. + * + * There are three concentric roles. Each role is a superset of the previous + * role's permitted operations: + * + * - reader can use the resource (e.g. tuned model, corpus) for inference + * - writer has reader's permissions and additionally can edit and share + * - owner has writer's permissions and additionally can delete + */ +export class Permission extends S.Class("Permission")({ /** - * Output only. The state of the batch. + * Required. The role granted by this permission. */ - "state": S.optionalWith(BatchState, { nullable: true }), + "role": PermissionRole, /** - * Optional. The priority of the batch. Batches with a higher priority value will be - * processed before batches with a lower priority value. Negative values are - * allowed. Default is 0. + * Output only. Identifier. The permission name. A unique name will be generated on create. + * Examples: + * tunedModels/{tuned_model}/permissions/{permission} + * corpora/{corpus}/permissions/{permission} + * Output only. + */ + "name": S.optionalWith(S.String, { nullable: true }), + /** + * Optional. Immutable. The email address of the user of group which this permission refers. + * Field is not set when permission's grantee type is EVERYONE. + */ + "emailAddress": S.optionalWith(S.String, { nullable: true }), + /** + * Optional. Immutable. The type of the grantee. */ - "priority": S.optionalWith(S.String, { nullable: true }) + "granteeType": S.optionalWith(PermissionGranteeType, { nullable: true }) }) {} /** - * Request for a `BatchGenerateContent` operation. + * Response from `ListPermissions` containing a paginated list of + * permissions. */ -export class BatchGenerateContentRequest extends S.Class("BatchGenerateContentRequest")({ +export class ListPermissionsResponse extends S.Class("ListPermissionsResponse")({ /** - * Required. The batch to create. + * A token, which can be sent as `page_token` to retrieve the next page. + * + * If this field is omitted, there are no more pages. */ - "batch": GenerateContentBatch + "nextPageToken": S.optionalWith(S.String, { nullable: true }), + /** + * Returned permissions. + */ + "permissions": S.optionalWith(S.Array(Permission), { nullable: true }) }) {} +/** + * Request for an `AsyncBatchEmbedContent` operation. + */ +export class AsyncBatchEmbedContentRequest + extends S.Class("AsyncBatchEmbedContentRequest")({ + /** + * Required. The batch to create. + */ + "batch": EmbedContentBatch + }) +{} + /** * Response for a `BatchGenerateContent` operation. */ -export class BatchGenerateContentResponse - extends S.Class("BatchGenerateContentResponse")({ +export class AsyncBatchEmbedContentResponse + extends S.Class("AsyncBatchEmbedContentResponse")({ /** * Output only. The output of the batch request. */ - "output": S.optionalWith(GenerateContentBatchOutput, { nullable: true }) + "output": S.optionalWith(EmbedContentBatchOutput, { nullable: true }) }) {} @@ -2223,16 +2620,14 @@ export class BatchGenerateContentResponse * This resource represents a long-running operation that is the result of a * network API call. */ -export class BatchGenerateContentOperation - extends S.Class("BatchGenerateContentOperation")({ - "metadata": S.optionalWith(GenerateContentBatch, { nullable: true }), - "response": S.optionalWith(BatchGenerateContentResponse, { nullable: true }), +export class AsyncBatchEmbedContentOperation + extends S.Class("AsyncBatchEmbedContentOperation")({ + "response": S.optionalWith(AsyncBatchEmbedContentResponse, { nullable: true }), + "metadata": S.optionalWith(EmbedContentBatch, { nullable: true }), /** - * The server-assigned name, which is only unique within the same service that - * originally returns it. If you use the default HTTP mapping, the - * `name` should be a resource name ending with `operations/{unique_id}`. + * The error result of the operation in case of failure or cancellation. */ - "name": S.optionalWith(S.String, { nullable: true }), + "error": S.optionalWith(Status, { nullable: true }), /** * If the value is `false`, it means the operation is still in progress. * If `true`, the operation is completed, and either `error` or `response` is @@ -2240,574 +2635,633 @@ export class BatchGenerateContentOperation */ "done": S.optionalWith(S.Boolean, { nullable: true }), /** - * The error result of the operation in case of failure or cancellation. + * The server-assigned name, which is only unique within the same service that + * originally returns it. If you use the default HTTP mapping, the + * `name` should be a resource name ending with `operations/{unique_id}`. */ - "error": S.optionalWith(Status, { nullable: true }) + "name": S.optionalWith(S.String, { nullable: true }) }) {} +export class ListOperationsParams extends S.Struct({ + "filter": S.optionalWith(S.String, { nullable: true }), + "pageSize": S.optionalWith(S.Int, { nullable: true }), + "pageToken": S.optionalWith(S.String, { nullable: true }), + "returnPartialSuccess": S.optionalWith(S.Boolean, { nullable: true }) +}) {} + /** - * The request to be processed in the batch. + * The response message for Operations.ListOperations. */ -export class InlinedEmbedContentRequest extends S.Class("InlinedEmbedContentRequest")({ +export class ListOperationsResponse extends S.Class("ListOperationsResponse")({ /** - * Required. The request to be processed in the batch. + * A list of operations that matches the specified filter in the request. */ - "request": EmbedContentRequest, + "operations": S.optionalWith(S.Array(Operation), { nullable: true }), /** - * Optional. The metadata to be associated with the request. + * The standard List next-page token. */ - "metadata": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true }) -}) {} - -/** - * The requests to be processed in the batch if provided as part of the - * batch creation request. - */ -export class InlinedEmbedContentRequests extends S.Class("InlinedEmbedContentRequests")({ + "nextPageToken": S.optionalWith(S.String, { nullable: true }), /** - * Required. The requests to be processed in the batch. + * Unordered list. Unreachable resources. Populated when the request sets + * `ListOperationsRequest.return_partial_success` and reads across + * collections. For example, when attempting to list all resources across all + * supported locations. */ - "requests": S.Array(InlinedEmbedContentRequest) + "unreachable": S.optionalWith(S.Array(S.String), { nullable: true }) +}) {} + +export class ListCorporaParams extends S.Struct({ + "pageSize": S.optionalWith(S.Int, { nullable: true }), + "pageToken": S.optionalWith(S.String, { nullable: true }) }) {} /** - * Configures the input to the batch request. + * A `Corpus` is a collection of `Document`s. + * A project can create up to 10 corpora. */ -export class InputEmbedContentConfig extends S.Class("InputEmbedContentConfig")({ +export class Corpus extends S.Class("Corpus")({ /** - * The name of the `File` containing the input requests. + * Optional. The human-readable display name for the `Corpus`. The display name must be + * no more than 512 characters in length, including spaces. + * Example: "Docs on Semantic Retriever" */ - "fileName": S.optionalWith(S.String, { nullable: true }), + "displayName": S.optionalWith(S.String, { nullable: true }), /** - * The requests to be processed in the batch. + * Output only. The Timestamp of when the `Corpus` was last updated. */ - "requests": S.optionalWith(InlinedEmbedContentRequests, { nullable: true }) + "updateTime": S.optionalWith(S.String, { nullable: true }), + /** + * Output only. The Timestamp of when the `Corpus` was created. + */ + "createTime": S.optionalWith(S.String, { nullable: true }), + /** + * Output only. Immutable. Identifier. The `Corpus` resource name. The ID (name excluding the "corpora/" prefix) + * can contain up to 40 characters that are lowercase alphanumeric or dashes + * (-). The ID cannot start or end with a dash. If the name is empty on + * create, a unique name will be derived from `display_name` along with a 12 + * character random suffix. + * Example: `corpora/my-awesome-corpora-123a456b789c` + */ + "name": S.optionalWith(S.String, { nullable: true }) }) {} /** - * The response to a single request in the batch. + * Response from `ListCorpora` containing a paginated list of `Corpora`. + * The results are sorted by ascending `corpus.create_time`. */ -export class InlinedEmbedContentResponse extends S.Class("InlinedEmbedContentResponse")({ - /** - * Output only. The error encountered while processing the request. - */ - "error": S.optionalWith(Status, { nullable: true }), +export class ListCorporaResponse extends S.Class("ListCorporaResponse")({ /** - * Output only. The response to the request. + * A token, which can be sent as `page_token` to retrieve the next page. + * If this field is omitted, there are no more pages. */ - "response": S.optionalWith(EmbedContentResponse, { nullable: true }), + "nextPageToken": S.optionalWith(S.String, { nullable: true }), /** - * Output only. The metadata associated with the request. + * The returned corpora. */ - "metadata": S.optionalWith(S.Record({ key: S.String, value: S.Unknown }), { nullable: true }) + "corpora": S.optionalWith(S.Array(Corpus), { nullable: true }) }) {} /** - * The responses to the requests in the batch. - */ -export class InlinedEmbedContentResponses - extends S.Class("InlinedEmbedContentResponses")({ - /** - * Output only. The responses to the requests in the batch. - */ - "inlinedResponses": S.optionalWith(S.Array(InlinedEmbedContentResponse), { nullable: true }) - }) -{} - -/** - * The output of a batch request. This is returned in the - * `AsyncBatchEmbedContentResponse` or the `EmbedContentBatch.output` field. + * Metadata on the usage of the cached content. */ -export class EmbedContentBatchOutput extends S.Class("EmbedContentBatchOutput")({ - /** - * Output only. The file ID of the file containing the responses. - * The file will be a JSONL file with a single response per line. - * The responses will be `EmbedContentResponse` messages formatted as JSON. - * The responses will be written in the same order as the input requests. - */ - "responsesFile": S.optionalWith(S.String, { nullable: true }), +export class CachedContentUsageMetadata extends S.Class("CachedContentUsageMetadata")({ /** - * Output only. The responses to the requests in the batch. Returned when the batch was - * built using inlined requests. The responses will be in the same order as - * the input requests. + * Total number of tokens that the cached content consumes. */ - "inlinedResponses": S.optionalWith(InlinedEmbedContentResponses, { nullable: true }) + "totalTokenCount": S.optionalWith(S.Int, { nullable: true }) }) {} /** - * Stats about the batch. + * Content that has been preprocessed and can be used in subsequent request + * to GenerativeService. + * + * Cached content can be only used with model it was created for. */ -export class EmbedContentBatchStats extends S.Class("EmbedContentBatchStats")({ +export class CachedContent extends S.Class("CachedContent")({ /** - * Output only. The number of requests in the batch. + * Timestamp in UTC of when this resource is considered expired. + * This is *always* provided on output, regardless of what was sent + * on input. */ - "requestCount": S.optionalWith(S.String, { nullable: true }), + "expireTime": S.optionalWith(S.String, { nullable: true }), /** - * Output only. The number of requests that were successfully processed. + * Optional. Input only. Immutable. Developer set system instruction. Currently text only. */ - "successfulRequestCount": S.optionalWith(S.String, { nullable: true }), + "systemInstruction": S.optionalWith(Content, { nullable: true }), /** - * Output only. The number of requests that failed to be processed. + * Input only. New TTL for this resource, input only. */ - "failedRequestCount": S.optionalWith(S.String, { nullable: true }), + "ttl": S.optionalWith(S.String, { nullable: true }), /** - * Output only. The number of requests that are still pending processing. + * Output only. When the cache entry was last updated in UTC time. */ - "pendingRequestCount": S.optionalWith(S.String, { nullable: true }) -}) {} - -/** - * A resource representing a batch of `EmbedContent` requests. - */ -export class EmbedContentBatch extends S.Class("EmbedContentBatch")({ + "updateTime": S.optionalWith(S.String, { nullable: true }), /** - * Required. The name of the `Model` to use for generating the completion. - * - * Format: `models/{model}`. - */ - "model": S.String, - /** - * Output only. Identifier. Resource name of the batch. - * - * Format: `batches/{batch_id}`. - */ - "name": S.optionalWith(S.String, { nullable: true }), - /** - * Required. The user-defined name of this batch. - */ - "displayName": S.String, - /** - * Required. Input configuration of the instances on which batch processing - * are performed. + * Output only. Metadata on the usage of the cached content. */ - "inputConfig": InputEmbedContentConfig, + "usageMetadata": S.optionalWith(CachedContentUsageMetadata, { nullable: true }), /** - * Output only. The output of the batch request. + * Required. Immutable. The name of the `Model` to use for cached content + * Format: `models/{model}` */ - "output": S.optionalWith(EmbedContentBatchOutput, { nullable: true }), + "model": S.String, /** - * Output only. The time at which the batch was created. + * Output only. Creation time of the cache entry. */ "createTime": S.optionalWith(S.String, { nullable: true }), /** - * Output only. The time at which the batch processing completed. + * Optional. Input only. Immutable. The content to cache. */ - "endTime": S.optionalWith(S.String, { nullable: true }), + "contents": S.optionalWith(S.Array(Content), { nullable: true }), /** - * Output only. The time at which the batch was last updated. + * Optional. Input only. Immutable. A list of `Tools` the model may use to generate the next response */ - "updateTime": S.optionalWith(S.String, { nullable: true }), + "tools": S.optionalWith(S.Array(Tool), { nullable: true }), /** - * Output only. Stats about the batch. + * Optional. Input only. Immutable. Tool config. This config is shared for all tools. */ - "batchStats": S.optionalWith(EmbedContentBatchStats, { nullable: true }), + "toolConfig": S.optionalWith(ToolConfig, { nullable: true }), /** - * Output only. The state of the batch. + * Output only. Identifier. The resource name referring to the cached content. + * Format: `cachedContents/{id}` */ - "state": S.optionalWith(BatchState, { nullable: true }), + "name": S.optionalWith(S.String, { nullable: true }), /** - * Optional. The priority of the batch. Batches with a higher priority value will be - * processed before batches with a lower priority value. Negative values are - * allowed. Default is 0. + * Optional. Immutable. The user-generated meaningful display name of the cached content. Maximum + * 128 Unicode characters. */ - "priority": S.optionalWith(S.String, { nullable: true }) + "displayName": S.optionalWith(S.String, { nullable: true }) }) {} -/** - * Request for an `AsyncBatchEmbedContent` operation. - */ -export class AsyncBatchEmbedContentRequest - extends S.Class("AsyncBatchEmbedContentRequest")({ - /** - * Required. The batch to create. - */ - "batch": EmbedContentBatch - }) -{} - -/** - * Response for a `BatchGenerateContent` operation. - */ -export class AsyncBatchEmbedContentResponse - extends S.Class("AsyncBatchEmbedContentResponse")({ - /** - * Output only. The output of the batch request. - */ - "output": S.optionalWith(EmbedContentBatchOutput, { nullable: true }) - }) -{} - -/** - * This resource represents a long-running operation that is the result of a - * network API call. - */ -export class AsyncBatchEmbedContentOperation - extends S.Class("AsyncBatchEmbedContentOperation")({ - "metadata": S.optionalWith(EmbedContentBatch, { nullable: true }), - "response": S.optionalWith(AsyncBatchEmbedContentResponse, { nullable: true }), - /** - * The server-assigned name, which is only unique within the same service that - * originally returns it. If you use the default HTTP mapping, the - * `name` should be a resource name ending with `operations/{unique_id}`. - */ - "name": S.optionalWith(S.String, { nullable: true }), - /** - * If the value is `false`, it means the operation is still in progress. - * If `true`, the operation is completed, and either `error` or `response` is - * available. - */ - "done": S.optionalWith(S.Boolean, { nullable: true }), - /** - * The error result of the operation in case of failure or cancellation. - */ - "error": S.optionalWith(Status, { nullable: true }) +export class UpdateCachedContentParams extends S.Struct({ + "updateMask": S.optionalWith(S.String.pipe(S.pattern(new RegExp("^(\\s*[^,\\s.]+(\\s*[,.]\\s*[^,\\s.]+)*)?$"))), { + nullable: true }) -{} +}) {} -export class ListCachedContentsParams extends S.Struct({ +export class ListGeneratedFilesParams extends S.Struct({ "pageSize": S.optionalWith(S.Int, { nullable: true }), "pageToken": S.optionalWith(S.String, { nullable: true }) }) {} /** - * Metadata on the usage of the cached content. + * Output only. The state of the GeneratedFile. */ -export class CachedContentUsageMetadata extends S.Class("CachedContentUsageMetadata")({ - /** - * Total number of tokens that the cached content consumes. - */ - "totalTokenCount": S.optionalWith(S.Int, { nullable: true }) -}) {} +export class GeneratedFileState extends S.Literal("STATE_UNSPECIFIED", "GENERATING", "GENERATED", "FAILED") {} /** - * Content that has been preprocessed and can be used in subsequent request - * to GenerativeService. - * - * Cached content can be only used with model it was created for. + * A file generated on behalf of a user. */ -export class CachedContent extends S.Class("CachedContent")({ +export class GeneratedFile extends S.Class("GeneratedFile")({ /** - * Timestamp in UTC of when this resource is considered expired. - * This is *always* provided on output, regardless of what was sent - * on input. + * Error details if the GeneratedFile ends up in the STATE_FAILED state. */ - "expireTime": S.optionalWith(S.String, { nullable: true }), + "error": S.optionalWith(Status, { nullable: true }), /** - * Input only. New TTL for this resource, input only. + * MIME type of the generatedFile. */ - "ttl": S.optionalWith(S.String, { nullable: true }), + "mimeType": S.optionalWith(S.String, { nullable: true }), /** - * Output only. Identifier. The resource name referring to the cached content. - * Format: `cachedContents/{id}` + * Output only. The state of the GeneratedFile. */ - "name": S.optionalWith(S.String, { nullable: true }), + "state": S.optionalWith(GeneratedFileState, { nullable: true }), /** - * Optional. Immutable. The user-generated meaningful display name of the cached content. Maximum - * 128 Unicode characters. + * Identifier. The name of the generated file. + * Example: `generatedFiles/abc-123` */ - "displayName": S.optionalWith(S.String, { nullable: true }), + "name": S.optionalWith(S.String, { nullable: true }) +}) {} + +/** + * Response for `ListGeneratedFiles`. + */ +export class ListGeneratedFilesResponse extends S.Class("ListGeneratedFilesResponse")({ /** - * Required. Immutable. The name of the `Model` to use for cached content - * Format: `models/{model}` + * A token that can be sent as a `page_token` into a subsequent + * `ListGeneratedFiles` call. */ - "model": S.String, + "nextPageToken": S.optionalWith(S.String, { nullable: true }), /** - * Optional. Input only. Immutable. Developer set system instruction. Currently text only. + * The list of `GeneratedFile`s. */ - "systemInstruction": S.optionalWith(Content, { nullable: true }), + "generatedFiles": S.optionalWith(S.Array(GeneratedFile), { nullable: true }) +}) {} + +/** + * Required. Style in which answers should be returned. + */ +export class GenerateAnswerRequestAnswerStyle + extends S.Literal("ANSWER_STYLE_UNSPECIFIED", "ABSTRACTIVE", "EXTRACTIVE", "VERBOSE") +{} + +/** + * Passage included inline with a grounding configuration. + */ +export class GroundingPassage extends S.Class("GroundingPassage")({ /** - * Optional. Input only. Immutable. The content to cache. + * Identifier for the passage for attributing this passage in grounded + * answers. */ - "contents": S.optionalWith(S.Array(Content), { nullable: true }), + "id": S.optionalWith(S.String, { nullable: true }), /** - * Optional. Input only. Immutable. A list of `Tools` the model may use to generate the next response + * Content of the passage. */ - "tools": S.optionalWith(S.Array(Tool), { nullable: true }), + "content": S.optionalWith(Content, { nullable: true }) +}) {} + +/** + * A repeated list of passages. + */ +export class GroundingPassages extends S.Class("GroundingPassages")({ /** - * Optional. Input only. Immutable. Tool config. This config is shared for all tools. + * List of passages. */ - "toolConfig": S.optionalWith(ToolConfig, { nullable: true }), + "passages": S.optionalWith(S.Array(GroundingPassage), { nullable: true }) +}) {} + +/** + * Required. Operator applied to the given key-value pair to trigger the condition. + */ +export class ConditionOperation extends S.Literal( + "OPERATOR_UNSPECIFIED", + "LESS", + "LESS_EQUAL", + "EQUAL", + "GREATER_EQUAL", + "GREATER", + "NOT_EQUAL", + "INCLUDES", + "EXCLUDES" +) {} + +/** + * Filter condition applicable to a single key. + */ +export class Condition extends S.Class("Condition")({ /** - * Output only. Creation time of the cache entry. + * Required. Operator applied to the given key-value pair to trigger the condition. */ - "createTime": S.optionalWith(S.String, { nullable: true }), + "operation": ConditionOperation, /** - * Output only. When the cache entry was last updated in UTC time. + * The string value to filter the metadata on. */ - "updateTime": S.optionalWith(S.String, { nullable: true }), + "stringValue": S.optionalWith(S.String, { nullable: true }), /** - * Output only. Metadata on the usage of the cached content. + * The numeric value to filter the metadata on. */ - "usageMetadata": S.optionalWith(CachedContentUsageMetadata, { nullable: true }) + "numericValue": S.optionalWith(S.Number, { nullable: true }) }) {} /** - * Response with CachedContents list. + * User provided filter to limit retrieval based on `Chunk` or `Document` level + * metadata values. + * Example (genre = drama OR genre = action): + * key = "document.custom_metadata.genre" + * conditions = [{string_value = "drama", operation = EQUAL}, + * {string_value = "action", operation = EQUAL}] */ -export class ListCachedContentsResponse extends S.Class("ListCachedContentsResponse")({ +export class MetadataFilter extends S.Class("MetadataFilter")({ /** - * List of cached contents. + * Required. The `Condition`s for the given key that will trigger this filter. Multiple + * `Condition`s are joined by logical ORs. */ - "cachedContents": S.optionalWith(S.Array(CachedContent), { nullable: true }), + "conditions": S.Array(Condition), /** - * A token, which can be sent as `page_token` to retrieve the next page. - * If this field is omitted, there are no subsequent pages. + * Required. The key of the metadata to filter on. */ - "nextPageToken": S.optionalWith(S.String, { nullable: true }) -}) {} - -export class UpdateCachedContentParams extends S.Struct({ - "updateMask": S.optionalWith(S.String.pipe(S.pattern(new RegExp("^(\\s*[^,\\s.]+(\\s*[,.]\\s*[^,\\s.]+)*)?$"))), { - nullable: true - }) + "key": S.String }) {} /** - * The base unit of structured text. - * - * A `Message` includes an `author` and the `content` of - * the `Message`. - * - * The `author` is used to tag messages when they are fed to the - * model as text. + * Configuration for retrieving grounding content from a `Corpus` or + * `Document` created using the Semantic Retriever API. */ -export class Message extends S.Class("Message")({ +export class SemanticRetrieverConfig extends S.Class("SemanticRetrieverConfig")({ /** - * Optional. The author of this Message. - * - * This serves as a key for tagging - * the content of this Message when it is fed to the model as text. - * - * The author can be any alphanumeric string. + * Optional. Maximum number of relevant `Chunk`s to retrieve. */ - "author": S.optionalWith(S.String, { nullable: true }), + "maxChunksCount": S.optionalWith(S.Int, { nullable: true }), /** - * Required. The text content of the structured `Message`. + * Optional. Filters for selecting `Document`s and/or `Chunk`s from the resource. */ - "content": S.String, + "metadataFilters": S.optionalWith(S.Array(MetadataFilter), { nullable: true }), /** - * Output only. Citation information for model-generated `content` in this `Message`. - * - * If this `Message` was generated as output from the model, this field may be - * populated with attribution information for any text included in the - * `content`. This field is used only on output. + * Optional. Minimum relevance score for retrieved relevant `Chunk`s. */ - "citationMetadata": S.optionalWith(CitationMetadata, { nullable: true }) -}) {} - -/** - * An input/output example used to instruct the Model. - * - * It demonstrates how the model should respond or format its response. - */ -export class Example extends S.Class("Example")({ + "minimumRelevanceScore": S.optionalWith(S.Number, { nullable: true }), /** - * Required. An example of an input `Message` from the user. + * Required. Name of the resource for retrieval. Example: `corpora/123` or + * `corpora/123/documents/abc`. */ - "input": Message, + "source": S.String, /** - * Required. An example of what the model should output given the input. + * Required. Query to use for matching `Chunk`s in the given resource by similarity. */ - "output": Message + "query": Content }) {} /** - * All of the structured input text passed to the model as a prompt. - * - * A `MessagePrompt` contains a structured set of fields that provide context - * for the conversation, examples of user input/model output message pairs that - * prime the model to respond in different ways, and the conversation history - * or list of messages representing the alternating turns of the conversation - * between the user and the model. + * Request to generate a grounded answer from the `Model`. */ -export class MessagePrompt extends S.Class("MessagePrompt")({ - /** - * Optional. Text that should be provided to the model first to ground the response. - * - * If not empty, this `context` will be given to the model first before the - * `examples` and `messages`. When using a `context` be sure to provide it - * with every request to maintain continuity. - * - * This field can be a description of your prompt to the model to help provide - * context and guide the responses. Examples: "Translate the phrase from - * English to French." or "Given a statement, classify the sentiment as happy, - * sad or neutral." - * - * Anything included in this field will take precedence over message history - * if the total input size exceeds the model's `input_token_limit` and the - * input request is truncated. - */ - "context": S.optionalWith(S.String, { nullable: true }), - /** - * Optional. Examples of what the model should generate. - * - * This includes both user input and the response that the model should - * emulate. - * - * These `examples` are treated identically to conversation messages except - * that they take precedence over the history in `messages`: - * If the total input size exceeds the model's `input_token_limit` the input - * will be truncated. Items will be dropped from `messages` before `examples`. - */ - "examples": S.optionalWith(S.Array(Example), { nullable: true }), +export class GenerateAnswerRequest extends S.Class("GenerateAnswerRequest")({ /** - * Required. A snapshot of the recent conversation history sorted chronologically. - * - * Turns alternate between two authors. + * Optional. A list of unique `SafetySetting` instances for blocking unsafe content. * - * If the total input size exceeds the model's `input_token_limit` the input - * will be truncated: The oldest items will be dropped from `messages`. + * This will be enforced on the `GenerateAnswerRequest.contents` and + * `GenerateAnswerResponse.candidate`. There should not be more than one + * setting for each `SafetyCategory` type. The API will block any contents and + * responses that fail to meet the thresholds set by these settings. This list + * overrides the default settings for each `SafetyCategory` specified in the + * safety_settings. If there is no `SafetySetting` for a given + * `SafetyCategory` provided in the list, the API will use the default safety + * setting for that category. Harm categories HARM_CATEGORY_HATE_SPEECH, + * HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT, + * HARM_CATEGORY_HARASSMENT are supported. + * Refer to the + * [guide](https://ai.google.dev/gemini-api/docs/safety-settings) + * for detailed information on available safety settings. Also refer to the + * [Safety guidance](https://ai.google.dev/gemini-api/docs/safety-guidance) to + * learn how to incorporate safety considerations in your AI applications. */ - "messages": S.Array(Message) -}) {} - -/** - * Request to generate a message response from the model. - */ -export class GenerateMessageRequest extends S.Class("GenerateMessageRequest")({ + "safetySettings": S.optionalWith(S.Array(SafetySetting), { nullable: true }), /** - * Required. The structured textual input given to the model as a prompt. - * - * Given a - * prompt, the model will return what it predicts is the next message in the - * discussion. + * Required. Style in which answers should be returned. */ - "prompt": MessagePrompt, + "answerStyle": GenerateAnswerRequestAnswerStyle, /** * Optional. Controls the randomness of the output. * - * Values can range over `[0.0,1.0]`, - * inclusive. A value closer to `1.0` will produce responses that are more - * varied, while a value closer to `0.0` will typically result in - * less surprising responses from the model. + * Values can range from [0.0,1.0], inclusive. A value closer to 1.0 will + * produce responses that are more varied and creative, while a value closer + * to 0.0 will typically result in more straightforward responses from the + * model. A low temperature (~0.2) is usually recommended for + * Attributed-Question-Answering use cases. */ "temperature": S.optionalWith(S.Number, { nullable: true }), /** - * Optional. The number of generated response messages to return. + * Required. The content of the current conversation with the `Model`. For single-turn + * queries, this is a single question to answer. For multi-turn queries, this + * is a repeated field that contains conversation history and the last + * `Content` in the list containing the question. * - * This value must be between - * `[1, 8]`, inclusive. If unset, this will default to `1`. + * Note: `GenerateAnswer` only supports queries in English. */ - "candidateCount": S.optionalWith(S.Int, { nullable: true }), + "contents": S.Array(Content), /** - * Optional. The maximum cumulative probability of tokens to consider when sampling. - * - * The model uses combined Top-k and nucleus sampling. - * - * Nucleus sampling considers the smallest set of tokens whose probability - * sum is at least `top_p`. + * Passages provided inline with the request. */ - "topP": S.optionalWith(S.Number, { nullable: true }), + "inlinePassages": S.optionalWith(GroundingPassages, { nullable: true }), /** - * Optional. The maximum number of tokens to consider when sampling. - * - * The model uses combined Top-k and nucleus sampling. - * - * Top-k sampling considers the set of `top_k` most probable tokens. + * Content retrieved from resources created via the Semantic Retriever + * API. */ - "topK": S.optionalWith(S.Int, { nullable: true }) + "semanticRetriever": S.optionalWith(SemanticRetrieverConfig, { nullable: true }) }) {} /** - * The reason content was blocked during request processing. + * Optional. If set, the input was blocked and no candidates are returned. + * Rephrase the input. */ -export class ContentFilterReason extends S.Literal("BLOCKED_REASON_UNSPECIFIED", "SAFETY", "OTHER") {} +export class InputFeedbackBlockReason extends S.Literal("BLOCK_REASON_UNSPECIFIED", "SAFETY", "OTHER") {} /** - * Content filtering metadata associated with processing a single request. - * - * ContentFilter contains a reason and an optional supporting string. The reason - * may be unspecified. + * Feedback related to the input data used to answer the question, as opposed + * to the model-generated response to the question. */ -export class ContentFilter extends S.Class("ContentFilter")({ +export class InputFeedback extends S.Class("InputFeedback")({ /** - * The reason content was blocked during request processing. + * Optional. If set, the input was blocked and no candidates are returned. + * Rephrase the input. */ - "reason": S.optionalWith(ContentFilterReason, { nullable: true }), + "blockReason": S.optionalWith(InputFeedbackBlockReason, { nullable: true }), /** - * A string that describes the filtering behavior in more detail. + * Ratings for safety of the input. + * There is at most one rating per category. */ - "message": S.optionalWith(S.String, { nullable: true }) + "safetyRatings": S.optionalWith(S.Array(SafetyRating), { nullable: true }) }) {} /** - * The response from the model. - * - * This includes candidate messages and - * conversation history in the form of chronologically-ordered messages. + * Response from the model for a grounded answer. */ -export class GenerateMessageResponse extends S.Class("GenerateMessageResponse")({ +export class GenerateAnswerResponse extends S.Class("GenerateAnswerResponse")({ /** - * Candidate response messages from the model. + * Candidate answer from the model. + * + * Note: The model *always* attempts to provide a grounded answer, even when + * the answer is unlikely to be answerable from the given passages. + * In that case, a low-quality or ungrounded answer may be provided, along + * with a low `answerable_probability`. */ - "candidates": S.optionalWith(S.Array(Message), { nullable: true }), + "answer": S.optionalWith(Candidate, { nullable: true }), /** - * The conversation history used by the model. + * Output only. Feedback related to the input data used to answer the question, as opposed + * to the model-generated response to the question. + * + * The input data can be one or more of the following: + * + * - Question specified by the last entry in `GenerateAnswerRequest.content` + * - Conversation history specified by the other entries in + * `GenerateAnswerRequest.content` + * - Grounding sources (`GenerateAnswerRequest.semantic_retriever` or + * `GenerateAnswerRequest.inline_passages`) */ - "messages": S.optionalWith(S.Array(Message), { nullable: true }), + "inputFeedback": S.optionalWith(InputFeedback, { nullable: true }), /** - * A set of content filtering metadata for the prompt and response - * text. + * Output only. The model's estimate of the probability that its answer is correct and + * grounded in the input passages. * - * This indicates which `SafetyCategory`(s) blocked a - * candidate from this response, the lowest `HarmProbability` - * that triggered a block, and the HarmThreshold setting for that category. + * A low `answerable_probability` indicates that the answer might not be + * grounded in the sources. + * + * When `answerable_probability` is low, you may want to: + * + * * Display a message to the effect of "We couldn’t answer that question" to + * the user. + * * Fall back to a general-purpose LLM that answers the question from world + * knowledge. The threshold and nature of such fallbacks will depend on + * individual use cases. `0.5` is a good starting threshold. */ - "filters": S.optionalWith(S.Array(ContentFilter), { nullable: true }) + "answerableProbability": S.optionalWith(S.Number, { nullable: true }) }) {} /** - * Counts the number of tokens in the `prompt` sent to a model. - * - * Models may tokenize text differently, so each model may return a different - * `token_count`. + * Response for `DownloadFile`. */ -export class CountMessageTokensRequest extends S.Class("CountMessageTokensRequest")({ - /** - * Required. The prompt, whose token count is to be returned. - */ - "prompt": MessagePrompt -}) {} +export class DownloadFileResponse extends S.Record({ key: S.String, value: S.Unknown }) {} /** - * A response from `CountMessageTokens`. - * - * It returns the model's `token_count` for the `prompt`. + * Request message for [PredictionService.PredictLongRunning]. */ -export class CountMessageTokensResponse extends S.Class("CountMessageTokensResponse")({ +export class PredictLongRunningRequest extends S.Class("PredictLongRunningRequest")({}) {} + +/** + * Metadata for PredictLongRunning long running operations. + */ +export class PredictLongRunningMetadata extends S.Record({ key: S.String, value: S.Unknown }) {} + +/** + * Representation of a video. + */ +export class Video extends S.Class