@langchain/google-common 0.2.18 → 1.0.1

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.
Files changed (173) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/LICENSE +6 -6
  3. package/dist/_virtual/rolldown_runtime.cjs +25 -0
  4. package/dist/auth.cjs +82 -116
  5. package/dist/auth.cjs.map +1 -0
  6. package/dist/auth.d.cts +46 -0
  7. package/dist/auth.d.cts.map +1 -0
  8. package/dist/auth.d.ts +41 -36
  9. package/dist/auth.d.ts.map +1 -0
  10. package/dist/auth.js +80 -110
  11. package/dist/auth.js.map +1 -0
  12. package/dist/chat_models.cjs +264 -466
  13. package/dist/chat_models.cjs.map +1 -0
  14. package/dist/chat_models.d.cts +109 -0
  15. package/dist/chat_models.d.cts.map +1 -0
  16. package/dist/chat_models.d.ts +98 -73
  17. package/dist/chat_models.d.ts.map +1 -0
  18. package/dist/chat_models.js +258 -457
  19. package/dist/chat_models.js.map +1 -0
  20. package/dist/connection.cjs +321 -466
  21. package/dist/connection.cjs.map +1 -0
  22. package/dist/connection.d.cts +109 -0
  23. package/dist/connection.d.cts.map +1 -0
  24. package/dist/connection.d.ts +98 -91
  25. package/dist/connection.d.ts.map +1 -0
  26. package/dist/connection.js +317 -459
  27. package/dist/connection.js.map +1 -0
  28. package/dist/embeddings.cjs +135 -186
  29. package/dist/embeddings.cjs.map +1 -0
  30. package/dist/embeddings.d.cts +44 -0
  31. package/dist/embeddings.d.cts.map +1 -0
  32. package/dist/embeddings.d.ts +38 -32
  33. package/dist/embeddings.d.ts.map +1 -0
  34. package/dist/embeddings.js +133 -181
  35. package/dist/embeddings.js.map +1 -0
  36. package/dist/experimental/media.cjs +380 -482
  37. package/dist/experimental/media.cjs.map +1 -0
  38. package/dist/experimental/media.d.cts +198 -0
  39. package/dist/experimental/media.d.cts.map +1 -0
  40. package/dist/experimental/media.d.ts +190 -202
  41. package/dist/experimental/media.d.ts.map +1 -0
  42. package/dist/experimental/media.js +369 -468
  43. package/dist/experimental/media.js.map +1 -0
  44. package/dist/experimental/utils/media_core.cjs +403 -517
  45. package/dist/experimental/utils/media_core.cjs.map +1 -0
  46. package/dist/experimental/utils/media_core.d.cts +215 -0
  47. package/dist/experimental/utils/media_core.d.cts.map +1 -0
  48. package/dist/experimental/utils/media_core.d.ts +171 -165
  49. package/dist/experimental/utils/media_core.d.ts.map +1 -0
  50. package/dist/experimental/utils/media_core.js +395 -506
  51. package/dist/experimental/utils/media_core.js.map +1 -0
  52. package/dist/index.cjs +58 -27
  53. package/dist/index.d.cts +13 -0
  54. package/dist/index.d.ts +13 -11
  55. package/dist/index.js +13 -11
  56. package/dist/llms.cjs +157 -244
  57. package/dist/llms.cjs.map +1 -0
  58. package/dist/llms.d.cts +72 -0
  59. package/dist/llms.d.cts.map +1 -0
  60. package/dist/llms.d.ts +64 -54
  61. package/dist/llms.d.ts.map +1 -0
  62. package/dist/llms.js +154 -238
  63. package/dist/llms.js.map +1 -0
  64. package/dist/output_parsers.cjs +148 -173
  65. package/dist/output_parsers.cjs.map +1 -0
  66. package/dist/output_parsers.d.cts +53 -0
  67. package/dist/output_parsers.d.cts.map +1 -0
  68. package/dist/output_parsers.d.ts +46 -42
  69. package/dist/output_parsers.d.ts.map +1 -0
  70. package/dist/output_parsers.js +146 -168
  71. package/dist/output_parsers.js.map +1 -0
  72. package/dist/profiles.cjs +219 -0
  73. package/dist/profiles.cjs.map +1 -0
  74. package/dist/profiles.js +218 -0
  75. package/dist/profiles.js.map +1 -0
  76. package/dist/types-anthropic.d.cts +229 -0
  77. package/dist/types-anthropic.d.cts.map +1 -0
  78. package/dist/types-anthropic.d.ts +221 -215
  79. package/dist/types-anthropic.d.ts.map +1 -0
  80. package/dist/types.cjs +51 -62
  81. package/dist/types.cjs.map +1 -0
  82. package/dist/types.d.cts +748 -0
  83. package/dist/types.d.cts.map +1 -0
  84. package/dist/types.d.ts +669 -656
  85. package/dist/types.d.ts.map +1 -0
  86. package/dist/types.js +46 -45
  87. package/dist/types.js.map +1 -0
  88. package/dist/utils/anthropic.cjs +598 -821
  89. package/dist/utils/anthropic.cjs.map +1 -0
  90. package/dist/utils/anthropic.js +597 -818
  91. package/dist/utils/anthropic.js.map +1 -0
  92. package/dist/utils/common.cjs +130 -211
  93. package/dist/utils/common.cjs.map +1 -0
  94. package/dist/utils/common.d.cts +13 -0
  95. package/dist/utils/common.d.cts.map +1 -0
  96. package/dist/utils/common.d.ts +12 -7
  97. package/dist/utils/common.d.ts.map +1 -0
  98. package/dist/utils/common.js +128 -207
  99. package/dist/utils/common.js.map +1 -0
  100. package/dist/utils/failed_handler.cjs +28 -30
  101. package/dist/utils/failed_handler.cjs.map +1 -0
  102. package/dist/utils/failed_handler.d.cts +9 -0
  103. package/dist/utils/failed_handler.d.cts.map +1 -0
  104. package/dist/utils/failed_handler.d.ts +8 -2
  105. package/dist/utils/failed_handler.d.ts.map +1 -0
  106. package/dist/utils/failed_handler.js +28 -28
  107. package/dist/utils/failed_handler.js.map +1 -0
  108. package/dist/utils/gemini.cjs +1020 -1488
  109. package/dist/utils/gemini.cjs.map +1 -0
  110. package/dist/utils/gemini.d.cts +51 -0
  111. package/dist/utils/gemini.d.cts.map +1 -0
  112. package/dist/utils/gemini.d.ts +51 -48
  113. package/dist/utils/gemini.d.ts.map +1 -0
  114. package/dist/utils/gemini.js +1015 -1479
  115. package/dist/utils/gemini.js.map +1 -0
  116. package/dist/utils/index.cjs +38 -23
  117. package/dist/utils/index.d.cts +8 -0
  118. package/dist/utils/index.d.ts +8 -7
  119. package/dist/utils/index.js +8 -7
  120. package/dist/utils/palm.d.cts +11 -0
  121. package/dist/utils/palm.d.cts.map +1 -0
  122. package/dist/utils/palm.d.ts +9 -4
  123. package/dist/utils/palm.d.ts.map +1 -0
  124. package/dist/utils/safety.cjs +13 -22
  125. package/dist/utils/safety.cjs.map +1 -0
  126. package/dist/utils/safety.d.cts +12 -0
  127. package/dist/utils/safety.d.cts.map +1 -0
  128. package/dist/utils/safety.d.ts +10 -4
  129. package/dist/utils/safety.d.ts.map +1 -0
  130. package/dist/utils/safety.js +13 -19
  131. package/dist/utils/safety.js.map +1 -0
  132. package/dist/utils/stream.cjs +296 -475
  133. package/dist/utils/stream.cjs.map +1 -0
  134. package/dist/utils/stream.d.cts +165 -0
  135. package/dist/utils/stream.d.cts.map +1 -0
  136. package/dist/utils/stream.d.ts +156 -131
  137. package/dist/utils/stream.d.ts.map +1 -0
  138. package/dist/utils/stream.js +293 -469
  139. package/dist/utils/stream.js.map +1 -0
  140. package/dist/utils/zod_to_gemini_parameters.cjs +43 -81
  141. package/dist/utils/zod_to_gemini_parameters.cjs.map +1 -0
  142. package/dist/utils/zod_to_gemini_parameters.d.cts +22 -0
  143. package/dist/utils/zod_to_gemini_parameters.d.cts.map +1 -0
  144. package/dist/utils/zod_to_gemini_parameters.d.ts +21 -6
  145. package/dist/utils/zod_to_gemini_parameters.d.ts.map +1 -0
  146. package/dist/utils/zod_to_gemini_parameters.js +40 -76
  147. package/dist/utils/zod_to_gemini_parameters.js.map +1 -0
  148. package/package.json +72 -85
  149. package/dist/types-anthropic.cjs +0 -2
  150. package/dist/types-anthropic.js +0 -1
  151. package/dist/utils/anthropic.d.ts +0 -4
  152. package/dist/utils/palm.cjs +0 -2
  153. package/dist/utils/palm.js +0 -1
  154. package/experimental/media.cjs +0 -1
  155. package/experimental/media.d.cts +0 -1
  156. package/experimental/media.d.ts +0 -1
  157. package/experimental/media.js +0 -1
  158. package/experimental/utils/media_core.cjs +0 -1
  159. package/experimental/utils/media_core.d.cts +0 -1
  160. package/experimental/utils/media_core.d.ts +0 -1
  161. package/experimental/utils/media_core.js +0 -1
  162. package/index.cjs +0 -1
  163. package/index.d.cts +0 -1
  164. package/index.d.ts +0 -1
  165. package/index.js +0 -1
  166. package/types.cjs +0 -1
  167. package/types.d.cts +0 -1
  168. package/types.d.ts +0 -1
  169. package/types.js +0 -1
  170. package/utils.cjs +0 -1
  171. package/utils.d.cts +0 -1
  172. package/utils.d.ts +0 -1
  173. package/utils.js +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat_models.cjs","names":["AbstractGoogleLLMConnection","fields: GoogleAIBaseLLMInput<AuthOptions> | undefined","caller: AsyncCaller","client: GoogleAbstractedClient","streaming: boolean","apiConfig: GeminiAPIConfig","geminiConfig: GeminiAPIConfig","getGeminiAPI","BaseChatModel","fields?: ChatGoogleBaseInput<AuthOptions>","ensureParams","copyAndValidateModelParamsInto","DefaultGeminiSafetyHandler","options: this[\"ParsedCallOptions\"]","apiKey: string","ApiKeyGoogleAuth","fields?: GoogleAIBaseLLMInput<AuthOptions>","fields: GoogleBaseLLMInput<AuthOptions>","tools: GoogleAIToolType[]","kwargs?: Partial<GoogleAIBaseLanguageModelCallOptions>","convertToGeminiTools","options?: this[\"ParsedCallOptions\"]","copyAIModelParams","messages: BaseMessage[]","runManager: CallbackManagerForLLMRun | undefined","finalChunk: ChatGenerationChunk | null","chunk","_messages: BaseMessage[]","runManager?: CallbackManagerForLLMRun","usageMetadata: UsageMetadata | undefined","ChatGenerationChunk","AIMessageChunk","PROFILES","outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>","config?: StructuredOutputMethodOptions<boolean>","schema: InteropZodType<RunOutput> | Record<string, any>","outputParser: BaseLLMOutputParser<RunOutput>","tools: GeminiTool[]","schemaToGeminiParameters","JsonOutputKeyToolsParser","geminiFunctionDefinition: GeminiFunctionDeclaration","parameters: GeminiJsonSchema","removeAdditionalProperties","RunnablePassthrough","input: any","config","RunnableSequence"],"sources":["../src/chat_models.ts"],"sourcesContent":["import { getEnvironmentVariable } from \"@langchain/core/utils/env\";\nimport { UsageMetadata, type BaseMessage } from \"@langchain/core/messages\";\nimport { CallbackManagerForLLMRun } from \"@langchain/core/callbacks/manager\";\n\nimport {\n BaseChatModel,\n LangSmithParams,\n type BaseChatModelParams,\n} from \"@langchain/core/language_models/chat_models\";\nimport { ChatGenerationChunk, ChatResult } from \"@langchain/core/outputs\";\nimport { AIMessageChunk } from \"@langchain/core/messages\";\nimport {\n BaseLanguageModelInput,\n StructuredOutputMethodOptions,\n} from \"@langchain/core/language_models/base\";\nimport { type ModelProfile } from \"@langchain/core/language_models/profile\";\nimport {\n Runnable,\n RunnablePassthrough,\n RunnableSequence,\n} from \"@langchain/core/runnables\";\nimport { JsonOutputKeyToolsParser } from \"@langchain/core/output_parsers/openai_tools\";\nimport { BaseLLMOutputParser } from \"@langchain/core/output_parsers\";\nimport { AsyncCaller } from \"@langchain/core/utils/async_caller\";\nimport { concat } from \"@langchain/core/utils/stream\";\nimport {\n InteropZodType,\n isInteropZodSchema,\n} from \"@langchain/core/utils/types\";\nimport {\n GoogleAIBaseLLMInput,\n GoogleAIModelParams,\n GoogleAISafetySetting,\n GoogleConnectionParams,\n GooglePlatformType,\n GeminiTool,\n GoogleAIBaseLanguageModelCallOptions,\n GoogleAIAPI,\n GoogleAIAPIParams,\n GoogleSearchToolSetting,\n GoogleSpeechConfig,\n GeminiJsonSchema,\n} from \"./types.js\";\nimport {\n convertToGeminiTools,\n copyAIModelParams,\n copyAndValidateModelParamsInto,\n} from \"./utils/common.js\";\nimport { AbstractGoogleLLMConnection } from \"./connection.js\";\nimport { DefaultGeminiSafetyHandler, getGeminiAPI } from \"./utils/gemini.js\";\nimport { ApiKeyGoogleAuth, GoogleAbstractedClient } from \"./auth.js\";\nimport { JsonStream } from \"./utils/stream.js\";\nimport { ensureParams } from \"./utils/failed_handler.js\";\nimport type {\n GoogleBaseLLMInput,\n GoogleAISafetyHandler,\n GoogleAISafetyParams,\n GeminiFunctionDeclaration,\n GeminiFunctionSchema,\n GoogleAIToolType,\n GeminiAPIConfig,\n GoogleAIModelModality,\n} from \"./types.js\";\nimport {\n removeAdditionalProperties,\n schemaToGeminiParameters,\n} from \"./utils/zod_to_gemini_parameters.js\";\nimport PROFILES from \"./profiles.js\";\n\nexport class ChatConnection<AuthOptions> extends AbstractGoogleLLMConnection<\n BaseMessage[],\n AuthOptions\n> {\n convertSystemMessageToHumanContent: boolean | undefined;\n\n constructor(\n fields: GoogleAIBaseLLMInput<AuthOptions> | undefined,\n caller: AsyncCaller,\n client: GoogleAbstractedClient,\n streaming: boolean\n ) {\n super(fields, caller, client, streaming);\n this.convertSystemMessageToHumanContent =\n fields?.convertSystemMessageToHumanContent;\n }\n\n get useSystemInstruction(): boolean {\n return typeof this.convertSystemMessageToHumanContent === \"boolean\"\n ? !this.convertSystemMessageToHumanContent\n : this.computeUseSystemInstruction;\n }\n\n get computeUseSystemInstruction(): boolean {\n // This works on models from April 2024 and later\n // Vertex AI: gemini-1.5-pro and gemini-1.0-002 and later\n // AI Studio: gemini-1.5-pro-latest\n if (this.modelFamily === \"palm\") {\n return false;\n } else if (this.modelName === \"gemini-1.0-pro-001\") {\n return false;\n } else if (this.modelName.startsWith(\"gemini-pro-vision\")) {\n return false;\n } else if (this.modelName.startsWith(\"gemini-1.0-pro-vision\")) {\n return false;\n } else if (this.modelName === \"gemini-pro\" && this.platform === \"gai\") {\n // on AI Studio gemini-pro is still pointing at gemini-1.0-pro-001\n return false;\n } else if (this.modelFamily === \"gemma\") {\n // At least as of 12 Mar 2025 gemma 3 on AIS, trying to use system instructions yields an error:\n // \"Developer instruction is not enabled for models/gemma-3-27b-it\"\n return false;\n }\n return true;\n }\n\n computeGoogleSearchToolAdjustmentFromModel(): Exclude<\n GoogleSearchToolSetting,\n boolean\n > {\n if (this.modelName.startsWith(\"gemini-1.0\")) {\n return \"googleSearchRetrieval\";\n } else if (this.modelName.startsWith(\"gemini-1.5\")) {\n return \"googleSearchRetrieval\";\n } else {\n return \"googleSearch\";\n }\n }\n\n computeGoogleSearchToolAdjustment(\n apiConfig: GeminiAPIConfig\n ): Exclude<GoogleSearchToolSetting, true> {\n const adj = apiConfig.googleSearchToolAdjustment;\n if (adj === undefined || adj === true) {\n return this.computeGoogleSearchToolAdjustmentFromModel();\n } else {\n return adj;\n }\n }\n\n buildGeminiAPI(): GoogleAIAPI {\n const apiConfig: GeminiAPIConfig =\n (this.apiConfig as GeminiAPIConfig) ?? {};\n const googleSearchToolAdjustment =\n this.computeGoogleSearchToolAdjustment(apiConfig);\n const geminiConfig: GeminiAPIConfig = {\n useSystemInstruction: this.useSystemInstruction,\n googleSearchToolAdjustment,\n ...apiConfig,\n };\n return getGeminiAPI(geminiConfig);\n }\n\n get api(): GoogleAIAPI {\n switch (this.apiName) {\n case \"google\":\n return this.buildGeminiAPI();\n default:\n return super.api;\n }\n }\n}\n\n/**\n * Input to chat model class.\n */\nexport interface ChatGoogleBaseInput<AuthOptions>\n extends BaseChatModelParams,\n GoogleConnectionParams<AuthOptions>,\n GoogleAIModelParams,\n GoogleAISafetyParams,\n GoogleAIAPIParams,\n Pick<GoogleAIBaseLanguageModelCallOptions, \"streamUsage\"> {}\n\n/**\n * Integration with a Google chat model.\n */\nexport abstract class ChatGoogleBase<AuthOptions>\n extends BaseChatModel<GoogleAIBaseLanguageModelCallOptions, AIMessageChunk>\n implements ChatGoogleBaseInput<AuthOptions>\n{\n // Used for tracing, replace with the same name as your class\n static lc_name() {\n return \"ChatGoogle\";\n }\n\n get lc_secrets(): { [key: string]: string } | undefined {\n return {\n authOptions: \"GOOGLE_AUTH_OPTIONS\",\n };\n }\n\n lc_serializable = true;\n\n // Set based on modelName\n model: string;\n\n modelName = \"gemini-pro\";\n\n temperature: number;\n\n maxOutputTokens: number;\n\n maxReasoningTokens: number;\n\n topP: number;\n\n topK: number;\n\n seed: number;\n\n presencePenalty: number;\n\n frequencyPenalty: number;\n\n stopSequences: string[] = [];\n\n logprobs: boolean;\n\n topLogprobs: number = 0;\n\n safetySettings: GoogleAISafetySetting[] = [];\n\n responseModalities?: GoogleAIModelModality[];\n\n // May intentionally be undefined, meaning to compute this.\n convertSystemMessageToHumanContent: boolean | undefined;\n\n safetyHandler: GoogleAISafetyHandler;\n\n speechConfig: GoogleSpeechConfig;\n\n streamUsage = true;\n\n streaming = false;\n\n labels?: Record<string, string>;\n\n protected connection: ChatConnection<AuthOptions>;\n\n protected streamedConnection: ChatConnection<AuthOptions>;\n\n constructor(fields?: ChatGoogleBaseInput<AuthOptions>) {\n super(ensureParams(fields));\n\n copyAndValidateModelParamsInto(fields, this);\n this.safetyHandler =\n fields?.safetyHandler ?? new DefaultGeminiSafetyHandler();\n this.streamUsage = fields?.streamUsage ?? this.streamUsage;\n const client = this.buildClient(fields);\n this.buildConnection(fields ?? {}, client);\n }\n\n getLsParams(options: this[\"ParsedCallOptions\"]): LangSmithParams {\n const params = this.invocationParams(options);\n return {\n ls_provider: \"google_vertexai\",\n ls_model_name: this.model,\n ls_model_type: \"chat\",\n ls_temperature: params.temperature ?? undefined,\n ls_max_tokens: params.maxOutputTokens ?? undefined,\n ls_stop: options.stop,\n };\n }\n\n abstract buildAbstractedClient(\n fields?: GoogleAIBaseLLMInput<AuthOptions>\n ): GoogleAbstractedClient;\n\n buildApiKeyClient(apiKey: string): GoogleAbstractedClient {\n return new ApiKeyGoogleAuth(apiKey);\n }\n\n buildApiKey(fields?: GoogleAIBaseLLMInput<AuthOptions>): string | undefined {\n return fields?.apiKey ?? getEnvironmentVariable(\"GOOGLE_API_KEY\");\n }\n\n buildClient(\n fields?: GoogleAIBaseLLMInput<AuthOptions>\n ): GoogleAbstractedClient {\n const apiKey = this.buildApiKey(fields);\n if (apiKey) {\n return this.buildApiKeyClient(apiKey);\n } else {\n return this.buildAbstractedClient(fields);\n }\n }\n\n buildConnection(\n fields: GoogleBaseLLMInput<AuthOptions>,\n client: GoogleAbstractedClient\n ) {\n this.connection = new ChatConnection(\n { ...fields, ...this },\n this.caller,\n client,\n false\n );\n\n this.streamedConnection = new ChatConnection(\n { ...fields, ...this },\n this.caller,\n client,\n true\n );\n }\n\n get platform(): GooglePlatformType {\n return this.connection.platform;\n }\n\n override bindTools(\n tools: GoogleAIToolType[],\n kwargs?: Partial<GoogleAIBaseLanguageModelCallOptions>\n ): Runnable<\n BaseLanguageModelInput,\n AIMessageChunk,\n GoogleAIBaseLanguageModelCallOptions\n > {\n return this.withConfig({ tools: convertToGeminiTools(tools), ...kwargs });\n }\n\n // Replace\n _llmType() {\n return \"chat_integration\";\n }\n\n /**\n * Get the parameters used to invoke the model\n */\n override invocationParams(options?: this[\"ParsedCallOptions\"]) {\n return copyAIModelParams(this, options);\n }\n\n async _generate(\n messages: BaseMessage[],\n options: this[\"ParsedCallOptions\"],\n runManager: CallbackManagerForLLMRun | undefined\n ): Promise<ChatResult> {\n const parameters = this.invocationParams(options);\n if (this.streaming) {\n const stream = this._streamResponseChunks(messages, options, runManager);\n let finalChunk: ChatGenerationChunk | null = null;\n for await (const chunk of stream) {\n finalChunk = !finalChunk ? chunk : concat(finalChunk, chunk);\n }\n if (!finalChunk) {\n throw new Error(\"No chunks were returned from the stream.\");\n }\n return {\n generations: [finalChunk],\n };\n }\n\n const response = await this.connection.request(\n messages,\n parameters,\n options,\n runManager\n );\n const ret = this.connection.api.responseToChatResult(response);\n const chunk = ret?.generations?.[0];\n if (chunk) {\n await runManager?.handleLLMNewToken(chunk.text || \"\");\n }\n return ret;\n }\n\n async *_streamResponseChunks(\n _messages: BaseMessage[],\n options: this[\"ParsedCallOptions\"],\n runManager?: CallbackManagerForLLMRun\n ): AsyncGenerator<ChatGenerationChunk> {\n // Make the call as a streaming request\n const parameters = this.invocationParams(options);\n const response = await this.streamedConnection.request(\n _messages,\n parameters,\n options,\n runManager\n );\n\n // Get the streaming parser of the response\n const stream = response.data as JsonStream;\n let usageMetadata: UsageMetadata | undefined;\n // Loop until the end of the stream\n // During the loop, yield each time we get a chunk from the streaming parser\n // that is either available or added to the queue\n while (!stream.streamDone) {\n const output = await stream.nextChunk();\n await runManager?.handleCustomEvent(\n `google-chunk-${this.constructor.name}`,\n {\n output,\n }\n );\n if (\n output &&\n output.usageMetadata &&\n this.streamUsage !== false &&\n options.streamUsage !== false\n ) {\n usageMetadata = {\n input_tokens: output.usageMetadata.promptTokenCount,\n output_tokens: output.usageMetadata.candidatesTokenCount,\n total_tokens: output.usageMetadata.totalTokenCount,\n };\n }\n const chunk =\n output !== null\n ? this.connection.api.responseToChatGeneration({ data: output })\n : new ChatGenerationChunk({\n text: \"\",\n generationInfo: { finishReason: \"stop\" },\n message: new AIMessageChunk({\n content: \"\",\n usage_metadata: usageMetadata,\n }),\n });\n if (chunk) {\n yield chunk;\n await runManager?.handleLLMNewToken(\n chunk.text ?? \"\",\n undefined,\n undefined,\n undefined,\n undefined,\n { chunk }\n );\n }\n }\n }\n\n /** @ignore */\n _combineLLMOutput() {\n return [];\n }\n\n /**\n * Return profiling information for the model.\n *\n * Provides information about the model's capabilities and constraints,\n * including token limits, multimodal support, and advanced features like\n * tool calling and structured output.\n *\n * @returns {ModelProfile} An object describing the model's capabilities and constraints\n */\n get profile(): ModelProfile {\n return PROFILES[this.model] ?? {};\n }\n\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<false>\n ): Runnable<BaseLanguageModelInput, RunOutput>;\n\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<true>\n ): Runnable<BaseLanguageModelInput, { raw: BaseMessage; parsed: RunOutput }>;\n\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<boolean>\n ):\n | Runnable<BaseLanguageModelInput, RunOutput>\n | Runnable<\n BaseLanguageModelInput,\n { raw: BaseMessage; parsed: RunOutput }\n > {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const schema: InteropZodType<RunOutput> | Record<string, any> =\n outputSchema;\n const name = config?.name;\n const method = config?.method;\n const includeRaw = config?.includeRaw;\n if (method === \"jsonMode\") {\n throw new Error(`Google only supports \"functionCalling\" as a method.`);\n }\n\n let functionName = name ?? \"extract\";\n let outputParser: BaseLLMOutputParser<RunOutput>;\n let tools: GeminiTool[];\n if (isInteropZodSchema(schema)) {\n const jsonSchema = schemaToGeminiParameters(schema);\n tools = [\n {\n functionDeclarations: [\n {\n name: functionName,\n description:\n jsonSchema.description ?? \"A function available to call.\",\n parameters: jsonSchema as GeminiFunctionSchema,\n },\n ],\n },\n ];\n outputParser = new JsonOutputKeyToolsParser({\n returnSingle: true,\n keyName: functionName,\n zodSchema: schema,\n });\n } else {\n let geminiFunctionDefinition: GeminiFunctionDeclaration;\n if (\n typeof schema.name === \"string\" &&\n typeof schema.parameters === \"object\" &&\n schema.parameters != null\n ) {\n geminiFunctionDefinition = schema as GeminiFunctionDeclaration;\n functionName = schema.name;\n } else {\n // We are providing the schema for *just* the parameters, probably\n const parameters: GeminiJsonSchema = removeAdditionalProperties(schema);\n geminiFunctionDefinition = {\n name: functionName,\n description: schema.description ?? \"\",\n parameters,\n };\n }\n tools = [\n {\n functionDeclarations: [geminiFunctionDefinition],\n },\n ];\n outputParser = new JsonOutputKeyToolsParser<RunOutput>({\n returnSingle: true,\n keyName: functionName,\n });\n }\n const llm = this.bindTools(tools).withConfig({ tool_choice: functionName });\n\n if (!includeRaw) {\n return llm.pipe(outputParser).withConfig({\n runName: \"ChatGoogleStructuredOutput\",\n }) as Runnable<BaseLanguageModelInput, RunOutput>;\n }\n\n const parserAssign = RunnablePassthrough.assign({\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n parsed: (input: any, config) => outputParser.invoke(input.raw, config),\n });\n const parserNone = RunnablePassthrough.assign({\n parsed: () => null,\n });\n const parsedWithFallback = parserAssign.withFallbacks({\n fallbacks: [parserNone],\n });\n return RunnableSequence.from<\n BaseLanguageModelInput,\n { raw: BaseMessage; parsed: RunOutput }\n >([\n {\n raw: llm,\n },\n parsedWithFallback,\n ]).withConfig({\n runName: \"StructuredOutputRunnable\",\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqEA,IAAa,iBAAb,cAAiDA,+CAG/C;CACA;CAEA,YACEC,QACAC,QACAC,QACAC,WACA;EACA,MAAM,QAAQ,QAAQ,QAAQ,UAAU;EACxC,KAAK,qCACH,QAAQ;CACX;CAED,IAAI,uBAAgC;AAClC,SAAO,OAAO,KAAK,uCAAuC,YACtD,CAAC,KAAK,qCACN,KAAK;CACV;CAED,IAAI,8BAAuC;AAIzC,MAAI,KAAK,gBAAgB,OACvB,QAAO;WACE,KAAK,cAAc,qBAC5B,QAAO;WACE,KAAK,UAAU,WAAW,oBAAoB,CACvD,QAAO;WACE,KAAK,UAAU,WAAW,wBAAwB,CAC3D,QAAO;WACE,KAAK,cAAc,gBAAgB,KAAK,aAAa,MAE9D,QAAO;WACE,KAAK,gBAAgB,QAG9B,QAAO;AAET,SAAO;CACR;CAED,6CAGE;AACA,MAAI,KAAK,UAAU,WAAW,aAAa,CACzC,QAAO;WACE,KAAK,UAAU,WAAW,aAAa,CAChD,QAAO;MAEP,QAAO;CAEV;CAED,kCACEC,WACwC;EACxC,MAAM,MAAM,UAAU;AACtB,MAAI,QAAQ,UAAa,QAAQ,KAC/B,QAAO,KAAK,4CAA4C;MAExD,QAAO;CAEV;CAED,iBAA8B;EAC5B,MAAMA,YACH,KAAK,aAAiC,CAAE;EAC3C,MAAM,6BACJ,KAAK,kCAAkC,UAAU;EACnD,MAAMC,eAAgC;GACpC,sBAAsB,KAAK;GAC3B;GACA,GAAG;EACJ;AACD,SAAOC,4BAAa,aAAa;CAClC;CAED,IAAI,MAAmB;AACrB,UAAQ,KAAK,SAAb;GACE,KAAK,SACH,QAAO,KA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vE,2BAA2B;KACzB,MAAM;KACN,aAAa,OAAO,eAAe;KACnC;IACD;GACF;GACD,QAAQ,CACN,EACE,sBAAsB,CAAC,wBAAyB,EACjD,CACF;GACD,eAAe,IAAIH,sEAAoC;IACrD,cAAc;IACd,SAAS;GACV;EACF;EACD,MAAM,MAAM,KAAK,UAAU,MAAM,CAAC,WAAW,EAAE,aAAa,aAAc,EAAC;AAE3E,MAAI,CAAC,WACH,QAAO,IAAI,KAAK,aAAa,CAAC,WAAW,EACvC,SAAS,6BACV,EAAC;EAGJ,MAAM,eAAeI,+CAAoB,OAAO,EAE9C,QAAQ,CAACC,OAAYC,aAAW,aAAa,OAAO,MAAM,KAAKA,SAAO,CACvE,EAAC;EACF,MAAM,aAAaF,+CAAoB,OAAO,EAC5C,QAAQ,MAAM,KACf,EAAC;EACF,MAAM,qBAAqB,aAAa,cAAc,EACpD,WAAW,CAAC,UAAW,EACxB,EAAC;AACF,SAAOG,4CAAiB,KAGtB,CACA,EACE,KAAK,IACN,GACD,kBACD,EAAC,CAAC,WAAW,EACZ,SAAS,2BACV,EAAC;CACH;AACF"}
@@ -0,0 +1,109 @@
1
+ import { GeminiAPIConfig, GoogleAIAPI, GoogleAIAPIParams, GoogleAIBaseLLMInput, GoogleAIBaseLanguageModelCallOptions, GoogleAIModelModality, GoogleAIModelParams, GoogleAIModelRequestParams, GoogleAISafetyHandler, GoogleAISafetyParams, GoogleAISafetySetting, GoogleAIToolType, GoogleBaseLLMInput, GoogleConnectionParams, GooglePlatformType, GoogleSearchToolSetting, GoogleSpeechConfig } from "./types.cjs";
2
+ import { GoogleAbstractedClient } from "./auth.cjs";
3
+ import { AbstractGoogleLLMConnection } from "./connection.cjs";
4
+ import { AsyncCaller } from "@langchain/core/utils/async_caller";
5
+ import { BaseChatModel, BaseChatModelParams, LangSmithParams } from "@langchain/core/language_models/chat_models";
6
+ import { AIMessageChunk, BaseMessage } from "@langchain/core/messages";
7
+ import { ChatGenerationChunk, ChatResult } from "@langchain/core/outputs";
8
+ import { BaseLanguageModelInput, StructuredOutputMethodOptions } from "@langchain/core/language_models/base";
9
+ import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager";
10
+ import { ModelProfile } from "@langchain/core/language_models/profile";
11
+ import { Runnable } from "@langchain/core/runnables";
12
+ import { InteropZodType } from "@langchain/core/utils/types";
13
+
14
+ //#region src/chat_models.d.ts
15
+ declare class ChatConnection<AuthOptions> extends AbstractGoogleLLMConnection<BaseMessage[], AuthOptions> {
16
+ convertSystemMessageToHumanContent: boolean | undefined;
17
+ constructor(fields: GoogleAIBaseLLMInput<AuthOptions> | undefined, caller: AsyncCaller, client: GoogleAbstractedClient, streaming: boolean);
18
+ get useSystemInstruction(): boolean;
19
+ get computeUseSystemInstruction(): boolean;
20
+ computeGoogleSearchToolAdjustmentFromModel(): Exclude<GoogleSearchToolSetting, boolean>;
21
+ computeGoogleSearchToolAdjustment(apiConfig: GeminiAPIConfig): Exclude<GoogleSearchToolSetting, true>;
22
+ buildGeminiAPI(): GoogleAIAPI;
23
+ get api(): GoogleAIAPI;
24
+ }
25
+ /**
26
+ * Input to chat model class.
27
+ */
28
+ interface ChatGoogleBaseInput<AuthOptions> extends BaseChatModelParams, GoogleConnectionParams<AuthOptions>, GoogleAIModelParams, GoogleAISafetyParams, GoogleAIAPIParams, Pick<GoogleAIBaseLanguageModelCallOptions, "streamUsage"> {}
29
+ /**
30
+ * Integration with a Google chat model.
31
+ */
32
+ declare abstract class ChatGoogleBase<AuthOptions> extends BaseChatModel<GoogleAIBaseLanguageModelCallOptions, AIMessageChunk> implements ChatGoogleBaseInput<AuthOptions> {
33
+ // Used for tracing, replace with the same name as your class
34
+ static lc_name(): string;
35
+ get lc_secrets(): {
36
+ [key: string]: string;
37
+ } | undefined;
38
+ lc_serializable: boolean;
39
+ // Set based on modelName
40
+ model: string;
41
+ modelName: string;
42
+ temperature: number;
43
+ maxOutputTokens: number;
44
+ maxReasoningTokens: number;
45
+ topP: number;
46
+ topK: number;
47
+ seed: number;
48
+ presencePenalty: number;
49
+ frequencyPenalty: number;
50
+ stopSequences: string[];
51
+ logprobs: boolean;
52
+ topLogprobs: number;
53
+ safetySettings: GoogleAISafetySetting[];
54
+ responseModalities?: GoogleAIModelModality[];
55
+ // May intentionally be undefined, meaning to compute this.
56
+ convertSystemMessageToHumanContent: boolean | undefined;
57
+ safetyHandler: GoogleAISafetyHandler;
58
+ speechConfig: GoogleSpeechConfig;
59
+ streamUsage: boolean;
60
+ streaming: boolean;
61
+ labels?: Record<string, string>;
62
+ protected connection: ChatConnection<AuthOptions>;
63
+ protected streamedConnection: ChatConnection<AuthOptions>;
64
+ constructor(fields?: ChatGoogleBaseInput<AuthOptions>);
65
+ getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
66
+ abstract buildAbstractedClient(fields?: GoogleAIBaseLLMInput<AuthOptions>): GoogleAbstractedClient;
67
+ buildApiKeyClient(apiKey: string): GoogleAbstractedClient;
68
+ buildApiKey(fields?: GoogleAIBaseLLMInput<AuthOptions>): string | undefined;
69
+ buildClient(fields?: GoogleAIBaseLLMInput<AuthOptions>): GoogleAbstractedClient;
70
+ buildConnection(fields: GoogleBaseLLMInput<AuthOptions>, client: GoogleAbstractedClient): void;
71
+ get platform(): GooglePlatformType;
72
+ bindTools(tools: GoogleAIToolType[], kwargs?: Partial<GoogleAIBaseLanguageModelCallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, GoogleAIBaseLanguageModelCallOptions>;
73
+ // Replace
74
+ _llmType(): string;
75
+ /**
76
+ * Get the parameters used to invoke the model
77
+ */
78
+ invocationParams(options?: this["ParsedCallOptions"]): GoogleAIModelRequestParams;
79
+ _generate(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager: CallbackManagerForLLMRun | undefined): Promise<ChatResult>;
80
+ _streamResponseChunks(_messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
81
+ /** @ignore */
82
+ _combineLLMOutput(): never[];
83
+ /**
84
+ * Return profiling information for the model.
85
+ *
86
+ * Provides information about the model's capabilities and constraints,
87
+ * including token limits, multimodal support, and advanced features like
88
+ * tool calling and structured output.
89
+ *
90
+ * @returns {ModelProfile} An object describing the model's capabilities and constraints
91
+ */
92
+ get profile(): ModelProfile;
93
+ withStructuredOutput<
94
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
95
+ RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>
96
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
97
+ | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
98
+ withStructuredOutput<
99
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
100
+ RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>
101
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
102
+ | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
103
+ raw: BaseMessage;
104
+ parsed: RunOutput;
105
+ }>;
106
+ }
107
+ //#endregion
108
+ export { ChatConnection, ChatGoogleBase, ChatGoogleBaseInput };
109
+ //# sourceMappingURL=chat_models.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat_models.d.cts","names":["BaseMessage","CallbackManagerForLLMRun","BaseChatModel","LangSmithParams","BaseChatModelParams","ChatGenerationChunk","ChatResult","AIMessageChunk","BaseLanguageModelInput","StructuredOutputMethodOptions","ModelProfile","Runnable","AsyncCaller","InteropZodType","GoogleAIBaseLLMInput","GoogleAIModelParams","GoogleAISafetySetting","GoogleConnectionParams","GooglePlatformType","GoogleAIBaseLanguageModelCallOptions","GoogleAIAPI","GoogleAIAPIParams","GoogleSearchToolSetting","GoogleSpeechConfig","AbstractGoogleLLMConnection","GoogleAbstractedClient","GoogleBaseLLMInput","GoogleAISafetyHandler","GoogleAISafetyParams","GoogleAIToolType","GeminiAPIConfig","GoogleAIModelModality","ChatConnection","AuthOptions","Exclude","ChatGoogleBaseInput","Pick","ChatGoogleBase","Record","Partial","__types_js0","GoogleAIModelRequestParams","Promise","AsyncGenerator","RunOutput"],"sources":["../src/chat_models.d.ts"],"sourcesContent":["import { type BaseMessage } from \"@langchain/core/messages\";\nimport { CallbackManagerForLLMRun } from \"@langchain/core/callbacks/manager\";\nimport { BaseChatModel, LangSmithParams, type BaseChatModelParams } from \"@langchain/core/language_models/chat_models\";\nimport { ChatGenerationChunk, ChatResult } from \"@langchain/core/outputs\";\nimport { AIMessageChunk } from \"@langchain/core/messages\";\nimport { BaseLanguageModelInput, StructuredOutputMethodOptions } from \"@langchain/core/language_models/base\";\nimport { type ModelProfile } from \"@langchain/core/language_models/profile\";\nimport { Runnable } from \"@langchain/core/runnables\";\nimport { AsyncCaller } from \"@langchain/core/utils/async_caller\";\nimport { InteropZodType } from \"@langchain/core/utils/types\";\nimport { GoogleAIBaseLLMInput, GoogleAIModelParams, GoogleAISafetySetting, GoogleConnectionParams, GooglePlatformType, GoogleAIBaseLanguageModelCallOptions, GoogleAIAPI, GoogleAIAPIParams, GoogleSearchToolSetting, GoogleSpeechConfig } from \"./types.js\";\nimport { AbstractGoogleLLMConnection } from \"./connection.js\";\nimport { GoogleAbstractedClient } from \"./auth.js\";\nimport type { GoogleBaseLLMInput, GoogleAISafetyHandler, GoogleAISafetyParams, GoogleAIToolType, GeminiAPIConfig, GoogleAIModelModality } from \"./types.js\";\nexport declare class ChatConnection<AuthOptions> extends AbstractGoogleLLMConnection<BaseMessage[], AuthOptions> {\n convertSystemMessageToHumanContent: boolean | undefined;\n constructor(fields: GoogleAIBaseLLMInput<AuthOptions> | undefined, caller: AsyncCaller, client: GoogleAbstractedClient, streaming: boolean);\n get useSystemInstruction(): boolean;\n get computeUseSystemInstruction(): boolean;\n computeGoogleSearchToolAdjustmentFromModel(): Exclude<GoogleSearchToolSetting, boolean>;\n computeGoogleSearchToolAdjustment(apiConfig: GeminiAPIConfig): Exclude<GoogleSearchToolSetting, true>;\n buildGeminiAPI(): GoogleAIAPI;\n get api(): GoogleAIAPI;\n}\n/**\n * Input to chat model class.\n */\nexport interface ChatGoogleBaseInput<AuthOptions> extends BaseChatModelParams, GoogleConnectionParams<AuthOptions>, GoogleAIModelParams, GoogleAISafetyParams, GoogleAIAPIParams, Pick<GoogleAIBaseLanguageModelCallOptions, \"streamUsage\"> {\n}\n/**\n * Integration with a Google chat model.\n */\nexport declare abstract class ChatGoogleBase<AuthOptions> extends BaseChatModel<GoogleAIBaseLanguageModelCallOptions, AIMessageChunk> implements ChatGoogleBaseInput<AuthOptions> {\n // Used for tracing, replace with the same name as your class\n static lc_name(): string;\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n lc_serializable: boolean;\n // Set based on modelName\n model: string;\n modelName: string;\n temperature: number;\n maxOutputTokens: number;\n maxReasoningTokens: number;\n topP: number;\n topK: number;\n seed: number;\n presencePenalty: number;\n frequencyPenalty: number;\n stopSequences: string[];\n logprobs: boolean;\n topLogprobs: number;\n safetySettings: GoogleAISafetySetting[];\n responseModalities?: GoogleAIModelModality[];\n // May intentionally be undefined, meaning to compute this.\n convertSystemMessageToHumanContent: boolean | undefined;\n safetyHandler: GoogleAISafetyHandler;\n speechConfig: GoogleSpeechConfig;\n streamUsage: boolean;\n streaming: boolean;\n labels?: Record<string, string>;\n protected connection: ChatConnection<AuthOptions>;\n protected streamedConnection: ChatConnection<AuthOptions>;\n constructor(fields?: ChatGoogleBaseInput<AuthOptions>);\n getLsParams(options: this[\"ParsedCallOptions\"]): LangSmithParams;\n abstract buildAbstractedClient(fields?: GoogleAIBaseLLMInput<AuthOptions>): GoogleAbstractedClient;\n buildApiKeyClient(apiKey: string): GoogleAbstractedClient;\n buildApiKey(fields?: GoogleAIBaseLLMInput<AuthOptions>): string | undefined;\n buildClient(fields?: GoogleAIBaseLLMInput<AuthOptions>): GoogleAbstractedClient;\n buildConnection(fields: GoogleBaseLLMInput<AuthOptions>, client: GoogleAbstractedClient): void;\n get platform(): GooglePlatformType;\n bindTools(tools: GoogleAIToolType[], kwargs?: Partial<GoogleAIBaseLanguageModelCallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, GoogleAIBaseLanguageModelCallOptions>;\n // Replace\n _llmType(): string;\n /**\n * Get the parameters used to invoke the model\n */\n invocationParams(options?: this[\"ParsedCallOptions\"]): import(\"./types.js\").GoogleAIModelRequestParams;\n _generate(messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager: CallbackManagerForLLMRun | undefined): Promise<ChatResult>;\n _streamResponseChunks(_messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;\n /** @ignore */\n _combineLLMOutput(): never[];\n /**\n * Return profiling information for the model.\n *\n * Provides information about the model's capabilities and constraints,\n * including token limits, multimodal support, and advanced features like\n * tool calling and structured output.\n *\n * @returns {ModelProfile} An object describing the model's capabilities and constraints\n */\n get profile(): ModelProfile;\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {\n raw: BaseMessage;\n parsed: RunOutput;\n }>;\n}\n"],"mappings":";;;;;;;;;;;;;;AAcqBgC,cAAAA,cAAc,CAAA,WAAA,CAAA,SAAsBR,2BAAtB,CAAkDxB,WAAlD,EAAA,EAAiEiC,WAAjE,CAAA,CAAA;EAAA,kCAAA,EAAA,OAAA,GAAA,SAAA;EAAA,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AFzC8B,MAEyC9B,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,CAAAA,CAAAA,YAAAA,EAFNK,cAEML,CAFSoC,SAETpC;EAAsB;EAAA,EAApG8B,MAAqE3B,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,EAAAA,MAAAA,CAAAA,EAAvCF,6BAAuCE,CAAAA,KAAAA,CAAAA,CAAAA,EAAAA,QAAAA,CAASH,sBAATG,EAAiCiC,SAAjCjC,CAAAA;EAAQ,oBAG9D2B;EAAM;EAAsB,kBAA5BA,MAAwEM,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,GAAlDN,MAAkDM,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,CAAAA,CAAAA,YAAAA,EAAf/B,cAAe+B,CAAAA,SAAAA;EAAS;EAAA,EAEhGN,MAAAA,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,EAAAA,MAAAA,CAAAA,EAA8B7B,6BAA9B6B,CAAAA,IAAAA,CAAAA,CAAAA,EAAoE3B,QAApE2B,CAA6E9B,sBAA7E8B,EAAAA;IAA8B7B,GAAAA,EACxBT,WADwBS;IAA+CD,MAAAA,EAEpEoC,SAFoEpC;EAAsB,CAAA,CAAA"}
@@ -1,84 +1,109 @@
1
- import { type BaseMessage } from "@langchain/core/messages";
2
- import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager";
3
- import { BaseChatModel, LangSmithParams, type BaseChatModelParams } from "@langchain/core/language_models/chat_models";
1
+ import { GeminiAPIConfig, GoogleAIAPI, GoogleAIAPIParams, GoogleAIBaseLLMInput, GoogleAIBaseLanguageModelCallOptions, GoogleAIModelModality, GoogleAIModelParams, GoogleAIModelRequestParams, GoogleAISafetyHandler, GoogleAISafetyParams, GoogleAISafetySetting, GoogleAIToolType, GoogleBaseLLMInput, GoogleConnectionParams, GooglePlatformType, GoogleSearchToolSetting, GoogleSpeechConfig } from "./types.js";
2
+ import { GoogleAbstractedClient } from "./auth.js";
3
+ import { AbstractGoogleLLMConnection } from "./connection.js";
4
+ import { BaseChatModel, BaseChatModelParams, LangSmithParams } from "@langchain/core/language_models/chat_models";
4
5
  import { ChatGenerationChunk, ChatResult } from "@langchain/core/outputs";
5
- import { AIMessageChunk } from "@langchain/core/messages";
6
- import { BaseLanguageModelInput, StructuredOutputMethodOptions } from "@langchain/core/language_models/base";
6
+ import { AIMessageChunk, BaseMessage } from "@langchain/core/messages";
7
7
  import { Runnable } from "@langchain/core/runnables";
8
- import { AsyncCaller } from "@langchain/core/utils/async_caller";
9
8
  import { InteropZodType } from "@langchain/core/utils/types";
10
- import { GoogleAIBaseLLMInput, GoogleAIModelParams, GoogleAISafetySetting, GoogleConnectionParams, GooglePlatformType, GoogleAIBaseLanguageModelCallOptions, GoogleAIAPI, GoogleAIAPIParams, GoogleSearchToolSetting, GoogleSpeechConfig } from "./types.js";
11
- import { AbstractGoogleLLMConnection } from "./connection.js";
12
- import { GoogleAbstractedClient } from "./auth.js";
13
- import type { GoogleBaseLLMInput, GoogleAISafetyHandler, GoogleAISafetyParams, GoogleAIToolType, GeminiAPIConfig, GoogleAIModelModality } from "./types.js";
14
- export declare class ChatConnection<AuthOptions> extends AbstractGoogleLLMConnection<BaseMessage[], AuthOptions> {
15
- convertSystemMessageToHumanContent: boolean | undefined;
16
- constructor(fields: GoogleAIBaseLLMInput<AuthOptions> | undefined, caller: AsyncCaller, client: GoogleAbstractedClient, streaming: boolean);
17
- get useSystemInstruction(): boolean;
18
- get computeUseSystemInstruction(): boolean;
19
- computeGoogleSearchToolAdjustmentFromModel(): Exclude<GoogleSearchToolSetting, boolean>;
20
- computeGoogleSearchToolAdjustment(apiConfig: GeminiAPIConfig): Exclude<GoogleSearchToolSetting, true>;
21
- buildGeminiAPI(): GoogleAIAPI;
22
- get api(): GoogleAIAPI;
9
+ import { BaseLanguageModelInput, StructuredOutputMethodOptions } from "@langchain/core/language_models/base";
10
+ import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager";
11
+ import { AsyncCaller } from "@langchain/core/utils/async_caller";
12
+ import { ModelProfile } from "@langchain/core/language_models/profile";
13
+
14
+ //#region src/chat_models.d.ts
15
+ declare class ChatConnection<AuthOptions> extends AbstractGoogleLLMConnection<BaseMessage[], AuthOptions> {
16
+ convertSystemMessageToHumanContent: boolean | undefined;
17
+ constructor(fields: GoogleAIBaseLLMInput<AuthOptions> | undefined, caller: AsyncCaller, client: GoogleAbstractedClient, streaming: boolean);
18
+ get useSystemInstruction(): boolean;
19
+ get computeUseSystemInstruction(): boolean;
20
+ computeGoogleSearchToolAdjustmentFromModel(): Exclude<GoogleSearchToolSetting, boolean>;
21
+ computeGoogleSearchToolAdjustment(apiConfig: GeminiAPIConfig): Exclude<GoogleSearchToolSetting, true>;
22
+ buildGeminiAPI(): GoogleAIAPI;
23
+ get api(): GoogleAIAPI;
23
24
  }
24
25
  /**
25
26
  * Input to chat model class.
26
27
  */
27
- export interface ChatGoogleBaseInput<AuthOptions> extends BaseChatModelParams, GoogleConnectionParams<AuthOptions>, GoogleAIModelParams, GoogleAISafetyParams, GoogleAIAPIParams, Pick<GoogleAIBaseLanguageModelCallOptions, "streamUsage"> {
28
- }
28
+ interface ChatGoogleBaseInput<AuthOptions> extends BaseChatModelParams, GoogleConnectionParams<AuthOptions>, GoogleAIModelParams, GoogleAISafetyParams, GoogleAIAPIParams, Pick<GoogleAIBaseLanguageModelCallOptions, "streamUsage"> {}
29
29
  /**
30
30
  * Integration with a Google chat model.
31
31
  */
32
- export declare abstract class ChatGoogleBase<AuthOptions> extends BaseChatModel<GoogleAIBaseLanguageModelCallOptions, AIMessageChunk> implements ChatGoogleBaseInput<AuthOptions> {
33
- static lc_name(): string;
34
- get lc_secrets(): {
35
- [key: string]: string;
36
- } | undefined;
37
- lc_serializable: boolean;
38
- model: string;
39
- modelName: string;
40
- temperature: number;
41
- maxOutputTokens: number;
42
- maxReasoningTokens: number;
43
- topP: number;
44
- topK: number;
45
- seed: number;
46
- presencePenalty: number;
47
- frequencyPenalty: number;
48
- stopSequences: string[];
49
- logprobs: boolean;
50
- topLogprobs: number;
51
- safetySettings: GoogleAISafetySetting[];
52
- responseModalities?: GoogleAIModelModality[];
53
- convertSystemMessageToHumanContent: boolean | undefined;
54
- safetyHandler: GoogleAISafetyHandler;
55
- speechConfig: GoogleSpeechConfig;
56
- streamUsage: boolean;
57
- streaming: boolean;
58
- labels?: Record<string, string>;
59
- protected connection: ChatConnection<AuthOptions>;
60
- protected streamedConnection: ChatConnection<AuthOptions>;
61
- constructor(fields?: ChatGoogleBaseInput<AuthOptions>);
62
- getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
63
- abstract buildAbstractedClient(fields?: GoogleAIBaseLLMInput<AuthOptions>): GoogleAbstractedClient;
64
- buildApiKeyClient(apiKey: string): GoogleAbstractedClient;
65
- buildApiKey(fields?: GoogleAIBaseLLMInput<AuthOptions>): string | undefined;
66
- buildClient(fields?: GoogleAIBaseLLMInput<AuthOptions>): GoogleAbstractedClient;
67
- buildConnection(fields: GoogleBaseLLMInput<AuthOptions>, client: GoogleAbstractedClient): void;
68
- get platform(): GooglePlatformType;
69
- bindTools(tools: GoogleAIToolType[], kwargs?: Partial<GoogleAIBaseLanguageModelCallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, GoogleAIBaseLanguageModelCallOptions>;
70
- _llmType(): string;
71
- /**
72
- * Get the parameters used to invoke the model
73
- */
74
- invocationParams(options?: this["ParsedCallOptions"]): import("./types.js").GoogleAIModelRequestParams;
75
- _generate(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager: CallbackManagerForLLMRun | undefined): Promise<ChatResult>;
76
- _streamResponseChunks(_messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
77
- /** @ignore */
78
- _combineLLMOutput(): never[];
79
- withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
80
- withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
81
- raw: BaseMessage;
82
- parsed: RunOutput;
83
- }>;
32
+ declare abstract class ChatGoogleBase<AuthOptions> extends BaseChatModel<GoogleAIBaseLanguageModelCallOptions, AIMessageChunk> implements ChatGoogleBaseInput<AuthOptions> {
33
+ // Used for tracing, replace with the same name as your class
34
+ static lc_name(): string;
35
+ get lc_secrets(): {
36
+ [key: string]: string;
37
+ } | undefined;
38
+ lc_serializable: boolean;
39
+ // Set based on modelName
40
+ model: string;
41
+ modelName: string;
42
+ temperature: number;
43
+ maxOutputTokens: number;
44
+ maxReasoningTokens: number;
45
+ topP: number;
46
+ topK: number;
47
+ seed: number;
48
+ presencePenalty: number;
49
+ frequencyPenalty: number;
50
+ stopSequences: string[];
51
+ logprobs: boolean;
52
+ topLogprobs: number;
53
+ safetySettings: GoogleAISafetySetting[];
54
+ responseModalities?: GoogleAIModelModality[];
55
+ // May intentionally be undefined, meaning to compute this.
56
+ convertSystemMessageToHumanContent: boolean | undefined;
57
+ safetyHandler: GoogleAISafetyHandler;
58
+ speechConfig: GoogleSpeechConfig;
59
+ streamUsage: boolean;
60
+ streaming: boolean;
61
+ labels?: Record<string, string>;
62
+ protected connection: ChatConnection<AuthOptions>;
63
+ protected streamedConnection: ChatConnection<AuthOptions>;
64
+ constructor(fields?: ChatGoogleBaseInput<AuthOptions>);
65
+ getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
66
+ abstract buildAbstractedClient(fields?: GoogleAIBaseLLMInput<AuthOptions>): GoogleAbstractedClient;
67
+ buildApiKeyClient(apiKey: string): GoogleAbstractedClient;
68
+ buildApiKey(fields?: GoogleAIBaseLLMInput<AuthOptions>): string | undefined;
69
+ buildClient(fields?: GoogleAIBaseLLMInput<AuthOptions>): GoogleAbstractedClient;
70
+ buildConnection(fields: GoogleBaseLLMInput<AuthOptions>, client: GoogleAbstractedClient): void;
71
+ get platform(): GooglePlatformType;
72
+ bindTools(tools: GoogleAIToolType[], kwargs?: Partial<GoogleAIBaseLanguageModelCallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, GoogleAIBaseLanguageModelCallOptions>;
73
+ // Replace
74
+ _llmType(): string;
75
+ /**
76
+ * Get the parameters used to invoke the model
77
+ */
78
+ invocationParams(options?: this["ParsedCallOptions"]): GoogleAIModelRequestParams;
79
+ _generate(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager: CallbackManagerForLLMRun | undefined): Promise<ChatResult>;
80
+ _streamResponseChunks(_messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
81
+ /** @ignore */
82
+ _combineLLMOutput(): never[];
83
+ /**
84
+ * Return profiling information for the model.
85
+ *
86
+ * Provides information about the model's capabilities and constraints,
87
+ * including token limits, multimodal support, and advanced features like
88
+ * tool calling and structured output.
89
+ *
90
+ * @returns {ModelProfile} An object describing the model's capabilities and constraints
91
+ */
92
+ get profile(): ModelProfile;
93
+ withStructuredOutput<
94
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
95
+ RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>
96
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
97
+ | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
98
+ withStructuredOutput<
99
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
100
+ RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>
101
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
102
+ | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
103
+ raw: BaseMessage;
104
+ parsed: RunOutput;
105
+ }>;
84
106
  }
107
+ //#endregion
108
+ export { ChatConnection, ChatGoogleBase, ChatGoogleBaseInput };
109
+ //# sourceMappingURL=chat_models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat_models.d.ts","names":["BaseMessage","CallbackManagerForLLMRun","BaseChatModel","LangSmithParams","BaseChatModelParams","ChatGenerationChunk","ChatResult","AIMessageChunk","BaseLanguageModelInput","StructuredOutputMethodOptions","ModelProfile","Runnable","AsyncCaller","InteropZodType","GoogleAIBaseLLMInput","GoogleAIModelParams","GoogleAISafetySetting","GoogleConnectionParams","GooglePlatformType","GoogleAIBaseLanguageModelCallOptions","GoogleAIAPI","GoogleAIAPIParams","GoogleSearchToolSetting","GoogleSpeechConfig","AbstractGoogleLLMConnection","GoogleAbstractedClient","GoogleBaseLLMInput","GoogleAISafetyHandler","GoogleAISafetyParams","GoogleAIToolType","GeminiAPIConfig","GoogleAIModelModality","ChatConnection","AuthOptions","Exclude","ChatGoogleBaseInput","Pick","ChatGoogleBase","Record","Partial","__types_js0","GoogleAIModelRequestParams","Promise","AsyncGenerator","RunOutput"],"sources":["../src/chat_models.d.ts"],"sourcesContent":["import { type BaseMessage } from \"@langchain/core/messages\";\nimport { CallbackManagerForLLMRun } from \"@langchain/core/callbacks/manager\";\nimport { BaseChatModel, LangSmithParams, type BaseChatModelParams } from \"@langchain/core/language_models/chat_models\";\nimport { ChatGenerationChunk, ChatResult } from \"@langchain/core/outputs\";\nimport { AIMessageChunk } from \"@langchain/core/messages\";\nimport { BaseLanguageModelInput, StructuredOutputMethodOptions } from \"@langchain/core/language_models/base\";\nimport { type ModelProfile } from \"@langchain/core/language_models/profile\";\nimport { Runnable } from \"@langchain/core/runnables\";\nimport { AsyncCaller } from \"@langchain/core/utils/async_caller\";\nimport { InteropZodType } from \"@langchain/core/utils/types\";\nimport { GoogleAIBaseLLMInput, GoogleAIModelParams, GoogleAISafetySetting, GoogleConnectionParams, GooglePlatformType, GoogleAIBaseLanguageModelCallOptions, GoogleAIAPI, GoogleAIAPIParams, GoogleSearchToolSetting, GoogleSpeechConfig } from \"./types.js\";\nimport { AbstractGoogleLLMConnection } from \"./connection.js\";\nimport { GoogleAbstractedClient } from \"./auth.js\";\nimport type { GoogleBaseLLMInput, GoogleAISafetyHandler, GoogleAISafetyParams, GoogleAIToolType, GeminiAPIConfig, GoogleAIModelModality } from \"./types.js\";\nexport declare class ChatConnection<AuthOptions> extends AbstractGoogleLLMConnection<BaseMessage[], AuthOptions> {\n convertSystemMessageToHumanContent: boolean | undefined;\n constructor(fields: GoogleAIBaseLLMInput<AuthOptions> | undefined, caller: AsyncCaller, client: GoogleAbstractedClient, streaming: boolean);\n get useSystemInstruction(): boolean;\n get computeUseSystemInstruction(): boolean;\n computeGoogleSearchToolAdjustmentFromModel(): Exclude<GoogleSearchToolSetting, boolean>;\n computeGoogleSearchToolAdjustment(apiConfig: GeminiAPIConfig): Exclude<GoogleSearchToolSetting, true>;\n buildGeminiAPI(): GoogleAIAPI;\n get api(): GoogleAIAPI;\n}\n/**\n * Input to chat model class.\n */\nexport interface ChatGoogleBaseInput<AuthOptions> extends BaseChatModelParams, GoogleConnectionParams<AuthOptions>, GoogleAIModelParams, GoogleAISafetyParams, GoogleAIAPIParams, Pick<GoogleAIBaseLanguageModelCallOptions, \"streamUsage\"> {\n}\n/**\n * Integration with a Google chat model.\n */\nexport declare abstract class ChatGoogleBase<AuthOptions> extends BaseChatModel<GoogleAIBaseLanguageModelCallOptions, AIMessageChunk> implements ChatGoogleBaseInput<AuthOptions> {\n // Used for tracing, replace with the same name as your class\n static lc_name(): string;\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n lc_serializable: boolean;\n // Set based on modelName\n model: string;\n modelName: string;\n temperature: number;\n maxOutputTokens: number;\n maxReasoningTokens: number;\n topP: number;\n topK: number;\n seed: number;\n presencePenalty: number;\n frequencyPenalty: number;\n stopSequences: string[];\n logprobs: boolean;\n topLogprobs: number;\n safetySettings: GoogleAISafetySetting[];\n responseModalities?: GoogleAIModelModality[];\n // May intentionally be undefined, meaning to compute this.\n convertSystemMessageToHumanContent: boolean | undefined;\n safetyHandler: GoogleAISafetyHandler;\n speechConfig: GoogleSpeechConfig;\n streamUsage: boolean;\n streaming: boolean;\n labels?: Record<string, string>;\n protected connection: ChatConnection<AuthOptions>;\n protected streamedConnection: ChatConnection<AuthOptions>;\n constructor(fields?: ChatGoogleBaseInput<AuthOptions>);\n getLsParams(options: this[\"ParsedCallOptions\"]): LangSmithParams;\n abstract buildAbstractedClient(fields?: GoogleAIBaseLLMInput<AuthOptions>): GoogleAbstractedClient;\n buildApiKeyClient(apiKey: string): GoogleAbstractedClient;\n buildApiKey(fields?: GoogleAIBaseLLMInput<AuthOptions>): string | undefined;\n buildClient(fields?: GoogleAIBaseLLMInput<AuthOptions>): GoogleAbstractedClient;\n buildConnection(fields: GoogleBaseLLMInput<AuthOptions>, client: GoogleAbstractedClient): void;\n get platform(): GooglePlatformType;\n bindTools(tools: GoogleAIToolType[], kwargs?: Partial<GoogleAIBaseLanguageModelCallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, GoogleAIBaseLanguageModelCallOptions>;\n // Replace\n _llmType(): string;\n /**\n * Get the parameters used to invoke the model\n */\n invocationParams(options?: this[\"ParsedCallOptions\"]): import(\"./types.js\").GoogleAIModelRequestParams;\n _generate(messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager: CallbackManagerForLLMRun | undefined): Promise<ChatResult>;\n _streamResponseChunks(_messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;\n /** @ignore */\n _combineLLMOutput(): never[];\n /**\n * Return profiling information for the model.\n *\n * Provides information about the model's capabilities and constraints,\n * including token limits, multimodal support, and advanced features like\n * tool calling and structured output.\n *\n * @returns {ModelProfile} An object describing the model's capabilities and constraints\n */\n get profile(): ModelProfile;\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {\n raw: BaseMessage;\n parsed: RunOutput;\n }>;\n}\n"],"mappings":";;;;;;;;;;;;;;AAcqBgC,cAAAA,cAAc,CAAA,WAAA,CAAA,SAAsBR,2BAAtB,CAAkDxB,WAAlD,EAAA,EAAiEiC,WAAjE,CAAA,CAAA;EAAA,kCAAA,EAAA,OAAA,GAAA,SAAA;EAAA,WAAkDjC,CAAAA,MAAAA,EAE7Dc,oBAF6Dd,CAExCiC,WAFwCjC,CAAAA,GAAAA,SAAAA,EAAAA,MAAAA,EAENY,WAFMZ,EAAAA,MAAAA,EAEeyB,sBAFfzB,EAAAA,SAAAA,EAAAA,OAAAA;EAAW,IAAIiC,oBAAAA,CAAAA,CAAAA,EAAAA,OAAAA;EAAW,IAElEA,2BAAAA,CAAAA,CAAAA,EAAAA,OAAAA;EAAW,0CAAhCnB,CAAAA,CAAAA,EAG0BoB,OAH1BpB,CAGkCQ,uBAHlCR,EAAAA,OAAAA,CAAAA;EAAoB,iCAAmCF,CAAAA,SAAAA,EAI9BkB,eAJ8BlB,CAAAA,EAIZsB,OAJYtB,CAIJU,uBAJIV,EAAAA,IAAAA,CAAAA;EAAW,cAAUa,CAAAA,CAAAA,EAK9EL,WAL8EK;EAAsB,IAGhEH,GAAAA,CAAAA,CAAAA,EAG3CF,WAH2CE;;;;;AAEpCF,UAMLe,mBANKf,CAAAA,WAAAA,CAAAA,SAMoChB,mBANpCgB,EAMyDH,sBANzDG,CAMgFa,WANhFb,CAAAA,EAM8FL,mBAN9F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