@langchain/google-common 0.2.18 → 1.0.0
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 +17 -0
- package/LICENSE +6 -6
- package/dist/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/auth.cjs +82 -116
- package/dist/auth.cjs.map +1 -0
- package/dist/auth.d.cts +46 -0
- package/dist/auth.d.cts.map +1 -0
- package/dist/auth.d.ts +41 -36
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +80 -110
- package/dist/auth.js.map +1 -0
- package/dist/chat_models.cjs +251 -466
- package/dist/chat_models.cjs.map +1 -0
- package/dist/chat_models.d.cts +98 -0
- package/dist/chat_models.d.cts.map +1 -0
- package/dist/chat_models.d.ts +87 -73
- package/dist/chat_models.d.ts.map +1 -0
- package/dist/chat_models.js +245 -457
- package/dist/chat_models.js.map +1 -0
- package/dist/connection.cjs +321 -466
- package/dist/connection.cjs.map +1 -0
- package/dist/connection.d.cts +109 -0
- package/dist/connection.d.cts.map +1 -0
- package/dist/connection.d.ts +98 -91
- package/dist/connection.d.ts.map +1 -0
- package/dist/connection.js +317 -459
- package/dist/connection.js.map +1 -0
- package/dist/embeddings.cjs +135 -186
- package/dist/embeddings.cjs.map +1 -0
- package/dist/embeddings.d.cts +44 -0
- package/dist/embeddings.d.cts.map +1 -0
- package/dist/embeddings.d.ts +38 -32
- package/dist/embeddings.d.ts.map +1 -0
- package/dist/embeddings.js +133 -181
- package/dist/embeddings.js.map +1 -0
- package/dist/experimental/media.cjs +380 -482
- package/dist/experimental/media.cjs.map +1 -0
- package/dist/experimental/media.d.cts +198 -0
- package/dist/experimental/media.d.cts.map +1 -0
- package/dist/experimental/media.d.ts +190 -202
- package/dist/experimental/media.d.ts.map +1 -0
- package/dist/experimental/media.js +369 -468
- package/dist/experimental/media.js.map +1 -0
- package/dist/experimental/utils/media_core.cjs +403 -517
- package/dist/experimental/utils/media_core.cjs.map +1 -0
- package/dist/experimental/utils/media_core.d.cts +215 -0
- package/dist/experimental/utils/media_core.d.cts.map +1 -0
- package/dist/experimental/utils/media_core.d.ts +171 -165
- package/dist/experimental/utils/media_core.d.ts.map +1 -0
- package/dist/experimental/utils/media_core.js +395 -506
- package/dist/experimental/utils/media_core.js.map +1 -0
- package/dist/index.cjs +58 -27
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -11
- package/dist/index.js +13 -11
- package/dist/llms.cjs +157 -244
- package/dist/llms.cjs.map +1 -0
- package/dist/llms.d.cts +72 -0
- package/dist/llms.d.cts.map +1 -0
- package/dist/llms.d.ts +64 -54
- package/dist/llms.d.ts.map +1 -0
- package/dist/llms.js +154 -238
- package/dist/llms.js.map +1 -0
- package/dist/output_parsers.cjs +148 -173
- package/dist/output_parsers.cjs.map +1 -0
- package/dist/output_parsers.d.cts +53 -0
- package/dist/output_parsers.d.cts.map +1 -0
- package/dist/output_parsers.d.ts +46 -42
- package/dist/output_parsers.d.ts.map +1 -0
- package/dist/output_parsers.js +146 -168
- package/dist/output_parsers.js.map +1 -0
- package/dist/types-anthropic.d.cts +229 -0
- package/dist/types-anthropic.d.cts.map +1 -0
- package/dist/types-anthropic.d.ts +221 -215
- package/dist/types-anthropic.d.ts.map +1 -0
- package/dist/types.cjs +51 -62
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +748 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.ts +669 -656
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +46 -45
- package/dist/types.js.map +1 -0
- package/dist/utils/anthropic.cjs +598 -821
- package/dist/utils/anthropic.cjs.map +1 -0
- package/dist/utils/anthropic.js +597 -818
- package/dist/utils/anthropic.js.map +1 -0
- package/dist/utils/common.cjs +130 -211
- package/dist/utils/common.cjs.map +1 -0
- package/dist/utils/common.d.cts +13 -0
- package/dist/utils/common.d.cts.map +1 -0
- package/dist/utils/common.d.ts +12 -7
- package/dist/utils/common.d.ts.map +1 -0
- package/dist/utils/common.js +128 -207
- package/dist/utils/common.js.map +1 -0
- package/dist/utils/failed_handler.cjs +28 -30
- package/dist/utils/failed_handler.cjs.map +1 -0
- package/dist/utils/failed_handler.d.cts +9 -0
- package/dist/utils/failed_handler.d.cts.map +1 -0
- package/dist/utils/failed_handler.d.ts +8 -2
- package/dist/utils/failed_handler.d.ts.map +1 -0
- package/dist/utils/failed_handler.js +28 -28
- package/dist/utils/failed_handler.js.map +1 -0
- package/dist/utils/gemini.cjs +1020 -1488
- package/dist/utils/gemini.cjs.map +1 -0
- package/dist/utils/gemini.d.cts +51 -0
- package/dist/utils/gemini.d.cts.map +1 -0
- package/dist/utils/gemini.d.ts +51 -48
- package/dist/utils/gemini.d.ts.map +1 -0
- package/dist/utils/gemini.js +1015 -1479
- package/dist/utils/gemini.js.map +1 -0
- package/dist/utils/index.cjs +38 -23
- package/dist/utils/index.d.cts +8 -0
- package/dist/utils/index.d.ts +8 -7
- package/dist/utils/index.js +8 -7
- package/dist/utils/palm.d.cts +11 -0
- package/dist/utils/palm.d.cts.map +1 -0
- package/dist/utils/palm.d.ts +9 -4
- package/dist/utils/palm.d.ts.map +1 -0
- package/dist/utils/safety.cjs +13 -22
- package/dist/utils/safety.cjs.map +1 -0
- package/dist/utils/safety.d.cts +12 -0
- package/dist/utils/safety.d.cts.map +1 -0
- package/dist/utils/safety.d.ts +10 -4
- package/dist/utils/safety.d.ts.map +1 -0
- package/dist/utils/safety.js +13 -19
- package/dist/utils/safety.js.map +1 -0
- package/dist/utils/stream.cjs +296 -475
- package/dist/utils/stream.cjs.map +1 -0
- package/dist/utils/stream.d.cts +165 -0
- package/dist/utils/stream.d.cts.map +1 -0
- package/dist/utils/stream.d.ts +156 -131
- package/dist/utils/stream.d.ts.map +1 -0
- package/dist/utils/stream.js +293 -469
- package/dist/utils/stream.js.map +1 -0
- package/dist/utils/zod_to_gemini_parameters.cjs +43 -81
- package/dist/utils/zod_to_gemini_parameters.cjs.map +1 -0
- package/dist/utils/zod_to_gemini_parameters.d.cts +22 -0
- package/dist/utils/zod_to_gemini_parameters.d.cts.map +1 -0
- package/dist/utils/zod_to_gemini_parameters.d.ts +21 -6
- package/dist/utils/zod_to_gemini_parameters.d.ts.map +1 -0
- package/dist/utils/zod_to_gemini_parameters.js +40 -76
- package/dist/utils/zod_to_gemini_parameters.js.map +1 -0
- package/package.json +69 -85
- package/dist/types-anthropic.cjs +0 -2
- package/dist/types-anthropic.js +0 -1
- package/dist/utils/anthropic.d.ts +0 -4
- package/dist/utils/palm.cjs +0 -2
- package/dist/utils/palm.js +0 -1
- package/experimental/media.cjs +0 -1
- package/experimental/media.d.cts +0 -1
- package/experimental/media.d.ts +0 -1
- package/experimental/media.js +0 -1
- package/experimental/utils/media_core.cjs +0 -1
- package/experimental/utils/media_core.d.cts +0 -1
- package/experimental/utils/media_core.d.ts +0 -1
- package/experimental/utils/media_core.js +0 -1
- package/index.cjs +0 -1
- package/index.d.cts +0 -1
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/types.cjs +0 -1
- package/types.d.cts +0 -1
- package/types.d.ts +0 -1
- package/types.js +0 -1
- package/utils.cjs +0 -1
- package/utils.d.cts +0 -1
- package/utils.d.ts +0 -1
- 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","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 {\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\";\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 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":";;;;;;;;;;;;;;;;;AAmEA,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;AAC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uB,OAAO,EAAE;GAC9B,MAAM,aAAaC,0DAAyB,OAAO;GACnD,QAAQ,CACN,EACE,sBAAsB,CACpB;IACE,MAAM;IACN,aACE,WAAW,eAAe;IAC5B,YAAY;GACb,CACF,EACF,CACF;GACD,eAAe,IAAIC,sEAAyB;IAC1C,cAAc;IACd,SAAS;IACT,WAAW;GACZ;EACF,OAAM;GACL,IAAIC;AACJ,OACE,OAAO,OAAO,SAAS,YACvB,OAAO,OAAO,eAAe,YAC7B,OAAO,cAAc,MACrB;IACA,2BAA2B;IAC3B,eAAe,OAAO;GACvB,OAAM;IAEL,MAAMC,aAA+BC,4DAA2B,OAAO;IACvE,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,98 @@
|
|
|
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 { Runnable } from "@langchain/core/runnables";
|
|
11
|
+
import { InteropZodType } from "@langchain/core/utils/types";
|
|
12
|
+
|
|
13
|
+
//#region src/chat_models.d.ts
|
|
14
|
+
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;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Input to chat model class.
|
|
26
|
+
*/
|
|
27
|
+
interface ChatGoogleBaseInput<AuthOptions> extends BaseChatModelParams, GoogleConnectionParams<AuthOptions>, GoogleAIModelParams, GoogleAISafetyParams, GoogleAIAPIParams, Pick<GoogleAIBaseLanguageModelCallOptions, "streamUsage"> {}
|
|
28
|
+
/**
|
|
29
|
+
* Integration with a Google chat model.
|
|
30
|
+
*/
|
|
31
|
+
declare abstract class ChatGoogleBase<AuthOptions> extends BaseChatModel<GoogleAIBaseLanguageModelCallOptions, AIMessageChunk> implements ChatGoogleBaseInput<AuthOptions> {
|
|
32
|
+
// Used for tracing, replace with the same name as your class
|
|
33
|
+
static lc_name(): string;
|
|
34
|
+
get lc_secrets(): {
|
|
35
|
+
[key: string]: string;
|
|
36
|
+
} | undefined;
|
|
37
|
+
lc_serializable: boolean;
|
|
38
|
+
// Set based on modelName
|
|
39
|
+
model: string;
|
|
40
|
+
modelName: string;
|
|
41
|
+
temperature: number;
|
|
42
|
+
maxOutputTokens: number;
|
|
43
|
+
maxReasoningTokens: number;
|
|
44
|
+
topP: number;
|
|
45
|
+
topK: number;
|
|
46
|
+
seed: number;
|
|
47
|
+
presencePenalty: number;
|
|
48
|
+
frequencyPenalty: number;
|
|
49
|
+
stopSequences: string[];
|
|
50
|
+
logprobs: boolean;
|
|
51
|
+
topLogprobs: number;
|
|
52
|
+
safetySettings: GoogleAISafetySetting[];
|
|
53
|
+
responseModalities?: GoogleAIModelModality[];
|
|
54
|
+
// May intentionally be undefined, meaning to compute this.
|
|
55
|
+
convertSystemMessageToHumanContent: boolean | undefined;
|
|
56
|
+
safetyHandler: GoogleAISafetyHandler;
|
|
57
|
+
speechConfig: GoogleSpeechConfig;
|
|
58
|
+
streamUsage: boolean;
|
|
59
|
+
streaming: boolean;
|
|
60
|
+
labels?: Record<string, string>;
|
|
61
|
+
protected connection: ChatConnection<AuthOptions>;
|
|
62
|
+
protected streamedConnection: ChatConnection<AuthOptions>;
|
|
63
|
+
constructor(fields?: ChatGoogleBaseInput<AuthOptions>);
|
|
64
|
+
getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
|
|
65
|
+
abstract buildAbstractedClient(fields?: GoogleAIBaseLLMInput<AuthOptions>): GoogleAbstractedClient;
|
|
66
|
+
buildApiKeyClient(apiKey: string): GoogleAbstractedClient;
|
|
67
|
+
buildApiKey(fields?: GoogleAIBaseLLMInput<AuthOptions>): string | undefined;
|
|
68
|
+
buildClient(fields?: GoogleAIBaseLLMInput<AuthOptions>): GoogleAbstractedClient;
|
|
69
|
+
buildConnection(fields: GoogleBaseLLMInput<AuthOptions>, client: GoogleAbstractedClient): void;
|
|
70
|
+
get platform(): GooglePlatformType;
|
|
71
|
+
bindTools(tools: GoogleAIToolType[], kwargs?: Partial<GoogleAIBaseLanguageModelCallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, GoogleAIBaseLanguageModelCallOptions>;
|
|
72
|
+
// Replace
|
|
73
|
+
_llmType(): string;
|
|
74
|
+
/**
|
|
75
|
+
* Get the parameters used to invoke the model
|
|
76
|
+
*/
|
|
77
|
+
invocationParams(options?: this["ParsedCallOptions"]): GoogleAIModelRequestParams;
|
|
78
|
+
_generate(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager: CallbackManagerForLLMRun | undefined): Promise<ChatResult>;
|
|
79
|
+
_streamResponseChunks(_messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
|
|
80
|
+
/** @ignore */
|
|
81
|
+
_combineLLMOutput(): never[];
|
|
82
|
+
withStructuredOutput<
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
|
+
RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
|
|
87
|
+
withStructuredOutput<
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
89
|
+
RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
91
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
|
|
92
|
+
raw: BaseMessage;
|
|
93
|
+
parsed: RunOutput;
|
|
94
|
+
}>;
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
export { ChatConnection, ChatGoogleBase, ChatGoogleBaseInput };
|
|
98
|
+
//# 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","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 { 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 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":";;;;;;;;;;;;;AAaqB+B,cAAAA,cAAc,CAAA,WAAA,CAAA,SAAsBR,2BAAtB,CAAkDvB,WAAlD,EAAA,EAAiEgC,WAAjE,CAAA,CAAA;EAAA,kCAAA,EAAA,OAAA,GAAA,SAAA;EAAA,WAAkDhC,CAAAA,MAAAA,EAE7Da,oBAF6Db,CAExCgC,WAFwChC,CAAAA,GAAAA,SAAAA,EAAAA,MAAAA,EAENW,WAFMX,EAAAA,MAAAA,EAEewB,sBAFfxB,EAAAA,SAAAA,EAAAA,OAAAA;EAAW,IAAIgC,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,EA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B,6BAL9B4B,CAAAA,IAAAA,CAAAA,CAAAA,EAKoE3B,QALpE2B,CAK6E7B,sBAL7E6B,EAAAA;IAA8B5B,GAAAA,EAMxBT,WANwBS;IAAgDD,MAAAA,EAOrEmC,SAPqEnC;EAAsB,CAAA,CAAA"}
|
package/dist/chat_models.d.ts
CHANGED
|
@@ -1,84 +1,98 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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 {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
+
|
|
13
|
+
//#region src/chat_models.d.ts
|
|
14
|
+
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;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Input to chat model class.
|
|
26
26
|
*/
|
|
27
|
-
|
|
28
|
-
}
|
|
27
|
+
interface ChatGoogleBaseInput<AuthOptions> extends BaseChatModelParams, GoogleConnectionParams<AuthOptions>, GoogleAIModelParams, GoogleAISafetyParams, GoogleAIAPIParams, Pick<GoogleAIBaseLanguageModelCallOptions, "streamUsage"> {}
|
|
29
28
|
/**
|
|
30
29
|
* Integration with a Google chat model.
|
|
31
30
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
31
|
+
declare abstract class ChatGoogleBase<AuthOptions> extends BaseChatModel<GoogleAIBaseLanguageModelCallOptions, AIMessageChunk> implements ChatGoogleBaseInput<AuthOptions> {
|
|
32
|
+
// Used for tracing, replace with the same name as your class
|
|
33
|
+
static lc_name(): string;
|
|
34
|
+
get lc_secrets(): {
|
|
35
|
+
[key: string]: string;
|
|
36
|
+
} | undefined;
|
|
37
|
+
lc_serializable: boolean;
|
|
38
|
+
// Set based on modelName
|
|
39
|
+
model: string;
|
|
40
|
+
modelName: string;
|
|
41
|
+
temperature: number;
|
|
42
|
+
maxOutputTokens: number;
|
|
43
|
+
maxReasoningTokens: number;
|
|
44
|
+
topP: number;
|
|
45
|
+
topK: number;
|
|
46
|
+
seed: number;
|
|
47
|
+
presencePenalty: number;
|
|
48
|
+
frequencyPenalty: number;
|
|
49
|
+
stopSequences: string[];
|
|
50
|
+
logprobs: boolean;
|
|
51
|
+
topLogprobs: number;
|
|
52
|
+
safetySettings: GoogleAISafetySetting[];
|
|
53
|
+
responseModalities?: GoogleAIModelModality[];
|
|
54
|
+
// May intentionally be undefined, meaning to compute this.
|
|
55
|
+
convertSystemMessageToHumanContent: boolean | undefined;
|
|
56
|
+
safetyHandler: GoogleAISafetyHandler;
|
|
57
|
+
speechConfig: GoogleSpeechConfig;
|
|
58
|
+
streamUsage: boolean;
|
|
59
|
+
streaming: boolean;
|
|
60
|
+
labels?: Record<string, string>;
|
|
61
|
+
protected connection: ChatConnection<AuthOptions>;
|
|
62
|
+
protected streamedConnection: ChatConnection<AuthOptions>;
|
|
63
|
+
constructor(fields?: ChatGoogleBaseInput<AuthOptions>);
|
|
64
|
+
getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
|
|
65
|
+
abstract buildAbstractedClient(fields?: GoogleAIBaseLLMInput<AuthOptions>): GoogleAbstractedClient;
|
|
66
|
+
buildApiKeyClient(apiKey: string): GoogleAbstractedClient;
|
|
67
|
+
buildApiKey(fields?: GoogleAIBaseLLMInput<AuthOptions>): string | undefined;
|
|
68
|
+
buildClient(fields?: GoogleAIBaseLLMInput<AuthOptions>): GoogleAbstractedClient;
|
|
69
|
+
buildConnection(fields: GoogleBaseLLMInput<AuthOptions>, client: GoogleAbstractedClient): void;
|
|
70
|
+
get platform(): GooglePlatformType;
|
|
71
|
+
bindTools(tools: GoogleAIToolType[], kwargs?: Partial<GoogleAIBaseLanguageModelCallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, GoogleAIBaseLanguageModelCallOptions>;
|
|
72
|
+
// Replace
|
|
73
|
+
_llmType(): string;
|
|
74
|
+
/**
|
|
75
|
+
* Get the parameters used to invoke the model
|
|
76
|
+
*/
|
|
77
|
+
invocationParams(options?: this["ParsedCallOptions"]): GoogleAIModelRequestParams;
|
|
78
|
+
_generate(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager: CallbackManagerForLLMRun | undefined): Promise<ChatResult>;
|
|
79
|
+
_streamResponseChunks(_messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
|
|
80
|
+
/** @ignore */
|
|
81
|
+
_combineLLMOutput(): never[];
|
|
82
|
+
withStructuredOutput<
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
|
+
RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
|
|
87
|
+
withStructuredOutput<
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
89
|
+
RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
91
|
+
| Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
|
|
92
|
+
raw: BaseMessage;
|
|
93
|
+
parsed: RunOutput;
|
|
94
|
+
}>;
|
|
84
95
|
}
|
|
96
|
+
//#endregion
|
|
97
|
+
export { ChatConnection, ChatGoogleBase, ChatGoogleBaseInput };
|
|
98
|
+
//# 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","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 { 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 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":";;;;;;;;;;;;;AAaqB+B,cAAAA,cAAc,CAAA,WAAA,CAAA,SAAsBR,2BAAtB,CAAkDvB,WAAlD,EAAA,EAAiEgC,WAAjE,CAAA,CAAA;EAAA,kCAAA,EAAA,OAAA,GAAA,SAAA;EAAA,WAAkDhC,CAAAA,MAAAA,EAE7Da,oBAF6Db,CAExCgC,WAFwChC,CAAAA,GAAAA,SAAAA,EAAAA,MAAAA,EAENW,WAFMX,EAAAA,MAAAA,EAEewB,sBAFfxB,EAAAA,SAAAA,EAAAA,OAAAA;EAAW,IAAIgC,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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