From a4e68aafa781c6b670cc0e92809bbcdf70272fbd Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Fri, 18 Apr 2025 12:57:58 -0700 Subject: [PATCH 1/5] Fix typings for functionDeclaration.parameters. --- .changeset/rotten-taxis-allow.md | 5 +++++ common/api-review/vertexai.api.md | 7 +++---- packages/ai/src/requests/schema-builder.ts | 5 ++--- packages/ai/src/types/requests.ts | 6 +++--- packages/ai/src/types/schema.ts | 12 +++++++++--- 5 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 .changeset/rotten-taxis-allow.md diff --git a/.changeset/rotten-taxis-allow.md b/.changeset/rotten-taxis-allow.md new file mode 100644 index 00000000000..0f009dbd8fe --- /dev/null +++ b/.changeset/rotten-taxis-allow.md @@ -0,0 +1,5 @@ +--- +'@firebase/vertexai': patch +--- + +Fix typings for functionDeclaration.parameters. diff --git a/common/api-review/vertexai.api.md b/common/api-review/vertexai.api.md index 42da114f9e9..1c43ae3a973 100644 --- a/common/api-review/vertexai.api.md +++ b/common/api-review/vertexai.api.md @@ -280,7 +280,7 @@ export interface FunctionCallPart { export interface FunctionDeclaration { description: string; name: string; - parameters?: ObjectSchemaInterface; + parameters?: ObjectSchema | ObjectSchemaRequest; } // @public @@ -701,9 +701,8 @@ export class ObjectSchema extends Schema { } // @public -export interface ObjectSchemaInterface extends SchemaInterface { - // (undocumented) - optionalProperties?: string[]; +export interface ObjectSchemaRequest extends SchemaRequest { + optionalProperties?: never; // (undocumented) type: SchemaType.OBJECT; } diff --git a/packages/ai/src/requests/schema-builder.ts b/packages/ai/src/requests/schema-builder.ts index 7d9ece462b3..593a29c2d19 100644 --- a/packages/ai/src/requests/schema-builder.ts +++ b/packages/ai/src/requests/schema-builder.ts @@ -21,8 +21,7 @@ import { SchemaInterface, SchemaType, SchemaParams, - SchemaRequest, - ObjectSchemaInterface + SchemaRequest } from '../types/schema'; /** @@ -292,7 +291,7 @@ export class ObjectSchema extends Schema { if (required.length > 0) { obj.required = required; } - delete (obj as ObjectSchemaInterface).optionalProperties; + delete obj.optionalProperties; return obj as SchemaRequest; } } diff --git a/packages/ai/src/types/requests.ts b/packages/ai/src/types/requests.ts index 67f45095c2a..9100a5c70aa 100644 --- a/packages/ai/src/types/requests.ts +++ b/packages/ai/src/types/requests.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { TypedSchema } from '../requests/schema-builder'; +import { ObjectSchema, TypedSchema } from '../requests/schema-builder'; import { Content, Part } from './content'; import { FunctionCallingMode, @@ -24,7 +24,7 @@ import { HarmCategory, ResponseModality } from './enums'; -import { ObjectSchemaInterface, SchemaRequest } from './schema'; +import { ObjectSchemaRequest, SchemaRequest } from './schema'; /** * Base parameters for a number of methods. @@ -193,7 +193,7 @@ export declare interface FunctionDeclaration { * format. Reflects the Open API 3.03 Parameter Object. Parameter names are * case-sensitive. For a function with no parameters, this can be left unset. */ - parameters?: ObjectSchemaInterface; + parameters?: ObjectSchema | ObjectSchemaRequest; } /** diff --git a/packages/ai/src/types/schema.ts b/packages/ai/src/types/schema.ts index 3a6c0c7301b..203f42cbdd2 100644 --- a/packages/ai/src/types/schema.ts +++ b/packages/ai/src/types/schema.ts @@ -114,10 +114,16 @@ export interface SchemaInterface extends SchemaShared { } /** - * Interface for {@link ObjectSchema} class. + * Interface for JSON parameters in {@link SchemaType.OBJECT} format when + * not using the {@link ObjectSchema} helper. * @public */ -export interface ObjectSchemaInterface extends SchemaInterface { +export interface ObjectSchemaRequest extends SchemaRequest { type: SchemaType.OBJECT; - optionalProperties?: string[]; + /** + * This is not a property accepted in the final request to the backend, but is + * a client-side convenience property that is only usable by constructing + * a schema through the `Schema.object()` helper method. + */ + optionalProperties?: never; } From 9a9d1c6ef54f2adb8f517bcc8ef090f98667449d Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Fri, 18 Apr 2025 13:13:48 -0700 Subject: [PATCH 2/5] Generate docs --- docs-devsite/ai.functiondeclaration.md | 2 +- docs-devsite/vertexai.objectschemarequest.md | 45 ++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 docs-devsite/vertexai.objectschemarequest.md diff --git a/docs-devsite/ai.functiondeclaration.md b/docs-devsite/ai.functiondeclaration.md index 2a87d67ed47..34164d51428 100644 --- a/docs-devsite/ai.functiondeclaration.md +++ b/docs-devsite/ai.functiondeclaration.md @@ -53,5 +53,5 @@ Optional. Describes the parameters to this function in JSON Schema Object format Signature: ```typescript -parameters?: ObjectSchemaInterface; +parameters?: ObjectSchema | ObjectSchemaRequest; ``` diff --git a/docs-devsite/vertexai.objectschemarequest.md b/docs-devsite/vertexai.objectschemarequest.md new file mode 100644 index 00000000000..f804ff822c0 --- /dev/null +++ b/docs-devsite/vertexai.objectschemarequest.md @@ -0,0 +1,45 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ObjectSchemaRequest interface +Interface for JSON parameters in [SchemaType.OBJECT](./vertexai.md#schematypeobject_enummember) format when not using the [ObjectSchema](./vertexai.objectschema.md#objectschema_class) helper. + +Signature: + +```typescript +export interface ObjectSchemaRequest extends SchemaRequest +``` +Extends: [SchemaRequest](./vertexai.schemarequest.md#schemarequest_interface) + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [optionalProperties](./vertexai.objectschemarequest.md#objectschemarequestoptionalproperties) | never | This is not a property accepted in the final request to the backend, but is a client-side convenience property that is only usable by constructing a schema through the Schema.object() helper method. | +| [type](./vertexai.objectschemarequest.md#objectschemarequesttype) | [SchemaType.OBJECT](./vertexai.md#schematypeobject_enummember) | | + +## ObjectSchemaRequest.optionalProperties + +This is not a property accepted in the final request to the backend, but is a client-side convenience property that is only usable by constructing a schema through the `Schema.object()` helper method. + +Signature: + +```typescript +optionalProperties?: never; +``` + +## ObjectSchemaRequest.type + +Signature: + +```typescript +type: SchemaType.OBJECT; +``` From 562735c9d94e72a230dc385e53cc85ed53c51821 Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Tue, 3 Jun 2025 11:23:49 -0700 Subject: [PATCH 3/5] regen docs --- common/api-review/ai.api.md | 7 ++- docs-devsite/_toc.yaml | 4 +- docs-devsite/ai.functiondeclaration.md | 2 +- docs-devsite/ai.md | 2 +- docs-devsite/ai.objectschemainterface.md | 43 ------------------- ...marequest.md => ai.objectschemarequest.md} | 8 ++-- 6 files changed, 11 insertions(+), 55 deletions(-) delete mode 100644 docs-devsite/ai.objectschemainterface.md rename docs-devsite/{vertexai.objectschemarequest.md => ai.objectschemarequest.md} (55%) diff --git a/common/api-review/ai.api.md b/common/api-review/ai.api.md index 23c13688fb1..03a411ee94b 100644 --- a/common/api-review/ai.api.md +++ b/common/api-review/ai.api.md @@ -280,7 +280,7 @@ export interface FunctionCallPart { export interface FunctionDeclaration { description: string; name: string; - parameters?: ObjectSchemaInterface; + parameters?: ObjectSchema | ObjectSchemaRequest; } // @public @@ -702,9 +702,8 @@ export class ObjectSchema extends Schema { } // @public -export interface ObjectSchemaInterface extends SchemaInterface { - // (undocumented) - optionalProperties?: string[]; +export interface ObjectSchemaRequest extends SchemaRequest { + optionalProperties?: never; // (undocumented) type: SchemaType.OBJECT; } diff --git a/docs-devsite/_toc.yaml b/docs-devsite/_toc.yaml index b77a6b5910e..548c5c05f54 100644 --- a/docs-devsite/_toc.yaml +++ b/docs-devsite/_toc.yaml @@ -108,8 +108,8 @@ toc: path: /docs/reference/js/ai.numberschema.md - title: ObjectSchema path: /docs/reference/js/ai.objectschema.md - - title: ObjectSchemaInterface - path: /docs/reference/js/ai.objectschemainterface.md + - title: ObjectSchemaRequest + path: /docs/reference/js/ai.objectschemarequest.md - title: PromptFeedback path: /docs/reference/js/ai.promptfeedback.md - title: RequestOptions diff --git a/docs-devsite/ai.functiondeclaration.md b/docs-devsite/ai.functiondeclaration.md index 34164d51428..29632463e2b 100644 --- a/docs-devsite/ai.functiondeclaration.md +++ b/docs-devsite/ai.functiondeclaration.md @@ -24,7 +24,7 @@ export declare interface FunctionDeclaration | --- | --- | --- | | [description](./ai.functiondeclaration.md#functiondeclarationdescription) | string | Description and purpose of the function. Model uses it to decide how and whether to call the function. | | [name](./ai.functiondeclaration.md#functiondeclarationname) | string | The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a max length of 64. | -| [parameters](./ai.functiondeclaration.md#functiondeclarationparameters) | [ObjectSchemaInterface](./ai.objectschemainterface.md#objectschemainterface_interface) | Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. Parameter names are case-sensitive. For a function with no parameters, this can be left unset. | +| [parameters](./ai.functiondeclaration.md#functiondeclarationparameters) | [ObjectSchema](./ai.objectschema.md#objectschema_class) \| [ObjectSchemaRequest](./ai.objectschemarequest.md#objectschemarequest_interface) | Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. Parameter names are case-sensitive. For a function with no parameters, this can be left unset. | ## FunctionDeclaration.description diff --git a/docs-devsite/ai.md b/docs-devsite/ai.md index 286c8351fd7..ad749658b4e 100644 --- a/docs-devsite/ai.md +++ b/docs-devsite/ai.md @@ -106,7 +106,7 @@ The Firebase AI Web SDK. | [InlineDataPart](./ai.inlinedatapart.md#inlinedatapart_interface) | Content part interface if the part represents an image. | | [ModalityTokenCount](./ai.modalitytokencount.md#modalitytokencount_interface) | Represents token counting info for a single modality. | | [ModelParams](./ai.modelparams.md#modelparams_interface) | Params passed to [getGenerativeModel()](./ai.md#getgenerativemodel_80bd839). | -| [ObjectSchemaInterface](./ai.objectschemainterface.md#objectschemainterface_interface) | Interface for [ObjectSchema](./ai.objectschema.md#objectschema_class) class. | +| [ObjectSchemaRequest](./ai.objectschemarequest.md#objectschemarequest_interface) | Interface for JSON parameters in [SchemaType.OBJECT](./ai.md#schematypeobject_enummember) format when not using the [ObjectSchema](./ai.objectschema.md#objectschema_class) helper. | | [PromptFeedback](./ai.promptfeedback.md#promptfeedback_interface) | If the prompt was blocked, this will be populated with blockReason and the relevant safetyRatings. | | [RequestOptions](./ai.requestoptions.md#requestoptions_interface) | Params passed to [getGenerativeModel()](./ai.md#getgenerativemodel_80bd839). | | [RetrievedContextAttribution](./ai.retrievedcontextattribution.md#retrievedcontextattribution_interface) | | diff --git a/docs-devsite/ai.objectschemainterface.md b/docs-devsite/ai.objectschemainterface.md deleted file mode 100644 index 15b1a97f40d..00000000000 --- a/docs-devsite/ai.objectschemainterface.md +++ /dev/null @@ -1,43 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ObjectSchemaInterface interface -Interface for [ObjectSchema](./ai.objectschema.md#objectschema_class) class. - -Signature: - -```typescript -export interface ObjectSchemaInterface extends SchemaInterface -``` -Extends: [SchemaInterface](./ai.schemainterface.md#schemainterface_interface) - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [optionalProperties](./ai.objectschemainterface.md#objectschemainterfaceoptionalproperties) | string\[\] | | -| [type](./ai.objectschemainterface.md#objectschemainterfacetype) | [SchemaType.OBJECT](./ai.md#schematypeobject_enummember) | | - -## ObjectSchemaInterface.optionalProperties - -Signature: - -```typescript -optionalProperties?: string[]; -``` - -## ObjectSchemaInterface.type - -Signature: - -```typescript -type: SchemaType.OBJECT; -``` diff --git a/docs-devsite/vertexai.objectschemarequest.md b/docs-devsite/ai.objectschemarequest.md similarity index 55% rename from docs-devsite/vertexai.objectschemarequest.md rename to docs-devsite/ai.objectschemarequest.md index f804ff822c0..e2e6bcdaed3 100644 --- a/docs-devsite/vertexai.objectschemarequest.md +++ b/docs-devsite/ai.objectschemarequest.md @@ -10,21 +10,21 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # ObjectSchemaRequest interface -Interface for JSON parameters in [SchemaType.OBJECT](./vertexai.md#schematypeobject_enummember) format when not using the [ObjectSchema](./vertexai.objectschema.md#objectschema_class) helper. +Interface for JSON parameters in [SchemaType.OBJECT](./ai.md#schematypeobject_enummember) format when not using the [ObjectSchema](./ai.objectschema.md#objectschema_class) helper. Signature: ```typescript export interface ObjectSchemaRequest extends SchemaRequest ``` -Extends: [SchemaRequest](./vertexai.schemarequest.md#schemarequest_interface) +Extends: [SchemaRequest](./ai.schemarequest.md#schemarequest_interface) ## Properties | Property | Type | Description | | --- | --- | --- | -| [optionalProperties](./vertexai.objectschemarequest.md#objectschemarequestoptionalproperties) | never | This is not a property accepted in the final request to the backend, but is a client-side convenience property that is only usable by constructing a schema through the Schema.object() helper method. | -| [type](./vertexai.objectschemarequest.md#objectschemarequesttype) | [SchemaType.OBJECT](./vertexai.md#schematypeobject_enummember) | | +| [optionalProperties](./ai.objectschemarequest.md#objectschemarequestoptionalproperties) | never | This is not a property accepted in the final request to the backend, but is a client-side convenience property that is only usable by constructing a schema through the Schema.object() helper method. | +| [type](./ai.objectschemarequest.md#objectschemarequesttype) | [SchemaType.OBJECT](./ai.md#schematypeobject_enummember) | | ## ObjectSchemaRequest.optionalProperties From 2979a024935c9bb124a5a4e7dbdaa7c5f3762d78 Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Tue, 3 Jun 2025 11:49:15 -0700 Subject: [PATCH 4/5] update changeset --- .changeset/rotten-taxis-allow.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/rotten-taxis-allow.md b/.changeset/rotten-taxis-allow.md index 0f009dbd8fe..dc7a7660164 100644 --- a/.changeset/rotten-taxis-allow.md +++ b/.changeset/rotten-taxis-allow.md @@ -1,5 +1,5 @@ --- -'@firebase/vertexai': patch +'@firebase/ai': patch --- -Fix typings for functionDeclaration.parameters. +Fix typings for `functionDeclaration.parameters`. From d2010c4f4d4b6e726212c986cb631b5cc4822498 Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Wed, 4 Jun 2025 10:09:01 -0700 Subject: [PATCH 5/5] remove vertex api-report --- common/api-review/vertexai.api.md | 954 ------------------------------ 1 file changed, 954 deletions(-) delete mode 100644 common/api-review/vertexai.api.md diff --git a/common/api-review/vertexai.api.md b/common/api-review/vertexai.api.md deleted file mode 100644 index 1c43ae3a973..00000000000 --- a/common/api-review/vertexai.api.md +++ /dev/null @@ -1,954 +0,0 @@ -## API Report File for "@firebase/vertexai" - -> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). - -```ts - -import { AppCheckTokenResult } from '@firebase/app-check-interop-types'; -import { FirebaseApp } from '@firebase/app'; -import { FirebaseAuthTokenData } from '@firebase/auth-interop-types'; -import { FirebaseError } from '@firebase/util'; - -// @public -export interface AI { - app: FirebaseApp; - backend: Backend; - // @deprecated - location: string; -} - -// @public -export class AIError extends FirebaseError { - constructor(code: AIErrorCode, message: string, customErrorData?: CustomErrorData | undefined); - // (undocumented) - readonly code: AIErrorCode; - // (undocumented) - readonly customErrorData?: CustomErrorData | undefined; -} - -// @public -const enum AIErrorCode { - API_NOT_ENABLED = "api-not-enabled", - ERROR = "error", - FETCH_ERROR = "fetch-error", - INVALID_CONTENT = "invalid-content", - INVALID_SCHEMA = "invalid-schema", - NO_API_KEY = "no-api-key", - NO_APP_ID = "no-app-id", - NO_MODEL = "no-model", - NO_PROJECT_ID = "no-project-id", - PARSE_FAILED = "parse-failed", - REQUEST_ERROR = "request-error", - RESPONSE_ERROR = "response-error", - UNSUPPORTED = "unsupported" -} - -export { AIErrorCode } - -export { AIErrorCode as VertexAIErrorCode } - -// @public -export abstract class AIModel { - // @internal - protected constructor(ai: AI, modelName: string); - // Warning: (ae-forgotten-export) The symbol "ApiSettings" needs to be exported by the entry point index.d.ts - // - // @internal (undocumented) - protected _apiSettings: ApiSettings; - readonly model: string; - // @internal - static normalizeModelName(modelName: string, backendType: BackendType): string; - } - -// @public -export interface AIOptions { - backend: Backend; -} - -// @public -export class ArraySchema extends Schema { - constructor(schemaParams: SchemaParams, items: TypedSchema); - // (undocumented) - items: TypedSchema; - // @internal (undocumented) - toJSON(): SchemaRequest; -} - -// @public -export abstract class Backend { - protected constructor(type: BackendType); - readonly backendType: BackendType; -} - -// @public -export const BackendType: { - readonly VERTEX_AI: "VERTEX_AI"; - readonly GOOGLE_AI: "GOOGLE_AI"; -}; - -// @public -export type BackendType = (typeof BackendType)[keyof typeof BackendType]; - -// @public -export interface BaseParams { - // (undocumented) - generationConfig?: GenerationConfig; - // (undocumented) - safetySettings?: SafetySetting[]; -} - -// @public -export enum BlockReason { - BLOCKLIST = "BLOCKLIST", - OTHER = "OTHER", - PROHIBITED_CONTENT = "PROHIBITED_CONTENT", - SAFETY = "SAFETY" -} - -// @public -export class BooleanSchema extends Schema { - constructor(schemaParams?: SchemaParams); -} - -// @public -export class ChatSession { - constructor(apiSettings: ApiSettings, model: string, params?: StartChatParams | undefined, requestOptions?: RequestOptions | undefined); - getHistory(): Promise; - // (undocumented) - model: string; - // (undocumented) - params?: StartChatParams | undefined; - // (undocumented) - requestOptions?: RequestOptions | undefined; - sendMessage(request: string | Array): Promise; - sendMessageStream(request: string | Array): Promise; - } - -// @public -export interface Citation { - // (undocumented) - endIndex?: number; - // (undocumented) - license?: string; - publicationDate?: Date_2; - // (undocumented) - startIndex?: number; - title?: string; - // (undocumented) - uri?: string; -} - -// @public -export interface CitationMetadata { - // (undocumented) - citations: Citation[]; -} - -// @public -export interface Content { - // (undocumented) - parts: Part[]; - // (undocumented) - role: Role; -} - -// @public -export interface CountTokensRequest { - // (undocumented) - contents: Content[]; - generationConfig?: GenerationConfig; - systemInstruction?: string | Part | Content; - tools?: Tool[]; -} - -// @public -export interface CountTokensResponse { - promptTokensDetails?: ModalityTokenCount[]; - totalBillableCharacters?: number; - totalTokens: number; -} - -// @public -export interface CustomErrorData { - errorDetails?: ErrorDetails[]; - response?: GenerateContentResponse; - status?: number; - statusText?: string; -} - -// @public -interface Date_2 { - // (undocumented) - day: number; - // (undocumented) - month: number; - // (undocumented) - year: number; -} - -export { Date_2 as Date } - -// @public -export interface EnhancedGenerateContentResponse extends GenerateContentResponse { - // (undocumented) - functionCalls: () => FunctionCall[] | undefined; - inlineDataParts: () => InlineDataPart[] | undefined; - text: () => string; -} - -// @public -export interface ErrorDetails { - // (undocumented) - '@type'?: string; - [key: string]: unknown; - domain?: string; - metadata?: Record; - reason?: string; -} - -// @public -export interface FileData { - // (undocumented) - fileUri: string; - // (undocumented) - mimeType: string; -} - -// @public -export interface FileDataPart { - // (undocumented) - fileData: FileData; - // (undocumented) - functionCall?: never; - // (undocumented) - functionResponse?: never; - // (undocumented) - inlineData?: never; - // (undocumented) - text?: never; -} - -// @public -export enum FinishReason { - BLOCKLIST = "BLOCKLIST", - MALFORMED_FUNCTION_CALL = "MALFORMED_FUNCTION_CALL", - MAX_TOKENS = "MAX_TOKENS", - OTHER = "OTHER", - PROHIBITED_CONTENT = "PROHIBITED_CONTENT", - RECITATION = "RECITATION", - SAFETY = "SAFETY", - SPII = "SPII", - STOP = "STOP" -} - -// @public -export interface FunctionCall { - // (undocumented) - args: object; - // (undocumented) - name: string; -} - -// @public (undocumented) -export interface FunctionCallingConfig { - // (undocumented) - allowedFunctionNames?: string[]; - // (undocumented) - mode?: FunctionCallingMode; -} - -// @public (undocumented) -export enum FunctionCallingMode { - ANY = "ANY", - AUTO = "AUTO", - NONE = "NONE" -} - -// @public -export interface FunctionCallPart { - // (undocumented) - functionCall: FunctionCall; - // (undocumented) - functionResponse?: never; - // (undocumented) - inlineData?: never; - // (undocumented) - text?: never; -} - -// @public -export interface FunctionDeclaration { - description: string; - name: string; - parameters?: ObjectSchema | ObjectSchemaRequest; -} - -// @public -export interface FunctionDeclarationsTool { - functionDeclarations?: FunctionDeclaration[]; -} - -// @public -export interface FunctionResponse { - // (undocumented) - name: string; - // (undocumented) - response: object; -} - -// @public -export interface FunctionResponsePart { - // (undocumented) - functionCall?: never; - // (undocumented) - functionResponse: FunctionResponse; - // (undocumented) - inlineData?: never; - // (undocumented) - text?: never; -} - -// @public -export interface GenerateContentCandidate { - // (undocumented) - citationMetadata?: CitationMetadata; - // (undocumented) - content: Content; - // (undocumented) - finishMessage?: string; - // (undocumented) - finishReason?: FinishReason; - // (undocumented) - groundingMetadata?: GroundingMetadata; - // (undocumented) - index: number; - // (undocumented) - safetyRatings?: SafetyRating[]; -} - -// @public -export interface GenerateContentRequest extends BaseParams { - // (undocumented) - contents: Content[]; - // (undocumented) - systemInstruction?: string | Part | Content; - // (undocumented) - toolConfig?: ToolConfig; - // (undocumented) - tools?: Tool[]; -} - -// @public -export interface GenerateContentResponse { - // (undocumented) - candidates?: GenerateContentCandidate[]; - // (undocumented) - promptFeedback?: PromptFeedback; - // (undocumented) - usageMetadata?: UsageMetadata; -} - -// @public -export interface GenerateContentResult { - // (undocumented) - response: EnhancedGenerateContentResponse; -} - -// @public -export interface GenerateContentStreamResult { - // (undocumented) - response: Promise; - // (undocumented) - stream: AsyncGenerator; -} - -// @public -export interface GenerationConfig { - // (undocumented) - candidateCount?: number; - // (undocumented) - frequencyPenalty?: number; - // (undocumented) - maxOutputTokens?: number; - // (undocumented) - presencePenalty?: number; - responseMimeType?: string; - // @beta - responseModalities?: ResponseModality[]; - responseSchema?: TypedSchema | SchemaRequest; - // (undocumented) - stopSequences?: string[]; - // (undocumented) - temperature?: number; - // (undocumented) - topK?: number; - // (undocumented) - topP?: number; -} - -// @public -export interface GenerativeContentBlob { - data: string; - // (undocumented) - mimeType: string; -} - -// @public -export class GenerativeModel extends AIModel { - constructor(ai: AI, modelParams: ModelParams, requestOptions?: RequestOptions); - countTokens(request: CountTokensRequest | string | Array): Promise; - generateContent(request: GenerateContentRequest | string | Array): Promise; - generateContentStream(request: GenerateContentRequest | string | Array): Promise; - // (undocumented) - generationConfig: GenerationConfig; - // (undocumented) - requestOptions?: RequestOptions; - // (undocumented) - safetySettings: SafetySetting[]; - startChat(startChatParams?: StartChatParams): ChatSession; - // (undocumented) - systemInstruction?: Content; - // (undocumented) - toolConfig?: ToolConfig; - // (undocumented) - tools?: Tool[]; -} - -// @public -export function getAI(app?: FirebaseApp, options?: AIOptions): AI; - -// @public -export function getGenerativeModel(ai: AI, modelParams: ModelParams, requestOptions?: RequestOptions): GenerativeModel; - -// @beta -export function getImagenModel(ai: AI, modelParams: ImagenModelParams, requestOptions?: RequestOptions): ImagenModel; - -// @public -export function getVertexAI(app?: FirebaseApp, options?: VertexAIOptions): VertexAI; - -// @public -export class GoogleAIBackend extends Backend { - constructor(); -} - -// Warning: (ae-internal-missing-underscore) The name "GoogleAICitationMetadata" should be prefixed with an underscore because the declaration is marked as @internal -// -// @internal (undocumented) -export interface GoogleAICitationMetadata { - // (undocumented) - citationSources: Citation[]; -} - -// Warning: (ae-internal-missing-underscore) The name "GoogleAICountTokensRequest" should be prefixed with an underscore because the declaration is marked as @internal -// -// @internal (undocumented) -export interface GoogleAICountTokensRequest { - // (undocumented) - generateContentRequest: { - model: string; - contents: Content[]; - systemInstruction?: string | Part | Content; - tools?: Tool[]; - generationConfig?: GenerationConfig; - }; -} - -// Warning: (ae-internal-missing-underscore) The name "GoogleAIGenerateContentCandidate" should be prefixed with an underscore because the declaration is marked as @internal -// -// @internal (undocumented) -export interface GoogleAIGenerateContentCandidate { - // (undocumented) - citationMetadata?: GoogleAICitationMetadata; - // (undocumented) - content: Content; - // (undocumented) - finishMessage?: string; - // (undocumented) - finishReason?: FinishReason; - // (undocumented) - groundingMetadata?: GroundingMetadata; - // (undocumented) - index: number; - // (undocumented) - safetyRatings?: SafetyRating[]; -} - -// Warning: (ae-internal-missing-underscore) The name "GoogleAIGenerateContentResponse" should be prefixed with an underscore because the declaration is marked as @internal -// -// @internal (undocumented) -export interface GoogleAIGenerateContentResponse { - // (undocumented) - candidates?: GoogleAIGenerateContentCandidate[]; - // (undocumented) - promptFeedback?: PromptFeedback; - // (undocumented) - usageMetadata?: UsageMetadata; -} - -// @public @deprecated (undocumented) -export interface GroundingAttribution { - // (undocumented) - confidenceScore?: number; - // (undocumented) - retrievedContext?: RetrievedContextAttribution; - // (undocumented) - segment: Segment; - // (undocumented) - web?: WebAttribution; -} - -// @public -export interface GroundingMetadata { - // @deprecated (undocumented) - groundingAttributions: GroundingAttribution[]; - // (undocumented) - retrievalQueries?: string[]; - // (undocumented) - webSearchQueries?: string[]; -} - -// @public -export enum HarmBlockMethod { - PROBABILITY = "PROBABILITY", - SEVERITY = "SEVERITY" -} - -// @public -export enum HarmBlockThreshold { - BLOCK_LOW_AND_ABOVE = "BLOCK_LOW_AND_ABOVE", - BLOCK_MEDIUM_AND_ABOVE = "BLOCK_MEDIUM_AND_ABOVE", - BLOCK_NONE = "BLOCK_NONE", - BLOCK_ONLY_HIGH = "BLOCK_ONLY_HIGH" -} - -// @public -export enum HarmCategory { - // (undocumented) - HARM_CATEGORY_DANGEROUS_CONTENT = "HARM_CATEGORY_DANGEROUS_CONTENT", - // (undocumented) - HARM_CATEGORY_HARASSMENT = "HARM_CATEGORY_HARASSMENT", - // (undocumented) - HARM_CATEGORY_HATE_SPEECH = "HARM_CATEGORY_HATE_SPEECH", - // (undocumented) - HARM_CATEGORY_SEXUALLY_EXPLICIT = "HARM_CATEGORY_SEXUALLY_EXPLICIT" -} - -// @public -export enum HarmProbability { - HIGH = "HIGH", - LOW = "LOW", - MEDIUM = "MEDIUM", - NEGLIGIBLE = "NEGLIGIBLE" -} - -// @public -export enum HarmSeverity { - HARM_SEVERITY_HIGH = "HARM_SEVERITY_HIGH", - HARM_SEVERITY_LOW = "HARM_SEVERITY_LOW", - HARM_SEVERITY_MEDIUM = "HARM_SEVERITY_MEDIUM", - HARM_SEVERITY_NEGLIGIBLE = "HARM_SEVERITY_NEGLIGIBLE", - HARM_SEVERITY_UNSUPPORTED = "HARM_SEVERITY_UNSUPPORTED" -} - -// @beta -export enum ImagenAspectRatio { - LANDSCAPE_16x9 = "16:9", - LANDSCAPE_3x4 = "3:4", - PORTRAIT_4x3 = "4:3", - PORTRAIT_9x16 = "9:16", - SQUARE = "1:1" -} - -// @public -export interface ImagenGCSImage { - gcsURI: string; - mimeType: string; -} - -// @beta -export interface ImagenGenerationConfig { - addWatermark?: boolean; - aspectRatio?: ImagenAspectRatio; - imageFormat?: ImagenImageFormat; - negativePrompt?: string; - numberOfImages?: number; -} - -// @beta -export interface ImagenGenerationResponse { - filteredReason?: string; - images: T[]; -} - -// @beta -export class ImagenImageFormat { - compressionQuality?: number; - static jpeg(compressionQuality?: number): ImagenImageFormat; - mimeType: string; - static png(): ImagenImageFormat; -} - -// @beta -export interface ImagenInlineImage { - bytesBase64Encoded: string; - mimeType: string; -} - -// @beta -export class ImagenModel extends AIModel { - constructor(ai: AI, modelParams: ImagenModelParams, requestOptions?: RequestOptions | undefined); - generateImages(prompt: string): Promise>; - // @internal - generateImagesGCS(prompt: string, gcsURI: string): Promise>; - generationConfig?: ImagenGenerationConfig; - // (undocumented) - requestOptions?: RequestOptions | undefined; - safetySettings?: ImagenSafetySettings; -} - -// @beta -export interface ImagenModelParams { - generationConfig?: ImagenGenerationConfig; - model: string; - safetySettings?: ImagenSafetySettings; -} - -// @beta -export enum ImagenPersonFilterLevel { - ALLOW_ADULT = "allow_adult", - ALLOW_ALL = "allow_all", - BLOCK_ALL = "dont_allow" -} - -// @beta -export enum ImagenSafetyFilterLevel { - BLOCK_LOW_AND_ABOVE = "block_low_and_above", - BLOCK_MEDIUM_AND_ABOVE = "block_medium_and_above", - BLOCK_NONE = "block_none", - BLOCK_ONLY_HIGH = "block_only_high" -} - -// @beta -export interface ImagenSafetySettings { - personFilterLevel?: ImagenPersonFilterLevel; - safetyFilterLevel?: ImagenSafetyFilterLevel; -} - -// @public -export interface InlineDataPart { - // (undocumented) - functionCall?: never; - // (undocumented) - functionResponse?: never; - // (undocumented) - inlineData: GenerativeContentBlob; - // (undocumented) - text?: never; - videoMetadata?: VideoMetadata; -} - -// @public -export class IntegerSchema extends Schema { - constructor(schemaParams?: SchemaParams); -} - -// @public -export enum Modality { - AUDIO = "AUDIO", - DOCUMENT = "DOCUMENT", - IMAGE = "IMAGE", - MODALITY_UNSPECIFIED = "MODALITY_UNSPECIFIED", - TEXT = "TEXT", - VIDEO = "VIDEO" -} - -// @public -export interface ModalityTokenCount { - modality: Modality; - tokenCount: number; -} - -// @public -export interface ModelParams extends BaseParams { - // (undocumented) - model: string; - // (undocumented) - systemInstruction?: string | Part | Content; - // (undocumented) - toolConfig?: ToolConfig; - // (undocumented) - tools?: Tool[]; -} - -// @public -export class NumberSchema extends Schema { - constructor(schemaParams?: SchemaParams); -} - -// @public -export class ObjectSchema extends Schema { - constructor(schemaParams: SchemaParams, properties: { - [k: string]: TypedSchema; - }, optionalProperties?: string[]); - // (undocumented) - optionalProperties: string[]; - // (undocumented) - properties: { - [k: string]: TypedSchema; - }; - // @internal (undocumented) - toJSON(): SchemaRequest; -} - -// @public -export interface ObjectSchemaRequest extends SchemaRequest { - optionalProperties?: never; - // (undocumented) - type: SchemaType.OBJECT; -} - -// @public -export type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart; - -// @public -export const POSSIBLE_ROLES: readonly ["user", "model", "function", "system"]; - -// @public -export interface PromptFeedback { - // (undocumented) - blockReason?: BlockReason; - blockReasonMessage?: string; - // (undocumented) - safetyRatings: SafetyRating[]; -} - -// @public -export interface RequestOptions { - baseUrl?: string; - timeout?: number; -} - -// @beta -export const ResponseModality: { - readonly TEXT: "TEXT"; - readonly IMAGE: "IMAGE"; -}; - -// @beta -export type ResponseModality = (typeof ResponseModality)[keyof typeof ResponseModality]; - -// @public (undocumented) -export interface RetrievedContextAttribution { - // (undocumented) - title: string; - // (undocumented) - uri: string; -} - -// @public -export type Role = (typeof POSSIBLE_ROLES)[number]; - -// @public -export interface SafetyRating { - // (undocumented) - blocked: boolean; - // (undocumented) - category: HarmCategory; - // (undocumented) - probability: HarmProbability; - probabilityScore: number; - severity: HarmSeverity; - severityScore: number; -} - -// @public -export interface SafetySetting { - // (undocumented) - category: HarmCategory; - method?: HarmBlockMethod; - // (undocumented) - threshold: HarmBlockThreshold; -} - -// @public -export abstract class Schema implements SchemaInterface { - constructor(schemaParams: SchemaInterface); - [key: string]: unknown; - // (undocumented) - static array(arrayParams: SchemaParams & { - items: Schema; - }): ArraySchema; - // (undocumented) - static boolean(booleanParams?: SchemaParams): BooleanSchema; - description?: string; - // (undocumented) - static enumString(stringParams: SchemaParams & { - enum: string[]; - }): StringSchema; - example?: unknown; - format?: string; - // (undocumented) - static integer(integerParams?: SchemaParams): IntegerSchema; - nullable: boolean; - // (undocumented) - static number(numberParams?: SchemaParams): NumberSchema; - // (undocumented) - static object(objectParams: SchemaParams & { - properties: { - [k: string]: Schema; - }; - optionalProperties?: string[]; - }): ObjectSchema; - // (undocumented) - static string(stringParams?: SchemaParams): StringSchema; - // @internal - toJSON(): SchemaRequest; - type: SchemaType; -} - -// @public -export interface SchemaInterface extends SchemaShared { - type: SchemaType; -} - -// @public -export interface SchemaParams extends SchemaShared { -} - -// @public -export interface SchemaRequest extends SchemaShared { - required?: string[]; - type: SchemaType; -} - -// @public -export interface SchemaShared { - // (undocumented) - [key: string]: unknown; - description?: string; - enum?: string[]; - example?: unknown; - format?: string; - items?: T; - nullable?: boolean; - properties?: { - [k: string]: T; - }; -} - -// @public -export enum SchemaType { - ARRAY = "array", - BOOLEAN = "boolean", - INTEGER = "integer", - NUMBER = "number", - OBJECT = "object", - STRING = "string" -} - -// @public (undocumented) -export interface Segment { - // (undocumented) - endIndex: number; - // (undocumented) - partIndex: number; - // (undocumented) - startIndex: number; -} - -// @public -export interface StartChatParams extends BaseParams { - // (undocumented) - history?: Content[]; - // (undocumented) - systemInstruction?: string | Part | Content; - // (undocumented) - toolConfig?: ToolConfig; - // (undocumented) - tools?: Tool[]; -} - -// @public -export class StringSchema extends Schema { - constructor(schemaParams?: SchemaParams, enumValues?: string[]); - // (undocumented) - enum?: string[]; - // @internal (undocumented) - toJSON(): SchemaRequest; -} - -// @public -export interface TextPart { - // (undocumented) - functionCall?: never; - // (undocumented) - functionResponse?: never; - // (undocumented) - inlineData?: never; - // (undocumented) - text: string; -} - -// @public -export type Tool = FunctionDeclarationsTool; - -// @public -export interface ToolConfig { - // (undocumented) - functionCallingConfig?: FunctionCallingConfig; -} - -// @public -export type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema; - -// @public -export interface UsageMetadata { - // (undocumented) - candidatesTokenCount: number; - // (undocumented) - candidatesTokensDetails?: ModalityTokenCount[]; - // (undocumented) - promptTokenCount: number; - // (undocumented) - promptTokensDetails?: ModalityTokenCount[]; - // (undocumented) - totalTokenCount: number; -} - -// @public -export type VertexAI = AI; - -// @public -export class VertexAIBackend extends Backend { - constructor(location?: string); - readonly location: string; -} - -// @public -export const VertexAIError: typeof AIError; - -// @public -export const VertexAIModel: typeof AIModel; - -// @public -export interface VertexAIOptions { - // (undocumented) - location?: string; -} - -// @public -export interface VideoMetadata { - endOffset: string; - startOffset: string; -} - -// @public (undocumented) -export interface WebAttribution { - // (undocumented) - title: string; - // (undocumented) - uri: string; -} - - -```