@langchain/google-common 2.1.27 → 2.1.28
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 +9 -0
- package/dist/chat_models.cjs +1 -1
- package/dist/chat_models.js +1 -1
- package/dist/llms.cjs +7 -3
- package/dist/llms.cjs.map +1 -1
- package/dist/llms.d.cts.map +1 -1
- package/dist/llms.d.ts.map +1 -1
- package/dist/llms.js +7 -3
- package/dist/llms.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @langchain/google-common
|
|
2
2
|
|
|
3
|
+
## 2.1.28
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#10711](https://github.com/langchain-ai/langchainjs/pull/10711) [`2e9e696`](https://github.com/langchain-ai/langchainjs/commit/2e9e6969e248a53ede0659a41d0ac8dbaf291ab4) Thanks [@jacoblee93](https://github.com/jacoblee93)! - feat(core): Add chat model and llm invocation params to traced metadata
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`589f29c`](https://github.com/langchain-ai/langchainjs/commit/589f29ce844eb252c2d5e6b0f8d26de37763a0d7), [`2e9e696`](https://github.com/langchain-ai/langchainjs/commit/2e9e6969e248a53ede0659a41d0ac8dbaf291ab4)]:
|
|
10
|
+
- @langchain/core@1.1.41
|
|
11
|
+
|
|
3
12
|
## 2.1.27
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/chat_models.cjs
CHANGED
|
@@ -94,7 +94,7 @@ var ChatGoogleBase = class extends _langchain_core_language_models_chat_models.B
|
|
|
94
94
|
streamedConnection;
|
|
95
95
|
constructor(fields) {
|
|
96
96
|
super(require_failed_handler.ensureParams(fields));
|
|
97
|
-
this._addVersion("@langchain/google-common", "2.1.
|
|
97
|
+
this._addVersion("@langchain/google-common", "2.1.28");
|
|
98
98
|
require_common.copyAndValidateModelParamsInto(fields, this);
|
|
99
99
|
this.safetyHandler = fields?.safetyHandler ?? new require_gemini.DefaultGeminiSafetyHandler();
|
|
100
100
|
this.streamUsage = fields?.streamUsage ?? this.streamUsage;
|
package/dist/chat_models.js
CHANGED
|
@@ -94,7 +94,7 @@ var ChatGoogleBase = class extends BaseChatModel {
|
|
|
94
94
|
streamedConnection;
|
|
95
95
|
constructor(fields) {
|
|
96
96
|
super(ensureParams(fields));
|
|
97
|
-
this._addVersion("@langchain/google-common", "2.1.
|
|
97
|
+
this._addVersion("@langchain/google-common", "2.1.28");
|
|
98
98
|
copyAndValidateModelParamsInto(fields, this);
|
|
99
99
|
this.safetyHandler = fields?.safetyHandler ?? new DefaultGeminiSafetyHandler();
|
|
100
100
|
this.streamUsage = fields?.streamUsage ?? this.streamUsage;
|
package/dist/llms.cjs
CHANGED
|
@@ -20,7 +20,7 @@ var GoogleLLMConnection = class extends require_connection.AbstractGoogleLLMConn
|
|
|
20
20
|
var ProxyChatGoogle = class extends require_chat_models.ChatGoogleBase {
|
|
21
21
|
constructor(fields) {
|
|
22
22
|
super(fields);
|
|
23
|
-
this._addVersion("@langchain/google-common", "2.1.
|
|
23
|
+
this._addVersion("@langchain/google-common", "2.1.28");
|
|
24
24
|
}
|
|
25
25
|
buildAbstractedClient(fields) {
|
|
26
26
|
return fields.connection.client;
|
|
@@ -102,10 +102,14 @@ var GoogleBaseLLM = class extends _langchain_core_language_models_llms.LLM {
|
|
|
102
102
|
async *_streamIterator(input, options) {
|
|
103
103
|
const prompt = _langchain_core_language_models_llms.BaseLLM._convertInputToPromptValue(input);
|
|
104
104
|
const [runnableConfig, callOptions] = this._separateRunnableConfigFromCallOptions(options);
|
|
105
|
-
const
|
|
105
|
+
const invocationParams = this.invocationParams(callOptions);
|
|
106
|
+
const callbackManager_ = await _langchain_core_callbacks_manager.CallbackManager.configure(runnableConfig.callbacks, this.callbacks, runnableConfig.tags, this.tags, runnableConfig.metadata, this.metadata, {
|
|
107
|
+
verbose: this.verbose,
|
|
108
|
+
tracerInheritableMetadata: this._filterInvocationParamsForTracing(invocationParams)
|
|
109
|
+
});
|
|
106
110
|
const extra = {
|
|
107
111
|
options: callOptions,
|
|
108
|
-
invocation_params:
|
|
112
|
+
invocation_params: invocationParams,
|
|
109
113
|
batch_size: 1
|
|
110
114
|
};
|
|
111
115
|
const runManagers = await callbackManager_?.handleLLMStart(this.toJSON(), [prompt.toString()], void 0, void 0, extra, void 0, void 0, runnableConfig.runName);
|
package/dist/llms.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llms.cjs","names":["AbstractGoogleLLMConnection","ChatGoogleBase","LLM","ensureParams","DefaultGeminiSafetyHandler","ApiKeyGoogleAuth","copyAIModelParams","BaseLLM","CallbackManager","GenerationChunk"],"sources":["../src/llms.ts"],"sourcesContent":["import { CallbackManager, Callbacks } from \"@langchain/core/callbacks/manager\";\nimport { BaseLLM, LLM } from \"@langchain/core/language_models/llms\";\nimport {\n type BaseLanguageModelCallOptions,\n BaseLanguageModelInput,\n} from \"@langchain/core/language_models/base\";\nimport { BaseMessage, MessageContent } from \"@langchain/core/messages\";\nimport { GenerationChunk } from \"@langchain/core/outputs\";\nimport { getEnvironmentVariable } from \"@langchain/core/utils/env\";\n\nimport { AbstractGoogleLLMConnection } from \"./connection.js\";\nimport {\n GoogleAIBaseLLMInput,\n GoogleAIModelParams,\n GoogleAISafetySetting,\n GooglePlatformType,\n GeminiContent,\n GoogleAIResponseMimeType,\n} from \"./types.js\";\nimport {\n copyAIModelParams,\n copyAndValidateModelParamsInto,\n} from \"./utils/common.js\";\nimport { DefaultGeminiSafetyHandler } from \"./utils/gemini.js\";\nimport { ApiKeyGoogleAuth, GoogleAbstractedClient } from \"./auth.js\";\nimport { ensureParams } from \"./utils/failed_handler.js\";\nimport { ChatGoogleBase } from \"./chat_models.js\";\nimport type { GoogleBaseLLMInput, GoogleAISafetyHandler } from \"./types.js\";\n\nexport { GoogleBaseLLMInput };\n\nclass GoogleLLMConnection<AuthOptions> extends AbstractGoogleLLMConnection<\n MessageContent,\n AuthOptions\n> {\n async formatContents(\n input: MessageContent,\n _parameters: GoogleAIModelParams\n ): Promise<GeminiContent[]> {\n const parts = await this.api.messageContentToParts!(input);\n const contents: GeminiContent[] = [\n {\n role: \"user\", // Required by Vertex AI\n parts,\n },\n ];\n return contents;\n }\n}\n\ntype ProxyChatInput<AuthOptions> = GoogleAIBaseLLMInput<AuthOptions> & {\n connection: GoogleLLMConnection<AuthOptions>;\n};\n\nclass ProxyChatGoogle<AuthOptions> extends ChatGoogleBase<AuthOptions> {\n constructor(fields: ProxyChatInput<AuthOptions>) {\n super(fields);\n this._addVersion(\"@langchain/google-common\", __PKG_VERSION__);\n }\n\n buildAbstractedClient(\n fields: ProxyChatInput<AuthOptions>\n ): GoogleAbstractedClient {\n return fields.connection.client;\n }\n}\n\n/**\n * Integration with an LLM.\n */\nexport abstract class GoogleBaseLLM<AuthOptions>\n extends LLM<BaseLanguageModelCallOptions>\n implements GoogleBaseLLMInput<AuthOptions>\n{\n // Used for tracing, replace with the same name as your class\n static lc_name() {\n return \"GoogleLLM\";\n }\n\n get lc_secrets(): { [key: string]: string } | undefined {\n return {\n authOptions: \"GOOGLE_AUTH_OPTIONS\",\n };\n }\n\n originalFields?: GoogleBaseLLMInput<AuthOptions>;\n\n lc_serializable = true;\n\n modelName = \"gemini-pro\";\n\n model = \"gemini-pro\";\n\n temperature = 0.7;\n\n maxOutputTokens = 1024;\n\n topP = 0.8;\n\n topK = 40;\n\n stopSequences: string[] = [];\n\n safetySettings: GoogleAISafetySetting[] = [];\n\n safetyHandler: GoogleAISafetyHandler;\n\n responseMimeType: GoogleAIResponseMimeType = \"text/plain\";\n\n protected connection: GoogleLLMConnection<AuthOptions>;\n\n protected streamedConnection: GoogleLLMConnection<AuthOptions>;\n\n constructor(fields?: GoogleBaseLLMInput<AuthOptions>) {\n super(ensureParams(fields));\n this.originalFields = fields;\n\n copyAndValidateModelParamsInto(fields, this);\n this.safetyHandler =\n fields?.safetyHandler ?? new DefaultGeminiSafetyHandler();\n\n const client = this.buildClient(fields);\n this.buildConnection(fields ?? {}, client);\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 GoogleLLMConnection(\n { ...fields, ...this },\n this.caller,\n client,\n false\n );\n\n this.streamedConnection = new GoogleLLMConnection(\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 // Replace\n _llmType() {\n return \"googlellm\";\n }\n\n formatPrompt(prompt: string): MessageContent {\n return prompt;\n }\n\n /**\n * For some given input string and options, return a string output.\n *\n * Despite the fact that `invoke` is overridden below, we still need this\n * in order to handle public APi calls to `generate()`.\n */\n async _call(\n prompt: string,\n options: this[\"ParsedCallOptions\"]\n ): Promise<string> {\n const parameters = copyAIModelParams(this, options);\n const result = await this.connection.request(prompt, parameters, options);\n const ret = this.connection.api.responseToString(result);\n return ret;\n }\n\n // Normally, you should not override this method and instead should override\n // _streamResponseChunks. We are doing so here to allow for multimodal inputs into\n // the LLM.\n async *_streamIterator(\n input: BaseLanguageModelInput,\n options?: BaseLanguageModelCallOptions\n ): AsyncGenerator<string> {\n // TODO: Refactor callback setup and teardown code into core\n const prompt = BaseLLM._convertInputToPromptValue(input);\n const [runnableConfig, callOptions] =\n this._separateRunnableConfigFromCallOptions(options);\n const callbackManager_ = await CallbackManager.configure(\n runnableConfig.callbacks,\n this.callbacks,\n runnableConfig.tags,\n this.tags,\n runnableConfig.metadata,\n this.metadata,\n { verbose: this.verbose }\n );\n const extra = {\n options: callOptions,\n invocation_params: this?.invocationParams(callOptions),\n batch_size: 1,\n };\n const runManagers = await callbackManager_?.handleLLMStart(\n this.toJSON(),\n [prompt.toString()],\n undefined,\n undefined,\n extra,\n undefined,\n undefined,\n runnableConfig.runName\n );\n let generation = new GenerationChunk({\n text: \"\",\n });\n const proxyChat = this.createProxyChat();\n try {\n for await (const chunk of proxyChat._streamIterator(input, options)) {\n const stringValue = this.connection.api.chunkToString(chunk);\n const generationChunk = new GenerationChunk({\n text: stringValue,\n });\n generation = generation.concat(generationChunk);\n yield stringValue;\n }\n } catch (err) {\n await Promise.all(\n (runManagers ?? []).map((runManager) => runManager?.handleLLMError(err))\n );\n throw err;\n }\n await Promise.all(\n (runManagers ?? []).map((runManager) =>\n runManager?.handleLLMEnd({\n generations: [[generation]],\n })\n )\n );\n }\n\n async predictMessages(\n messages: BaseMessage[],\n options?: string[] | BaseLanguageModelCallOptions,\n _callbacks?: Callbacks\n ): Promise<BaseMessage> {\n const { content } = messages[0];\n const result = await this.connection.request(\n content,\n {},\n options as BaseLanguageModelCallOptions\n );\n const ret = this.connection.api.responseToBaseMessage(result);\n return ret;\n }\n\n /**\n * Internal implementation detail to allow Google LLMs to support\n * multimodal input by delegating to the chat model implementation.\n *\n * TODO: Replace with something less hacky.\n */\n protected createProxyChat(): ChatGoogleBase<AuthOptions> {\n return new ProxyChatGoogle<AuthOptions>({\n ...this.originalFields,\n connection: this.connection,\n });\n }\n\n // TODO: Remove the need to override this - we are doing it to\n // allow the LLM to handle multimodal types of input.\n async invoke(\n input: BaseLanguageModelInput,\n options?: BaseLanguageModelCallOptions\n ): Promise<string> {\n const stream = await this._streamIterator(input, options);\n let generatedO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5D,MAAM,kBAAkB,IAAIA,wBAAAA,gBAAgB,EAC1C,MAAM,aACP,CAAC;AACF,iBAAa,WAAW,OAAO,gBAAgB;AAC/C,UAAM;;WAED,KAAK;AACZ,SAAM,QAAQ,KACX,eAAe,EAAE,EAAE,KAAK,eAAe,YAAY,eAAe,IAAI,CAAC,CACzE;AACD,SAAM;;AAER,QAAM,QAAQ,KACX,eAAe,EAAE,EAAE,KAAK,eACvB,YAAY,aAAa,EACvB,aAAa,CAAC,CAAC,WAAW,CAAC,EAC5B,CAAC,CACH,CACF;;CAGH,MAAM,gBACJ,UACA,SACA,YACsB;EACtB,MAAM,EAAE,YAAY,SAAS;EAC7B,MAAM,SAAS,MAAM,KAAK,WAAW,QACnC,SACA,EAAE,EACF,QACD;AAED,SADY,KAAK,WAAW,IAAI,sBAAsB,OAAO;;;;;;;;CAU/D,kBAAyD;AACvD,SAAO,IAAI,gBAA6B;GACtC,GAAG,KAAK;GACR,YAAY,KAAK;GAClB,CAAC;;CAKJ,MAAM,OACJ,OACA,SACiB;EACjB,MAAM,SAAS,MAAM,KAAK,gBAAgB,OAAO,QAAQ;EACzD,IAAI,kBAAkB;AACtB,aAAW,MAAM,SAAS,OACxB,oBAAmB;AAErB,SAAO"}
|
|
1
|
+
{"version":3,"file":"llms.cjs","names":["AbstractGoogleLLMConnection","ChatGoogleBase","LLM","ensureParams","DefaultGeminiSafetyHandler","ApiKeyGoogleAuth","copyAIModelParams","BaseLLM","CallbackManager","GenerationChunk"],"sources":["../src/llms.ts"],"sourcesContent":["import { CallbackManager, Callbacks } from \"@langchain/core/callbacks/manager\";\nimport { BaseLLM, LLM } from \"@langchain/core/language_models/llms\";\nimport {\n type BaseLanguageModelCallOptions,\n BaseLanguageModelInput,\n} from \"@langchain/core/language_models/base\";\nimport { BaseMessage, MessageContent } from \"@langchain/core/messages\";\nimport { GenerationChunk } from \"@langchain/core/outputs\";\nimport { getEnvironmentVariable } from \"@langchain/core/utils/env\";\n\nimport { AbstractGoogleLLMConnection } from \"./connection.js\";\nimport {\n GoogleAIBaseLLMInput,\n GoogleAIModelParams,\n GoogleAISafetySetting,\n GooglePlatformType,\n GeminiContent,\n GoogleAIResponseMimeType,\n} from \"./types.js\";\nimport {\n copyAIModelParams,\n copyAndValidateModelParamsInto,\n} from \"./utils/common.js\";\nimport { DefaultGeminiSafetyHandler } from \"./utils/gemini.js\";\nimport { ApiKeyGoogleAuth, GoogleAbstractedClient } from \"./auth.js\";\nimport { ensureParams } from \"./utils/failed_handler.js\";\nimport { ChatGoogleBase } from \"./chat_models.js\";\nimport type { GoogleBaseLLMInput, GoogleAISafetyHandler } from \"./types.js\";\n\nexport { GoogleBaseLLMInput };\n\nclass GoogleLLMConnection<AuthOptions> extends AbstractGoogleLLMConnection<\n MessageContent,\n AuthOptions\n> {\n async formatContents(\n input: MessageContent,\n _parameters: GoogleAIModelParams\n ): Promise<GeminiContent[]> {\n const parts = await this.api.messageContentToParts!(input);\n const contents: GeminiContent[] = [\n {\n role: \"user\", // Required by Vertex AI\n parts,\n },\n ];\n return contents;\n }\n}\n\ntype ProxyChatInput<AuthOptions> = GoogleAIBaseLLMInput<AuthOptions> & {\n connection: GoogleLLMConnection<AuthOptions>;\n};\n\nclass ProxyChatGoogle<AuthOptions> extends ChatGoogleBase<AuthOptions> {\n constructor(fields: ProxyChatInput<AuthOptions>) {\n super(fields);\n this._addVersion(\"@langchain/google-common\", __PKG_VERSION__);\n }\n\n buildAbstractedClient(\n fields: ProxyChatInput<AuthOptions>\n ): GoogleAbstractedClient {\n return fields.connection.client;\n }\n}\n\n/**\n * Integration with an LLM.\n */\nexport abstract class GoogleBaseLLM<AuthOptions>\n extends LLM<BaseLanguageModelCallOptions>\n implements GoogleBaseLLMInput<AuthOptions>\n{\n // Used for tracing, replace with the same name as your class\n static lc_name() {\n return \"GoogleLLM\";\n }\n\n get lc_secrets(): { [key: string]: string } | undefined {\n return {\n authOptions: \"GOOGLE_AUTH_OPTIONS\",\n };\n }\n\n originalFields?: GoogleBaseLLMInput<AuthOptions>;\n\n lc_serializable = true;\n\n modelName = \"gemini-pro\";\n\n model = \"gemini-pro\";\n\n temperature = 0.7;\n\n maxOutputTokens = 1024;\n\n topP = 0.8;\n\n topK = 40;\n\n stopSequences: string[] = [];\n\n safetySettings: GoogleAISafetySetting[] = [];\n\n safetyHandler: GoogleAISafetyHandler;\n\n responseMimeType: GoogleAIResponseMimeType = \"text/plain\";\n\n protected connection: GoogleLLMConnection<AuthOptions>;\n\n protected streamedConnection: GoogleLLMConnection<AuthOptions>;\n\n constructor(fields?: GoogleBaseLLMInput<AuthOptions>) {\n super(ensureParams(fields));\n this.originalFields = fields;\n\n copyAndValidateModelParamsInto(fields, this);\n this.safetyHandler =\n fields?.safetyHandler ?? new DefaultGeminiSafetyHandler();\n\n const client = this.buildClient(fields);\n this.buildConnection(fields ?? {}, client);\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 GoogleLLMConnection(\n { ...fields, ...this },\n this.caller,\n client,\n false\n );\n\n this.streamedConnection = new GoogleLLMConnection(\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 // Replace\n _llmType() {\n return \"googlellm\";\n }\n\n formatPrompt(prompt: string): MessageContent {\n return prompt;\n }\n\n /**\n * For some given input string and options, return a string output.\n *\n * Despite the fact that `invoke` is overridden below, we still need this\n * in order to handle public APi calls to `generate()`.\n */\n async _call(\n prompt: string,\n options: this[\"ParsedCallOptions\"]\n ): Promise<string> {\n const parameters = copyAIModelParams(this, options);\n const result = await this.connection.request(prompt, parameters, options);\n const ret = this.connection.api.responseToString(result);\n return ret;\n }\n\n // Normally, you should not override this method and instead should override\n // _streamResponseChunks. We are doing so here to allow for multimodal inputs into\n // the LLM.\n async *_streamIterator(\n input: BaseLanguageModelInput,\n options?: BaseLanguageModelCallOptions\n ): AsyncGenerator<string> {\n // TODO: Refactor callback setup and teardown code into core\n const prompt = BaseLLM._convertInputToPromptValue(input);\n const [runnableConfig, callOptions] =\n this._separateRunnableConfigFromCallOptions(options);\n const invocationParams = this.invocationParams(callOptions);\n const callbackManager_ = await CallbackManager.configure(\n runnableConfig.callbacks,\n this.callbacks,\n runnableConfig.tags,\n this.tags,\n runnableConfig.metadata,\n this.metadata,\n {\n verbose: this.verbose,\n tracerInheritableMetadata:\n this._filterInvocationParamsForTracing(invocationParams),\n }\n );\n const extra = {\n options: callOptions,\n invocation_params: invocationParams,\n batch_size: 1,\n };\n const runManagers = await callbackManager_?.handleLLMStart(\n this.toJSON(),\n [prompt.toString()],\n undefined,\n undefined,\n extra,\n undefined,\n undefined,\n runnableConfig.runName\n );\n let generation = new GenerationChunk({\n text: \"\",\n });\n const proxyChat = this.createProxyChat();\n try {\n for await (const chunk of proxyChat._streamIterator(input, options)) {\n const stringValue = this.connection.api.chunkToString(chunk);\n const generationChunk = new GenerationChunk({\n text: stringValue,\n });\n generation = generation.concat(generationChunk);\n yield stringValue;\n }\n } catch (err) {\n await Promise.all(\n (runManagers ?? []).map((runManager) => runManager?.handleLLMError(err))\n );\n throw err;\n }\n await Promise.all(\n (runManagers ?? []).map((runManager) =>\n runManager?.handleLLMEnd({\n generations: [[generation]],\n })\n )\n );\n }\n\n async predictMessages(\n messages: BaseMessage[],\n options?: string[] | BaseLanguageModelCallOptions,\n _callbacks?: Callbacks\n ): Promise<BaseMessage> {\n const { content } = messages[0];\n const result = await this.connection.request(\n content,\n {},\n options as BaseLanguageModelCallOptions\n );\n const ret = this.connection.api.responseToBaseMessage(result);\n return ret;\n }\n\n /**\n * Internal implementation detail to allow Google LLMs to support\n * multimodal input by delegating to the chat model implementation.\n *\n * TODO: Replace with something less hacky.\n */\n protected createProxyChat(): ChatGoogleBase<AuthOptions> {\n return new ProxyChatGoogle<AuthOptions>({\n ...this.originalFields,\n connection: this.connection,\n });\n }\n\n // TODO: Remove the need to override this - we are doing it to\n // allow the LLM to handle multimodal types of input.\n async invoke(\n input: BaseLanguageModelInput,\n options?: BaseLanguageModelCallOptions\n ): Promise<string> {\n const stream = await this._streamIterator(input, options);\n let generatedOutput = \"\";\n for await (const chunk of stream) {\n generatedOutput += chunk;\n }\n return generatedOutput;\n }\n}\n"],"mappings":";;;;;;;;;;;AA+BA,IAAM,sBAAN,cAA+CA,mBAAAA,4BAG7C;CACA,MAAM,eACJ,OACA,aAC0B;AAQ1B,SANkC,CAChC;GACE,MAAM;GACN,OAJU,MAAM,KAAK,IAAI,sBAAuB,MAAM;GAKvD,CACF;;;AASL,IAAM,kBAAN,cAA2CC,oBAAAA,eAA4B;CACrE,YAAY,QAAqC;AAC/C,QAAM,OAAO;AACb,OAAK,YAAY,4BAAA,SAA4C;;CAG/D,sBACE,QACwB;AACxB,SAAO,OAAO,WAAW;;;;;;AAO7B,IAAsB,gBAAtB,cACUC,qCAAAA,IAEV;CAEE,OAAO,UAAU;AACf,SAAO;;CAGT,IAAI,aAAoD;AACtD,SAAO,EACL,aAAa,uBACd;;CAGH;CAEA,kBAAkB;CAElB,YAAY;CAEZ,QAAQ;CAER,cAAc;CAEd,kBAAkB;CAElB,OAAO;CAEP,OAAO;CAEP,gBAA0B,EAAE;CAE5B,iBAA0C,EAAE;CAE5C;CAEA,mBAA6C;CAE7C;CAEA;CAEA,YAAY,QA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,GAAS,kBAAA,CAAmB,WAAA;EAAA,SAY/B,qBAAA,CACP,MAAA,GAAS,oBAAA,CAAqB,WAAA,IAC7B,sBAAA;EAEH,iBAAA,CAAkB,MAAA,WAAiB,sBAAA;EAInC,WAAA,CAAY,MAAA,GAAS,oBAAA,CAAqB,WAAA;EAI1C,WAAA,CACE,MAAA,GAAS,oBAAA,CAAqB,WAAA,IAC7B,sBAAA;EASH,eAAA,CACE,MAAA,EAAQ,kBAAA,CAAmB,WAAA,GAC3B,MAAA,EAAQ,sBAAA;EAAA,IAiBN,QAAA,CAAA,GAAY,kBAAA;EAKhB,QAAA,CAAA;EAIA,YAAA,CAAa,MAAA,WAAiB,cAAA;EArEZ;;;;;;EA+EZ,KAAA,CACJ,MAAA,UACA,OAAA,8BACC,OAAA;EAUI,eAAA,CACL,KAAA,EAAO,sBAAA,EACP,OAAA,GAAU,4BAAA,GACT,cAAA;EA8DG,eAAA,CACJ,QAAA,EAAU,WAAA,IACV,OAAA,cAAqB,4BAAA,EACrB,UAAA,GAAa,SAAA,GACZ,OAAA,CAAQ,WAAA;EA7IR;;;;;;EAAA,UA8JO,eAAA,CAAA,GAAmB,cAAA,CAAe,WAAA;EAStC,MAAA,CACJ,KAAA,EAAO,sBAAA,EACP,OAAA,GAAU,4BAAA,GACT,OAAA;AAAA"}
|
package/dist/llms.js
CHANGED
|
@@ -20,7 +20,7 @@ var GoogleLLMConnection = class extends AbstractGoogleLLMConnection {
|
|
|
20
20
|
var ProxyChatGoogle = class extends ChatGoogleBase {
|
|
21
21
|
constructor(fields) {
|
|
22
22
|
super(fields);
|
|
23
|
-
this._addVersion("@langchain/google-common", "2.1.
|
|
23
|
+
this._addVersion("@langchain/google-common", "2.1.28");
|
|
24
24
|
}
|
|
25
25
|
buildAbstractedClient(fields) {
|
|
26
26
|
return fields.connection.client;
|
|
@@ -102,10 +102,14 @@ var GoogleBaseLLM = class extends LLM {
|
|
|
102
102
|
async *_streamIterator(input, options) {
|
|
103
103
|
const prompt = BaseLLM._convertInputToPromptValue(input);
|
|
104
104
|
const [runnableConfig, callOptions] = this._separateRunnableConfigFromCallOptions(options);
|
|
105
|
-
const
|
|
105
|
+
const invocationParams = this.invocationParams(callOptions);
|
|
106
|
+
const callbackManager_ = await CallbackManager.configure(runnableConfig.callbacks, this.callbacks, runnableConfig.tags, this.tags, runnableConfig.metadata, this.metadata, {
|
|
107
|
+
verbose: this.verbose,
|
|
108
|
+
tracerInheritableMetadata: this._filterInvocationParamsForTracing(invocationParams)
|
|
109
|
+
});
|
|
106
110
|
const extra = {
|
|
107
111
|
options: callOptions,
|
|
108
|
-
invocation_params:
|
|
112
|
+
invocation_params: invocationParams,
|
|
109
113
|
batch_size: 1
|
|
110
114
|
};
|
|
111
115
|
const runManagers = await callbackManager_?.handleLLMStart(this.toJSON(), [prompt.toString()], void 0, void 0, extra, void 0, void 0, runnableConfig.runName);
|
package/dist/llms.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llms.js","names":[],"sources":["../src/llms.ts"],"sourcesContent":["import { CallbackManager, Callbacks } from \"@langchain/core/callbacks/manager\";\nimport { BaseLLM, LLM } from \"@langchain/core/language_models/llms\";\nimport {\n type BaseLanguageModelCallOptions,\n BaseLanguageModelInput,\n} from \"@langchain/core/language_models/base\";\nimport { BaseMessage, MessageContent } from \"@langchain/core/messages\";\nimport { GenerationChunk } from \"@langchain/core/outputs\";\nimport { getEnvironmentVariable } from \"@langchain/core/utils/env\";\n\nimport { AbstractGoogleLLMConnection } from \"./connection.js\";\nimport {\n GoogleAIBaseLLMInput,\n GoogleAIModelParams,\n GoogleAISafetySetting,\n GooglePlatformType,\n GeminiContent,\n GoogleAIResponseMimeType,\n} from \"./types.js\";\nimport {\n copyAIModelParams,\n copyAndValidateModelParamsInto,\n} from \"./utils/common.js\";\nimport { DefaultGeminiSafetyHandler } from \"./utils/gemini.js\";\nimport { ApiKeyGoogleAuth, GoogleAbstractedClient } from \"./auth.js\";\nimport { ensureParams } from \"./utils/failed_handler.js\";\nimport { ChatGoogleBase } from \"./chat_models.js\";\nimport type { GoogleBaseLLMInput, GoogleAISafetyHandler } from \"./types.js\";\n\nexport { GoogleBaseLLMInput };\n\nclass GoogleLLMConnection<AuthOptions> extends AbstractGoogleLLMConnection<\n MessageContent,\n AuthOptions\n> {\n async formatContents(\n input: MessageContent,\n _parameters: GoogleAIModelParams\n ): Promise<GeminiContent[]> {\n const parts = await this.api.messageContentToParts!(input);\n const contents: GeminiContent[] = [\n {\n role: \"user\", // Required by Vertex AI\n parts,\n },\n ];\n return contents;\n }\n}\n\ntype ProxyChatInput<AuthOptions> = GoogleAIBaseLLMInput<AuthOptions> & {\n connection: GoogleLLMConnection<AuthOptions>;\n};\n\nclass ProxyChatGoogle<AuthOptions> extends ChatGoogleBase<AuthOptions> {\n constructor(fields: ProxyChatInput<AuthOptions>) {\n super(fields);\n this._addVersion(\"@langchain/google-common\", __PKG_VERSION__);\n }\n\n buildAbstractedClient(\n fields: ProxyChatInput<AuthOptions>\n ): GoogleAbstractedClient {\n return fields.connection.client;\n }\n}\n\n/**\n * Integration with an LLM.\n */\nexport abstract class GoogleBaseLLM<AuthOptions>\n extends LLM<BaseLanguageModelCallOptions>\n implements GoogleBaseLLMInput<AuthOptions>\n{\n // Used for tracing, replace with the same name as your class\n static lc_name() {\n return \"GoogleLLM\";\n }\n\n get lc_secrets(): { [key: string]: string } | undefined {\n return {\n authOptions: \"GOOGLE_AUTH_OPTIONS\",\n };\n }\n\n originalFields?: GoogleBaseLLMInput<AuthOptions>;\n\n lc_serializable = true;\n\n modelName = \"gemini-pro\";\n\n model = \"gemini-pro\";\n\n temperature = 0.7;\n\n maxOutputTokens = 1024;\n\n topP = 0.8;\n\n topK = 40;\n\n stopSequences: string[] = [];\n\n safetySettings: GoogleAISafetySetting[] = [];\n\n safetyHandler: GoogleAISafetyHandler;\n\n responseMimeType: GoogleAIResponseMimeType = \"text/plain\";\n\n protected connection: GoogleLLMConnection<AuthOptions>;\n\n protected streamedConnection: GoogleLLMConnection<AuthOptions>;\n\n constructor(fields?: GoogleBaseLLMInput<AuthOptions>) {\n super(ensureParams(fields));\n this.originalFields = fields;\n\n copyAndValidateModelParamsInto(fields, this);\n this.safetyHandler =\n fields?.safetyHandler ?? new DefaultGeminiSafetyHandler();\n\n const client = this.buildClient(fields);\n this.buildConnection(fields ?? {}, client);\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 GoogleLLMConnection(\n { ...fields, ...this },\n this.caller,\n client,\n false\n );\n\n this.streamedConnection = new GoogleLLMConnection(\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 // Replace\n _llmType() {\n return \"googlellm\";\n }\n\n formatPrompt(prompt: string): MessageContent {\n return prompt;\n }\n\n /**\n * For some given input string and options, return a string output.\n *\n * Despite the fact that `invoke` is overridden below, we still need this\n * in order to handle public APi calls to `generate()`.\n */\n async _call(\n prompt: string,\n options: this[\"ParsedCallOptions\"]\n ): Promise<string> {\n const parameters = copyAIModelParams(this, options);\n const result = await this.connection.request(prompt, parameters, options);\n const ret = this.connection.api.responseToString(result);\n return ret;\n }\n\n // Normally, you should not override this method and instead should override\n // _streamResponseChunks. We are doing so here to allow for multimodal inputs into\n // the LLM.\n async *_streamIterator(\n input: BaseLanguageModelInput,\n options?: BaseLanguageModelCallOptions\n ): AsyncGenerator<string> {\n // TODO: Refactor callback setup and teardown code into core\n const prompt = BaseLLM._convertInputToPromptValue(input);\n const [runnableConfig, callOptions] =\n this._separateRunnableConfigFromCallOptions(options);\n const callbackManager_ = await CallbackManager.configure(\n runnableConfig.callbacks,\n this.callbacks,\n runnableConfig.tags,\n this.tags,\n runnableConfig.metadata,\n this.metadata,\n { verbose: this.verbose }\n );\n const extra = {\n options: callOptions,\n invocation_params: this?.invocationParams(callOptions),\n batch_size: 1,\n };\n const runManagers = await callbackManager_?.handleLLMStart(\n this.toJSON(),\n [prompt.toString()],\n undefined,\n undefined,\n extra,\n undefined,\n undefined,\n runnableConfig.runName\n );\n let generation = new GenerationChunk({\n text: \"\",\n });\n const proxyChat = this.createProxyChat();\n try {\n for await (const chunk of proxyChat._streamIterator(input, options)) {\n const stringValue = this.connection.api.chunkToString(chunk);\n const generationChunk = new GenerationChunk({\n text: stringValue,\n });\n generation = generation.concat(generationChunk);\n yield stringValue;\n }\n } catch (err) {\n await Promise.all(\n (runManagers ?? []).map((runManager) => runManager?.handleLLMError(err))\n );\n throw err;\n }\n await Promise.all(\n (runManagers ?? []).map((runManager) =>\n runManager?.handleLLMEnd({\n generations: [[generation]],\n })\n )\n );\n }\n\n async predictMessages(\n messages: BaseMessage[],\n options?: string[] | BaseLanguageModelCallOptions,\n _callbacks?: Callbacks\n ): Promise<BaseMessage> {\n const { content } = messages[0];\n const result = await this.connection.request(\n content,\n {},\n options as BaseLanguageModelCallOptions\n );\n const ret = this.connection.api.responseToBaseMessage(result);\n return ret;\n }\n\n /**\n * Internal implementation detail to allow Google LLMs to support\n * multimodal input by delegating to the chat model implementation.\n *\n * TODO: Replace with something less hacky.\n */\n protected createProxyChat(): ChatGoogleBase<AuthOptions> {\n return new ProxyChatGoogle<AuthOptions>({\n ...this.originalFields,\n connection: this.connection,\n });\n }\n\n // TODO: Remove the need to override this - we are doing it to\n // allow the LLM to handle multimodal types of input.\n async invoke(\n input: BaseLanguageModelInput,\n options?: BaseLanguageModelCallOptions\n ): Promise<string> {\n const stream = await this._streamIterator(input, options);\n let generatedOutput = \"\";\n for await (const chunk of stream) {\n generatedOutput += chunk;\n }\n return generatedOutput;\n }\n}\n"],"mappings":";;;;;;;;;;;AA+BA,IAAM,sBAAN,cAA+C,4BAG7C;CACA,MAAM,eACJ,OACA,aAC0B;AAQ1B,SANkC,CAChC;GACE,MAAM;GACN,OAJU,MAAM,KAAK,IAAI,sBAAuB,MAAM;GAKvD,CACF;;;AASL,IAAM,kBAAN,cAA2C,eAA4B;CACrE,YAAY,QAAqC;AAC/C,QAAM,OAAO;AACb,OAAK,YAAY,4BAAA,SAA4C;;CAG/D,sBACE,QACwB;AACxB,SAAO,OAAO,WAAW;;;;;;AAO7B,IAAsB,gBAAtB,cACU,IAEV;CAEE,OAAO,UAAU;AACf,SAAO;;CAGT,IAAI,aAAoD;AACtD,SAAO,EACL,aAAa,uBACd;;CAGH;CAEA,kBAAkB;CAElB,YAAY;CAEZ,QAAQ;CAER,cAAc;CAEd,kBAAkB;CAElB,OAAO;CAEP,OAAO;CAEP,gBAA0B,EAAE;CAE5B,iBAA0C,EAAE;CAE5C;CAEA,mBAA6C;CAE7C;CAEA;CAEA,YAAY,QAA0C;AACpD,QAAM,aAAa,OAAO,CAAC;AAC3B,OAAK,iBAAiB;AAEtB,iCAA+B,QAAQ,KAAK;AAC5C,OAAK,gBACH,QAAQ,iBAAiB,IAAI,4BAA4B;EAE3D,MAAM,SAAS,KAAK,YAAY,OAAO;AACvC,OAAK,gBAAgB,UAAU,EAAE,EAAE,OAAO;;CAO5C,kBAAkB,QAAwC;AACxD,SAAO,IAAI,iBAAiB,OAAO;;CAGrC,YAAY,QAAgE;AAC1E,SAAO,QAAQ,UAAU,uBAAuB,iBAAiB;;CAGnE,YACE,QACwB;EACxB,MAAM,SAAS,KAAK,YAAY,OAAO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AAK,WAAW,IAAI,cAAc,MAAM;IAC5D,MAAM,kBAAkB,IAAI,gBAAgB,EAC1C,MAAM,aACP,CAAC;AACF,iBAAa,WAAW,OAAO,gBAAgB;AAC/C,UAAM;;WAED,KAAK;AACZ,SAAM,QAAQ,KACX,eAAe,EAAE,EAAE,KAAK,eAAe,YAAY,eAAe,IAAI,CAAC,CACzE;AACD,SAAM;;AAER,QAAM,QAAQ,KACX,eAAe,EAAE,EAAE,KAAK,eACvB,YAAY,aAAa,EACvB,aAAa,CAAC,CAAC,WAAW,CAAC,EAC5B,CAAC,CACH,CACF;;CAGH,MAAM,gBACJ,UACA,SACA,YACsB;EACtB,MAAM,EAAE,YAAY,SAAS;EAC7B,MAAM,SAAS,MAAM,KAAK,WAAW,QACnC,SACA,EAAE,EACF,QACD;AAED,SADY,KAAK,WAAW,IAAI,sBAAsB,OAAO;;;;;;;;CAU/D,kBAAyD;AACvD,SAAO,IAAI,gBAA6B;GACtC,GAAG,KAAK;GACR,YAAY,KAAK;GAClB,CAAC;;CAKJ,MAAM,OACJ,OACA,SACiB;EACjB,MAAM,SAAS,MAAM,KAAK,gBAAgB,OAAO,QAAQ;EACzD,IAAI,kBAAkB;AACtB,aAAW,MAAM,SAAS,OACxB,oBAAmB;AAErB,SAAO"}
|
|
1
|
+
{"version":3,"file":"llms.js","names":[],"sources":["../src/llms.ts"],"sourcesContent":["import { CallbackManager, Callbacks } from \"@langchain/core/callbacks/manager\";\nimport { BaseLLM, LLM } from \"@langchain/core/language_models/llms\";\nimport {\n type BaseLanguageModelCallOptions,\n BaseLanguageModelInput,\n} from \"@langchain/core/language_models/base\";\nimport { BaseMessage, MessageContent } from \"@langchain/core/messages\";\nimport { GenerationChunk } from \"@langchain/core/outputs\";\nimport { getEnvironmentVariable } from \"@langchain/core/utils/env\";\n\nimport { AbstractGoogleLLMConnection } from \"./connection.js\";\nimport {\n GoogleAIBaseLLMInput,\n GoogleAIModelParams,\n GoogleAISafetySetting,\n GooglePlatformType,\n GeminiContent,\n GoogleAIResponseMimeType,\n} from \"./types.js\";\nimport {\n copyAIModelParams,\n copyAndValidateModelParamsInto,\n} from \"./utils/common.js\";\nimport { DefaultGeminiSafetyHandler } from \"./utils/gemini.js\";\nimport { ApiKeyGoogleAuth, GoogleAbstractedClient } from \"./auth.js\";\nimport { ensureParams } from \"./utils/failed_handler.js\";\nimport { ChatGoogleBase } from \"./chat_models.js\";\nimport type { GoogleBaseLLMInput, GoogleAISafetyHandler } from \"./types.js\";\n\nexport { GoogleBaseLLMInput };\n\nclass GoogleLLMConnection<AuthOptions> extends AbstractGoogleLLMConnection<\n MessageContent,\n AuthOptions\n> {\n async formatContents(\n input: MessageContent,\n _parameters: GoogleAIModelParams\n ): Promise<GeminiContent[]> {\n const parts = await this.api.messageContentToParts!(input);\n const contents: GeminiContent[] = [\n {\n role: \"user\", // Required by Vertex AI\n parts,\n },\n ];\n return contents;\n }\n}\n\ntype ProxyChatInput<AuthOptions> = GoogleAIBaseLLMInput<AuthOptions> & {\n connection: GoogleLLMConnection<AuthOptions>;\n};\n\nclass ProxyChatGoogle<AuthOptions> extends ChatGoogleBase<AuthOptions> {\n constructor(fields: ProxyChatInput<AuthOptions>) {\n super(fields);\n this._addVersion(\"@langchain/google-common\", __PKG_VERSION__);\n }\n\n buildAbstractedClient(\n fields: ProxyChatInput<AuthOptions>\n ): GoogleAbstractedClient {\n return fields.connection.client;\n }\n}\n\n/**\n * Integration with an LLM.\n */\nexport abstract class GoogleBaseLLM<AuthOptions>\n extends LLM<BaseLanguageModelCallOptions>\n implements GoogleBaseLLMInput<AuthOptions>\n{\n // Used for tracing, replace with the same name as your class\n static lc_name() {\n return \"GoogleLLM\";\n }\n\n get lc_secrets(): { [key: string]: string } | undefined {\n return {\n authOptions: \"GOOGLE_AUTH_OPTIONS\",\n };\n }\n\n originalFields?: GoogleBaseLLMInput<AuthOptions>;\n\n lc_serializable = true;\n\n modelName = \"gemini-pro\";\n\n model = \"gemini-pro\";\n\n temperature = 0.7;\n\n maxOutputTokens = 1024;\n\n topP = 0.8;\n\n topK = 40;\n\n stopSequences: string[] = [];\n\n safetySettings: GoogleAISafetySetting[] = [];\n\n safetyHandler: GoogleAISafetyHandler;\n\n responseMimeType: GoogleAIResponseMimeType = \"text/plain\";\n\n protected connection: GoogleLLMConnection<AuthOptions>;\n\n protected streamedConnection: GoogleLLMConnection<AuthOptions>;\n\n constructor(fields?: GoogleBaseLLMInput<AuthOptions>) {\n super(ensureParams(fields));\n this.originalFields = fields;\n\n copyAndValidateModelParamsInto(fields, this);\n this.safetyHandler =\n fields?.safetyHandler ?? new DefaultGeminiSafetyHandler();\n\n const client = this.buildClient(fields);\n this.buildConnection(fields ?? {}, client);\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 GoogleLLMConnection(\n { ...fields, ...this },\n this.caller,\n client,\n false\n );\n\n this.streamedConnection = new GoogleLLMConnection(\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 // Replace\n _llmType() {\n return \"googlellm\";\n }\n\n formatPrompt(prompt: string): MessageContent {\n return prompt;\n }\n\n /**\n * For some given input string and options, return a string output.\n *\n * Despite the fact that `invoke` is overridden below, we still need this\n * in order to handle public APi calls to `generate()`.\n */\n async _call(\n prompt: string,\n options: this[\"ParsedCallOptions\"]\n ): Promise<string> {\n const parameters = copyAIModelParams(this, options);\n const result = await this.connection.request(prompt, parameters, options);\n const ret = this.connection.api.responseToString(result);\n return ret;\n }\n\n // Normally, you should not override this method and instead should override\n // _streamResponseChunks. We are doing so here to allow for multimodal inputs into\n // the LLM.\n async *_streamIterator(\n input: BaseLanguageModelInput,\n options?: BaseLanguageModelCallOptions\n ): AsyncGenerator<string> {\n // TODO: Refactor callback setup and teardown code into core\n const prompt = BaseLLM._convertInputToPromptValue(input);\n const [runnableConfig, callOptions] =\n this._separateRunnableConfigFromCallOptions(options);\n const invocationParams = this.invocationParams(callOptions);\n const callbackManager_ = await CallbackManager.configure(\n runnableConfig.callbacks,\n this.callbacks,\n runnableConfig.tags,\n this.tags,\n runnableConfig.metadata,\n this.metadata,\n {\n verbose: this.verbose,\n tracerInheritableMetadata:\n this._filterInvocationParamsForTracing(invocationParams),\n }\n );\n const extra = {\n options: callOptions,\n invocation_params: invocationParams,\n batch_size: 1,\n };\n const runManagers = await callbackManager_?.handleLLMStart(\n this.toJSON(),\n [prompt.toString()],\n undefined,\n undefined,\n extra,\n undefined,\n undefined,\n runnableConfig.runName\n );\n let generation = new GenerationChunk({\n text: \"\",\n });\n const proxyChat = this.createProxyChat();\n try {\n for await (const chunk of proxyChat._streamIterator(input, options)) {\n const stringValue = this.connection.api.chunkToString(chunk);\n const generationChunk = new GenerationChunk({\n text: stringValue,\n });\n generation = generation.concat(generationChunk);\n yield stringValue;\n }\n } catch (err) {\n await Promise.all(\n (runManagers ?? []).map((runManager) => runManager?.handleLLMError(err))\n );\n throw err;\n }\n await Promise.all(\n (runManagers ?? []).map((runManager) =>\n runManager?.handleLLMEnd({\n generations: [[generation]],\n })\n )\n );\n }\n\n async predictMessages(\n messages: BaseMessage[],\n options?: string[] | BaseLanguageModelCallOptions,\n _callbacks?: Callbacks\n ): Promise<BaseMessage> {\n const { content } = messages[0];\n const result = await this.connection.request(\n content,\n {},\n options as BaseLanguageModelCallOptions\n );\n const ret = this.connection.api.responseToBaseMessage(result);\n return ret;\n }\n\n /**\n * Internal implementation detail to allow Google LLMs to support\n * multimodal input by delegating to the chat model implementation.\n *\n * TODO: Replace with something less hacky.\n */\n protected createProxyChat(): ChatGoogleBase<AuthOptions> {\n return new ProxyChatGoogle<AuthOptions>({\n ...this.originalFields,\n connection: this.connection,\n });\n }\n\n // TODO: Remove the need to override this - we are doing it to\n // allow the LLM to handle multimodal types of input.\n async invoke(\n input: BaseLanguageModelInput,\n options?: BaseLanguageModelCallOptions\n ): Promise<string> {\n const stream = await this._streamIterator(input, options);\n let generatedOutput = \"\";\n for await (const chunk of stream) {\n generatedOutput += chunk;\n }\n return generatedOutput;\n }\n}\n"],"mappings":";;;;;;;;;;;AA+BA,IAAM,sBAAN,cAA+C,4BAG7C;CACA,MAAM,eACJ,OACA,aAC0B;AAQ1B,SANkC,CAChC;GACE,MAAM;GACN,OAJU,MAAM,KAAK,IAAI,sBAAuB,MAAM;GAKvD,CACF;;;AASL,IAAM,kBAAN,cAA2C,eAA4B;CACrE,YAAY,QAAqC;AAC/C,QAAM,OAAO;AACb,OAAK,YAAY,4BAAA,SAA4C;;CAG/D,sBACE,QACwB;AACxB,SAAO,OAAO,WAAW;;;;;;AAO7B,IAAsB,gBAAtB,cACU,IAEV;CAEE,OAAO,UAAU;AACf,SAAO;;CAGT,IAAI,aAAoD;AACtD,SAAO,EACL,aAAa,uBACd;;CAGH;CAEA,kBAAkB;CAElB,YAAY;CAEZ,QAAQ;CAER,cAAc;CAEd,kBAAkB;CAElB,OAAO;CAEP,OAAO;CAEP,gBAA0B,EAAE;CAE5B,iBAA0C,EAAE;CAE5C;CAEA,mBAA6C;CAE7C;CAEA;CAEA,YAAY,QAA0C;AACpD,QAAM,aAAa,OAAO,CAAC;AAC3B,OAAK,iBAAiB;AAEtB,iCAA+B,QAAQ,KAAK;AAC5C,OAAK,gBACH,QAAQ,iBAAiB,IAA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
"version": "2.1.28",
|
|
4
4
|
"description": "Core types and classes for Google services.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"uuid": "^10.0.0"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
|
-
"@langchain/core": "^1.1.
|
|
20
|
+
"@langchain/core": "^1.1.41"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/uuid": "^10.0.0",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"typescript": "~5.8.3",
|
|
28
28
|
"vitest": "^4.1.2",
|
|
29
29
|
"zod": "^3.25.76",
|
|
30
|
-
"@langchain/core": "^1.1.
|
|
30
|
+
"@langchain/core": "^1.1.41",
|
|
31
31
|
"@langchain/tsconfig": "0.0.1"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|