@langchain/google-common 2.1.15 → 2.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/auth.cjs +37 -11
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +10 -0
- package/dist/auth.d.cts.map +1 -1
- package/dist/auth.d.ts +10 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +37 -11
- package/dist/auth.js.map +1 -1
- package/dist/chat_models.cjs +1 -1
- package/dist/chat_models.cjs.map +1 -1
- package/dist/chat_models.js +1 -1
- package/dist/chat_models.js.map +1 -1
- package/dist/connection.cjs.map +1 -1
- package/dist/connection.js.map +1 -1
- package/dist/experimental/media.cjs.map +1 -1
- package/dist/experimental/media.d.cts.map +1 -1
- package/dist/experimental/media.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/gemini.cjs.map +1 -1
- package/dist/utils/gemini.js.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.js","names":["fields: GoogleConnectionParams<AuthOptions> | undefined","caller: AsyncCaller","client: GoogleAbstractedClient","separator: string","data: MediaBlob","metadata: Record<string, unknown>","options: CallOptions","fields?: BlobStoreGoogleParams<AuthOptions>","keyValuePair: [string, MediaBlob]","keyValuePairs: [string, MediaBlob][]","key: string","keys: string[]","_prefix: string | undefined","uri: string","fields: GoogleCloudStorageUploadConnectionParams<AuthOptions>","fields: GoogleCloudStorageDownloadConnectionParams<AuthOptions>","fields: GoogleCloudStorageRawConnectionParams<AuthOptions>","fields: BlobStoreGoogleCloudStorageBaseParams<AuthOptions>","params: GoogleCloudStorageUploadConnectionParams<AuthOptions>","ret: GoogleCloudStorageObject","params: GoogleCloudStorageDownloadConnectionParams<AuthOptions>","params: GoogleCloudStorageRawConnectionParams<AuthOptions>","value: string","field: string","fields: AIStudioFileDownloadConnectionParams<AuthOptions>","fields?: BlobStoreAIStudioFileBaseParams<AuthOptions>","params: BlobStoreAIStudioFileBaseParams<AuthOptions>","path: string","apiKey: string","params: AIStudioFileDownloadConnectionParams<AuthOptions>","_key: string","data: MediaBlobData"],"sources":["../../src/experimental/media.ts"],"sourcesContent":["import {\n AsyncCaller,\n AsyncCallerCallOptions,\n AsyncCallerParams,\n} from \"@langchain/core/utils/async_caller\";\nimport { getEnvironmentVariable } from \"@langchain/core/utils/env\";\nimport {\n MediaBlob,\n BlobStore,\n BlobStoreOptions,\n MediaBlobData,\n} from \"./utils/media_core.js\";\nimport {\n GoogleConnectionParams,\n GoogleRawResponse,\n GoogleResponse,\n} from \"../types.js\";\nimport { GoogleHostConnection, GoogleRawConnection } from \"../connection.js\";\nimport {\n ApiKeyGoogleAuth,\n GoogleAbstractedClient,\n GoogleAbstractedClientOpsMethod,\n} from \"../auth.js\";\n\nexport interface GoogleUploadConnectionParams<AuthOptions>\n extends GoogleConnectionParams<AuthOptions> {}\n\nexport abstract class GoogleMultipartUploadConnection<\n CallOptions extends AsyncCallerCallOptions,\n ResponseType extends GoogleResponse,\n AuthOptions,\n> extends GoogleHostConnection<CallOptions, ResponseType, AuthOptions> {\n constructor(\n fields: GoogleConnectionParams<AuthOptions> | undefined,\n caller: AsyncCaller,\n client: GoogleAbstractedClient\n ) {\n super(fields, caller, client);\n }\n\n async _body(\n separator: string,\n data: MediaBlob,\n metadata: Record<string, unknown>\n ): Promise<string> {\n const contentType = data.mimetype;\n const { encoded, encoding } = await data.encode();\n const body = [\n `--${separator}`,\n \"Content-Type: application/json; charset=UTF-8\",\n \"\",\n JSON.stringify(metadata),\n \"\",\n `--${separator}`,\n `Content-Type: ${contentType}`,\n `Content-Transfer-Encoding: ${encoding}`,\n \"\",\n encoded,\n `--${separator}--`,\n ];\n return body.join(\"\\n\");\n }\n\n async request(\n data: MediaBlob,\n metadata: Record<string, unknown>,\n options: CallOptions\n ): Promise<ResponseType> {\n const separator = `separator-${Date.now()}`;\n const body = await this._body(separator, data, metadata);\n const requestHeaders = {\n \"Content-Type\": `multipart/related; boundary=${separator}`,\n \"X-Goog-Upload-Protocol\": \"multipart\",\n };\n const response = this._request(body, options, requestHeaders);\n return response;\n }\n}\n\nexport abstract class GoogleDownloadConnection<\n CallOptions extends AsyncCallerCallOptions,\n ResponseType extends GoogleResponse,\n AuthOptions,\n> extends GoogleHostConnection<CallOptions, ResponseType, AuthOptions> {\n async request(options: CallOptions): Promise<ResponseType> {\n return this._request(undefined, options);\n }\n}\n\nexport abstract class GoogleDownloadRawConnection<\n CallOptions extends AsyncCallerCallOptions,\n AuthOptions,\n> extends GoogleRawConnection<CallOptions, AuthOptions> {\n buildMethod(): GoogleAbstractedClientOpsMethod {\n return \"GET\";\n }\n\n async request(options: CallOptions): Promise<GoogleRawResponse> {\n return this._request(undefined, options);\n }\n}\n\nexport interface BlobStoreGoogleParams<AuthOptions>\n extends GoogleConnectionParams<AuthOptions>,\n AsyncCallerParams,\n BlobStoreOptions {}\n\nexport abstract class BlobStoreGoogle<\n ResponseType extends GoogleResponse,\n AuthOptions,\n> extends BlobStore {\n caller: AsyncCaller;\n\n client: GoogleAbstractedClient;\n\n constructor(fields?: BlobStoreGoogleParams<AuthOptions>) {\n super(fields);\n this.caller = new AsyncCaller(fields ?? {});\n this.client = this.buildClient(fields);\n }\n\n abstract buildClient(\n fields?: BlobStoreGoogleParams<AuthOptions>\n ): GoogleAbstractedClient;\n\n abstract buildSetMetadata([key, blob]: [string, MediaBlob]): Record<\n string,\n unknown\n >;\n\n abstract buildSetConnection([key, blob]: [\n string,\n MediaBlob,\n ]): GoogleMultipartUploadConnection<\n AsyncCallerCallOptions,\n ResponseType,\n AuthOptions\n >;\n\n async _set(keyValuePair: [string, MediaBlob]): Promise<ResponseType> {\n const [, blob] = keyValuePair;\n const setMetadata = this.buildSetMetadata(keyValuePair);\n const metadata = setMetadata;\n const options = {};\n const connection = this.buildSetConnection(keyValuePair);\n const response = await connection.request(blob, metadata, options);\n return response;\n }\n\n async mset(keyValuePairs: [string, MediaBlob][]): Promise<void> {\n const ret = keyValuePairs.map((keyValue) => this._set(keyValue));\n await Promise.all(ret);\n }\n\n abstract buildGetMetadataConnection(\n key: string\n ): GoogleDownloadConnection<\n AsyncCallerCallOptions,\n ResponseType,\n AuthOptions\n >;\n\n async _getMetadata(key: string): Promise<Record<string, unknown>> {\n const connection = this.buildGetMetadataConnection(key);\n const options = {};\n const response = await connection.request(options);\n return response.data;\n }\n\n abstract buildGetDataConnection(\n key: string\n ): GoogleDownloadRawConnection<AsyncCallerCallOptions, AuthOptions>;\n\n async _getData(key: string): Promise<Blob> {\n const connection = this.buildGetDataConnection(key);\n const options = {};\n const response = await connection.request(options);\n return response.data;\n }\n\n _getMimetypeFromMetadata(metadata: Record<string, unknown>): string {\n return metadata.contentType as string;\n }\n\n async _get(key: string): Promise<MediaBlob | undefined> {\n const metadata = await this._getMetadata(key);\n const data = await this._getData(key);\n if (data && metadata) {\n const ret = await MediaBlob.fromBlob(data, { metadata, path: key });\n return ret;\n } else {\n return undefined;\n }\n }\n\n async mget(keys: string[]): Promise<(MediaBlob | undefined)[]> {\n const ret = keys.map((key) => this._get(key));\n return await Promise.all(ret);\n }\n\n abstract buildDeleteConnection(\n key: string\n ): GoogleDownloadConnection<\n AsyncCallerCallOptions,\n GoogleResponse,\n AuthOptions\n >;\n\n async _del(key: string): Promise<void> {\n const connection = this.buildDeleteConnection(key);\n const options = {};\n await connection.request(options);\n }\n\n async mdelete(keys: string[]): Promise<void> {\n const ret = keys.map((key) => this._del(key));\n await Promise.all(ret);\n }\n\n // eslint-disable-next-line require-yield\n async *yieldKeys(_prefix: string | undefined): AsyncGenerator<string> {\n // TODO: Implement. Most have an implementation that uses nextToken.\n throw new Error(\"yieldKeys is not implemented\");\n }\n}\n\n/**\n * Based on https://cloud.google.com/storage/docs/json_api/v1/objects#resource\n */\nexport interface GoogleCloudStorageObject extends Record<string, unknown> {\n id?: string;\n name?: string;\n contentType?: string;\n metadata?: Record<string, unknown>;\n // This is incomplete.\n}\n\nexport interface GoogleCloudStorageResponse extends GoogleResponse {\n data: GoogleCloudStorageObject;\n}\n\nexport type BucketAndPath = {\n bucket: string;\n path: string;\n};\n\nexport class GoogleCloudStorageUri {\n static uriRegexp = /gs:\\/\\/([a-z0-9][a-z0-9._-]+[a-z0-9])\\/(.*)/;\n\n bucket: string;\n\n path: string;\n\n constructor(uri: string) {\n const bucketAndPath = GoogleCloudStorageUri.uriToBucketAndPath(uri);\n this.bucket = bucketAndPath.bucket;\n this.path = bucketAndPath.path;\n }\n\n get uri() {\n return `gs://${this.bucket}/${this.path}`;\n }\n\n get isValid() {\n return (\n typeof this.bucket !== \"undefined\" && typeof this.path !== \"undefined\"\n );\n }\n\n static uriToBucketAndPath(uri: string): BucketAndPath {\n const match = this.uriRegexp.exec(uri);\n if (!match) {\n throw new Error(`Invalid gs:// URI: ${uri}`);\n }\n return {\n bucket: match[1],\n path: match[2],\n };\n }\n\n static isValidUri(uri: string): boolean {\n return this.uriRegexp.test(uri);\n }\n}\n\nexport interface GoogleCloudStorageConnectionParams {\n uri: string;\n}\n\nexport interface GoogleCloudStorageUploadConnectionParams<AuthOptions>\n extends GoogleUploadConnectionParams<AuthOptions>,\n GoogleCloudStorageConnectionParams {}\n\nexport class GoogleCloudStorageUploadConnection<\n AuthOptions,\n> extends GoogleMultipartUploadConnection<\n AsyncCallerCallOptions,\n GoogleCloudStorageResponse,\n AuthOptions\n> {\n uri: GoogleCloudStorageUri;\n\n constructor(\n fields: GoogleCloudStorageUploadConnectionParams<AuthOptions>,\n caller: AsyncCaller,\n client: GoogleAbstractedClient\n ) {\n super(fields, caller, client);\n this.uri = new GoogleCloudStorageUri(fields.uri);\n }\n\n async buildUrl(): Promise<string> {\n return `https://storage.googleapis.com/upload/storage/${this.apiVersion}/b/${this.uri.bucket}/o?uploadType=multipart`;\n }\n}\n\nexport interface GoogleCloudStorageDownloadConnectionParams<AuthOptions>\n extends GoogleCloudStorageConnectionParams,\n GoogleConnectionParams<AuthOptions> {\n method: GoogleAbstractedClientOpsMethod;\n alt: \"media\" | undefined;\n}\n\nexport class GoogleCloudStorageDownloadConnection<\n ResponseType extends GoogleResponse,\n AuthOptions,\n> extends GoogleDownloadConnection<\n AsyncCallerCallOptions,\n ResponseType,\n AuthOptions\n> {\n uri: GoogleCloudStorageUri;\n\n method: GoogleAbstractedClientOpsMethod;\n\n alt: \"media\" | undefined;\n\n constructor(\n fields: GoogleCloudStorageDownloadConnectionParams<AuthOptions>,\n caller: AsyncCaller,\n client: GoogleAbstractedClient\n ) {\n super(fields, caller, client);\n this.uri = new GoogleCloudStorageUri(fields.uri);\n this.method = fields.method;\n this.alt = fields.alt;\n }\n\n buildMethod(): GoogleAbstractedClientOpsMethod {\n return this.method;\n }\n\n async buildUrl(): Promise<string> {\n const path = encodeURIComponent(this.uri.path);\n const ret = `https://storage.googleapis.com/storage/${this.apiVersion}/b/${this.uri.bucket}/o/${path}`;\n return this.alt ? `${ret}?alt=${this.alt}` : ret;\n }\n}\n\nexport interface GoogleCloudStorageRawConnectionParams<AuthOptions>\n extends GoogleCloudStorageConnectionParams,\n GoogleConnectionParams<AuthOptions> {}\n\nexport class GoogleCloudStorageRawConnection<\n AuthOptions,\n> extends GoogleDownloadRawConnection<AsyncCallerCallOptions, AuthOptions> {\n uri: GoogleCloudStorageUri;\n\n constructor(\n fields: GoogleCloudStorageRawConnectionParams<AuthOptions>,\n caller: AsyncCaller,\n client: GoogleAbstractedClient\n ) {\n super(fields, caller, client);\n this.uri = new GoogleCloudStorageUri(fields.uri);\n }\n\n async buildUrl(): Promise<string> {\n const path = encodeURIComponent(this.uri.path);\n const ret = `https://storage.googleapis.com/storage/${this.apiVersion}/b/${this.uri.bucket}/o/${path}?alt=media`;\n return ret;\n }\n}\n\nexport interface BlobStoreGoogleCloudStorageBaseParams<AuthOptions>\n extends BlobStoreGoogleParams<AuthOptions> {\n uriPrefix: GoogleCloudStorageUri;\n}\n\nexport abstract class BlobStoreGoogleCloudStorageBase<\n AuthOptions,\n> extends BlobStoreGoogle<GoogleCloudStorageResponse, AuthOptions> {\n params: BlobStoreGoogleCloudStorageBaseParams<AuthOptions>;\n\n constructor(fields: BlobStoreGoogleCloudStorageBaseParams<AuthOptions>) {\n super(fields);\n this.params = fields;\n this.defaultStoreOptions = {\n ...this.defaultStoreOptions,\n pathPrefix: fields.uriPrefix.uri,\n };\n }\n\n buildSetConnection([key, _blob]: [\n string,\n MediaBlob,\n ]): GoogleMultipartUploadConnection<\n AsyncCallerCallOptions,\n GoogleCloudStorageResponse,\n AuthOptions\n > {\n const params: GoogleCloudStorageUploadConnectionParams<AuthOptions> = {\n ...this.params,\n uri: key,\n };\n return new GoogleCloudStorageUploadConnection<AuthOptions>(\n params,\n this.caller,\n this.client\n );\n }\n\n buildSetMetadata([key, blob]: [string, MediaBlob]): Record<string, unknown> {\n const uri = new GoogleCloudStorageUri(key);\n const ret: GoogleCloudStorageObject = {\n name: uri.path,\n metadata: blob.metadata,\n contentType: blob.mimetype,\n };\n return ret;\n }\n\n buildGetMetadataConnection(\n key: string\n ): GoogleDownloadConnection<\n AsyncCallerCallOptions,\n GoogleCloudStorageResponse,\n AuthOptions\n > {\n const params: GoogleCloudStorageDownloadConnectionParams<AuthOptions> = {\n uri: key,\n method: \"GET\",\n alt: undefined,\n };\n return new GoogleCloudStorageDownloadConnection<\n GoogleCloudStorageResponse,\n AuthOptions\n >(params, this.caller, this.client);\n }\n\n buildGetDataConnection(\n key: string\n ): GoogleDownloadRawConnection<AsyncCallerCallOptions, AuthOptions> {\n const params: GoogleCloudStorageRawConnectionParams<AuthOptions> = {\n uri: key,\n };\n return new GoogleCloudStorageRawConnection<AuthOptions>(\n params,\n this.caller,\n this.client\n );\n }\n\n buildDeleteConnection(\n key: string\n ): GoogleDownloadConnection<\n AsyncCallerCallOptions,\n GoogleResponse,\n AuthOptions\n > {\n const params: GoogleCloudStorageDownloadConnectionParams<AuthOptions> = {\n uri: key,\n method: \"DELETE\",\n alt: undefined,\n };\n return new GoogleCloudStorageDownloadConnection<\n GoogleResponse,\n AuthOptions\n >(params, this.caller, this.client);\n }\n}\n\nexport type AIStudioFileState =\n | \"PROCESSING\"\n | \"ACTIVE\"\n | \"FAILED\"\n | \"STATE_UNSPECIFIED\";\n\nexport type AIStudioFileVideoMetadata = {\n videoMetadata: {\n videoDuration: string; // Duration in seconds, possibly with fractional, ending in \"s\"\n };\n};\n\nexport type AIStudioFileMetadata = AIStudioFileVideoMetadata;\n\nexport interface AIStudioFileObject {\n name?: string;\n displayName?: string;\n mimeType?: string;\n sizeBytes?: string; // int64 format\n createTime?: string; // timestamp format\n updateTime?: string; // timestamp format\n expirationTime?: string; // timestamp format\n sha256Hash?: string; // base64 encoded\n uri?: string;\n state?: AIStudioFileState;\n error?: {\n code: number;\n message: string;\n details: Record<string, unknown>[];\n };\n metadata?: AIStudioFileMetadata;\n}\n\nexport class AIStudioMediaBlob extends MediaBlob {\n _valueAsDate(value: string): Date {\n if (!value) {\n return new Date(0);\n }\n return new Date(value);\n }\n\n _metadataFieldAsDate(field: string): Date {\n return this._valueAsDate(this.metadata?.[field]);\n }\n\n get createDate(): Date {\n return this._metadataFieldAsDate(\"createTime\");\n }\n\n get updateDate(): Date {\n return this._metadataFieldAsDate(\"updateTime\");\n }\n\n get expirationDate(): Date {\n return this._metadataFieldAsDate(\"expirationTime\");\n }\n\n get isExpired(): boolean {\n const now = new Date().toISOString();\n const exp = this.metadata?.expirationTime ?? now;\n return exp <= now;\n }\n}\n\nexport interface AIStudioFileGetResponse extends GoogleResponse {\n data: AIStudioFileObject;\n}\n\nexport interface AIStudioFileSaveResponse extends GoogleResponse {\n data: {\n file: AIStudioFileObject;\n };\n}\n\nexport interface AIStudioFileListResponse extends GoogleResponse {\n data: {\n files: AIStudioFileObject[];\n nextPageToken: string;\n };\n}\n\nexport type AIStudioFileResponse =\n | AIStudioFileGetResponse\n | AIStudioFileSaveResponse\n | AIStudioFileListResponse;\n\nexport interface AIStudioFileConnectionParams {}\n\nexport interface AIStudioFileUploadConnectionParams<AuthOptions>\n extends GoogleUploadConnectionParams<AuthOptions>,\n AIStudioFileConnectionParams {}\n\nexport class AIStudioFileUploadConnection<\n AuthOptions,\n> extends GoogleMultipartUploadConnection<\n AsyncCallerCallOptions,\n AIStudioFileSaveResponse,\n AuthOptions\n> {\n get computedApiVersion(): string {\n return \"v1beta\";\n }\n\n async buildUrl(): Promise<string> {\n return `https://generativelanguage.googleapis.com/upload/${this.apiVersion}/files`;\n }\n}\n\nexport interface AIStudioFileDownloadConnectionParams<AuthOptions>\n extends AIStudioFileConnectionParams,\n GoogleConnectionParams<AuthOptions> {\n method: GoogleAbstractedClientOpsMethod;\n name: string;\n}\n\nexport class AIStudioFileDownloadConnection<\n ResponseType extends GoogleResponse,\n AuthOptions,\n> extends GoogleDownloadConnection<\n AsyncCallerCallOptions,\n ResponseType,\n AuthOptions\n> {\n method: GoogleAbstractedClientOpsMethod;\n\n name: string;\n\n constructor(\n fields: AIStudioFileDownloadConnectionParams<AuthOptions>,\n caller: AsyncCaller,\n client: GoogleAbstractedClient\n ) {\n super(fields, caller, client);\n this.method = fields.method;\n this.name = fields.name;\n }\n\n get computedApiVersion(): string {\n return \"v1beta\";\n }\n\n buildMethod(): GoogleAbstractedClientOpsMethod {\n return this.method;\n }\n\n async buildUrl(): Promise<string> {\n return `https://generativelanguage.googleapis.com/${this.apiVersion}/files/${this.name}`;\n }\n}\n\nexport interface BlobStoreAIStudioFileBaseParams<AuthOptions>\n extends BlobStoreGoogleParams<AuthOptions> {\n retryTime?: number;\n}\n\nexport abstract class BlobStoreAIStudioFileBase<\n AuthOptions,\n> extends BlobStoreGoogle<AIStudioFileResponse, AuthOptions> {\n params?: BlobStoreAIStudioFileBaseParams<AuthOptions>;\n\n retryTime: number = 1000;\n\n constructor(fields?: BlobStoreAIStudioFileBaseParams<AuthOptions>) {\n const params: BlobStoreAIStudioFileBaseParams<AuthOptions> = {\n defaultStoreOptions: {\n pathPrefix: \"https://generativelanguage.googleapis.com/v1beta/files/\",\n actionIfInvalid: \"removePath\",\n },\n ...fields,\n };\n super(params);\n this.params = params;\n this.retryTime = params?.retryTime ?? this.retryTime ?? 1000;\n }\n\n _pathToName(path: string): string {\n return path.split(\"/\").pop() ?? path;\n }\n\n abstract buildAbstractedClient(\n fields?: BlobStoreGoogleParams<AuthOptions>\n ): GoogleAbstractedClient;\n\n buildApiKeyClient(apiKey: string): GoogleAbstractedClient {\n return new ApiKeyGoogleAuth(apiKey);\n }\n\n buildApiKey(fields?: BlobStoreGoogleParams<AuthOptions>): string | undefined {\n return fields?.apiKey ?? getEnvironmentVariable(\"GOOGLE_API_KEY\");\n }\n\n buildClient(\n fields?: BlobStoreGoogleParams<AuthOptions>\n ): GoogleAbstractedClient {\n const apiKey = this.buildApiKey(fields);\n if (apiKey) {\n return this.buildApiKeyClient(apiKey);\n } else {\n // TODO: Test that you can use OAuth to access\n return this.buildAbstractedClient(fields);\n }\n }\n\n async _regetMetadata(key: string): Promise<AIStudioFileObject> {\n // Sleep for some time period\n await new Promise((resolve) => setTimeout(resolve, this.retryTime));\n\n // Fetch the latest metadata\n return this._getMetadata(key);\n }\n\n async _set([key, blob]: [\n string,\n MediaBlob,\n ]): Promise<AIStudioFileSaveResponse> {\n const response = (await super._set([\n key,\n blob,\n ])) as AIStudioFileSaveResponse;\n\n let file = response.data?.file ?? { state: \"FAILED\" };\n while (file.state === \"PROCESSING\" && file.uri && this.retryTime > 0) {\n file = await this._regetMetadata(file.uri);\n }\n\n // The response should contain the name (and valid URI), so we need to\n // update the blob with this. We can't return a new blob, since mset()\n // doesn't return anything.\n blob.path = file.uri;\n blob.metadata = {\n ...blob.metadata,\n ...file,\n };\n return response;\n }\n\n buildSetConnection([_key, _blob]: [\n string,\n MediaBlob,\n ]): GoogleMultipartUploadConnection<\n AsyncCallerCallOptions,\n AIStudioFileResponse,\n AuthOptions\n > {\n return new AIStudioFileUploadConnection(\n this.params,\n this.caller,\n this.client\n );\n }\n\n buildSetMetadata([_key, _blob]: [string, MediaBlob]): Record<\n string,\n unknown\n > {\n return {};\n }\n\n buildGetMetadataConnection(\n key: string\n ): GoogleDownloadConnection<\n AsyncCallerCallOptions,\n AIStudioFileResponse,\n AuthOptions\n > {\n const params: AIStudioFileDownloadConnectionParams<AuthOptions> = {\n ...this.params,\n method: \"GET\",\n name: this._pathToName(key),\n };\n return new AIStudioFileDownloadConnection<\n AIStudioFileResponse,\n AuthOptions\n >(params, this.caller, this.client);\n }\n\n buildGetDataConnection(\n _key: string\n ): GoogleDownloadRawConnection<AsyncCallerCallOptions, AuthOptions> {\n throw new Error(\"AI Studio File API does not provide data\");\n }\n\n async _get(key: string): Promise<MediaBlob | undefined> {\n const metadata = await this._getMetadata(key);\n if (metadata) {\n const contentType =\n (metadata?.mimeType as string) ?? \"application/octet-stream\";\n // TODO - Get the actual data (and other metadata) from an optional backing store\n const data: MediaBlobData = {\n value: \"\",\n type: contentType,\n };\n\n return new MediaBlob({\n path: key,\n data,\n metadata,\n });\n } else {\n return undefined;\n }\n }\n\n buildDeleteConnection(\n key: string\n ): GoogleDownloadConnection<\n AsyncCallerCallOptions,\n AIStudioFileResponse,\n AuthOptions\n > {\n const params: AIStudioFileDownloadConnectionParams<AuthOptions> = {\n ...this.params,\n method: \"DELETE\",\n name: this._pathToName(key),\n };\n return new AIStudioFileDownloadConnection<\n AIStudioFileResponse,\n AuthOptions\n >(params, this.caller, this.client);\n }\n}\n"],"mappings":";;;;;;;AA2BA,IAAsB,kCAAtB,cAIU,qBAA6D;CACrE,YACEA,QACAC,QACAC,QACA;EACA,MAAM,QAAQ,QAAQ,OAAO;CAC9B;CAED,MAAM,MACJC,WACAC,MACAC,UACiB;EACjB,MAAM,cAAc,KAAK;EACzB,MAAM,EAAE,SAAS,UAAU,GAAG,MAAM,KAAK,QAAQ;EACjD,MAAM,OAAO;GACX,CAAC,EAAE,EAAE,WAAW;GAChB;GACA;GACA,KAAK,UAAU,SAAS;GACxB;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,UAAU;GACZ,MAAM,cACH,UAAU,YAAuB;GAEpC,MAAMqB,OAAsB;IAC1B,OAAO;IACP,MAAM;GACP;AAED,UAAO,IAAI,UAAU;IACnB,MAAM;IACN;IACA;GACD;EACF,MACC,QAAO;CAEV;CAED,sBACErB,KAKA;EACA,MAAMmB,SAA4D;GAChE,GAAG,KAAK;GACR,QAAQ;GACR,MAAM,KAAK,YAAY,IAAI;EAC5B;AACD,SAAO,IAAI,+BAGT,QAAQ,KAAK,QAAQ,KAAK;CAC7B;AACF"}
|
|
1
|
+
{"version":3,"file":"media.js","names":["fields: GoogleConnectionParams<AuthOptions> | undefined","caller: AsyncCaller","client: GoogleAbstractedClient","separator: string","data: MediaBlob","metadata: Record<string, unknown>","options: CallOptions","fields?: BlobStoreGoogleParams<AuthOptions>","keyValuePair: [string, MediaBlob]","keyValuePairs: [string, MediaBlob][]","key: string","keys: string[]","_prefix: string | undefined","uri: string","fields: GoogleCloudStorageUploadConnectionParams<AuthOptions>","fields: GoogleCloudStorageDownloadConnectionParams<AuthOptions>","fields: GoogleCloudStorageRawConnectionParams<AuthOptions>","fields: BlobStoreGoogleCloudStorageBaseParams<AuthOptions>","params: GoogleCloudStorageUploadConnectionParams<AuthOptions>","ret: GoogleCloudStorageObject","params: GoogleCloudStorageDownloadConnectionParams<AuthOptions>","params: GoogleCloudStorageRawConnectionParams<AuthOptions>","value: string","field: string","fields: AIStudioFileDownloadConnectionParams<AuthOptions>","fields?: BlobStoreAIStudioFileBaseParams<AuthOptions>","params: BlobStoreAIStudioFileBaseParams<AuthOptions>","path: string","apiKey: string","params: AIStudioFileDownloadConnectionParams<AuthOptions>","_key: string","data: MediaBlobData"],"sources":["../../src/experimental/media.ts"],"sourcesContent":["import {\n AsyncCaller,\n AsyncCallerCallOptions,\n AsyncCallerParams,\n} from \"@langchain/core/utils/async_caller\";\nimport { getEnvironmentVariable } from \"@langchain/core/utils/env\";\nimport {\n MediaBlob,\n BlobStore,\n BlobStoreOptions,\n MediaBlobData,\n} from \"./utils/media_core.js\";\nimport {\n GoogleConnectionParams,\n GoogleRawResponse,\n GoogleResponse,\n} from \"../types.js\";\nimport { GoogleHostConnection, GoogleRawConnection } from \"../connection.js\";\nimport {\n ApiKeyGoogleAuth,\n GoogleAbstractedClient,\n GoogleAbstractedClientOpsMethod,\n} from \"../auth.js\";\n\nexport interface GoogleUploadConnectionParams<\n AuthOptions,\n> extends GoogleConnectionParams<AuthOptions> {}\n\nexport abstract class GoogleMultipartUploadConnection<\n CallOptions extends AsyncCallerCallOptions,\n ResponseType extends GoogleResponse,\n AuthOptions,\n> extends GoogleHostConnection<CallOptions, ResponseType, AuthOptions> {\n constructor(\n fields: GoogleConnectionParams<AuthOptions> | undefined,\n caller: AsyncCaller,\n client: GoogleAbstractedClient\n ) {\n super(fields, caller, client);\n }\n\n async _body(\n separator: string,\n data: MediaBlob,\n metadata: Record<string, unknown>\n ): Promise<string> {\n const contentType = data.mimetype;\n const { encoded, encoding } = await data.encode();\n const body = [\n `--${separator}`,\n \"Content-Type: application/json; charset=UTF-8\",\n \"\",\n JSON.stringify(metadata),\n \"\",\n `--${separator}`,\n `Content-Type: ${contentType}`,\n `Content-Transfer-Encoding: ${encoding}`,\n \"\",\n encoded,\n `--${separator}--`,\n ];\n return body.join(\"\\n\");\n }\n\n async request(\n data: MediaBlob,\n metadata: Record<string, unknown>,\n options: CallOptions\n ): Promise<ResponseType> {\n const separator = `separator-${Date.now()}`;\n const body = await this._body(separator, data, metadata);\n const requestHeaders = {\n \"Content-Type\": `multipart/related; boundary=${separator}`,\n \"X-Goog-Upload-Protocol\": \"multipart\",\n };\n const response = this._request(body, options, requestHeaders);\n return response;\n }\n}\n\nexport abstract class GoogleDownloadConnection<\n CallOptions extends AsyncCallerCallOptions,\n ResponseType extends GoogleResponse,\n AuthOptions,\n> extends GoogleHostConnection<CallOptions, ResponseType, AuthOptions> {\n async request(options: CallOptions): Promise<ResponseType> {\n return this._request(undefined, options);\n }\n}\n\nexport abstract class GoogleDownloadRawConnection<\n CallOptions extends AsyncCallerCallOptions,\n AuthOptions,\n> extends GoogleRawConnection<CallOptions, AuthOptions> {\n buildMethod(): GoogleAbstractedClientOpsMethod {\n return \"GET\";\n }\n\n async request(options: CallOptions): Promise<GoogleRawResponse> {\n return this._request(undefined, options);\n }\n}\n\nexport interface BlobStoreGoogleParams<AuthOptions>\n extends\n GoogleConnectionParams<AuthOptions>,\n AsyncCallerParams,\n BlobStoreOptions {}\n\nexport abstract class BlobStoreGoogle<\n ResponseType extends GoogleResponse,\n AuthOptions,\n> extends BlobStore {\n caller: AsyncCaller;\n\n client: GoogleAbstractedClient;\n\n constructor(fields?: BlobStoreGoogleParams<AuthOptions>) {\n super(fields);\n this.caller = new AsyncCaller(fields ?? {});\n this.client = this.buildClient(fields);\n }\n\n abstract buildClient(\n fields?: BlobStoreGoogleParams<AuthOptions>\n ): GoogleAbstractedClient;\n\n abstract buildSetMetadata([key, blob]: [string, MediaBlob]): Record<\n string,\n unknown\n >;\n\n abstract buildSetConnection([key, blob]: [\n string,\n MediaBlob,\n ]): GoogleMultipartUploadConnection<\n AsyncCallerCallOptions,\n ResponseType,\n AuthOptions\n >;\n\n async _set(keyValuePair: [string, MediaBlob]): Promise<ResponseType> {\n const [, blob] = keyValuePair;\n const setMetadata = this.buildSetMetadata(keyValuePair);\n const metadata = setMetadata;\n const options = {};\n const connection = this.buildSetConnection(keyValuePair);\n const response = await connection.request(blob, metadata, options);\n return response;\n }\n\n async mset(keyValuePairs: [string, MediaBlob][]): Promise<void> {\n const ret = keyValuePairs.map((keyValue) => this._set(keyValue));\n await Promise.all(ret);\n }\n\n abstract buildGetMetadataConnection(\n key: string\n ): GoogleDownloadConnection<\n AsyncCallerCallOptions,\n ResponseType,\n AuthOptions\n >;\n\n async _getMetadata(key: string): Promise<Record<string, unknown>> {\n const connection = this.buildGetMetadataConnection(key);\n const options = {};\n const response = await connection.request(options);\n return response.data;\n }\n\n abstract buildGetDataConnection(\n key: string\n ): GoogleDownloadRawConnection<AsyncCallerCallOptions, AuthOptions>;\n\n async _getData(key: string): Promise<Blob> {\n const connection = this.buildGetDataConnection(key);\n const options = {};\n const response = await connection.request(options);\n return response.data;\n }\n\n _getMimetypeFromMetadata(metadata: Record<string, unknown>): string {\n return metadata.contentType as string;\n }\n\n async _get(key: string): Promise<MediaBlob | undefined> {\n const metadata = await this._getMetadata(key);\n const data = await this._getData(key);\n if (data && metadata) {\n const ret = await MediaBlob.fromBlob(data, { metadata, path: key });\n return ret;\n } else {\n return undefined;\n }\n }\n\n async mget(keys: string[]): Promise<(MediaBlob | undefined)[]> {\n const ret = keys.map((key) => this._get(key));\n return await Promise.all(ret);\n }\n\n abstract buildDeleteConnection(\n key: string\n ): GoogleDownloadConnection<\n AsyncCallerCallOptions,\n GoogleResponse,\n AuthOptions\n >;\n\n async _del(key: string): Promise<void> {\n const connection = this.buildDeleteConnection(key);\n const options = {};\n await connection.request(options);\n }\n\n async mdelete(keys: string[]): Promise<void> {\n const ret = keys.map((key) => this._del(key));\n await Promise.all(ret);\n }\n\n // eslint-disable-next-line require-yield\n async *yieldKeys(_prefix: string | undefined): AsyncGenerator<string> {\n // TODO: Implement. Most have an implementation that uses nextToken.\n throw new Error(\"yieldKeys is not implemented\");\n }\n}\n\n/**\n * Based on https://cloud.google.com/storage/docs/json_api/v1/objects#resource\n */\nexport interface GoogleCloudStorageObject extends Record<string, unknown> {\n id?: string;\n name?: string;\n contentType?: string;\n metadata?: Record<string, unknown>;\n // This is incomplete.\n}\n\nexport interface GoogleCloudStorageResponse extends GoogleResponse {\n data: GoogleCloudStorageObject;\n}\n\nexport type BucketAndPath = {\n bucket: string;\n path: string;\n};\n\nexport class GoogleCloudStorageUri {\n static uriRegexp = /gs:\\/\\/([a-z0-9][a-z0-9._-]+[a-z0-9])\\/(.*)/;\n\n bucket: string;\n\n path: string;\n\n constructor(uri: string) {\n const bucketAndPath = GoogleCloudStorageUri.uriToBucketAndPath(uri);\n this.bucket = bucketAndPath.bucket;\n this.path = bucketAndPath.path;\n }\n\n get uri() {\n return `gs://${this.bucket}/${this.path}`;\n }\n\n get isValid() {\n return (\n typeof this.bucket !== \"undefined\" && typeof this.path !== \"undefined\"\n );\n }\n\n static uriToBucketAndPath(uri: string): BucketAndPath {\n const match = this.uriRegexp.exec(uri);\n if (!match) {\n throw new Error(`Invalid gs:// URI: ${uri}`);\n }\n return {\n bucket: match[1],\n path: match[2],\n };\n }\n\n static isValidUri(uri: string): boolean {\n return this.uriRegexp.test(uri);\n }\n}\n\nexport interface GoogleCloudStorageConnectionParams {\n uri: string;\n}\n\nexport interface GoogleCloudStorageUploadConnectionParams<AuthOptions>\n extends\n GoogleUploadConnectionParams<AuthOptions>,\n GoogleCloudStorageConnectionParams {}\n\nexport class GoogleCloudStorageUploadConnection<\n AuthOptions,\n> extends GoogleMultipartUploadConnection<\n AsyncCallerCallOptions,\n GoogleCloudStorageResponse,\n AuthOptions\n> {\n uri: GoogleCloudStorageUri;\n\n constructor(\n fields: GoogleCloudStorageUploadConnectionParams<AuthOptions>,\n caller: AsyncCaller,\n client: GoogleAbstractedClient\n ) {\n super(fields, caller, client);\n this.uri = new GoogleCloudStorageUri(fields.uri);\n }\n\n async buildUrl(): Promise<string> {\n return `https://storage.googleapis.com/upload/storage/${this.apiVersion}/b/${this.uri.bucket}/o?uploadType=multipart`;\n }\n}\n\nexport interface GoogleCloudStorageDownloadConnectionParams<AuthOptions>\n extends\n GoogleCloudStorageConnectionParams,\n GoogleConnectionParams<AuthOptions> {\n method: GoogleAbstractedClientOpsMethod;\n alt: \"media\" | undefined;\n}\n\nexport class GoogleCloudStorageDownloadConnection<\n ResponseType extends GoogleResponse,\n AuthOptions,\n> extends GoogleDownloadConnection<\n AsyncCallerCallOptions,\n ResponseType,\n AuthOptions\n> {\n uri: GoogleCloudStorageUri;\n\n method: GoogleAbstractedClientOpsMethod;\n\n alt: \"media\" | undefined;\n\n constructor(\n fields: GoogleCloudStorageDownloadConnectionParams<AuthOptions>,\n caller: AsyncCaller,\n client: GoogleAbstractedClient\n ) {\n super(fields, caller, client);\n this.uri = new GoogleCloudStorageUri(fields.uri);\n this.method = fields.method;\n this.alt = fields.alt;\n }\n\n buildMethod(): GoogleAbstractedClientOpsMethod {\n return this.method;\n }\n\n async buildUrl(): Promise<string> {\n const path = encodeURIComponent(this.uri.path);\n const ret = `https://storage.googleapis.com/storage/${this.apiVersion}/b/${this.uri.bucket}/o/${path}`;\n return this.alt ? `${ret}?alt=${this.alt}` : ret;\n }\n}\n\nexport interface GoogleCloudStorageRawConnectionParams<AuthOptions>\n extends\n GoogleCloudStorageConnectionParams,\n GoogleConnectionParams<AuthOptions> {}\n\nexport class GoogleCloudStorageRawConnection<\n AuthOptions,\n> extends GoogleDownloadRawConnection<AsyncCallerCallOptions, AuthOptions> {\n uri: GoogleCloudStorageUri;\n\n constructor(\n fields: GoogleCloudStorageRawConnectionParams<AuthOptions>,\n caller: AsyncCaller,\n client: GoogleAbstractedClient\n ) {\n super(fields, caller, client);\n this.uri = new GoogleCloudStorageUri(fields.uri);\n }\n\n async buildUrl(): Promise<string> {\n const path = encodeURIComponent(this.uri.path);\n const ret = `https://storage.googleapis.com/storage/${this.apiVersion}/b/${this.uri.bucket}/o/${path}?alt=media`;\n return ret;\n }\n}\n\nexport interface BlobStoreGoogleCloudStorageBaseParams<\n AuthOptions,\n> extends BlobStoreGoogleParams<AuthOptions> {\n uriPrefix: GoogleCloudStorageUri;\n}\n\nexport abstract class BlobStoreGoogleCloudStorageBase<\n AuthOptions,\n> extends BlobStoreGoogle<GoogleCloudStorageResponse, AuthOptions> {\n params: BlobStoreGoogleCloudStorageBaseParams<AuthOptions>;\n\n constructor(fields: BlobStoreGoogleCloudStorageBaseParams<AuthOptions>) {\n super(fields);\n this.params = fields;\n this.defaultStoreOptions = {\n ...this.defaultStoreOptions,\n pathPrefix: fields.uriPrefix.uri,\n };\n }\n\n buildSetConnection([key, _blob]: [\n string,\n MediaBlob,\n ]): GoogleMultipartUploadConnection<\n AsyncCallerCallOptions,\n GoogleCloudStorageResponse,\n AuthOptions\n > {\n const params: GoogleCloudStorageUploadConnectionParams<AuthOptions> = {\n ...this.params,\n uri: key,\n };\n return new GoogleCloudStorageUploadConnection<AuthOptions>(\n params,\n this.caller,\n this.client\n );\n }\n\n buildSetMetadata([key, blob]: [string, MediaBlob]): Record<string, unknown> {\n const uri = new GoogleCloudStorageUri(key);\n const ret: GoogleCloudStorageObject = {\n name: uri.path,\n metadata: blob.metadata,\n contentType: blob.mimetype,\n };\n return ret;\n }\n\n buildGetMetadataConnection(\n key: string\n ): GoogleDownloadConnection<\n AsyncCallerCallOptions,\n GoogleCloudStorageResponse,\n AuthOptions\n > {\n const params: GoogleCloudStorageDownloadConnectionParams<AuthOptions> = {\n uri: key,\n method: \"GET\",\n alt: undefined,\n };\n return new GoogleCloudStorageDownloadConnection<\n GoogleCloudStorageResponse,\n AuthOptions\n >(params, this.caller, this.client);\n }\n\n buildGetDataConnection(\n key: string\n ): GoogleDownloadRawConnection<AsyncCallerCallOptions, AuthOptions> {\n const params: GoogleCloudStorageRawConnectionParams<AuthOptions> = {\n uri: key,\n };\n return new GoogleCloudStorageRawConnection<AuthOptions>(\n params,\n this.caller,\n this.client\n );\n }\n\n buildDeleteConnection(\n key: string\n ): GoogleDownloadConnection<\n AsyncCallerCallOptions,\n GoogleResponse,\n AuthOptions\n > {\n const params: GoogleCloudStorageDownloadConnectionParams<AuthOptions> = {\n uri: key,\n method: \"DELETE\",\n alt: undefined,\n };\n return new GoogleCloudStorageDownloadConnection<\n GoogleResponse,\n AuthOptions\n >(params, this.caller, this.client);\n }\n}\n\nexport type AIStudioFileState =\n | \"PROCESSING\"\n | \"ACTIVE\"\n | \"FAILED\"\n | \"STATE_UNSPECIFIED\";\n\nexport type AIStudioFileVideoMetadata = {\n videoMetadata: {\n videoDuration: string; // Duration in seconds, possibly with fractional, ending in \"s\"\n };\n};\n\nexport type AIStudioFileMetadata = AIStudioFileVideoMetadata;\n\nexport interface AIStudioFileObject {\n name?: string;\n displayName?: string;\n mimeType?: string;\n sizeBytes?: string; // int64 format\n createTime?: string; // timestamp format\n updateTime?: string; // timestamp format\n expirationTime?: string; // timestamp format\n sha256Hash?: string; // base64 encoded\n uri?: string;\n state?: AIStudioFileState;\n error?: {\n code: number;\n message: string;\n details: Record<string, unknown>[];\n };\n metadata?: AIStudioFileMetadata;\n}\n\nexport class AIStudioMediaBlob extends MediaBlob {\n _valueAsDate(value: string): Date {\n if (!value) {\n return new Date(0);\n }\n return new Date(value);\n }\n\n _metadataFieldAsDate(field: string): Date {\n return this._valueAsDate(this.metadata?.[field]);\n }\n\n get createDate(): Date {\n return this._metadataFieldAsDate(\"createTime\");\n }\n\n get updateDate(): Date {\n return this._metadataFieldAsDate(\"updateTime\");\n }\n\n get expirationDate(): Date {\n return this._metadataFieldAsDate(\"expirationTime\");\n }\n\n get isExpired(): boolean {\n const now = new Date().toISOString();\n const exp = this.metadata?.expirationTime ?? now;\n return exp <= now;\n }\n}\n\nexport interface AIStudioFileGetResponse extends GoogleResponse {\n data: AIStudioFileObject;\n}\n\nexport interface AIStudioFileSaveResponse extends GoogleResponse {\n data: {\n file: AIStudioFileObject;\n };\n}\n\nexport interface AIStudioFileListResponse extends GoogleResponse {\n data: {\n files: AIStudioFileObject[];\n nextPageToken: string;\n };\n}\n\nexport type AIStudioFileResponse =\n | AIStudioFileGetResponse\n | AIStudioFileSaveResponse\n | AIStudioFileListResponse;\n\nexport interface AIStudioFileConnectionParams {}\n\nexport interface AIStudioFileUploadConnectionParams<AuthOptions>\n extends\n GoogleUploadConnectionParams<AuthOptions>,\n AIStudioFileConnectionParams {}\n\nexport class AIStudioFileUploadConnection<\n AuthOptions,\n> extends GoogleMultipartUploadConnection<\n AsyncCallerCallOptions,\n AIStudioFileSaveResponse,\n AuthOptions\n> {\n get computedApiVersion(): string {\n return \"v1beta\";\n }\n\n async buildUrl(): Promise<string> {\n return `https://generativelanguage.googleapis.com/upload/${this.apiVersion}/files`;\n }\n}\n\nexport interface AIStudioFileDownloadConnectionParams<AuthOptions>\n extends AIStudioFileConnectionParams, GoogleConnectionParams<AuthOptions> {\n method: GoogleAbstractedClientOpsMethod;\n name: string;\n}\n\nexport class AIStudioFileDownloadConnection<\n ResponseType extends GoogleResponse,\n AuthOptions,\n> extends GoogleDownloadConnection<\n AsyncCallerCallOptions,\n ResponseType,\n AuthOptions\n> {\n method: GoogleAbstractedClientOpsMethod;\n\n name: string;\n\n constructor(\n fields: AIStudioFileDownloadConnectionParams<AuthOptions>,\n caller: AsyncCaller,\n client: GoogleAbstractedClient\n ) {\n super(fields, caller, client);\n this.method = fields.method;\n this.name = fields.name;\n }\n\n get computedApiVersion(): string {\n return \"v1beta\";\n }\n\n buildMethod(): GoogleAbstractedClientOpsMethod {\n return this.method;\n }\n\n async buildUrl(): Promise<string> {\n return `https://generativelanguage.googleapis.com/${this.apiVersion}/files/${this.name}`;\n }\n}\n\nexport interface BlobStoreAIStudioFileBaseParams<\n AuthOptions,\n> extends BlobStoreGoogleParams<AuthOptions> {\n retryTime?: number;\n}\n\nexport abstract class BlobStoreAIStudioFileBase<\n AuthOptions,\n> extends BlobStoreGoogle<AIStudioFileResponse, AuthOptions> {\n params?: BlobStoreAIStudioFileBaseParams<AuthOptions>;\n\n retryTime: number = 1000;\n\n constructor(fields?: BlobStoreAIStudioFileBaseParams<AuthOptions>) {\n const params: BlobStoreAIStudioFileBaseParams<AuthOptions> = {\n defaultStoreOptions: {\n pathPrefix: \"https://generativelanguage.googleapis.com/v1beta/files/\",\n actionIfInvalid: \"removePath\",\n },\n ...fields,\n };\n super(params);\n this.params = params;\n this.retryTime = params?.retryTime ?? this.retryTime ?? 1000;\n }\n\n _pathToName(path: string): string {\n return path.split(\"/\").pop() ?? path;\n }\n\n abstract buildAbstractedClient(\n fields?: BlobStoreGoogleParams<AuthOptions>\n ): GoogleAbstractedClient;\n\n buildApiKeyClient(apiKey: string): GoogleAbstractedClient {\n return new ApiKeyGoogleAuth(apiKey);\n }\n\n buildApiKey(fields?: BlobStoreGoogleParams<AuthOptions>): string | undefined {\n return fields?.apiKey ?? getEnvironmentVariable(\"GOOGLE_API_KEY\");\n }\n\n buildClient(\n fields?: BlobStoreGoogleParams<AuthOptions>\n ): GoogleAbstractedClient {\n const apiKey = this.buildApiKey(fields);\n if (apiKey) {\n return this.buildApiKeyClient(apiKey);\n } else {\n // TODO: Test that you can use OAuth to access\n return this.buildAbstractedClient(fields);\n }\n }\n\n async _regetMetadata(key: string): Promise<AIStudioFileObject> {\n // Sleep for some time period\n await new Promise((resolve) => setTimeout(resolve, this.retryTime));\n\n // Fetch the latest metadata\n return this._getMetadata(key);\n }\n\n async _set([key, blob]: [\n string,\n MediaBlob,\n ]): Promise<AIStudioFileSaveResponse> {\n const response = (await super._set([\n key,\n blob,\n ])) as AIStudioFileSaveResponse;\n\n let file = response.data?.file ?? { state: \"FAILED\" };\n while (file.state === \"PROCESSING\" && file.uri && this.retryTime > 0) {\n file = await this._regetMetadata(file.uri);\n }\n\n // The response should contain the name (and valid URI), so we need to\n // update the blob with this. We can't return a new blob, since mset()\n // doesn't return anything.\n blob.path = file.uri;\n blob.metadata = {\n ...blob.metadata,\n ...file,\n };\n return response;\n }\n\n buildSetConnection([_key, _blob]: [\n string,\n MediaBlob,\n ]): GoogleMultipartUploadConnection<\n AsyncCallerCallOptions,\n AIStudioFileResponse,\n AuthOptions\n > {\n return new AIStudioFileUploadConnection(\n this.params,\n this.caller,\n this.client\n );\n }\n\n buildSetMetadata([_key, _blob]: [string, MediaBlob]): Record<\n string,\n unknown\n > {\n return {};\n }\n\n buildGetMetadataConnection(\n key: string\n ): GoogleDownloadConnection<\n AsyncCallerCallOptions,\n AIStudioFileResponse,\n AuthOptions\n > {\n const params: AIStudioFileDownloadConnectionParams<AuthOptions> = {\n ...this.params,\n method: \"GET\",\n name: this._pathToName(key),\n };\n return new AIStudioFileDownloadConnection<\n AIStudioFileResponse,\n AuthOptions\n >(params, this.caller, this.client);\n }\n\n buildGetDataConnection(\n _key: string\n ): GoogleDownloadRawConnection<AsyncCallerCallOptions, AuthOptions> {\n throw new Error(\"AI Studio File API does not provide data\");\n }\n\n async _get(key: string): Promise<MediaBlob | undefined> {\n const metadata = await this._getMetadata(key);\n if (metadata) {\n const contentType =\n (metadata?.mimeType as string) ?? \"application/octet-stream\";\n // TODO - Get the actual data (and other metadata) from an optional backing store\n const data: MediaBlobData = {\n value: \"\",\n type: contentType,\n };\n\n return new MediaBlob({\n path: key,\n data,\n metadata,\n });\n } else {\n return undefined;\n }\n }\n\n buildDeleteConnection(\n key: string\n ): GoogleDownloadConnection<\n AsyncCallerCallOptions,\n AIStudioFileResponse,\n AuthOptions\n > {\n const params: AIStudioFileDownloadConnectionParams<AuthOptions> = {\n ...this.params,\n method: \"DELETE\",\n name: this._pathToName(key),\n };\n return new AIStudioFileDownloadConnection<\n AIStudioFileResponse,\n AuthOptions\n >(params, this.caller, this.client);\n }\n}\n"],"mappings":";;;;;;;AA4BA,IAAsB,kCAAtB,cAIU,qBAA6D;CACrE,YACEA,QACAC,QACAC,QACA;EACA,MAAM,QAAQ,QAAQ,OAAO;CAC9B;CAED,MAAM,MACJC,WACAC,MACAC,UACiB;EACjB,MAAM,cAAc,KAAK;EACzB,MAAM,EAAE,SAAS,UAAU,GAAG,MAAM,KAAK,QAAQ;EACjD,MAAM,OAAO;GACX,CAAC,EAAE,EAAE,WAAW;GAChB;GACA;GACA,KAAK,UAAU,SAAS;GACxB;GACA,CAAC,EAAE,EAAE,WAAW;GAChB,CAAC,cAAc,EAAE,aAAa;GAC9B,CAAC,2BAA2B,EAAE,UAAU;GACxC;GACA;GACA,CAAC,EAAE,EAAE,UAAU,EAAE,CAAC;EACnB;AACD,SAAO,KAAK,KAAK,KAAK;CACvB;CAED,MAAM,QACJD,MACAC,UACAC,SACuB;EACvB,MAAM,YAAY,CAAC,UAAU,EAAE,KAAK,KAAK,EAAE;EAC3C,MAAM,OAAO,MAAM,KAAK,MAAM,WAAW,MAA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7B;AACF"}
|
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type { BaseLLMParams } from \"@langchain/core/language_models/llms\";\nimport type {\n BaseChatModelCallOptions,\n BindToolsInput,\n} from \"@langchain/core/language_models/chat_models\";\nimport {\n BaseMessage,\n BaseMessageChunk,\n MessageContent,\n} from \"@langchain/core/messages\";\nimport { ChatGenerationChunk, ChatResult } from \"@langchain/core/outputs\";\nimport { EmbeddingsParams } from \"@langchain/core/embeddings\";\nimport { AsyncCallerCallOptions } from \"@langchain/core/utils/async_caller\";\nimport type { JsonStream } from \"./utils/stream.js\";\nimport { MediaManager } from \"./experimental/utils/media_core.js\";\nimport {\n AnthropicResponseData,\n AnthropicAPIConfig,\n} from \"./types-anthropic.js\";\n\nexport * from \"./types-anthropic.js\";\n\n/**\n * Parameters needed to setup the client connection.\n * AuthOptions are something like GoogleAuthOptions (from google-auth-library)\n * or WebGoogleAuthOptions.\n */\nexport interface GoogleClientParams<AuthOptions> {\n authOptions?: AuthOptions;\n\n /** Some APIs allow an API key instead */\n apiKey?: string;\n}\n\n/**\n * What platform is this running on?\n * gai - Google AI Studio / MakerSuite / Generative AI platform\n * gcp - Google Cloud Platform\n */\nexport type GooglePlatformType = \"gai\" | \"gcp\";\n\nexport interface GoogleConnectionParams<AuthOptions>\n extends GoogleClientParams<AuthOptions> {\n /** Hostname for the API call (if this is running on GCP) */\n endpoint?: string;\n\n /** Region where the LLM is stored (if this is running on GCP) */\n location?: string;\n\n /** The version of the API functions. Part of the path. */\n apiVersion?: string;\n\n /**\n * What platform to run the service on.\n * If not specified, the class should determine this from other\n * means. Either way, the platform actually used will be in\n * the \"platform\" getter.\n */\n platformType?: GooglePlatformType;\n\n /**\n * For compatibility with Google's libraries, should this use Vertex?\n * The \"platformType\" parmeter takes precedence.\n */\n vertexai?: boolean;\n}\n\nexport const GoogleAISafetyCategory = {\n Harassment: \"HARM_CATEGORY_HARASSMENT\",\n HARASSMENT: \"HARM_CATEGORY_HARASSMENT\",\n HARM_CATEGORY_HARASSMENT: \"HARM_CATEGORY_HARASSMENT\",\n\n HateSpeech: \"HARM_CATEGORY_HATE_SPEECH\",\n HATE_SPEECH: \"HARM_CATEGORY_HATE_SPEECH\",\n HARM_CATEGORY_HATE_SPEECH: \"HARM_CATEGORY_HATE_SPEECH\",\n\n SexuallyExplicit: \"HARM_CATEGORY_SEXUALLY_EXPLICIT\",\n SEXUALLY_EXPLICIT: \"HARM_CATEGORY_SEXUALLY_EXPLICIT\",\n HARM_CATEGORY_SEXUALLY_EXPLICIT: \"HARM_CATEGORY_SEXUALLY_EXPLICIT\",\n\n Dangerous: \"HARM_CATEGORY_DANGEROUS\",\n DANGEROUS: \"HARM_CATEGORY_DANGEROUS\",\n HARM_CATEGORY_DANGEROUS: \"HARM_CATEGORY_DANGEROUS\",\n\n CivicIntegrity: \"HARM_CATEGORY_CIVIC_INTEGRITY\",\n CIVIC_INTEGRITY: \"HARM_CATEGORY_CIVIC_INTEGRITY\",\n HARM_CATEGORY_CIVIC_INTEGRITY: \"HARM_CATEGORY_CIVIC_INTEGRITY\",\n} as const;\n\nexport type GoogleAISafetyCategory =\n (typeof GoogleAISafetyCategory)[keyof typeof GoogleAISafetyCategory];\n\nexport const GoogleAISafetyThreshold = {\n None: \"BLOCK_NONE\",\n NONE: \"BLOCK_NONE\",\n BLOCK_NONE: \"BLOCK_NONE\",\n\n Few: \"BLOCK_ONLY_HIGH\",\n FEW: \"BLOCK_ONLY_HIGH\",\n BLOCK_ONLY_HIGH: \"BLOCK_ONLY_HIGH\",\n\n Some: \"BLOCK_MEDIUM_AND_ABOVE\",\n SOME: \"BLOCK_MEDIUM_AND_ABOVE\",\n BLOCK_MEDIUM_AND_ABOVE: \"BLOCK_MEDIUM_AND_ABOVE\",\n\n Most: \"BLOCK_LOW_AND_ABOVE\",\n MOST: \"BLOCK_LOW_AND_ABOVE\",\n BLOCK_LOW_AND_ABOVE: \"BLOCK_LOW_AND_ABOVE\",\n\n Off: \"OFF\",\n OFF: \"OFF\",\n BLOCK_OFF: \"OFF\",\n} as const;\n\nexport type GoogleAISafetyThreshold =\n (typeof GoogleAISafetyThreshold)[keyof typeof GoogleAISafetyThreshold];\n\nexport const GoogleAISafetyMethod = {\n Severity: \"SEVERITY\",\n Probability: \"PROBABILITY\",\n} as const;\n\nexport type GoogleAISafetyMethod =\n (typeof GoogleAISafetyMethod)[keyof typeof GoogleAISafetyMethod];\n\nexport interface GoogleAISafetySetting {\n category: GoogleAISafetyCategory | string;\n threshold: GoogleAISafetyThreshold | string;\n method?: GoogleAISafetyMethod | string; // Just for Vertex AI?\n}\n\nexport type GoogleAIResponseMimeType = \"text/plain\" | \"application/json\";\n\nexport type GoogleAIModelModality = \"TEXT\" | \"IMAGE\" | \"AUDIO\" | string;\n\nexport type GoogleThinkingLevel =\n | \"THINKING_LEVEL_UNSPECIFIED\"\n | \"LOW\"\n | \"MEDIUM\"\n | \"HIGH\";\n\nexport interface GoogleThinkingConfig {\n thinkingBudget?: number;\n includeThoughts?: boolean;\n thinkingLevel?: GoogleThinkingLevel;\n}\n\nexport type GooglePrebuiltVoiceName = string;\n\nexport interface GooglePrebuiltVoiceConfig {\n voiceName: GooglePrebuiltVoiceName;\n}\n\nexport interface GoogleVoiceConfig {\n prebuiltVoiceConfig: GooglePrebuiltVoiceConfig;\n}\n\nexport interface GoogleSpeakerVoiceConfig {\n speaker: string;\n voiceConfig: GoogleVoiceConfig;\n}\n\nexport interface GoogleMultiSpeakerVoiceConfig {\n speakerVoiceConfigs: GoogleSpeakerVoiceConfig[];\n}\n\nexport interface GoogleSpeechConfigSingle {\n voiceConfig: GoogleVoiceConfig;\n languageCode?: string;\n}\n\nexport interface GoogleSpeechConfigMulti {\n multiSpeakerVoiceConfig: GoogleMultiSpeakerVoiceConfig;\n languageCode?: string;\n}\n\nexport type GoogleSpeechConfig =\n | GoogleSpeechConfigSingle\n | GoogleSpeechConfigMulti;\n\n/**\n * A simplified version of the GoogleSpeakerVoiceConfig\n */\nexport interface GoogleSpeechSpeakerName {\n speaker: string;\n name: GooglePrebuiltVoiceName;\n}\n\nexport type GoogleSpeechVoice =\n | GooglePrebuiltVoiceName\n | GoogleSpeechSpeakerName\n | GoogleSpeechSpeakerName[];\n\nexport interface GoogleSpeechVoiceLanguage {\n voice: GoogleSpeechVoice;\n languageCode: string;\n}\n\nexport interface GoogleSpeechVoicesLanguage {\n voices: GoogleSpeechVoice;\n languageCode: string;\n}\n\n/**\n * A simplified way to represent the voice (or voices) and language code.\n * \"voice\" and \"voices\" are semantically the same, we're not enforcing\n * that one is an array and one isn't.\n */\nexport type GoogleSpeechSimplifiedLanguage =\n | GoogleSpeechVoiceLanguage\n | GoogleSpeechVoicesLanguage;\n\n/**\n * A simplified way to represent the voices.\n * It can either be the voice (or voices), or the voice or voices with language configuration\n */\nexport type GoogleSpeechConfigSimplified =\n | GoogleSpeechVoice\n | GoogleSpeechSimplifiedLanguage;\n\nexport interface GoogleModelParams {\n /** Model to use */\n model?: string;\n\n /**\n * Model to use\n * Alias for `model`\n */\n modelName?: string;\n}\n\nexport interface GoogleAIModelParams extends GoogleModelParams {\n /** Sampling temperature to use */\n temperature?: number;\n\n /**\n * Maximum number of tokens to generate in the completion.\n * This may include reasoning tokens (for backwards compatibility).\n */\n maxOutputTokens?: number;\n\n /**\n * The maximum number of the output tokens that will be used\n * for the \"thinking\" or \"reasoning\" stages.\n */\n maxReasoningTokens?: number;\n\n /**\n * An alias for \"maxReasoningTokens\"\n */\n thinkingBudget?: number;\n\n /**\n * An OpenAI compatible parameter that will map to \"maxReasoningTokens\"\n */\n reasoningEffort?: \"low\" | \"medium\" | \"high\";\n\n /**\n * Optional. The level of thoughts tokens that the model should generate.\n * Can be specified directly or via reasoningLevel for OpenAI compatibility.\n */\n thinkingLevel?: GoogleThinkingLevel;\n\n /**\n * An OpenAI compatible parameter that will map to \"thinkingLevel\"\n */\n reasoningLevel?: \"low\" | \"medium\" | \"high\";\n\n /**\n * Top-p changes how the model selects tokens for output.\n *\n * Tokens are selected from most probable to least until the sum\n * of their probabilities equals the top-p value.\n *\n * For example, if tokens A, B, and C have a probability of\n * .3, .2, and .1 and the top-p value is .5, then the model will\n * select either A or B as the next token (using temperature).\n */\n topP?: number;\n\n /**\n * Top-k changes how the model selects tokens for output.\n *\n * A top-k of 1 means the selected token is the most probable among\n * all tokens in the model’s vocabulary (also called greedy decoding),\n * while a top-k of 3 means that the next token is selected from\n * among the 3 most probable tokens (using temperature).\n */\n topK?: number;\n\n /**\n * Seed used in decoding. If not set, the request uses a randomly generated seed.\n */\n seed?: number;\n\n /**\n * Presence penalty applied to the next token's logprobs\n * if the token has already been seen in the response.\n * This penalty is binary on/off and not dependant on the\n * number of times the token is used (after the first).\n * Use frequencyPenalty for a penalty that increases with each use.\n * A positive penalty will discourage the use of tokens that have\n * already been used in the response, increasing the vocabulary.\n * A negative penalty will encourage the use of tokens that have\n * already been used in the response, decreasing the vocabulary.\n */\n presencePenalty?: number;\n\n /**\n * Frequency penalty applied to the next token's logprobs,\n * multiplied by the number of times each token has been seen\n * in the respponse so far.\n * A positive penalty will discourage the use of tokens that\n * have already been used, proportional to the number of times\n * the token has been used:\n * The more a token is used, the more dificult it is for the model\n * to use that token again increasing the vocabulary of responses.\n * Caution: A _negative_ penalty will encourage the model to reuse\n * tokens proportional to the number of times the token has been used.\n * Small negative values will reduce the vocabulary of a response.\n * Larger negative values will cause the model to start repeating\n * a common token until it hits the maxOutputTokens limit.\n */\n frequencyPenalty?: number;\n\n stopSequences?: string[];\n\n safetySettings?: GoogleAISafetySetting[];\n\n convertSystemMessageToHumanContent?: boolean;\n\n /**\n * Available for `gemini-1.5-pro`.\n * The output format of the generated candidate text.\n * Supported MIME types:\n * - `text/plain`: Text output.\n * - `application/json`: JSON response in the candidates.\n *\n * @default \"text/plain\"\n */\n responseMimeType?: GoogleAIResponseMimeType;\n\n /**\n * The schema that the model's output should conform to.\n * When this is set, the model will output JSON that conforms to the schema.\n */\n responseSchema?: GeminiJsonSchema;\n\n /**\n * Whether or not to stream.\n * @default false\n */\n streaming?: boolean;\n\n /**\n * Whether to return log probabilities of the output tokens or not.\n * If true, returns the log probabilities of each output token\n * returned in the content of message.\n */\n logprobs?: boolean;\n\n /**\n * An integer between 0 and 5 specifying the number of\n * most likely tokens to return at each token position,\n * each with an associated log probability.\n * logprobs must be set to true if this parameter is used.\n */\n topLogprobs?: number;\n\n /**\n * The modalities of the response.\n */\n responseModalities?: GoogleAIModelModality[];\n\n /**\n * Custom metadata labels to associate with the request.\n * Only supported on Vertex AI (Google Cloud Platform).\n * Labels are key-value pairs where both keys and values must be strings.\n *\n * Example:\n * ```typescript\n * {\n * labels: {\n * \"team\": \"research\",\n * \"component\": \"frontend\",\n * \"environment\": \"production\"\n * }\n * }\n * ```\n */\n labels?: Record<string, string>;\n\n /**\n * Speech generation configuration.\n * You can use either Google's definition of the speech configuration,\n * or a simplified version we've defined (which can be as simple\n * as the name of a pre-defined voice).\n */\n speechConfig?: GoogleSpeechConfig | GoogleSpeechConfigSimplified;\n}\n\nexport type GoogleAIToolType = BindToolsInput | GeminiTool;\n\n/**\n * The params which can be passed to the API at request time.\n */\nexport interface GoogleAIModelRequestParams extends GoogleAIModelParams {\n tools?: GoogleAIToolType[];\n /**\n * Force the model to use tools in a specific way.\n *\n * | Mode |\tDescription |\n * |----------|---------------------------------------------------------------------------------------------------------------------------------------------------------|\n * | \"auto\"\t | The default model behavior. The model decides whether to predict a function call or a natural language response. |\n * | \"any\"\t | The model must predict only function calls. To limit the model to a subset of functions, define the allowed function names in `allowed_function_names`. |\n * | \"none\"\t | The model must not predict function calls. This behavior is equivalent to a model request without any associated function declarations. |\n * | string | The string value must be one of the function names. This will force the model to predict the specified function call. |\n *\n * The tool configuration's \"any\" mode (\"forced function calling\") is supported for Gemini 1.5 Pro models only.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n tool_choice?: string | \"auto\" | \"any\" | \"none\" | Record<string, any>;\n /**\n * Allowed functions to call when the mode is \"any\".\n * If empty, any one of the provided functions are called.\n */\n allowed_function_names?: string[];\n\n /**\n * Used to specify a previously created context cache to use with generation.\n * For Vertex, this should be of the form:\n * \"projects/PROJECT_NUMBER/locations/LOCATION/cachedContents/CACHE_ID\",\n *\n * See these guides for more information on how to use context caching:\n * https://cloud.google.com/vertex-ai/generative-ai/docs/context-cache/context-cache-create\n * https://cloud.google.com/vertex-ai/generative-ai/docs/context-cache/context-cache-use\n */\n cachedContent?: string;\n\n /**\n * The schema that the model's output should conform to.\n * When this is set, the model will output JSON that conforms to the schema.\n */\n responseSchema?: GeminiJsonSchema;\n}\n\nexport interface GoogleAIBaseLLMInput<AuthOptions>\n extends BaseLLMParams,\n GoogleConnectionParams<AuthOptions>,\n GoogleAIModelParams,\n GoogleAISafetyParams,\n GoogleAIAPIParams {}\n\nexport interface GoogleAIBaseLanguageModelCallOptions\n extends BaseChatModelCallOptions,\n GoogleAIModelRequestParams,\n GoogleAISafetyParams {\n /**\n * Whether or not to include usage data, like token counts\n * in the streamed response chunks.\n * @default true\n */\n streamUsage?: boolean;\n}\n\n/**\n * Input to LLM class.\n */\nexport interface GoogleBaseLLMInput<AuthOptions>\n extends GoogleAIBaseLLMInput<AuthOptions> {}\n\nexport interface GoogleResponse {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any;\n}\n\nexport interface GoogleRawResponse extends GoogleResponse {\n data: Blob;\n}\n\nexport interface GeminiPartBase {\n thought?: boolean; // Output only\n thoughtSignature?: string;\n}\n\nexport interface GeminiVideoMetadata {\n fps?: number; // Double in range (0.0, 24.0]\n startOffset?: string;\n endOffset?: string;\n}\n\nexport interface GeminiPartBaseFile extends GeminiPartBase {\n videoMetadata?: GeminiVideoMetadata;\n}\n\nexport interface GeminiPartText extends GeminiPartBase {\n text: string;\n}\n\nexport interface GeminiPartInlineData extends GeminiPartBaseFile {\n inlineData: {\n mimeType: string;\n data: string;\n };\n}\n\nexport interface GeminiPartFileData extends GeminiPartBaseFile {\n fileData: {\n mimeType: string;\n fileUri: string;\n };\n}\n\n// AI Studio only?\nexport interface GeminiPartFunctionCall extends GeminiPartBase {\n functionCall: {\n name: string;\n args?: object;\n };\n}\n\n// AI Studio Only?\nexport interface GeminiPartFunctionResponse extends GeminiPartBase {\n functionResponse: {\n name: string;\n response: object;\n };\n}\n\nexport type GeminiPart =\n | GeminiPartText\n | GeminiPartInlineData\n | GeminiPartFileData\n | GeminiPartFunctionCall\n | GeminiPartFunctionResponse;\n\nexport interface GeminiSafetySetting {\n category: string;\n threshold: string;\n}\n\nexport type GeminiSafetyRating = {\n category: string;\n probability: string;\n} & Record<string, unknown>;\n\nexport interface GeminiCitationMetadata {\n citations: GeminiCitation[];\n}\n\nexport interface GeminiCitation {\n startIndex: number;\n endIndex: number;\n uri: string;\n title: string;\n license: string;\n publicationDate: GoogleTypeDate;\n}\n\nexport interface GoogleTypeDate {\n year: number; // 1-9999 or 0 to specify a date without a year\n month: number; // 1-12 or 0 to specify a year without a month and day\n day: number; // Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant\n}\n\nexport interface GeminiGroundingMetadata {\n webSearchQueries?: string[];\n searchEntryPoint?: GeminiSearchEntryPoint;\n groundingChunks: GeminiGroundingChunk[];\n groundingSupports?: GeminiGroundingSupport[];\n retrievalMetadata?: GeminiRetrievalMetadata;\n}\n\nexport interface GeminiSearchEntryPoint {\n renderedContent?: string;\n sdkBlob?: string; // Base64 encoded JSON representing array of tuple.\n}\n\nexport interface GeminiGroundingChunk {\n web: GeminiGroundingChunkWeb;\n retrievedContext: GeminiGroundingChunkRetrievedContext;\n}\n\nexport interface GeminiGroundingChunkWeb {\n uri: string;\n title: string;\n}\n\nexport interface GeminiGroundingChunkRetrievedContext {\n uri: string;\n title: string;\n text: string;\n}\n\nexport interface GeminiGroundingSupport {\n segment: GeminiSegment;\n groundingChunkIndices: number[];\n confidenceScores: number[];\n}\n\nexport interface GeminiSegment {\n partIndex: number;\n startIndex: number;\n endIndex: number;\n text: string;\n}\n\nexport interface GeminiRetrievalMetadata {\n googleSearchDynamicRetrievalScore: number;\n}\n\nexport type GeminiUrlRetrievalStatus =\n | \"URL_RETRIEVAL_STATUS_SUCCESS\"\n | \"URL_RETRIEVAL_STATUS_ERROR\";\n\nexport interface GeminiUrlRetrievalContext {\n retrievedUrl: string;\n urlRetrievalStatus: GeminiUrlRetrievalStatus;\n}\n\nexport interface GeminiUrlRetrievalMetadata {\n urlRetrievalContexts: GeminiUrlRetrievalContext[];\n}\n\nexport type GeminiUrlMetadata = GeminiUrlRetrievalContext;\n\nexport interface GeminiUrlContextMetadata {\n urlMetadata: GeminiUrlMetadata[];\n}\n\nexport interface GeminiLogprobsResult {\n topCandidates: GeminiLogprobsTopCandidate[];\n chosenCandidates: GeminiLogprobsResultCandidate[];\n}\n\nexport interface GeminiLogprobsTopCandidate {\n candidates: GeminiLogprobsResultCandidate[];\n}\n\nexport interface GeminiLogprobsResultCandidate {\n token: string;\n tokenId: number;\n logProbability: number;\n}\n\n// The \"system\" content appears to only be valid in the systemInstruction\nexport type GeminiRole = \"system\" | \"user\" | \"model\" | \"function\";\n\nexport interface GeminiContent {\n parts: GeminiPart[];\n role: GeminiRole; // Vertex AI requires the role\n}\n\n/*\n * If additional attributes are added here, they should also be\n * added to the attributes below\n */\nexport interface GeminiTool {\n functionDeclarations?: GeminiFunctionDeclaration[];\n googleSearchRetrieval?: GoogleSearchRetrieval; // Gemini-1.5\n googleSearch?: GoogleSearch; // Gemini-2.0\n urlContext?: UrlContext;\n retrieval?: VertexAIRetrieval;\n}\n\n/*\n * The known strings in this type should match those in GeminiSearchToolAttribuets\n */\nexport type GoogleSearchToolSetting =\n | boolean\n | \"googleSearchRetrieval\"\n | \"googleSearch\"\n | string;\n\nexport const GeminiSearchToolAttributes = [\n \"googleSearchRetrieval\",\n \"googleSearch\",\n];\n\nexport const GeminiToolAttributes = [\n \"functionDeclaration\",\n \"retrieval\",\n \"urlContext\",\n ...GeminiSearchToolAttributes,\n];\n\nexport interface GoogleSearchRetrieval {\n dynamicRetrievalConfig?: {\n mode?: string;\n dynamicThreshold?: number;\n };\n}\n\nexport interface GoogleSearch {}\n\nexport interface UrlContext {}\n\nexport interface VertexAIRetrieval {\n vertexAiSearch: {\n datastore: string;\n };\n disableAttribution?: boolean;\n}\n\nexport interface GeminiFunctionDeclaration {\n name: string;\n description: string;\n parameters?: GeminiFunctionSchema;\n}\n\nexport interface GeminiFunctionSchema {\n type: GeminiFunctionSchemaType;\n format?: string;\n description?: string;\n nullable?: boolean;\n enum?: string[];\n properties?: Record<string, GeminiFunctionSchema>;\n required?: string[];\n items?: GeminiFunctionSchema;\n}\n\nexport type GeminiFunctionSchemaType =\n | \"string\"\n | \"number\"\n | \"integer\"\n | \"boolean\"\n | \"array\"\n | \"object\";\n\nexport interface GeminiGenerationConfig {\n stopSequences?: string[];\n candidateCount?: number;\n maxOutputTokens?: number;\n temperature?: number;\n topP?: number;\n topK?: number;\n seed?: number;\n presencePenalty?: number;\n frequencyPenalty?: number;\n responseMimeType?: GoogleAIResponseMimeType;\n responseLogprobs?: boolean;\n logprobs?: number;\n responseModalities?: GoogleAIModelModality[];\n thinkingConfig?: GoogleThinkingConfig;\n speechConfig?: GoogleSpeechConfig;\n responseSchema?: GeminiJsonSchema;\n}\n\nexport interface GeminiRequest {\n contents?: GeminiContent[];\n systemInstruction?: GeminiContent;\n tools?: GeminiTool[];\n toolConfig?: {\n functionCallingConfig: {\n mode: \"auto\" | \"any\" | \"none\";\n allowedFunctionNames?: string[];\n };\n };\n safetySettings?: GeminiSafetySetting[];\n generationConfig?: GeminiGenerationConfig;\n cachedContent?: string;\n\n /**\n * Custom metadata labels to associate with the API call.\n */\n labels?: Record<string, string>;\n}\n\nexport interface GeminiResponseCandidate {\n content: {\n parts: GeminiPart[];\n role: string;\n };\n finishReason: string;\n index: number;\n tokenCount?: number;\n safetyRatings: GeminiSafetyRating[];\n citationMetadata?: GeminiCitationMetadata;\n groundingMetadata?: GeminiGroundingMetadata;\n urlRetrievalMetadata?: GeminiUrlRetrievalMetadata;\n urlContextMetadata?: GeminiUrlContextMetadata;\n avgLogprobs?: number;\n logprobsResult: GeminiLogprobsResult;\n finishMessage?: string;\n}\n\ninterface GeminiResponsePromptFeedback {\n blockReason?: string;\n safetyRatings: GeminiSafetyRating[];\n}\n\nexport type ModalityEnum =\n | \"TEXT\"\n | \"IMAGE\"\n | \"VIDEO\"\n | \"AUDIO\"\n | \"DOCUMENT\"\n | string;\n\nexport interface ModalityTokenCount {\n modality: ModalityEnum;\n tokenCount: number;\n}\n\nexport interface GenerateContentResponseUsageMetadata {\n promptTokenCount: number;\n toolUsePromptTokenCount: number;\n cachedContentTokenCount: number;\n thoughtsTokenCount: number;\n candidatesTokenCount: number;\n totalTokenCount: number;\n\n promptTokensDetails: ModalityTokenCount[];\n toolUsePromptTokensDetails: ModalityTokenCount[];\n cacheTokensDetails: ModalityTokenCount[];\n candidatesTokensDetails: ModalityTokenCount[];\n\n [key: string]: unknown;\n}\n\nexport interface GenerateContentResponseData {\n candidates: GeminiResponseCandidate[];\n promptFeedback: GeminiResponsePromptFeedback;\n usageMetadata: GenerateContentResponseUsageMetadata;\n}\n\nexport type GoogleLLMModelFamily = null | \"palm\" | \"gemini\" | \"gemma\";\n\nexport type VertexModelFamily = GoogleLLMModelFamily | \"claude\";\n\nexport type GoogleLLMResponseData =\n | JsonStream\n | GenerateContentResponseData\n | GenerateContentResponseData[];\n\nexport interface GoogleLLMResponse extends GoogleResponse {\n data: GoogleLLMResponseData | AnthropicResponseData;\n}\n\nexport interface GoogleAISafetyHandler {\n /**\n * A function that will take a response and return the, possibly modified,\n * response or throw an exception if there are safety issues.\n *\n * @throws GoogleAISafetyError\n */\n handle(response: GoogleLLMResponse): GoogleLLMResponse;\n}\n\nexport interface GoogleAISafetyParams {\n safetyHandler?: GoogleAISafetyHandler;\n}\n\nexport type GeminiJsonSchema = Record<string, unknown> & {\n properties?: Record<string, GeminiJsonSchema>;\n type: GeminiFunctionSchemaType;\n nullable?: boolean;\n};\n\nexport interface GeminiJsonSchemaDirty extends GeminiJsonSchema {\n items?: GeminiJsonSchemaDirty;\n properties?: Record<string, GeminiJsonSchemaDirty>;\n additionalProperties?: boolean;\n}\n\nexport type GoogleAIAPI = {\n messageContentToParts?: (content: MessageContent) => Promise<GeminiPart[]>;\n\n baseMessageToContent?: (\n message: BaseMessage,\n prevMessage: BaseMessage | undefined,\n useSystemInstruction: boolean\n ) => Promise<GeminiContent[]>;\n\n responseToString: (response: GoogleLLMResponse) => string;\n\n responseToChatGeneration: (\n response: GoogleLLMResponse\n ) => ChatGenerationChunk | null;\n\n chunkToString: (chunk: BaseMessageChunk) => string;\n\n responseToBaseMessage: (response: GoogleLLMResponse) => BaseMessage;\n\n responseToChatResult: (response: GoogleLLMResponse) => ChatResult;\n\n formatData: (\n input: unknown,\n parameters: GoogleAIModelRequestParams\n ) => Promise<unknown>;\n};\n\nexport interface GeminiAPIConfig {\n safetyHandler?: GoogleAISafetyHandler;\n mediaManager?: MediaManager;\n useSystemInstruction?: boolean;\n\n /**\n * How to handle the Google Search tool, since the name (and format)\n * of the tool changes between Gemini 1.5 and Gemini 2.0.\n * true - Change based on the model version. (Default)\n * false - Do not change the tool name provided\n * string value - Use this as the attribute name for the search\n * tool, adapting any tool attributes if possible.\n * When the model is created, a \"true\" or default setting\n * will be changed to a string based on the model.\n */\n googleSearchToolAdjustment?: GoogleSearchToolSetting;\n}\n\nexport type GoogleAIAPIConfig = GeminiAPIConfig | AnthropicAPIConfig;\n\nexport interface GoogleAIAPIParams {\n apiName?: string;\n apiConfig?: GoogleAIAPIConfig;\n}\n\n// Embeddings\n\n/**\n * Defines the parameters required to initialize a\n * GoogleEmbeddings instance. It extends EmbeddingsParams and\n * GoogleConnectionParams.\n */\nexport interface BaseGoogleEmbeddingsParams<AuthOptions>\n extends EmbeddingsParams,\n GoogleConnectionParams<AuthOptions> {\n model: string;\n\n /**\n * Used to specify output embedding size.\n * If set, output embeddings will be truncated to the size specified.\n */\n dimensions?: number;\n\n /**\n * An alias for \"dimensions\"\n */\n outputDimensionality?: number;\n}\n\n/**\n * Defines additional options specific to the\n * GoogleEmbeddingsInstance. It extends AsyncCallerCallOptions.\n */\nexport interface BaseGoogleEmbeddingsOptions extends AsyncCallerCallOptions {}\n\nexport type GoogleEmbeddingsTaskType =\n | \"RETRIEVAL_QUERY\"\n | \"RETRIEVAL_DOCUMENT\"\n | \"SEMANTIC_SIMILARITY\"\n | \"CLASSIFICATION\"\n | \"CLUSTERING\"\n | \"QUESTION_ANSWERING\"\n | \"FACT_VERIFICATION\"\n | \"CODE_RETRIEVAL_QUERY\"\n | string;\n\n/**\n * Represents an instance for generating embeddings using the Google\n * Vertex AI API. It contains the content to be embedded.\n */\nexport interface VertexEmbeddingsInstance {\n content: string;\n taskType?: GoogleEmbeddingsTaskType;\n title?: string;\n}\n\nexport interface VertexEmbeddingsParameters extends GoogleModelParams {\n autoTruncate?: boolean;\n outputDimensionality?: number;\n}\n\nexport interface VertexEmbeddingsRequest {\n instances: VertexEmbeddingsInstance[];\n parameters?: VertexEmbeddingsParameters;\n}\n\nexport interface AIStudioEmbeddingsRequest {\n content: {\n parts: GeminiPartText[];\n };\n model?: string; // Documentation says required, but tests say otherwise\n taskType?: GoogleEmbeddingsTaskType;\n title?: string;\n outputDimensionality?: number;\n}\n\nexport type GoogleEmbeddingsRequest =\n | VertexEmbeddingsRequest\n | AIStudioEmbeddingsRequest;\n\nexport interface VertexEmbeddingsResponsePrediction {\n embeddings: {\n statistics: {\n token_count: number;\n truncated: boolean;\n };\n values: number[];\n };\n}\n\n/**\n * Defines the structure of the embeddings results returned by the Google\n * Vertex AI API. It extends GoogleBasePrediction and contains the\n * embeddings and their statistics.\n */\nexport interface VertexEmbeddingsResponse extends GoogleResponse {\n data: {\n predictions: VertexEmbeddingsResponsePrediction[];\n };\n}\n\nexport interface AIStudioEmbeddingsResponse extends GoogleResponse {\n data: {\n embedding: {\n values: number[];\n };\n };\n}\n\nexport type GoogleEmbeddingsResponse =\n | VertexEmbeddingsResponse\n | AIStudioEmbeddingsResponse;\n"],"mappings":";;AAmEA,MAAa,yBAAyB;CACpC,YAAY;CACZ,YAAY;CACZ,0BAA0B;CAE1B,YAAY;CACZ,aAAa;CACb,2BAA2B;CAE3B,kBAAkB;CAClB,mBAAmB;CACnB,iCAAiC;CAEjC,WAAW;CACX,WAAW;CACX,yBAAyB;CAEzB,gBAAgB;CAChB,iBAAiB;CACjB,+BAA+B;AAChC;AAKD,MAAa,0BAA0B;CACrC,MAAM;CACN,MAAM;CACN,YAAY;CAEZ,KAAK;CACL,KAAK;CACL,iBAAiB;CAEjB,MAAM;CACN,MAAM;CACN,wBAAwB;CAExB,MAAM;CACN,MAAM;CACN,qBAAqB;CAErB,KAAK;CACL,KAAK;CACL,WAAW;AACZ;AAKD,MAAa,uBAAuB;CAClC,UAAU;CACV,aAAa;AACd;AA0iBD,MAAa,6BAA6B,CACxC,yBACA,cACD;AAED,MAAa,uBAAuB;CAClC;CACA;CACA;CACA,GAAG;AACJ"}
|
|
1
|
+
{"version":3,"file":"types.cjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type { BaseLLMParams } from \"@langchain/core/language_models/llms\";\nimport type {\n BaseChatModelCallOptions,\n BindToolsInput,\n} from \"@langchain/core/language_models/chat_models\";\nimport {\n BaseMessage,\n BaseMessageChunk,\n MessageContent,\n} from \"@langchain/core/messages\";\nimport { ChatGenerationChunk, ChatResult } from \"@langchain/core/outputs\";\nimport { EmbeddingsParams } from \"@langchain/core/embeddings\";\nimport { AsyncCallerCallOptions } from \"@langchain/core/utils/async_caller\";\nimport type { JsonStream } from \"./utils/stream.js\";\nimport { MediaManager } from \"./experimental/utils/media_core.js\";\nimport {\n AnthropicResponseData,\n AnthropicAPIConfig,\n} from \"./types-anthropic.js\";\n\nexport * from \"./types-anthropic.js\";\n\n/**\n * Parameters needed to setup the client connection.\n * AuthOptions are something like GoogleAuthOptions (from google-auth-library)\n * or WebGoogleAuthOptions.\n */\nexport interface GoogleClientParams<AuthOptions> {\n authOptions?: AuthOptions;\n\n /** Some APIs allow an API key instead */\n apiKey?: string;\n}\n\n/**\n * What platform is this running on?\n * gai - Google AI Studio / MakerSuite / Generative AI platform\n * gcp - Google Cloud Platform\n */\nexport type GooglePlatformType = \"gai\" | \"gcp\";\n\nexport interface GoogleConnectionParams<\n AuthOptions,\n> extends GoogleClientParams<AuthOptions> {\n /** Hostname for the API call (if this is running on GCP) */\n endpoint?: string;\n\n /** Region where the LLM is stored (if this is running on GCP) */\n location?: string;\n\n /** The version of the API functions. Part of the path. */\n apiVersion?: string;\n\n /**\n * What platform to run the service on.\n * If not specified, the class should determine this from other\n * means. Either way, the platform actually used will be in\n * the \"platform\" getter.\n */\n platformType?: GooglePlatformType;\n\n /**\n * For compatibility with Google's libraries, should this use Vertex?\n * The \"platformType\" parmeter takes precedence.\n */\n vertexai?: boolean;\n}\n\nexport const GoogleAISafetyCategory = {\n Harassment: \"HARM_CATEGORY_HARASSMENT\",\n HARASSMENT: \"HARM_CATEGORY_HARASSMENT\",\n HARM_CATEGORY_HARASSMENT: \"HARM_CATEGORY_HARASSMENT\",\n\n HateSpeech: \"HARM_CATEGORY_HATE_SPEECH\",\n HATE_SPEECH: \"HARM_CATEGORY_HATE_SPEECH\",\n HARM_CATEGORY_HATE_SPEECH: \"HARM_CATEGORY_HATE_SPEECH\",\n\n SexuallyExplicit: \"HARM_CATEGORY_SEXUALLY_EXPLICIT\",\n SEXUALLY_EXPLICIT: \"HARM_CATEGORY_SEXUALLY_EXPLICIT\",\n HARM_CATEGORY_SEXUALLY_EXPLICIT: \"HARM_CATEGORY_SEXUALLY_EXPLICIT\",\n\n Dangerous: \"HARM_CATEGORY_DANGEROUS\",\n DANGEROUS: \"HARM_CATEGORY_DANGEROUS\",\n HARM_CATEGORY_DANGEROUS: \"HARM_CATEGORY_DANGEROUS\",\n\n CivicIntegrity: \"HARM_CATEGORY_CIVIC_INTEGRITY\",\n CIVIC_INTEGRITY: \"HARM_CATEGORY_CIVIC_INTEGRITY\",\n HARM_CATEGORY_CIVIC_INTEGRITY: \"HARM_CATEGORY_CIVIC_INTEGRITY\",\n} as const;\n\nexport type GoogleAISafetyCategory =\n (typeof GoogleAISafetyCategory)[keyof typeof GoogleAISafetyCategory];\n\nexport const GoogleAISafetyThreshold = {\n None: \"BLOCK_NONE\",\n NONE: \"BLOCK_NONE\",\n BLOCK_NONE: \"BLOCK_NONE\",\n\n Few: \"BLOCK_ONLY_HIGH\",\n FEW: \"BLOCK_ONLY_HIGH\",\n BLOCK_ONLY_HIGH: \"BLOCK_ONLY_HIGH\",\n\n Some: \"BLOCK_MEDIUM_AND_ABOVE\",\n SOME: \"BLOCK_MEDIUM_AND_ABOVE\",\n BLOCK_MEDIUM_AND_ABOVE: \"BLOCK_MEDIUM_AND_ABOVE\",\n\n Most: \"BLOCK_LOW_AND_ABOVE\",\n MOST: \"BLOCK_LOW_AND_ABOVE\",\n BLOCK_LOW_AND_ABOVE: \"BLOCK_LOW_AND_ABOVE\",\n\n Off: \"OFF\",\n OFF: \"OFF\",\n BLOCK_OFF: \"OFF\",\n} as const;\n\nexport type GoogleAISafetyThreshold =\n (typeof GoogleAISafetyThreshold)[keyof typeof GoogleAISafetyThreshold];\n\nexport const GoogleAISafetyMethod = {\n Severity: \"SEVERITY\",\n Probability: \"PROBABILITY\",\n} as const;\n\nexport type GoogleAISafetyMethod =\n (typeof GoogleAISafetyMethod)[keyof typeof GoogleAISafetyMethod];\n\nexport interface GoogleAISafetySetting {\n category: GoogleAISafetyCategory | string;\n threshold: GoogleAISafetyThreshold | string;\n method?: GoogleAISafetyMethod | string; // Just for Vertex AI?\n}\n\nexport type GoogleAIResponseMimeType = \"text/plain\" | \"application/json\";\n\nexport type GoogleAIModelModality = \"TEXT\" | \"IMAGE\" | \"AUDIO\" | string;\n\nexport type GoogleThinkingLevel =\n | \"THINKING_LEVEL_UNSPECIFIED\"\n | \"LOW\"\n | \"MEDIUM\"\n | \"HIGH\";\n\nexport interface GoogleThinkingConfig {\n thinkingBudget?: number;\n includeThoughts?: boolean;\n thinkingLevel?: GoogleThinkingLevel;\n}\n\nexport type GooglePrebuiltVoiceName = string;\n\nexport interface GooglePrebuiltVoiceConfig {\n voiceName: GooglePrebuiltVoiceName;\n}\n\nexport interface GoogleVoiceConfig {\n prebuiltVoiceConfig: GooglePrebuiltVoiceConfig;\n}\n\nexport interface GoogleSpeakerVoiceConfig {\n speaker: string;\n voiceConfig: GoogleVoiceConfig;\n}\n\nexport interface GoogleMultiSpeakerVoiceConfig {\n speakerVoiceConfigs: GoogleSpeakerVoiceConfig[];\n}\n\nexport interface GoogleSpeechConfigSingle {\n voiceConfig: GoogleVoiceConfig;\n languageCode?: string;\n}\n\nexport interface GoogleSpeechConfigMulti {\n multiSpeakerVoiceConfig: GoogleMultiSpeakerVoiceConfig;\n languageCode?: string;\n}\n\nexport type GoogleSpeechConfig =\n | GoogleSpeechConfigSingle\n | GoogleSpeechConfigMulti;\n\n/**\n * A simplified version of the GoogleSpeakerVoiceConfig\n */\nexport interface GoogleSpeechSpeakerName {\n speaker: string;\n name: GooglePrebuiltVoiceName;\n}\n\nexport type GoogleSpeechVoice =\n | GooglePrebuiltVoiceName\n | GoogleSpeechSpeakerName\n | GoogleSpeechSpeakerName[];\n\nexport interface GoogleSpeechVoiceLanguage {\n voice: GoogleSpeechVoice;\n languageCode: string;\n}\n\nexport interface GoogleSpeechVoicesLanguage {\n voices: GoogleSpeechVoice;\n languageCode: string;\n}\n\n/**\n * A simplified way to represent the voice (or voices) and language code.\n * \"voice\" and \"voices\" are semantically the same, we're not enforcing\n * that one is an array and one isn't.\n */\nexport type GoogleSpeechSimplifiedLanguage =\n | GoogleSpeechVoiceLanguage\n | GoogleSpeechVoicesLanguage;\n\n/**\n * A simplified way to represent the voices.\n * It can either be the voice (or voices), or the voice or voices with language configuration\n */\nexport type GoogleSpeechConfigSimplified =\n | GoogleSpeechVoice\n | GoogleSpeechSimplifiedLanguage;\n\nexport interface GoogleModelParams {\n /** Model to use */\n model?: string;\n\n /**\n * Model to use\n * Alias for `model`\n */\n modelName?: string;\n}\n\nexport interface GoogleAIModelParams extends GoogleModelParams {\n /** Sampling temperature to use */\n temperature?: number;\n\n /**\n * Maximum number of tokens to generate in the completion.\n * This may include reasoning tokens (for backwards compatibility).\n */\n maxOutputTokens?: number;\n\n /**\n * The maximum number of the output tokens that will be used\n * for the \"thinking\" or \"reasoning\" stages.\n */\n maxReasoningTokens?: number;\n\n /**\n * An alias for \"maxReasoningTokens\"\n */\n thinkingBudget?: number;\n\n /**\n * An OpenAI compatible parameter that will map to \"maxReasoningTokens\"\n */\n reasoningEffort?: \"low\" | \"medium\" | \"high\";\n\n /**\n * Optional. The level of thoughts tokens that the model should generate.\n * Can be specified directly or via reasoningLevel for OpenAI compatibility.\n */\n thinkingLevel?: GoogleThinkingLevel;\n\n /**\n * An OpenAI compatible parameter that will map to \"thinkingLevel\"\n */\n reasoningLevel?: \"low\" | \"medium\" | \"high\";\n\n /**\n * Top-p changes how the model selects tokens for output.\n *\n * Tokens are selected from most probable to least until the sum\n * of their probabilities equals the top-p value.\n *\n * For example, if tokens A, B, and C have a probability of\n * .3, .2, and .1 and the top-p value is .5, then the model will\n * select either A or B as the next token (using temperature).\n */\n topP?: number;\n\n /**\n * Top-k changes how the model selects tokens for output.\n *\n * A top-k of 1 means the selected token is the most probable among\n * all tokens in the model’s vocabulary (also called greedy decoding),\n * while a top-k of 3 means that the next token is selected from\n * among the 3 most probable tokens (using temperature).\n */\n topK?: number;\n\n /**\n * Seed used in decoding. If not set, the request uses a randomly generated seed.\n */\n seed?: number;\n\n /**\n * Presence penalty applied to the next token's logprobs\n * if the token has already been seen in the response.\n * This penalty is binary on/off and not dependant on the\n * number of times the token is used (after the first).\n * Use frequencyPenalty for a penalty that increases with each use.\n * A positive penalty will discourage the use of tokens that have\n * already been used in the response, increasing the vocabulary.\n * A negative penalty will encourage the use of tokens that have\n * already been used in the response, decreasing the vocabulary.\n */\n presencePenalty?: number;\n\n /**\n * Frequency penalty applied to the next token's logprobs,\n * multiplied by the number of times each token has been seen\n * in the respponse so far.\n * A positive penalty will discourage the use of tokens that\n * have already been used, proportional to the number of times\n * the token has been used:\n * The more a token is used, the more dificult it is for the model\n * to use that token again increasing the vocabulary of responses.\n * Caution: A _negative_ penalty will encourage the model to reuse\n * tokens proportional to the number of times the token has been used.\n * Small negative values will reduce the vocabulary of a response.\n * Larger negative values will cause the model to start repeating\n * a common token until it hits the maxOutputTokens limit.\n */\n frequencyPenalty?: number;\n\n stopSequences?: string[];\n\n safetySettings?: GoogleAISafetySetting[];\n\n convertSystemMessageToHumanContent?: boolean;\n\n /**\n * Available for `gemini-1.5-pro`.\n * The output format of the generated candidate text.\n * Supported MIME types:\n * - `text/plain`: Text output.\n * - `application/json`: JSON response in the candidates.\n *\n * @default \"text/plain\"\n */\n responseMimeType?: GoogleAIResponseMimeType;\n\n /**\n * The schema that the model's output should conform to.\n * When this is set, the model will output JSON that conforms to the schema.\n */\n responseSchema?: GeminiJsonSchema;\n\n /**\n * Whether or not to stream.\n * @default false\n */\n streaming?: boolean;\n\n /**\n * Whether to return log probabilities of the output tokens or not.\n * If true, returns the log probabilities of each output token\n * returned in the content of message.\n */\n logprobs?: boolean;\n\n /**\n * An integer between 0 and 5 specifying the number of\n * most likely tokens to return at each token position,\n * each with an associated log probability.\n * logprobs must be set to true if this parameter is used.\n */\n topLogprobs?: number;\n\n /**\n * The modalities of the response.\n */\n responseModalities?: GoogleAIModelModality[];\n\n /**\n * Custom metadata labels to associate with the request.\n * Only supported on Vertex AI (Google Cloud Platform).\n * Labels are key-value pairs where both keys and values must be strings.\n *\n * Example:\n * ```typescript\n * {\n * labels: {\n * \"team\": \"research\",\n * \"component\": \"frontend\",\n * \"environment\": \"production\"\n * }\n * }\n * ```\n */\n labels?: Record<string, string>;\n\n /**\n * Speech generation configuration.\n * You can use either Google's definition of the speech configuration,\n * or a simplified version we've defined (which can be as simple\n * as the name of a pre-defined voice).\n */\n speechConfig?: GoogleSpeechConfig | GoogleSpeechConfigSimplified;\n}\n\nexport type GoogleAIToolType = BindToolsInput | GeminiTool;\n\n/**\n * The params which can be passed to the API at request time.\n */\nexport interface GoogleAIModelRequestParams extends GoogleAIModelParams {\n tools?: GoogleAIToolType[];\n /**\n * Force the model to use tools in a specific way.\n *\n * | Mode |\tDescription |\n * |----------|---------------------------------------------------------------------------------------------------------------------------------------------------------|\n * | \"auto\"\t | The default model behavior. The model decides whether to predict a function call or a natural language response. |\n * | \"any\"\t | The model must predict only function calls. To limit the model to a subset of functions, define the allowed function names in `allowed_function_names`. |\n * | \"none\"\t | The model must not predict function calls. This behavior is equivalent to a model request without any associated function declarations. |\n * | string | The string value must be one of the function names. This will force the model to predict the specified function call. |\n *\n * The tool configuration's \"any\" mode (\"forced function calling\") is supported for Gemini 1.5 Pro models only.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n tool_choice?: string | \"auto\" | \"any\" | \"none\" | Record<string, any>;\n /**\n * Allowed functions to call when the mode is \"any\".\n * If empty, any one of the provided functions are called.\n */\n allowed_function_names?: string[];\n\n /**\n * Used to specify a previously created context cache to use with generation.\n * For Vertex, this should be of the form:\n * \"projects/PROJECT_NUMBER/locations/LOCATION/cachedContents/CACHE_ID\",\n *\n * See these guides for more information on how to use context caching:\n * https://cloud.google.com/vertex-ai/generative-ai/docs/context-cache/context-cache-create\n * https://cloud.google.com/vertex-ai/generative-ai/docs/context-cache/context-cache-use\n */\n cachedContent?: string;\n\n /**\n * The schema that the model's output should conform to.\n * When this is set, the model will output JSON that conforms to the schema.\n */\n responseSchema?: GeminiJsonSchema;\n}\n\nexport interface GoogleAIBaseLLMInput<AuthOptions>\n extends\n BaseLLMParams,\n GoogleConnectionParams<AuthOptions>,\n GoogleAIModelParams,\n GoogleAISafetyParams,\n GoogleAIAPIParams {}\n\nexport interface GoogleAIBaseLanguageModelCallOptions\n extends\n BaseChatModelCallOptions,\n GoogleAIModelRequestParams,\n GoogleAISafetyParams {\n /**\n * Whether or not to include usage data, like token counts\n * in the streamed response chunks.\n * @default true\n */\n streamUsage?: boolean;\n}\n\n/**\n * Input to LLM class.\n */\nexport interface GoogleBaseLLMInput<\n AuthOptions,\n> extends GoogleAIBaseLLMInput<AuthOptions> {}\n\nexport interface GoogleResponse {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any;\n}\n\nexport interface GoogleRawResponse extends GoogleResponse {\n data: Blob;\n}\n\nexport interface GeminiPartBase {\n thought?: boolean; // Output only\n thoughtSignature?: string;\n}\n\nexport interface GeminiVideoMetadata {\n fps?: number; // Double in range (0.0, 24.0]\n startOffset?: string;\n endOffset?: string;\n}\n\nexport interface GeminiPartBaseFile extends GeminiPartBase {\n videoMetadata?: GeminiVideoMetadata;\n}\n\nexport interface GeminiPartText extends GeminiPartBase {\n text: string;\n}\n\nexport interface GeminiPartInlineData extends GeminiPartBaseFile {\n inlineData: {\n mimeType: string;\n data: string;\n };\n}\n\nexport interface GeminiPartFileData extends GeminiPartBaseFile {\n fileData: {\n mimeType: string;\n fileUri: string;\n };\n}\n\n// AI Studio only?\nexport interface GeminiPartFunctionCall extends GeminiPartBase {\n functionCall: {\n name: string;\n args?: object;\n };\n}\n\n// AI Studio Only?\nexport interface GeminiPartFunctionResponse extends GeminiPartBase {\n functionResponse: {\n name: string;\n response: object;\n };\n}\n\nexport type GeminiPart =\n | GeminiPartText\n | GeminiPartInlineData\n | GeminiPartFileData\n | GeminiPartFunctionCall\n | GeminiPartFunctionResponse;\n\nexport interface GeminiSafetySetting {\n category: string;\n threshold: string;\n}\n\nexport type GeminiSafetyRating = {\n category: string;\n probability: string;\n} & Record<string, unknown>;\n\nexport interface GeminiCitationMetadata {\n citations: GeminiCitation[];\n}\n\nexport interface GeminiCitation {\n startIndex: number;\n endIndex: number;\n uri: string;\n title: string;\n license: string;\n publicationDate: GoogleTypeDate;\n}\n\nexport interface GoogleTypeDate {\n year: number; // 1-9999 or 0 to specify a date without a year\n month: number; // 1-12 or 0 to specify a year without a month and day\n day: number; // Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant\n}\n\nexport interface GeminiGroundingMetadata {\n webSearchQueries?: string[];\n searchEntryPoint?: GeminiSearchEntryPoint;\n groundingChunks: GeminiGroundingChunk[];\n groundingSupports?: GeminiGroundingSupport[];\n retrievalMetadata?: GeminiRetrievalMetadata;\n}\n\nexport interface GeminiSearchEntryPoint {\n renderedContent?: string;\n sdkBlob?: string; // Base64 encoded JSON representing array of tuple.\n}\n\nexport interface GeminiGroundingChunk {\n web: GeminiGroundingChunkWeb;\n retrievedContext: GeminiGroundingChunkRetrievedContext;\n}\n\nexport interface GeminiGroundingChunkWeb {\n uri: string;\n title: string;\n}\n\nexport interface GeminiGroundingChunkRetrievedContext {\n uri: string;\n title: string;\n text: string;\n}\n\nexport interface GeminiGroundingSupport {\n segment: GeminiSegment;\n groundingChunkIndices: number[];\n confidenceScores: number[];\n}\n\nexport interface GeminiSegment {\n partIndex: number;\n startIndex: number;\n endIndex: number;\n text: string;\n}\n\nexport interface GeminiRetrievalMetadata {\n googleSearchDynamicRetrievalScore: number;\n}\n\nexport type GeminiUrlRetrievalStatus =\n | \"URL_RETRIEVAL_STATUS_SUCCESS\"\n | \"URL_RETRIEVAL_STATUS_ERROR\";\n\nexport interface GeminiUrlRetrievalContext {\n retrievedUrl: string;\n urlRetrievalStatus: GeminiUrlRetrievalStatus;\n}\n\nexport interface GeminiUrlRetrievalMetadata {\n urlRetrievalContexts: GeminiUrlRetrievalContext[];\n}\n\nexport type GeminiUrlMetadata = GeminiUrlRetrievalContext;\n\nexport interface GeminiUrlContextMetadata {\n urlMetadata: GeminiUrlMetadata[];\n}\n\nexport interface GeminiLogprobsResult {\n topCandidates: GeminiLogprobsTopCandidate[];\n chosenCandidates: GeminiLogprobsResultCandidate[];\n}\n\nexport interface GeminiLogprobsTopCandidate {\n candidates: GeminiLogprobsResultCandidate[];\n}\n\nexport interface GeminiLogprobsResultCandidate {\n token: string;\n tokenId: number;\n logProbability: number;\n}\n\n// The \"system\" content appears to only be valid in the systemInstruction\nexport type GeminiRole = \"system\" | \"user\" | \"model\" | \"function\";\n\nexport interface GeminiContent {\n parts: GeminiPart[];\n role: GeminiRole; // Vertex AI requires the role\n}\n\n/*\n * If additional attributes are added here, they should also be\n * added to the attributes below\n */\nexport interface GeminiTool {\n functionDeclarations?: GeminiFunctionDeclaration[];\n googleSearchRetrieval?: GoogleSearchRetrieval; // Gemini-1.5\n googleSearch?: GoogleSearch; // Gemini-2.0\n urlContext?: UrlContext;\n retrieval?: VertexAIRetrieval;\n}\n\n/*\n * The known strings in this type should match those in GeminiSearchToolAttribuets\n */\nexport type GoogleSearchToolSetting =\n | boolean\n | \"googleSearchRetrieval\"\n | \"googleSearch\"\n | string;\n\nexport const GeminiSearchToolAttributes = [\n \"googleSearchRetrieval\",\n \"googleSearch\",\n];\n\nexport const GeminiToolAttributes = [\n \"functionDeclaration\",\n \"retrieval\",\n \"urlContext\",\n ...GeminiSearchToolAttributes,\n];\n\nexport interface GoogleSearchRetrieval {\n dynamicRetrievalConfig?: {\n mode?: string;\n dynamicThreshold?: number;\n };\n}\n\nexport interface GoogleSearch {}\n\nexport interface UrlContext {}\n\nexport interface VertexAIRetrieval {\n vertexAiSearch: {\n datastore: string;\n };\n disableAttribution?: boolean;\n}\n\nexport interface GeminiFunctionDeclaration {\n name: string;\n description: string;\n parameters?: GeminiFunctionSchema;\n}\n\nexport interface GeminiFunctionSchema {\n type: GeminiFunctionSchemaType;\n format?: string;\n description?: string;\n nullable?: boolean;\n enum?: string[];\n properties?: Record<string, GeminiFunctionSchema>;\n required?: string[];\n items?: GeminiFunctionSchema;\n}\n\nexport type GeminiFunctionSchemaType =\n | \"string\"\n | \"number\"\n | \"integer\"\n | \"boolean\"\n | \"array\"\n | \"object\";\n\nexport interface GeminiGenerationConfig {\n stopSequences?: string[];\n candidateCount?: number;\n maxOutputTokens?: number;\n temperature?: number;\n topP?: number;\n topK?: number;\n seed?: number;\n presencePenalty?: number;\n frequencyPenalty?: number;\n responseMimeType?: GoogleAIResponseMimeType;\n responseLogprobs?: boolean;\n logprobs?: number;\n responseModalities?: GoogleAIModelModality[];\n thinkingConfig?: GoogleThinkingConfig;\n speechConfig?: GoogleSpeechConfig;\n responseSchema?: GeminiJsonSchema;\n}\n\nexport interface GeminiRequest {\n contents?: GeminiContent[];\n systemInstruction?: GeminiContent;\n tools?: GeminiTool[];\n toolConfig?: {\n functionCallingConfig: {\n mode: \"auto\" | \"any\" | \"none\";\n allowedFunctionNames?: string[];\n };\n };\n safetySettings?: GeminiSafetySetting[];\n generationConfig?: GeminiGenerationConfig;\n cachedContent?: string;\n\n /**\n * Custom metadata labels to associate with the API call.\n */\n labels?: Record<string, string>;\n}\n\nexport interface GeminiResponseCandidate {\n content: {\n parts: GeminiPart[];\n role: string;\n };\n finishReason: string;\n index: number;\n tokenCount?: number;\n safetyRatings: GeminiSafetyRating[];\n citationMetadata?: GeminiCitationMetadata;\n groundingMetadata?: GeminiGroundingMetadata;\n urlRetrievalMetadata?: GeminiUrlRetrievalMetadata;\n urlContextMetadata?: GeminiUrlContextMetadata;\n avgLogprobs?: number;\n logprobsResult: GeminiLogprobsResult;\n finishMessage?: string;\n}\n\ninterface GeminiResponsePromptFeedback {\n blockReason?: string;\n safetyRatings: GeminiSafetyRating[];\n}\n\nexport type ModalityEnum =\n | \"TEXT\"\n | \"IMAGE\"\n | \"VIDEO\"\n | \"AUDIO\"\n | \"DOCUMENT\"\n | string;\n\nexport interface ModalityTokenCount {\n modality: ModalityEnum;\n tokenCount: number;\n}\n\nexport interface GenerateContentResponseUsageMetadata {\n promptTokenCount: number;\n toolUsePromptTokenCount: number;\n cachedContentTokenCount: number;\n thoughtsTokenCount: number;\n candidatesTokenCount: number;\n totalTokenCount: number;\n\n promptTokensDetails: ModalityTokenCount[];\n toolUsePromptTokensDetails: ModalityTokenCount[];\n cacheTokensDetails: ModalityTokenCount[];\n candidatesTokensDetails: ModalityTokenCount[];\n\n [key: string]: unknown;\n}\n\nexport interface GenerateContentResponseData {\n candidates: GeminiResponseCandidate[];\n promptFeedback: GeminiResponsePromptFeedback;\n usageMetadata: GenerateContentResponseUsageMetadata;\n}\n\nexport type GoogleLLMModelFamily = null | \"palm\" | \"gemini\" | \"gemma\";\n\nexport type VertexModelFamily = GoogleLLMModelFamily | \"claude\";\n\nexport type GoogleLLMResponseData =\n | JsonStream\n | GenerateContentResponseData\n | GenerateContentResponseData[];\n\nexport interface GoogleLLMResponse extends GoogleResponse {\n data: GoogleLLMResponseData | AnthropicResponseData;\n}\n\nexport interface GoogleAISafetyHandler {\n /**\n * A function that will take a response and return the, possibly modified,\n * response or throw an exception if there are safety issues.\n *\n * @throws GoogleAISafetyError\n */\n handle(response: GoogleLLMResponse): GoogleLLMResponse;\n}\n\nexport interface GoogleAISafetyParams {\n safetyHandler?: GoogleAISafetyHandler;\n}\n\nexport type GeminiJsonSchema = Record<string, unknown> & {\n properties?: Record<string, GeminiJsonSchema>;\n type: GeminiFunctionSchemaType;\n nullable?: boolean;\n};\n\nexport interface GeminiJsonSchemaDirty extends GeminiJsonSchema {\n items?: GeminiJsonSchemaDirty;\n properties?: Record<string, GeminiJsonSchemaDirty>;\n additionalProperties?: boolean;\n}\n\nexport type GoogleAIAPI = {\n messageContentToParts?: (content: MessageContent) => Promise<GeminiPart[]>;\n\n baseMessageToContent?: (\n message: BaseMessage,\n prevMessage: BaseMessage | undefined,\n useSystemInstruction: boolean\n ) => Promise<GeminiContent[]>;\n\n responseToString: (response: GoogleLLMResponse) => string;\n\n responseToChatGeneration: (\n response: GoogleLLMResponse\n ) => ChatGenerationChunk | null;\n\n chunkToString: (chunk: BaseMessageChunk) => string;\n\n responseToBaseMessage: (response: GoogleLLMResponse) => BaseMessage;\n\n responseToChatResult: (response: GoogleLLMResponse) => ChatResult;\n\n formatData: (\n input: unknown,\n parameters: GoogleAIModelRequestParams\n ) => Promise<unknown>;\n};\n\nexport interface GeminiAPIConfig {\n safetyHandler?: GoogleAISafetyHandler;\n mediaManager?: MediaManager;\n useSystemInstruction?: boolean;\n\n /**\n * How to handle the Google Search tool, since the name (and format)\n * of the tool changes between Gemini 1.5 and Gemini 2.0.\n * true - Change based on the model version. (Default)\n * false - Do not change the tool name provided\n * string value - Use this as the attribute name for the search\n * tool, adapting any tool attributes if possible.\n * When the model is created, a \"true\" or default setting\n * will be changed to a string based on the model.\n */\n googleSearchToolAdjustment?: GoogleSearchToolSetting;\n}\n\nexport type GoogleAIAPIConfig = GeminiAPIConfig | AnthropicAPIConfig;\n\nexport interface GoogleAIAPIParams {\n apiName?: string;\n apiConfig?: GoogleAIAPIConfig;\n}\n\n// Embeddings\n\n/**\n * Defines the parameters required to initialize a\n * GoogleEmbeddings instance. It extends EmbeddingsParams and\n * GoogleConnectionParams.\n */\nexport interface BaseGoogleEmbeddingsParams<AuthOptions>\n extends EmbeddingsParams, GoogleConnectionParams<AuthOptions> {\n model: string;\n\n /**\n * Used to specify output embedding size.\n * If set, output embeddings will be truncated to the size specified.\n */\n dimensions?: number;\n\n /**\n * An alias for \"dimensions\"\n */\n outputDimensionality?: number;\n}\n\n/**\n * Defines additional options specific to the\n * GoogleEmbeddingsInstance. It extends AsyncCallerCallOptions.\n */\nexport interface BaseGoogleEmbeddingsOptions extends AsyncCallerCallOptions {}\n\nexport type GoogleEmbeddingsTaskType =\n | \"RETRIEVAL_QUERY\"\n | \"RETRIEVAL_DOCUMENT\"\n | \"SEMANTIC_SIMILARITY\"\n | \"CLASSIFICATION\"\n | \"CLUSTERING\"\n | \"QUESTION_ANSWERING\"\n | \"FACT_VERIFICATION\"\n | \"CODE_RETRIEVAL_QUERY\"\n | string;\n\n/**\n * Represents an instance for generating embeddings using the Google\n * Vertex AI API. It contains the content to be embedded.\n */\nexport interface VertexEmbeddingsInstance {\n content: string;\n taskType?: GoogleEmbeddingsTaskType;\n title?: string;\n}\n\nexport interface VertexEmbeddingsParameters extends GoogleModelParams {\n autoTruncate?: boolean;\n outputDimensionality?: number;\n}\n\nexport interface VertexEmbeddingsRequest {\n instances: VertexEmbeddingsInstance[];\n parameters?: VertexEmbeddingsParameters;\n}\n\nexport interface AIStudioEmbeddingsRequest {\n content: {\n parts: GeminiPartText[];\n };\n model?: string; // Documentation says required, but tests say otherwise\n taskType?: GoogleEmbeddingsTaskType;\n title?: string;\n outputDimensionality?: number;\n}\n\nexport type GoogleEmbeddingsRequest =\n | VertexEmbeddingsRequest\n | AIStudioEmbeddingsRequest;\n\nexport interface VertexEmbeddingsResponsePrediction {\n embeddings: {\n statistics: {\n token_count: number;\n truncated: boolean;\n };\n values: number[];\n };\n}\n\n/**\n * Defines the structure of the embeddings results returned by the Google\n * Vertex AI API. It extends GoogleBasePrediction and contains the\n * embeddings and their statistics.\n */\nexport interface VertexEmbeddingsResponse extends GoogleResponse {\n data: {\n predictions: VertexEmbeddingsResponsePrediction[];\n };\n}\n\nexport interface AIStudioEmbeddingsResponse extends GoogleResponse {\n data: {\n embedding: {\n values: number[];\n };\n };\n}\n\nexport type GoogleEmbeddingsResponse =\n | VertexEmbeddingsResponse\n | AIStudioEmbeddingsResponse;\n"],"mappings":";;AAoEA,MAAa,yBAAyB;CACpC,YAAY;CACZ,YAAY;CACZ,0BAA0B;CAE1B,YAAY;CACZ,aAAa;CACb,2BAA2B;CAE3B,kBAAkB;CAClB,mBAAmB;CACnB,iCAAiC;CAEjC,WAAW;CACX,WAAW;CACX,yBAAyB;CAEzB,gBAAgB;CAChB,iBAAiB;CACjB,+BAA+B;AAChC;AAKD,MAAa,0BAA0B;CACrC,MAAM;CACN,MAAM;CACN,YAAY;CAEZ,KAAK;CACL,KAAK;CACL,iBAAiB;CAEjB,MAAM;CACN,MAAM;CACN,wBAAwB;CAExB,MAAM;CACN,MAAM;CACN,qBAAqB;CAErB,KAAK;CACL,KAAK;CACL,WAAW;AACZ;AAKD,MAAa,uBAAuB;CAClC,UAAU;CACV,aAAa;AACd;AA6iBD,MAAa,6BAA6B,CACxC,yBACA,cACD;AAED,MAAa,uBAAuB;CAClC;CACA;CACA;CACA,GAAG;AACJ"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type { BaseLLMParams } from \"@langchain/core/language_models/llms\";\nimport type {\n BaseChatModelCallOptions,\n BindToolsInput,\n} from \"@langchain/core/language_models/chat_models\";\nimport {\n BaseMessage,\n BaseMessageChunk,\n MessageContent,\n} from \"@langchain/core/messages\";\nimport { ChatGenerationChunk, ChatResult } from \"@langchain/core/outputs\";\nimport { EmbeddingsParams } from \"@langchain/core/embeddings\";\nimport { AsyncCallerCallOptions } from \"@langchain/core/utils/async_caller\";\nimport type { JsonStream } from \"./utils/stream.js\";\nimport { MediaManager } from \"./experimental/utils/media_core.js\";\nimport {\n AnthropicResponseData,\n AnthropicAPIConfig,\n} from \"./types-anthropic.js\";\n\nexport * from \"./types-anthropic.js\";\n\n/**\n * Parameters needed to setup the client connection.\n * AuthOptions are something like GoogleAuthOptions (from google-auth-library)\n * or WebGoogleAuthOptions.\n */\nexport interface GoogleClientParams<AuthOptions> {\n authOptions?: AuthOptions;\n\n /** Some APIs allow an API key instead */\n apiKey?: string;\n}\n\n/**\n * What platform is this running on?\n * gai - Google AI Studio / MakerSuite / Generative AI platform\n * gcp - Google Cloud Platform\n */\nexport type GooglePlatformType = \"gai\" | \"gcp\";\n\nexport interface GoogleConnectionParams<AuthOptions>\n extends GoogleClientParams<AuthOptions> {\n /** Hostname for the API call (if this is running on GCP) */\n endpoint?: string;\n\n /** Region where the LLM is stored (if this is running on GCP) */\n location?: string;\n\n /** The version of the API functions. Part of the path. */\n apiVersion?: string;\n\n /**\n * What platform to run the service on.\n * If not specified, the class should determine this from other\n * means. Either way, the platform actually used will be in\n * the \"platform\" getter.\n */\n platformType?: GooglePlatformType;\n\n /**\n * For compatibility with Google's libraries, should this use Vertex?\n * The \"platformType\" parmeter takes precedence.\n */\n vertexai?: boolean;\n}\n\nexport const GoogleAISafetyCategory = {\n Harassment: \"HARM_CATEGORY_HARASSMENT\",\n HARASSMENT: \"HARM_CATEGORY_HARASSMENT\",\n HARM_CATEGORY_HARASSMENT: \"HARM_CATEGORY_HARASSMENT\",\n\n HateSpeech: \"HARM_CATEGORY_HATE_SPEECH\",\n HATE_SPEECH: \"HARM_CATEGORY_HATE_SPEECH\",\n HARM_CATEGORY_HATE_SPEECH: \"HARM_CATEGORY_HATE_SPEECH\",\n\n SexuallyExplicit: \"HARM_CATEGORY_SEXUALLY_EXPLICIT\",\n SEXUALLY_EXPLICIT: \"HARM_CATEGORY_SEXUALLY_EXPLICIT\",\n HARM_CATEGORY_SEXUALLY_EXPLICIT: \"HARM_CATEGORY_SEXUALLY_EXPLICIT\",\n\n Dangerous: \"HARM_CATEGORY_DANGEROUS\",\n DANGEROUS: \"HARM_CATEGORY_DANGEROUS\",\n HARM_CATEGORY_DANGEROUS: \"HARM_CATEGORY_DANGEROUS\",\n\n CivicIntegrity: \"HARM_CATEGORY_CIVIC_INTEGRITY\",\n CIVIC_INTEGRITY: \"HARM_CATEGORY_CIVIC_INTEGRITY\",\n HARM_CATEGORY_CIVIC_INTEGRITY: \"HARM_CATEGORY_CIVIC_INTEGRITY\",\n} as const;\n\nexport type GoogleAISafetyCategory =\n (typeof GoogleAISafetyCategory)[keyof typeof GoogleAISafetyCategory];\n\nexport const GoogleAISafetyThreshold = {\n None: \"BLOCK_NONE\",\n NONE: \"BLOCK_NONE\",\n BLOCK_NONE: \"BLOCK_NONE\",\n\n Few: \"BLOCK_ONLY_HIGH\",\n FEW: \"BLOCK_ONLY_HIGH\",\n BLOCK_ONLY_HIGH: \"BLOCK_ONLY_HIGH\",\n\n Some: \"BLOCK_MEDIUM_AND_ABOVE\",\n SOME: \"BLOCK_MEDIUM_AND_ABOVE\",\n BLOCK_MEDIUM_AND_ABOVE: \"BLOCK_MEDIUM_AND_ABOVE\",\n\n Most: \"BLOCK_LOW_AND_ABOVE\",\n MOST: \"BLOCK_LOW_AND_ABOVE\",\n BLOCK_LOW_AND_ABOVE: \"BLOCK_LOW_AND_ABOVE\",\n\n Off: \"OFF\",\n OFF: \"OFF\",\n BLOCK_OFF: \"OFF\",\n} as const;\n\nexport type GoogleAISafetyThreshold =\n (typeof GoogleAISafetyThreshold)[keyof typeof GoogleAISafetyThreshold];\n\nexport const GoogleAISafetyMethod = {\n Severity: \"SEVERITY\",\n Probability: \"PROBABILITY\",\n} as const;\n\nexport type GoogleAISafetyMethod =\n (typeof GoogleAISafetyMethod)[keyof typeof GoogleAISafetyMethod];\n\nexport interface GoogleAISafetySetting {\n category: GoogleAISafetyCategory | string;\n threshold: GoogleAISafetyThreshold | string;\n method?: GoogleAISafetyMethod | string; // Just for Vertex AI?\n}\n\nexport type GoogleAIResponseMimeType = \"text/plain\" | \"application/json\";\n\nexport type GoogleAIModelModality = \"TEXT\" | \"IMAGE\" | \"AUDIO\" | string;\n\nexport type GoogleThinkingLevel =\n | \"THINKING_LEVEL_UNSPECIFIED\"\n | \"LOW\"\n | \"MEDIUM\"\n | \"HIGH\";\n\nexport interface GoogleThinkingConfig {\n thinkingBudget?: number;\n includeThoughts?: boolean;\n thinkingLevel?: GoogleThinkingLevel;\n}\n\nexport type GooglePrebuiltVoiceName = string;\n\nexport interface GooglePrebuiltVoiceConfig {\n voiceName: GooglePrebuiltVoiceName;\n}\n\nexport interface GoogleVoiceConfig {\n prebuiltVoiceConfig: GooglePrebuiltVoiceConfig;\n}\n\nexport interface GoogleSpeakerVoiceConfig {\n speaker: string;\n voiceConfig: GoogleVoiceConfig;\n}\n\nexport interface GoogleMultiSpeakerVoiceConfig {\n speakerVoiceConfigs: GoogleSpeakerVoiceConfig[];\n}\n\nexport interface GoogleSpeechConfigSingle {\n voiceConfig: GoogleVoiceConfig;\n languageCode?: string;\n}\n\nexport interface GoogleSpeechConfigMulti {\n multiSpeakerVoiceConfig: GoogleMultiSpeakerVoiceConfig;\n languageCode?: string;\n}\n\nexport type GoogleSpeechConfig =\n | GoogleSpeechConfigSingle\n | GoogleSpeechConfigMulti;\n\n/**\n * A simplified version of the GoogleSpeakerVoiceConfig\n */\nexport interface GoogleSpeechSpeakerName {\n speaker: string;\n name: GooglePrebuiltVoiceName;\n}\n\nexport type GoogleSpeechVoice =\n | GooglePrebuiltVoiceName\n | GoogleSpeechSpeakerName\n | GoogleSpeechSpeakerName[];\n\nexport interface GoogleSpeechVoiceLanguage {\n voice: GoogleSpeechVoice;\n languageCode: string;\n}\n\nexport interface GoogleSpeechVoicesLanguage {\n voices: GoogleSpeechVoice;\n languageCode: string;\n}\n\n/**\n * A simplified way to represent the voice (or voices) and language code.\n * \"voice\" and \"voices\" are semantically the same, we're not enforcing\n * that one is an array and one isn't.\n */\nexport type GoogleSpeechSimplifiedLanguage =\n | GoogleSpeechVoiceLanguage\n | GoogleSpeechVoicesLanguage;\n\n/**\n * A simplified way to represent the voices.\n * It can either be the voice (or voices), or the voice or voices with language configuration\n */\nexport type GoogleSpeechConfigSimplified =\n | GoogleSpeechVoice\n | GoogleSpeechSimplifiedLanguage;\n\nexport interface GoogleModelParams {\n /** Model to use */\n model?: string;\n\n /**\n * Model to use\n * Alias for `model`\n */\n modelName?: string;\n}\n\nexport interface GoogleAIModelParams extends GoogleModelParams {\n /** Sampling temperature to use */\n temperature?: number;\n\n /**\n * Maximum number of tokens to generate in the completion.\n * This may include reasoning tokens (for backwards compatibility).\n */\n maxOutputTokens?: number;\n\n /**\n * The maximum number of the output tokens that will be used\n * for the \"thinking\" or \"reasoning\" stages.\n */\n maxReasoningTokens?: number;\n\n /**\n * An alias for \"maxReasoningTokens\"\n */\n thinkingBudget?: number;\n\n /**\n * An OpenAI compatible parameter that will map to \"maxReasoningTokens\"\n */\n reasoningEffort?: \"low\" | \"medium\" | \"high\";\n\n /**\n * Optional. The level of thoughts tokens that the model should generate.\n * Can be specified directly or via reasoningLevel for OpenAI compatibility.\n */\n thinkingLevel?: GoogleThinkingLevel;\n\n /**\n * An OpenAI compatible parameter that will map to \"thinkingLevel\"\n */\n reasoningLevel?: \"low\" | \"medium\" | \"high\";\n\n /**\n * Top-p changes how the model selects tokens for output.\n *\n * Tokens are selected from most probable to least until the sum\n * of their probabilities equals the top-p value.\n *\n * For example, if tokens A, B, and C have a probability of\n * .3, .2, and .1 and the top-p value is .5, then the model will\n * select either A or B as the next token (using temperature).\n */\n topP?: number;\n\n /**\n * Top-k changes how the model selects tokens for output.\n *\n * A top-k of 1 means the selected token is the most probable among\n * all tokens in the model’s vocabulary (also called greedy decoding),\n * while a top-k of 3 means that the next token is selected from\n * among the 3 most probable tokens (using temperature).\n */\n topK?: number;\n\n /**\n * Seed used in decoding. If not set, the request uses a randomly generated seed.\n */\n seed?: number;\n\n /**\n * Presence penalty applied to the next token's logprobs\n * if the token has already been seen in the response.\n * This penalty is binary on/off and not dependant on the\n * number of times the token is used (after the first).\n * Use frequencyPenalty for a penalty that increases with each use.\n * A positive penalty will discourage the use of tokens that have\n * already been used in the response, increasing the vocabulary.\n * A negative penalty will encourage the use of tokens that have\n * already been used in the response, decreasing the vocabulary.\n */\n presencePenalty?: number;\n\n /**\n * Frequency penalty applied to the next token's logprobs,\n * multiplied by the number of times each token has been seen\n * in the respponse so far.\n * A positive penalty will discourage the use of tokens that\n * have already been used, proportional to the number of times\n * the token has been used:\n * The more a token is used, the more dificult it is for the model\n * to use that token again increasing the vocabulary of responses.\n * Caution: A _negative_ penalty will encourage the model to reuse\n * tokens proportional to the number of times the token has been used.\n * Small negative values will reduce the vocabulary of a response.\n * Larger negative values will cause the model to start repeating\n * a common token until it hits the maxOutputTokens limit.\n */\n frequencyPenalty?: number;\n\n stopSequences?: string[];\n\n safetySettings?: GoogleAISafetySetting[];\n\n convertSystemMessageToHumanContent?: boolean;\n\n /**\n * Available for `gemini-1.5-pro`.\n * The output format of the generated candidate text.\n * Supported MIME types:\n * - `text/plain`: Text output.\n * - `application/json`: JSON response in the candidates.\n *\n * @default \"text/plain\"\n */\n responseMimeType?: GoogleAIResponseMimeType;\n\n /**\n * The schema that the model's output should conform to.\n * When this is set, the model will output JSON that conforms to the schema.\n */\n responseSchema?: GeminiJsonSchema;\n\n /**\n * Whether or not to stream.\n * @default false\n */\n streaming?: boolean;\n\n /**\n * Whether to return log probabilities of the output tokens or not.\n * If true, returns the log probabilities of each output token\n * returned in the content of message.\n */\n logprobs?: boolean;\n\n /**\n * An integer between 0 and 5 specifying the number of\n * most likely tokens to return at each token position,\n * each with an associated log probability.\n * logprobs must be set to true if this parameter is used.\n */\n topLogprobs?: number;\n\n /**\n * The modalities of the response.\n */\n responseModalities?: GoogleAIModelModality[];\n\n /**\n * Custom metadata labels to associate with the request.\n * Only supported on Vertex AI (Google Cloud Platform).\n * Labels are key-value pairs where both keys and values must be strings.\n *\n * Example:\n * ```typescript\n * {\n * labels: {\n * \"team\": \"research\",\n * \"component\": \"frontend\",\n * \"environment\": \"production\"\n * }\n * }\n * ```\n */\n labels?: Record<string, string>;\n\n /**\n * Speech generation configuration.\n * You can use either Google's definition of the speech configuration,\n * or a simplified version we've defined (which can be as simple\n * as the name of a pre-defined voice).\n */\n speechConfig?: GoogleSpeechConfig | GoogleSpeechConfigSimplified;\n}\n\nexport type GoogleAIToolType = BindToolsInput | GeminiTool;\n\n/**\n * The params which can be passed to the API at request time.\n */\nexport interface GoogleAIModelRequestParams extends GoogleAIModelParams {\n tools?: GoogleAIToolType[];\n /**\n * Force the model to use tools in a specific way.\n *\n * | Mode |\tDescription |\n * |----------|---------------------------------------------------------------------------------------------------------------------------------------------------------|\n * | \"auto\"\t | The default model behavior. The model decides whether to predict a function call or a natural language response. |\n * | \"any\"\t | The model must predict only function calls. To limit the model to a subset of functions, define the allowed function names in `allowed_function_names`. |\n * | \"none\"\t | The model must not predict function calls. This behavior is equivalent to a model request without any associated function declarations. |\n * | string | The string value must be one of the function names. This will force the model to predict the specified function call. |\n *\n * The tool configuration's \"any\" mode (\"forced function calling\") is supported for Gemini 1.5 Pro models only.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n tool_choice?: string | \"auto\" | \"any\" | \"none\" | Record<string, any>;\n /**\n * Allowed functions to call when the mode is \"any\".\n * If empty, any one of the provided functions are called.\n */\n allowed_function_names?: string[];\n\n /**\n * Used to specify a previously created context cache to use with generation.\n * For Vertex, this should be of the form:\n * \"projects/PROJECT_NUMBER/locations/LOCATION/cachedContents/CACHE_ID\",\n *\n * See these guides for more information on how to use context caching:\n * https://cloud.google.com/vertex-ai/generative-ai/docs/context-cache/context-cache-create\n * https://cloud.google.com/vertex-ai/generative-ai/docs/context-cache/context-cache-use\n */\n cachedContent?: string;\n\n /**\n * The schema that the model's output should conform to.\n * When this is set, the model will output JSON that conforms to the schema.\n */\n responseSchema?: GeminiJsonSchema;\n}\n\nexport interface GoogleAIBaseLLMInput<AuthOptions>\n extends BaseLLMParams,\n GoogleConnectionParams<AuthOptions>,\n GoogleAIModelParams,\n GoogleAISafetyParams,\n GoogleAIAPIParams {}\n\nexport interface GoogleAIBaseLanguageModelCallOptions\n extends BaseChatModelCallOptions,\n GoogleAIModelRequestParams,\n GoogleAISafetyParams {\n /**\n * Whether or not to include usage data, like token counts\n * in the streamed response chunks.\n * @default true\n */\n streamUsage?: boolean;\n}\n\n/**\n * Input to LLM class.\n */\nexport interface GoogleBaseLLMInput<AuthOptions>\n extends GoogleAIBaseLLMInput<AuthOptions> {}\n\nexport interface GoogleResponse {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any;\n}\n\nexport interface GoogleRawResponse extends GoogleResponse {\n data: Blob;\n}\n\nexport interface GeminiPartBase {\n thought?: boolean; // Output only\n thoughtSignature?: string;\n}\n\nexport interface GeminiVideoMetadata {\n fps?: number; // Double in range (0.0, 24.0]\n startOffset?: string;\n endOffset?: string;\n}\n\nexport interface GeminiPartBaseFile extends GeminiPartBase {\n videoMetadata?: GeminiVideoMetadata;\n}\n\nexport interface GeminiPartText extends GeminiPartBase {\n text: string;\n}\n\nexport interface GeminiPartInlineData extends GeminiPartBaseFile {\n inlineData: {\n mimeType: string;\n data: string;\n };\n}\n\nexport interface GeminiPartFileData extends GeminiPartBaseFile {\n fileData: {\n mimeType: string;\n fileUri: string;\n };\n}\n\n// AI Studio only?\nexport interface GeminiPartFunctionCall extends GeminiPartBase {\n functionCall: {\n name: string;\n args?: object;\n };\n}\n\n// AI Studio Only?\nexport interface GeminiPartFunctionResponse extends GeminiPartBase {\n functionResponse: {\n name: string;\n response: object;\n };\n}\n\nexport type GeminiPart =\n | GeminiPartText\n | GeminiPartInlineData\n | GeminiPartFileData\n | GeminiPartFunctionCall\n | GeminiPartFunctionResponse;\n\nexport interface GeminiSafetySetting {\n category: string;\n threshold: string;\n}\n\nexport type GeminiSafetyRating = {\n category: string;\n probability: string;\n} & Record<string, unknown>;\n\nexport interface GeminiCitationMetadata {\n citations: GeminiCitation[];\n}\n\nexport interface GeminiCitation {\n startIndex: number;\n endIndex: number;\n uri: string;\n title: string;\n license: string;\n publicationDate: GoogleTypeDate;\n}\n\nexport interface GoogleTypeDate {\n year: number; // 1-9999 or 0 to specify a date without a year\n month: number; // 1-12 or 0 to specify a year without a month and day\n day: number; // Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant\n}\n\nexport interface GeminiGroundingMetadata {\n webSearchQueries?: string[];\n searchEntryPoint?: GeminiSearchEntryPoint;\n groundingChunks: GeminiGroundingChunk[];\n groundingSupports?: GeminiGroundingSupport[];\n retrievalMetadata?: GeminiRetrievalMetadata;\n}\n\nexport interface GeminiSearchEntryPoint {\n renderedContent?: string;\n sdkBlob?: string; // Base64 encoded JSON representing array of tuple.\n}\n\nexport interface GeminiGroundingChunk {\n web: GeminiGroundingChunkWeb;\n retrievedContext: GeminiGroundingChunkRetrievedContext;\n}\n\nexport interface GeminiGroundingChunkWeb {\n uri: string;\n title: string;\n}\n\nexport interface GeminiGroundingChunkRetrievedContext {\n uri: string;\n title: string;\n text: string;\n}\n\nexport interface GeminiGroundingSupport {\n segment: GeminiSegment;\n groundingChunkIndices: number[];\n confidenceScores: number[];\n}\n\nexport interface GeminiSegment {\n partIndex: number;\n startIndex: number;\n endIndex: number;\n text: string;\n}\n\nexport interface GeminiRetrievalMetadata {\n googleSearchDynamicRetrievalScore: number;\n}\n\nexport type GeminiUrlRetrievalStatus =\n | \"URL_RETRIEVAL_STATUS_SUCCESS\"\n | \"URL_RETRIEVAL_STATUS_ERROR\";\n\nexport interface GeminiUrlRetrievalContext {\n retrievedUrl: string;\n urlRetrievalStatus: GeminiUrlRetrievalStatus;\n}\n\nexport interface GeminiUrlRetrievalMetadata {\n urlRetrievalContexts: GeminiUrlRetrievalContext[];\n}\n\nexport type GeminiUrlMetadata = GeminiUrlRetrievalContext;\n\nexport interface GeminiUrlContextMetadata {\n urlMetadata: GeminiUrlMetadata[];\n}\n\nexport interface GeminiLogprobsResult {\n topCandidates: GeminiLogprobsTopCandidate[];\n chosenCandidates: GeminiLogprobsResultCandidate[];\n}\n\nexport interface GeminiLogprobsTopCandidate {\n candidates: GeminiLogprobsResultCandidate[];\n}\n\nexport interface GeminiLogprobsResultCandidate {\n token: string;\n tokenId: number;\n logProbability: number;\n}\n\n// The \"system\" content appears to only be valid in the systemInstruction\nexport type GeminiRole = \"system\" | \"user\" | \"model\" | \"function\";\n\nexport interface GeminiContent {\n parts: GeminiPart[];\n role: GeminiRole; // Vertex AI requires the role\n}\n\n/*\n * If additional attributes are added here, they should also be\n * added to the attributes below\n */\nexport interface GeminiTool {\n functionDeclarations?: GeminiFunctionDeclaration[];\n googleSearchRetrieval?: GoogleSearchRetrieval; // Gemini-1.5\n googleSearch?: GoogleSearch; // Gemini-2.0\n urlContext?: UrlContext;\n retrieval?: VertexAIRetrieval;\n}\n\n/*\n * The known strings in this type should match those in GeminiSearchToolAttribuets\n */\nexport type GoogleSearchToolSetting =\n | boolean\n | \"googleSearchRetrieval\"\n | \"googleSearch\"\n | string;\n\nexport const GeminiSearchToolAttributes = [\n \"googleSearchRetrieval\",\n \"googleSearch\",\n];\n\nexport const GeminiToolAttributes = [\n \"functionDeclaration\",\n \"retrieval\",\n \"urlContext\",\n ...GeminiSearchToolAttributes,\n];\n\nexport interface GoogleSearchRetrieval {\n dynamicRetrievalConfig?: {\n mode?: string;\n dynamicThreshold?: number;\n };\n}\n\nexport interface GoogleSearch {}\n\nexport interface UrlContext {}\n\nexport interface VertexAIRetrieval {\n vertexAiSearch: {\n datastore: string;\n };\n disableAttribution?: boolean;\n}\n\nexport interface GeminiFunctionDeclaration {\n name: string;\n description: string;\n parameters?: GeminiFunctionSchema;\n}\n\nexport interface GeminiFunctionSchema {\n type: GeminiFunctionSchemaType;\n format?: string;\n description?: string;\n nullable?: boolean;\n enum?: string[];\n properties?: Record<string, GeminiFunctionSchema>;\n required?: string[];\n items?: GeminiFunctionSchema;\n}\n\nexport type GeminiFunctionSchemaType =\n | \"string\"\n | \"number\"\n | \"integer\"\n | \"boolean\"\n | \"array\"\n | \"object\";\n\nexport interface GeminiGenerationConfig {\n stopSequences?: string[];\n candidateCount?: number;\n maxOutputTokens?: number;\n temperature?: number;\n topP?: number;\n topK?: number;\n seed?: number;\n presencePenalty?: number;\n frequencyPenalty?: number;\n responseMimeType?: GoogleAIResponseMimeType;\n responseLogprobs?: boolean;\n logprobs?: number;\n responseModalities?: GoogleAIModelModality[];\n thinkingConfig?: GoogleThinkingConfig;\n speechConfig?: GoogleSpeechConfig;\n responseSchema?: GeminiJsonSchema;\n}\n\nexport interface GeminiRequest {\n contents?: GeminiContent[];\n systemInstruction?: GeminiContent;\n tools?: GeminiTool[];\n toolConfig?: {\n functionCallingConfig: {\n mode: \"auto\" | \"any\" | \"none\";\n allowedFunctionNames?: string[];\n };\n };\n safetySettings?: GeminiSafetySetting[];\n generationConfig?: GeminiGenerationConfig;\n cachedContent?: string;\n\n /**\n * Custom metadata labels to associate with the API call.\n */\n labels?: Record<string, string>;\n}\n\nexport interface GeminiResponseCandidate {\n content: {\n parts: GeminiPart[];\n role: string;\n };\n finishReason: string;\n index: number;\n tokenCount?: number;\n safetyRatings: GeminiSafetyRating[];\n citationMetadata?: GeminiCitationMetadata;\n groundingMetadata?: GeminiGroundingMetadata;\n urlRetrievalMetadata?: GeminiUrlRetrievalMetadata;\n urlContextMetadata?: GeminiUrlContextMetadata;\n avgLogprobs?: number;\n logprobsResult: GeminiLogprobsResult;\n finishMessage?: string;\n}\n\ninterface GeminiResponsePromptFeedback {\n blockReason?: string;\n safetyRatings: GeminiSafetyRating[];\n}\n\nexport type ModalityEnum =\n | \"TEXT\"\n | \"IMAGE\"\n | \"VIDEO\"\n | \"AUDIO\"\n | \"DOCUMENT\"\n | string;\n\nexport interface ModalityTokenCount {\n modality: ModalityEnum;\n tokenCount: number;\n}\n\nexport interface GenerateContentResponseUsageMetadata {\n promptTokenCount: number;\n toolUsePromptTokenCount: number;\n cachedContentTokenCount: number;\n thoughtsTokenCount: number;\n candidatesTokenCount: number;\n totalTokenCount: number;\n\n promptTokensDetails: ModalityTokenCount[];\n toolUsePromptTokensDetails: ModalityTokenCount[];\n cacheTokensDetails: ModalityTokenCount[];\n candidatesTokensDetails: ModalityTokenCount[];\n\n [key: string]: unknown;\n}\n\nexport interface GenerateContentResponseData {\n candidates: GeminiResponseCandidate[];\n promptFeedback: GeminiResponsePromptFeedback;\n usageMetadata: GenerateContentResponseUsageMetadata;\n}\n\nexport type GoogleLLMModelFamily = null | \"palm\" | \"gemini\" | \"gemma\";\n\nexport type VertexModelFamily = GoogleLLMModelFamily | \"claude\";\n\nexport type GoogleLLMResponseData =\n | JsonStream\n | GenerateContentResponseData\n | GenerateContentResponseData[];\n\nexport interface GoogleLLMResponse extends GoogleResponse {\n data: GoogleLLMResponseData | AnthropicResponseData;\n}\n\nexport interface GoogleAISafetyHandler {\n /**\n * A function that will take a response and return the, possibly modified,\n * response or throw an exception if there are safety issues.\n *\n * @throws GoogleAISafetyError\n */\n handle(response: GoogleLLMResponse): GoogleLLMResponse;\n}\n\nexport interface GoogleAISafetyParams {\n safetyHandler?: GoogleAISafetyHandler;\n}\n\nexport type GeminiJsonSchema = Record<string, unknown> & {\n properties?: Record<string, GeminiJsonSchema>;\n type: GeminiFunctionSchemaType;\n nullable?: boolean;\n};\n\nexport interface GeminiJsonSchemaDirty extends GeminiJsonSchema {\n items?: GeminiJsonSchemaDirty;\n properties?: Record<string, GeminiJsonSchemaDirty>;\n additionalProperties?: boolean;\n}\n\nexport type GoogleAIAPI = {\n messageContentToParts?: (content: MessageContent) => Promise<GeminiPart[]>;\n\n baseMessageToContent?: (\n message: BaseMessage,\n prevMessage: BaseMessage | undefined,\n useSystemInstruction: boolean\n ) => Promise<GeminiContent[]>;\n\n responseToString: (response: GoogleLLMResponse) => string;\n\n responseToChatGeneration: (\n response: GoogleLLMResponse\n ) => ChatGenerationChunk | null;\n\n chunkToString: (chunk: BaseMessageChunk) => string;\n\n responseToBaseMessage: (response: GoogleLLMResponse) => BaseMessage;\n\n responseToChatResult: (response: GoogleLLMResponse) => ChatResult;\n\n formatData: (\n input: unknown,\n parameters: GoogleAIModelRequestParams\n ) => Promise<unknown>;\n};\n\nexport interface GeminiAPIConfig {\n safetyHandler?: GoogleAISafetyHandler;\n mediaManager?: MediaManager;\n useSystemInstruction?: boolean;\n\n /**\n * How to handle the Google Search tool, since the name (and format)\n * of the tool changes between Gemini 1.5 and Gemini 2.0.\n * true - Change based on the model version. (Default)\n * false - Do not change the tool name provided\n * string value - Use this as the attribute name for the search\n * tool, adapting any tool attributes if possible.\n * When the model is created, a \"true\" or default setting\n * will be changed to a string based on the model.\n */\n googleSearchToolAdjustment?: GoogleSearchToolSetting;\n}\n\nexport type GoogleAIAPIConfig = GeminiAPIConfig | AnthropicAPIConfig;\n\nexport interface GoogleAIAPIParams {\n apiName?: string;\n apiConfig?: GoogleAIAPIConfig;\n}\n\n// Embeddings\n\n/**\n * Defines the parameters required to initialize a\n * GoogleEmbeddings instance. It extends EmbeddingsParams and\n * GoogleConnectionParams.\n */\nexport interface BaseGoogleEmbeddingsParams<AuthOptions>\n extends EmbeddingsParams,\n GoogleConnectionParams<AuthOptions> {\n model: string;\n\n /**\n * Used to specify output embedding size.\n * If set, output embeddings will be truncated to the size specified.\n */\n dimensions?: number;\n\n /**\n * An alias for \"dimensions\"\n */\n outputDimensionality?: number;\n}\n\n/**\n * Defines additional options specific to the\n * GoogleEmbeddingsInstance. It extends AsyncCallerCallOptions.\n */\nexport interface BaseGoogleEmbeddingsOptions extends AsyncCallerCallOptions {}\n\nexport type GoogleEmbeddingsTaskType =\n | \"RETRIEVAL_QUERY\"\n | \"RETRIEVAL_DOCUMENT\"\n | \"SEMANTIC_SIMILARITY\"\n | \"CLASSIFICATION\"\n | \"CLUSTERING\"\n | \"QUESTION_ANSWERING\"\n | \"FACT_VERIFICATION\"\n | \"CODE_RETRIEVAL_QUERY\"\n | string;\n\n/**\n * Represents an instance for generating embeddings using the Google\n * Vertex AI API. It contains the content to be embedded.\n */\nexport interface VertexEmbeddingsInstance {\n content: string;\n taskType?: GoogleEmbeddingsTaskType;\n title?: string;\n}\n\nexport interface VertexEmbeddingsParameters extends GoogleModelParams {\n autoTruncate?: boolean;\n outputDimensionality?: number;\n}\n\nexport interface VertexEmbeddingsRequest {\n instances: VertexEmbeddingsInstance[];\n parameters?: VertexEmbeddingsParameters;\n}\n\nexport interface AIStudioEmbeddingsRequest {\n content: {\n parts: GeminiPartText[];\n };\n model?: string; // Documentation says required, but tests say otherwise\n taskType?: GoogleEmbeddingsTaskType;\n title?: string;\n outputDimensionality?: number;\n}\n\nexport type GoogleEmbeddingsRequest =\n | VertexEmbeddingsRequest\n | AIStudioEmbeddingsRequest;\n\nexport interface VertexEmbeddingsResponsePrediction {\n embeddings: {\n statistics: {\n token_count: number;\n truncated: boolean;\n };\n values: number[];\n };\n}\n\n/**\n * Defines the structure of the embeddings results returned by the Google\n * Vertex AI API. It extends GoogleBasePrediction and contains the\n * embeddings and their statistics.\n */\nexport interface VertexEmbeddingsResponse extends GoogleResponse {\n data: {\n predictions: VertexEmbeddingsResponsePrediction[];\n };\n}\n\nexport interface AIStudioEmbeddingsResponse extends GoogleResponse {\n data: {\n embedding: {\n values: number[];\n };\n };\n}\n\nexport type GoogleEmbeddingsResponse =\n | VertexEmbeddingsResponse\n | AIStudioEmbeddingsResponse;\n"],"mappings":";AAmEA,MAAa,yBAAyB;CACpC,YAAY;CACZ,YAAY;CACZ,0BAA0B;CAE1B,YAAY;CACZ,aAAa;CACb,2BAA2B;CAE3B,kBAAkB;CAClB,mBAAmB;CACnB,iCAAiC;CAEjC,WAAW;CACX,WAAW;CACX,yBAAyB;CAEzB,gBAAgB;CAChB,iBAAiB;CACjB,+BAA+B;AAChC;AAKD,MAAa,0BAA0B;CACrC,MAAM;CACN,MAAM;CACN,YAAY;CAEZ,KAAK;CACL,KAAK;CACL,iBAAiB;CAEjB,MAAM;CACN,MAAM;CACN,wBAAwB;CAExB,MAAM;CACN,MAAM;CACN,qBAAqB;CAErB,KAAK;CACL,KAAK;CACL,WAAW;AACZ;AAKD,MAAa,uBAAuB;CAClC,UAAU;CACV,aAAa;AACd;AA0iBD,MAAa,6BAA6B,CACxC,yBACA,cACD;AAED,MAAa,uBAAuB;CAClC;CACA;CACA;CACA,GAAG;AACJ"}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type { BaseLLMParams } from \"@langchain/core/language_models/llms\";\nimport type {\n BaseChatModelCallOptions,\n BindToolsInput,\n} from \"@langchain/core/language_models/chat_models\";\nimport {\n BaseMessage,\n BaseMessageChunk,\n MessageContent,\n} from \"@langchain/core/messages\";\nimport { ChatGenerationChunk, ChatResult } from \"@langchain/core/outputs\";\nimport { EmbeddingsParams } from \"@langchain/core/embeddings\";\nimport { AsyncCallerCallOptions } from \"@langchain/core/utils/async_caller\";\nimport type { JsonStream } from \"./utils/stream.js\";\nimport { MediaManager } from \"./experimental/utils/media_core.js\";\nimport {\n AnthropicResponseData,\n AnthropicAPIConfig,\n} from \"./types-anthropic.js\";\n\nexport * from \"./types-anthropic.js\";\n\n/**\n * Parameters needed to setup the client connection.\n * AuthOptions are something like GoogleAuthOptions (from google-auth-library)\n * or WebGoogleAuthOptions.\n */\nexport interface GoogleClientParams<AuthOptions> {\n authOptions?: AuthOptions;\n\n /** Some APIs allow an API key instead */\n apiKey?: string;\n}\n\n/**\n * What platform is this running on?\n * gai - Google AI Studio / MakerSuite / Generative AI platform\n * gcp - Google Cloud Platform\n */\nexport type GooglePlatformType = \"gai\" | \"gcp\";\n\nexport interface GoogleConnectionParams<\n AuthOptions,\n> extends GoogleClientParams<AuthOptions> {\n /** Hostname for the API call (if this is running on GCP) */\n endpoint?: string;\n\n /** Region where the LLM is stored (if this is running on GCP) */\n location?: string;\n\n /** The version of the API functions. Part of the path. */\n apiVersion?: string;\n\n /**\n * What platform to run the service on.\n * If not specified, the class should determine this from other\n * means. Either way, the platform actually used will be in\n * the \"platform\" getter.\n */\n platformType?: GooglePlatformType;\n\n /**\n * For compatibility with Google's libraries, should this use Vertex?\n * The \"platformType\" parmeter takes precedence.\n */\n vertexai?: boolean;\n}\n\nexport const GoogleAISafetyCategory = {\n Harassment: \"HARM_CATEGORY_HARASSMENT\",\n HARASSMENT: \"HARM_CATEGORY_HARASSMENT\",\n HARM_CATEGORY_HARASSMENT: \"HARM_CATEGORY_HARASSMENT\",\n\n HateSpeech: \"HARM_CATEGORY_HATE_SPEECH\",\n HATE_SPEECH: \"HARM_CATEGORY_HATE_SPEECH\",\n HARM_CATEGORY_HATE_SPEECH: \"HARM_CATEGORY_HATE_SPEECH\",\n\n SexuallyExplicit: \"HARM_CATEGORY_SEXUALLY_EXPLICIT\",\n SEXUALLY_EXPLICIT: \"HARM_CATEGORY_SEXUALLY_EXPLICIT\",\n HARM_CATEGORY_SEXUALLY_EXPLICIT: \"HARM_CATEGORY_SEXUALLY_EXPLICIT\",\n\n Dangerous: \"HARM_CATEGORY_DANGEROUS\",\n DANGEROUS: \"HARM_CATEGORY_DANGEROUS\",\n HARM_CATEGORY_DANGEROUS: \"HARM_CATEGORY_DANGEROUS\",\n\n CivicIntegrity: \"HARM_CATEGORY_CIVIC_INTEGRITY\",\n CIVIC_INTEGRITY: \"HARM_CATEGORY_CIVIC_INTEGRITY\",\n HARM_CATEGORY_CIVIC_INTEGRITY: \"HARM_CATEGORY_CIVIC_INTEGRITY\",\n} as const;\n\nexport type GoogleAISafetyCategory =\n (typeof GoogleAISafetyCategory)[keyof typeof GoogleAISafetyCategory];\n\nexport const GoogleAISafetyThreshold = {\n None: \"BLOCK_NONE\",\n NONE: \"BLOCK_NONE\",\n BLOCK_NONE: \"BLOCK_NONE\",\n\n Few: \"BLOCK_ONLY_HIGH\",\n FEW: \"BLOCK_ONLY_HIGH\",\n BLOCK_ONLY_HIGH: \"BLOCK_ONLY_HIGH\",\n\n Some: \"BLOCK_MEDIUM_AND_ABOVE\",\n SOME: \"BLOCK_MEDIUM_AND_ABOVE\",\n BLOCK_MEDIUM_AND_ABOVE: \"BLOCK_MEDIUM_AND_ABOVE\",\n\n Most: \"BLOCK_LOW_AND_ABOVE\",\n MOST: \"BLOCK_LOW_AND_ABOVE\",\n BLOCK_LOW_AND_ABOVE: \"BLOCK_LOW_AND_ABOVE\",\n\n Off: \"OFF\",\n OFF: \"OFF\",\n BLOCK_OFF: \"OFF\",\n} as const;\n\nexport type GoogleAISafetyThreshold =\n (typeof GoogleAISafetyThreshold)[keyof typeof GoogleAISafetyThreshold];\n\nexport const GoogleAISafetyMethod = {\n Severity: \"SEVERITY\",\n Probability: \"PROBABILITY\",\n} as const;\n\nexport type GoogleAISafetyMethod =\n (typeof GoogleAISafetyMethod)[keyof typeof GoogleAISafetyMethod];\n\nexport interface GoogleAISafetySetting {\n category: GoogleAISafetyCategory | string;\n threshold: GoogleAISafetyThreshold | string;\n method?: GoogleAISafetyMethod | string; // Just for Vertex AI?\n}\n\nexport type GoogleAIResponseMimeType = \"text/plain\" | \"application/json\";\n\nexport type GoogleAIModelModality = \"TEXT\" | \"IMAGE\" | \"AUDIO\" | string;\n\nexport type GoogleThinkingLevel =\n | \"THINKING_LEVEL_UNSPECIFIED\"\n | \"LOW\"\n | \"MEDIUM\"\n | \"HIGH\";\n\nexport interface GoogleThinkingConfig {\n thinkingBudget?: number;\n includeThoughts?: boolean;\n thinkingLevel?: GoogleThinkingLevel;\n}\n\nexport type GooglePrebuiltVoiceName = string;\n\nexport interface GooglePrebuiltVoiceConfig {\n voiceName: GooglePrebuiltVoiceName;\n}\n\nexport interface GoogleVoiceConfig {\n prebuiltVoiceConfig: GooglePrebuiltVoiceConfig;\n}\n\nexport interface GoogleSpeakerVoiceConfig {\n speaker: string;\n voiceConfig: GoogleVoiceConfig;\n}\n\nexport interface GoogleMultiSpeakerVoiceConfig {\n speakerVoiceConfigs: GoogleSpeakerVoiceConfig[];\n}\n\nexport interface GoogleSpeechConfigSingle {\n voiceConfig: GoogleVoiceConfig;\n languageCode?: string;\n}\n\nexport interface GoogleSpeechConfigMulti {\n multiSpeakerVoiceConfig: GoogleMultiSpeakerVoiceConfig;\n languageCode?: string;\n}\n\nexport type GoogleSpeechConfig =\n | GoogleSpeechConfigSingle\n | GoogleSpeechConfigMulti;\n\n/**\n * A simplified version of the GoogleSpeakerVoiceConfig\n */\nexport interface GoogleSpeechSpeakerName {\n speaker: string;\n name: GooglePrebuiltVoiceName;\n}\n\nexport type GoogleSpeechVoice =\n | GooglePrebuiltVoiceName\n | GoogleSpeechSpeakerName\n | GoogleSpeechSpeakerName[];\n\nexport interface GoogleSpeechVoiceLanguage {\n voice: GoogleSpeechVoice;\n languageCode: string;\n}\n\nexport interface GoogleSpeechVoicesLanguage {\n voices: GoogleSpeechVoice;\n languageCode: string;\n}\n\n/**\n * A simplified way to represent the voice (or voices) and language code.\n * \"voice\" and \"voices\" are semantically the same, we're not enforcing\n * that one is an array and one isn't.\n */\nexport type GoogleSpeechSimplifiedLanguage =\n | GoogleSpeechVoiceLanguage\n | GoogleSpeechVoicesLanguage;\n\n/**\n * A simplified way to represent the voices.\n * It can either be the voice (or voices), or the voice or voices with language configuration\n */\nexport type GoogleSpeechConfigSimplified =\n | GoogleSpeechVoice\n | GoogleSpeechSimplifiedLanguage;\n\nexport interface GoogleModelParams {\n /** Model to use */\n model?: string;\n\n /**\n * Model to use\n * Alias for `model`\n */\n modelName?: string;\n}\n\nexport interface GoogleAIModelParams extends GoogleModelParams {\n /** Sampling temperature to use */\n temperature?: number;\n\n /**\n * Maximum number of tokens to generate in the completion.\n * This may include reasoning tokens (for backwards compatibility).\n */\n maxOutputTokens?: number;\n\n /**\n * The maximum number of the output tokens that will be used\n * for the \"thinking\" or \"reasoning\" stages.\n */\n maxReasoningTokens?: number;\n\n /**\n * An alias for \"maxReasoningTokens\"\n */\n thinkingBudget?: number;\n\n /**\n * An OpenAI compatible parameter that will map to \"maxReasoningTokens\"\n */\n reasoningEffort?: \"low\" | \"medium\" | \"high\";\n\n /**\n * Optional. The level of thoughts tokens that the model should generate.\n * Can be specified directly or via reasoningLevel for OpenAI compatibility.\n */\n thinkingLevel?: GoogleThinkingLevel;\n\n /**\n * An OpenAI compatible parameter that will map to \"thinkingLevel\"\n */\n reasoningLevel?: \"low\" | \"medium\" | \"high\";\n\n /**\n * Top-p changes how the model selects tokens for output.\n *\n * Tokens are selected from most probable to least until the sum\n * of their probabilities equals the top-p value.\n *\n * For example, if tokens A, B, and C have a probability of\n * .3, .2, and .1 and the top-p value is .5, then the model will\n * select either A or B as the next token (using temperature).\n */\n topP?: number;\n\n /**\n * Top-k changes how the model selects tokens for output.\n *\n * A top-k of 1 means the selected token is the most probable among\n * all tokens in the model’s vocabulary (also called greedy decoding),\n * while a top-k of 3 means that the next token is selected from\n * among the 3 most probable tokens (using temperature).\n */\n topK?: number;\n\n /**\n * Seed used in decoding. If not set, the request uses a randomly generated seed.\n */\n seed?: number;\n\n /**\n * Presence penalty applied to the next token's logprobs\n * if the token has already been seen in the response.\n * This penalty is binary on/off and not dependant on the\n * number of times the token is used (after the first).\n * Use frequencyPenalty for a penalty that increases with each use.\n * A positive penalty will discourage the use of tokens that have\n * already been used in the response, increasing the vocabulary.\n * A negative penalty will encourage the use of tokens that have\n * already been used in the response, decreasing the vocabulary.\n */\n presencePenalty?: number;\n\n /**\n * Frequency penalty applied to the next token's logprobs,\n * multiplied by the number of times each token has been seen\n * in the respponse so far.\n * A positive penalty will discourage the use of tokens that\n * have already been used, proportional to the number of times\n * the token has been used:\n * The more a token is used, the more dificult it is for the model\n * to use that token again increasing the vocabulary of responses.\n * Caution: A _negative_ penalty will encourage the model to reuse\n * tokens proportional to the number of times the token has been used.\n * Small negative values will reduce the vocabulary of a response.\n * Larger negative values will cause the model to start repeating\n * a common token until it hits the maxOutputTokens limit.\n */\n frequencyPenalty?: number;\n\n stopSequences?: string[];\n\n safetySettings?: GoogleAISafetySetting[];\n\n convertSystemMessageToHumanContent?: boolean;\n\n /**\n * Available for `gemini-1.5-pro`.\n * The output format of the generated candidate text.\n * Supported MIME types:\n * - `text/plain`: Text output.\n * - `application/json`: JSON response in the candidates.\n *\n * @default \"text/plain\"\n */\n responseMimeType?: GoogleAIResponseMimeType;\n\n /**\n * The schema that the model's output should conform to.\n * When this is set, the model will output JSON that conforms to the schema.\n */\n responseSchema?: GeminiJsonSchema;\n\n /**\n * Whether or not to stream.\n * @default false\n */\n streaming?: boolean;\n\n /**\n * Whether to return log probabilities of the output tokens or not.\n * If true, returns the log probabilities of each output token\n * returned in the content of message.\n */\n logprobs?: boolean;\n\n /**\n * An integer between 0 and 5 specifying the number of\n * most likely tokens to return at each token position,\n * each with an associated log probability.\n * logprobs must be set to true if this parameter is used.\n */\n topLogprobs?: number;\n\n /**\n * The modalities of the response.\n */\n responseModalities?: GoogleAIModelModality[];\n\n /**\n * Custom metadata labels to associate with the request.\n * Only supported on Vertex AI (Google Cloud Platform).\n * Labels are key-value pairs where both keys and values must be strings.\n *\n * Example:\n * ```typescript\n * {\n * labels: {\n * \"team\": \"research\",\n * \"component\": \"frontend\",\n * \"environment\": \"production\"\n * }\n * }\n * ```\n */\n labels?: Record<string, string>;\n\n /**\n * Speech generation configuration.\n * You can use either Google's definition of the speech configuration,\n * or a simplified version we've defined (which can be as simple\n * as the name of a pre-defined voice).\n */\n speechConfig?: GoogleSpeechConfig | GoogleSpeechConfigSimplified;\n}\n\nexport type GoogleAIToolType = BindToolsInput | GeminiTool;\n\n/**\n * The params which can be passed to the API at request time.\n */\nexport interface GoogleAIModelRequestParams extends GoogleAIModelParams {\n tools?: GoogleAIToolType[];\n /**\n * Force the model to use tools in a specific way.\n *\n * | Mode |\tDescription |\n * |----------|---------------------------------------------------------------------------------------------------------------------------------------------------------|\n * | \"auto\"\t | The default model behavior. The model decides whether to predict a function call or a natural language response. |\n * | \"any\"\t | The model must predict only function calls. To limit the model to a subset of functions, define the allowed function names in `allowed_function_names`. |\n * | \"none\"\t | The model must not predict function calls. This behavior is equivalent to a model request without any associated function declarations. |\n * | string | The string value must be one of the function names. This will force the model to predict the specified function call. |\n *\n * The tool configuration's \"any\" mode (\"forced function calling\") is supported for Gemini 1.5 Pro models only.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n tool_choice?: string | \"auto\" | \"any\" | \"none\" | Record<string, any>;\n /**\n * Allowed functions to call when the mode is \"any\".\n * If empty, any one of the provided functions are called.\n */\n allowed_function_names?: string[];\n\n /**\n * Used to specify a previously created context cache to use with generation.\n * For Vertex, this should be of the form:\n * \"projects/PROJECT_NUMBER/locations/LOCATION/cachedContents/CACHE_ID\",\n *\n * See these guides for more information on how to use context caching:\n * https://cloud.google.com/vertex-ai/generative-ai/docs/context-cache/context-cache-create\n * https://cloud.google.com/vertex-ai/generative-ai/docs/context-cache/context-cache-use\n */\n cachedContent?: string;\n\n /**\n * The schema that the model's output should conform to.\n * When this is set, the model will output JSON that conforms to the schema.\n */\n responseSchema?: GeminiJsonSchema;\n}\n\nexport interface GoogleAIBaseLLMInput<AuthOptions>\n extends\n BaseLLMParams,\n GoogleConnectionParams<AuthOptions>,\n GoogleAIModelParams,\n GoogleAISafetyParams,\n GoogleAIAPIParams {}\n\nexport interface GoogleAIBaseLanguageModelCallOptions\n extends\n BaseChatModelCallOptions,\n GoogleAIModelRequestParams,\n GoogleAISafetyParams {\n /**\n * Whether or not to include usage data, like token counts\n * in the streamed response chunks.\n * @default true\n */\n streamUsage?: boolean;\n}\n\n/**\n * Input to LLM class.\n */\nexport interface GoogleBaseLLMInput<\n AuthOptions,\n> extends GoogleAIBaseLLMInput<AuthOptions> {}\n\nexport interface GoogleResponse {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n data: any;\n}\n\nexport interface GoogleRawResponse extends GoogleResponse {\n data: Blob;\n}\n\nexport interface GeminiPartBase {\n thought?: boolean; // Output only\n thoughtSignature?: string;\n}\n\nexport interface GeminiVideoMetadata {\n fps?: number; // Double in range (0.0, 24.0]\n startOffset?: string;\n endOffset?: string;\n}\n\nexport interface GeminiPartBaseFile extends GeminiPartBase {\n videoMetadata?: GeminiVideoMetadata;\n}\n\nexport interface GeminiPartText extends GeminiPartBase {\n text: string;\n}\n\nexport interface GeminiPartInlineData extends GeminiPartBaseFile {\n inlineData: {\n mimeType: string;\n data: string;\n };\n}\n\nexport interface GeminiPartFileData extends GeminiPartBaseFile {\n fileData: {\n mimeType: string;\n fileUri: string;\n };\n}\n\n// AI Studio only?\nexport interface GeminiPartFunctionCall extends GeminiPartBase {\n functionCall: {\n name: string;\n args?: object;\n };\n}\n\n// AI Studio Only?\nexport interface GeminiPartFunctionResponse extends GeminiPartBase {\n functionResponse: {\n name: string;\n response: object;\n };\n}\n\nexport type GeminiPart =\n | GeminiPartText\n | GeminiPartInlineData\n | GeminiPartFileData\n | GeminiPartFunctionCall\n | GeminiPartFunctionResponse;\n\nexport interface GeminiSafetySetting {\n category: string;\n threshold: string;\n}\n\nexport type GeminiSafetyRating = {\n category: string;\n probability: string;\n} & Record<string, unknown>;\n\nexport interface GeminiCitationMetadata {\n citations: GeminiCitation[];\n}\n\nexport interface GeminiCitation {\n startIndex: number;\n endIndex: number;\n uri: string;\n title: string;\n license: string;\n publicationDate: GoogleTypeDate;\n}\n\nexport interface GoogleTypeDate {\n year: number; // 1-9999 or 0 to specify a date without a year\n month: number; // 1-12 or 0 to specify a year without a month and day\n day: number; // Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant\n}\n\nexport interface GeminiGroundingMetadata {\n webSearchQueries?: string[];\n searchEntryPoint?: GeminiSearchEntryPoint;\n groundingChunks: GeminiGroundingChunk[];\n groundingSupports?: GeminiGroundingSupport[];\n retrievalMetadata?: GeminiRetrievalMetadata;\n}\n\nexport interface GeminiSearchEntryPoint {\n renderedContent?: string;\n sdkBlob?: string; // Base64 encoded JSON representing array of tuple.\n}\n\nexport interface GeminiGroundingChunk {\n web: GeminiGroundingChunkWeb;\n retrievedContext: GeminiGroundingChunkRetrievedContext;\n}\n\nexport interface GeminiGroundingChunkWeb {\n uri: string;\n title: string;\n}\n\nexport interface GeminiGroundingChunkRetrievedContext {\n uri: string;\n title: string;\n text: string;\n}\n\nexport interface GeminiGroundingSupport {\n segment: GeminiSegment;\n groundingChunkIndices: number[];\n confidenceScores: number[];\n}\n\nexport interface GeminiSegment {\n partIndex: number;\n startIndex: number;\n endIndex: number;\n text: string;\n}\n\nexport interface GeminiRetrievalMetadata {\n googleSearchDynamicRetrievalScore: number;\n}\n\nexport type GeminiUrlRetrievalStatus =\n | \"URL_RETRIEVAL_STATUS_SUCCESS\"\n | \"URL_RETRIEVAL_STATUS_ERROR\";\n\nexport interface GeminiUrlRetrievalContext {\n retrievedUrl: string;\n urlRetrievalStatus: GeminiUrlRetrievalStatus;\n}\n\nexport interface GeminiUrlRetrievalMetadata {\n urlRetrievalContexts: GeminiUrlRetrievalContext[];\n}\n\nexport type GeminiUrlMetadata = GeminiUrlRetrievalContext;\n\nexport interface GeminiUrlContextMetadata {\n urlMetadata: GeminiUrlMetadata[];\n}\n\nexport interface GeminiLogprobsResult {\n topCandidates: GeminiLogprobsTopCandidate[];\n chosenCandidates: GeminiLogprobsResultCandidate[];\n}\n\nexport interface GeminiLogprobsTopCandidate {\n candidates: GeminiLogprobsResultCandidate[];\n}\n\nexport interface GeminiLogprobsResultCandidate {\n token: string;\n tokenId: number;\n logProbability: number;\n}\n\n// The \"system\" content appears to only be valid in the systemInstruction\nexport type GeminiRole = \"system\" | \"user\" | \"model\" | \"function\";\n\nexport interface GeminiContent {\n parts: GeminiPart[];\n role: GeminiRole; // Vertex AI requires the role\n}\n\n/*\n * If additional attributes are added here, they should also be\n * added to the attributes below\n */\nexport interface GeminiTool {\n functionDeclarations?: GeminiFunctionDeclaration[];\n googleSearchRetrieval?: GoogleSearchRetrieval; // Gemini-1.5\n googleSearch?: GoogleSearch; // Gemini-2.0\n urlContext?: UrlContext;\n retrieval?: VertexAIRetrieval;\n}\n\n/*\n * The known strings in this type should match those in GeminiSearchToolAttribuets\n */\nexport type GoogleSearchToolSetting =\n | boolean\n | \"googleSearchRetrieval\"\n | \"googleSearch\"\n | string;\n\nexport const GeminiSearchToolAttributes = [\n \"googleSearchRetrieval\",\n \"googleSearch\",\n];\n\nexport const GeminiToolAttributes = [\n \"functionDeclaration\",\n \"retrieval\",\n \"urlContext\",\n ...GeminiSearchToolAttributes,\n];\n\nexport interface GoogleSearchRetrieval {\n dynamicRetrievalConfig?: {\n mode?: string;\n dynamicThreshold?: number;\n };\n}\n\nexport interface GoogleSearch {}\n\nexport interface UrlContext {}\n\nexport interface VertexAIRetrieval {\n vertexAiSearch: {\n datastore: string;\n };\n disableAttribution?: boolean;\n}\n\nexport interface GeminiFunctionDeclaration {\n name: string;\n description: string;\n parameters?: GeminiFunctionSchema;\n}\n\nexport interface GeminiFunctionSchema {\n type: GeminiFunctionSchemaType;\n format?: string;\n description?: string;\n nullable?: boolean;\n enum?: string[];\n properties?: Record<string, GeminiFunctionSchema>;\n required?: string[];\n items?: GeminiFunctionSchema;\n}\n\nexport type GeminiFunctionSchemaType =\n | \"string\"\n | \"number\"\n | \"integer\"\n | \"boolean\"\n | \"array\"\n | \"object\";\n\nexport interface GeminiGenerationConfig {\n stopSequences?: string[];\n candidateCount?: number;\n maxOutputTokens?: number;\n temperature?: number;\n topP?: number;\n topK?: number;\n seed?: number;\n presencePenalty?: number;\n frequencyPenalty?: number;\n responseMimeType?: GoogleAIResponseMimeType;\n responseLogprobs?: boolean;\n logprobs?: number;\n responseModalities?: GoogleAIModelModality[];\n thinkingConfig?: GoogleThinkingConfig;\n speechConfig?: GoogleSpeechConfig;\n responseSchema?: GeminiJsonSchema;\n}\n\nexport interface GeminiRequest {\n contents?: GeminiContent[];\n systemInstruction?: GeminiContent;\n tools?: GeminiTool[];\n toolConfig?: {\n functionCallingConfig: {\n mode: \"auto\" | \"any\" | \"none\";\n allowedFunctionNames?: string[];\n };\n };\n safetySettings?: GeminiSafetySetting[];\n generationConfig?: GeminiGenerationConfig;\n cachedContent?: string;\n\n /**\n * Custom metadata labels to associate with the API call.\n */\n labels?: Record<string, string>;\n}\n\nexport interface GeminiResponseCandidate {\n content: {\n parts: GeminiPart[];\n role: string;\n };\n finishReason: string;\n index: number;\n tokenCount?: number;\n safetyRatings: GeminiSafetyRating[];\n citationMetadata?: GeminiCitationMetadata;\n groundingMetadata?: GeminiGroundingMetadata;\n urlRetrievalMetadata?: GeminiUrlRetrievalMetadata;\n urlContextMetadata?: GeminiUrlContextMetadata;\n avgLogprobs?: number;\n logprobsResult: GeminiLogprobsResult;\n finishMessage?: string;\n}\n\ninterface GeminiResponsePromptFeedback {\n blockReason?: string;\n safetyRatings: GeminiSafetyRating[];\n}\n\nexport type ModalityEnum =\n | \"TEXT\"\n | \"IMAGE\"\n | \"VIDEO\"\n | \"AUDIO\"\n | \"DOCUMENT\"\n | string;\n\nexport interface ModalityTokenCount {\n modality: ModalityEnum;\n tokenCount: number;\n}\n\nexport interface GenerateContentResponseUsageMetadata {\n promptTokenCount: number;\n toolUsePromptTokenCount: number;\n cachedContentTokenCount: number;\n thoughtsTokenCount: number;\n candidatesTokenCount: number;\n totalTokenCount: number;\n\n promptTokensDetails: ModalityTokenCount[];\n toolUsePromptTokensDetails: ModalityTokenCount[];\n cacheTokensDetails: ModalityTokenCount[];\n candidatesTokensDetails: ModalityTokenCount[];\n\n [key: string]: unknown;\n}\n\nexport interface GenerateContentResponseData {\n candidates: GeminiResponseCandidate[];\n promptFeedback: GeminiResponsePromptFeedback;\n usageMetadata: GenerateContentResponseUsageMetadata;\n}\n\nexport type GoogleLLMModelFamily = null | \"palm\" | \"gemini\" | \"gemma\";\n\nexport type VertexModelFamily = GoogleLLMModelFamily | \"claude\";\n\nexport type GoogleLLMResponseData =\n | JsonStream\n | GenerateContentResponseData\n | GenerateContentResponseData[];\n\nexport interface GoogleLLMResponse extends GoogleResponse {\n data: GoogleLLMResponseData | AnthropicResponseData;\n}\n\nexport interface GoogleAISafetyHandler {\n /**\n * A function that will take a response and return the, possibly modified,\n * response or throw an exception if there are safety issues.\n *\n * @throws GoogleAISafetyError\n */\n handle(response: GoogleLLMResponse): GoogleLLMResponse;\n}\n\nexport interface GoogleAISafetyParams {\n safetyHandler?: GoogleAISafetyHandler;\n}\n\nexport type GeminiJsonSchema = Record<string, unknown> & {\n properties?: Record<string, GeminiJsonSchema>;\n type: GeminiFunctionSchemaType;\n nullable?: boolean;\n};\n\nexport interface GeminiJsonSchemaDirty extends GeminiJsonSchema {\n items?: GeminiJsonSchemaDirty;\n properties?: Record<string, GeminiJsonSchemaDirty>;\n additionalProperties?: boolean;\n}\n\nexport type GoogleAIAPI = {\n messageContentToParts?: (content: MessageContent) => Promise<GeminiPart[]>;\n\n baseMessageToContent?: (\n message: BaseMessage,\n prevMessage: BaseMessage | undefined,\n useSystemInstruction: boolean\n ) => Promise<GeminiContent[]>;\n\n responseToString: (response: GoogleLLMResponse) => string;\n\n responseToChatGeneration: (\n response: GoogleLLMResponse\n ) => ChatGenerationChunk | null;\n\n chunkToString: (chunk: BaseMessageChunk) => string;\n\n responseToBaseMessage: (response: GoogleLLMResponse) => BaseMessage;\n\n responseToChatResult: (response: GoogleLLMResponse) => ChatResult;\n\n formatData: (\n input: unknown,\n parameters: GoogleAIModelRequestParams\n ) => Promise<unknown>;\n};\n\nexport interface GeminiAPIConfig {\n safetyHandler?: GoogleAISafetyHandler;\n mediaManager?: MediaManager;\n useSystemInstruction?: boolean;\n\n /**\n * How to handle the Google Search tool, since the name (and format)\n * of the tool changes between Gemini 1.5 and Gemini 2.0.\n * true - Change based on the model version. (Default)\n * false - Do not change the tool name provided\n * string value - Use this as the attribute name for the search\n * tool, adapting any tool attributes if possible.\n * When the model is created, a \"true\" or default setting\n * will be changed to a string based on the model.\n */\n googleSearchToolAdjustment?: GoogleSearchToolSetting;\n}\n\nexport type GoogleAIAPIConfig = GeminiAPIConfig | AnthropicAPIConfig;\n\nexport interface GoogleAIAPIParams {\n apiName?: string;\n apiConfig?: GoogleAIAPIConfig;\n}\n\n// Embeddings\n\n/**\n * Defines the parameters required to initialize a\n * GoogleEmbeddings instance. It extends EmbeddingsParams and\n * GoogleConnectionParams.\n */\nexport interface BaseGoogleEmbeddingsParams<AuthOptions>\n extends EmbeddingsParams, GoogleConnectionParams<AuthOptions> {\n model: string;\n\n /**\n * Used to specify output embedding size.\n * If set, output embeddings will be truncated to the size specified.\n */\n dimensions?: number;\n\n /**\n * An alias for \"dimensions\"\n */\n outputDimensionality?: number;\n}\n\n/**\n * Defines additional options specific to the\n * GoogleEmbeddingsInstance. It extends AsyncCallerCallOptions.\n */\nexport interface BaseGoogleEmbeddingsOptions extends AsyncCallerCallOptions {}\n\nexport type GoogleEmbeddingsTaskType =\n | \"RETRIEVAL_QUERY\"\n | \"RETRIEVAL_DOCUMENT\"\n | \"SEMANTIC_SIMILARITY\"\n | \"CLASSIFICATION\"\n | \"CLUSTERING\"\n | \"QUESTION_ANSWERING\"\n | \"FACT_VERIFICATION\"\n | \"CODE_RETRIEVAL_QUERY\"\n | string;\n\n/**\n * Represents an instance for generating embeddings using the Google\n * Vertex AI API. It contains the content to be embedded.\n */\nexport interface VertexEmbeddingsInstance {\n content: string;\n taskType?: GoogleEmbeddingsTaskType;\n title?: string;\n}\n\nexport interface VertexEmbeddingsParameters extends GoogleModelParams {\n autoTruncate?: boolean;\n outputDimensionality?: number;\n}\n\nexport interface VertexEmbeddingsRequest {\n instances: VertexEmbeddingsInstance[];\n parameters?: VertexEmbeddingsParameters;\n}\n\nexport interface AIStudioEmbeddingsRequest {\n content: {\n parts: GeminiPartText[];\n };\n model?: string; // Documentation says required, but tests say otherwise\n taskType?: GoogleEmbeddingsTaskType;\n title?: string;\n outputDimensionality?: number;\n}\n\nexport type GoogleEmbeddingsRequest =\n | VertexEmbeddingsRequest\n | AIStudioEmbeddingsRequest;\n\nexport interface VertexEmbeddingsResponsePrediction {\n embeddings: {\n statistics: {\n token_count: number;\n truncated: boolean;\n };\n values: number[];\n };\n}\n\n/**\n * Defines the structure of the embeddings results returned by the Google\n * Vertex AI API. It extends GoogleBasePrediction and contains the\n * embeddings and their statistics.\n */\nexport interface VertexEmbeddingsResponse extends GoogleResponse {\n data: {\n predictions: VertexEmbeddingsResponsePrediction[];\n };\n}\n\nexport interface AIStudioEmbeddingsResponse extends GoogleResponse {\n data: {\n embedding: {\n values: number[];\n };\n };\n}\n\nexport type GoogleEmbeddingsResponse =\n | VertexEmbeddingsResponse\n | AIStudioEmbeddingsResponse;\n"],"mappings":";AAoEA,MAAa,yBAAyB;CACpC,YAAY;CACZ,YAAY;CACZ,0BAA0B;CAE1B,YAAY;CACZ,aAAa;CACb,2BAA2B;CAE3B,kBAAkB;CAClB,mBAAmB;CACnB,iCAAiC;CAEjC,WAAW;CACX,WAAW;CACX,yBAAyB;CAEzB,gBAAgB;CAChB,iBAAiB;CACjB,+BAA+B;AAChC;AAKD,MAAa,0BAA0B;CACrC,MAAM;CACN,MAAM;CACN,YAAY;CAEZ,KAAK;CACL,KAAK;CACL,iBAAiB;CAEjB,MAAM;CACN,MAAM;CACN,wBAAwB;CAExB,MAAM;CACN,MAAM;CACN,qBAAqB;CAErB,KAAK;CACL,KAAK;CACL,WAAW;AACZ;AAKD,MAAa,uBAAuB;CAClC,UAAU;CACV,aAAa;AACd;AA6iBD,MAAa,6BAA6B,CACxC,yBACA,cACD;AAED,MAAa,uBAAuB;CAClC;CACA;CACA;CACA,GAAG;AACJ"}
|