@langchain/google 0.2.6 → 0.2.7

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @langchain/google
2
2
 
3
+ ## 0.2.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [#11664](https://github.com/langchain-ai/langchainjs/pull/11664) [`16c5a5e`](https://github.com/langchain-ai/langchainjs/commit/16c5a5e7284b14ee81ec0140a144e097712c48bc) Thanks [@jackjin1997](https://github.com/jackjin1997)! - Configure the required OAuth scopes when the Node.js client falls back to Application Default Credentials.
8
+
3
9
  ## 0.2.6
4
10
 
5
11
  ### Patch Changes
@@ -107,7 +107,7 @@ var BaseChatGoogle = class extends _langchain_core_language_models_chat_models.B
107
107
  constructor(params) {
108
108
  super(params);
109
109
  this.params = params;
110
- this._addVersion("@langchain/google", "0.2.6");
110
+ this._addVersion("@langchain/google", "0.2.7");
111
111
  if (!params.apiClient) throw new require_errors.ConfigurationError("BaseChatGoogle requires an apiClient. This should be provided automatically by ChatGoogle constructors. If you're extending BaseChatGoogle directly, please provide an apiClient instance.");
112
112
  this.apiClient = params.apiClient;
113
113
  this.model = params.model;
@@ -107,7 +107,7 @@ var BaseChatGoogle = class extends BaseChatModel {
107
107
  constructor(params) {
108
108
  super(params);
109
109
  this.params = params;
110
- this._addVersion("@langchain/google", "0.2.6");
110
+ this._addVersion("@langchain/google", "0.2.7");
111
111
  if (!params.apiClient) throw new ConfigurationError("BaseChatGoogle requires an apiClient. This should be provided automatically by ChatGoogle constructors. If you're extending BaseChatGoogle directly, please provide an apiClient instance.");
112
112
  this.apiClient = params.apiClient;
113
113
  this.model = params.model;
@@ -12,7 +12,8 @@ var ChatGoogleNode = class extends require_base.BaseChatGoogle {
12
12
  params.apiKey = params.apiKey ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("GOOGLE_API_KEY");
13
13
  }
14
14
  const requiredScopes = getRequiredAuthScopes(params);
15
- if (params.googleAuthOptions) params.googleAuthOptions = require_node.ensureAuthScopes(params.googleAuthOptions, requiredScopes);
15
+ const usesImplicitGoogleAuth = !params.apiClient && !params.apiKey && !params.credentials && !(0, _langchain_core_utils_env.getEnvironmentVariable)("GOOGLE_CLOUD_CREDENTIALS");
16
+ if (params.googleAuthOptions || usesImplicitGoogleAuth) params.googleAuthOptions = require_node.ensureAuthScopes(params.googleAuthOptions ?? {}, requiredScopes);
16
17
  const apiClient = params?.apiClient ?? new require_node.NodeApiClient(params);
17
18
  super({
18
19
  ...params,
@@ -1 +1 @@
1
- {"version":3,"file":"node.cjs","names":["BaseChatGoogle","getGoogleChatModelParams","applyGeminiGatewayParams","getEnvironmentVariable","ensureAuthScopes","NodeApiClient","convertParamsToPlatformType","getPlatformType","GENERATIVE_AI_AUTH_SCOPES","VERTEX_AI_AUTH_SCOPES"],"sources":["../../src/chat_models/node.ts"],"sourcesContent":["import { getEnvironmentVariable } from \"@langchain/core/utils/env\";\nimport { ChatGoogleParams } from \"./index.js\";\nimport {\n applyGeminiGatewayParams,\n BaseChatGoogle,\n getGoogleChatModelParams,\n getPlatformType,\n} from \"./base.js\";\nimport { GENERATIVE_AI_AUTH_SCOPES, VERTEX_AI_AUTH_SCOPES } from \"../const.js\";\nimport {\n ensureAuthScopes,\n NodeApiClient,\n NodeApiClientParams,\n} from \"../clients/node.js\";\nimport { convertParamsToPlatformType } from \"../converters/params.js\";\n\ninterface ChatGoogleNodeParams extends NodeApiClientParams, ChatGoogleParams {}\n\nclass ChatGoogleNode extends BaseChatGoogle {\n constructor(model: string, params?: Omit<ChatGoogleNodeParams, \"model\">);\n constructor(params: ChatGoogleNodeParams);\n constructor(\n modelOrParams: string | ChatGoogleNodeParams,\n paramsArg?: Omit<ChatGoogleNodeParams, \"model\">\n ) {\n let params = getGoogleChatModelParams(modelOrParams, paramsArg);\n if (!params.googleAuthOptions) {\n // Route through the LangSmith gateway (Gemini Developer API path) when\n // configured, before falling back to the provider API-key env var so the\n // gateway key can take precedence. Skipped when Vertex OAuth\n // (`googleAuthOptions`) is used, which the gateway does not proxy.\n params = applyGeminiGatewayParams(params);\n params.apiKey = params.apiKey ?? getEnvironmentVariable(\"GOOGLE_API_KEY\");\n }\n const requiredScopes: string[] = getRequiredAuthScopes(params);\n if (params.googleAuthOptions) {\n params.googleAuthOptions = ensureAuthScopes(\n params.googleAuthOptions,\n requiredScopes\n );\n }\n const apiClient = params?.apiClient ?? new NodeApiClient(params);\n super({ ...params, apiClient });\n }\n}\n\nfunction getRequiredAuthScopes(params: ChatGoogleNodeParams): string[] {\n const hasApiKey = typeof params.apiKey !== \"undefined\";\n const platformType = convertParamsToPlatformType(params);\n const platform = getPlatformType(platformType, hasApiKey);\n switch (platform) {\n case \"gai\":\n return GENERATIVE_AI_AUTH_SCOPES;\n case \"gcp\":\n return VERTEX_AI_AUTH_SCOPES;\n default:\n return VERTEX_AI_AUTH_SCOPES;\n }\n}\n\nexport {\n type ChatGoogleNodeParams as ChatGoogleParams,\n ChatGoogleNode as ChatGoogle,\n};\n"],"mappings":";;;;;;AAkBA,IAAM,iBAAN,cAA6BA,aAAAA,eAAe;CAG1C,YACE,eACA,WACA;EACA,IAAI,SAASC,aAAAA,yBAAyB,eAAe,SAAS;EAC9D,IAAI,CAAC,OAAO,mBAAmB;GAK7B,SAASC,aAAAA,yBAAyB,MAAM;GACxC,OAAO,SAAS,OAAO,WAAA,GAAUC,0BAAAA,uBAAAA,CAAuB,gBAAgB;EAC1E;EACA,MAAM,iBAA2B,sBAAsB,MAAM;EAC7D,IAAI,OAAO,mBACT,OAAO,oBAAoBC,aAAAA,iBACzB,OAAO,mBACP,cACF;EAEF,MAAM,YAAY,QAAQ,aAAa,IAAIC,aAAAA,cAAc,MAAM;EAC/D,MAAM;GAAE,GAAG;GAAQ;EAAU,CAAC;CAChC;AACF;AAEA,SAAS,sBAAsB,QAAwC;CACrE,MAAM,YAAY,OAAO,OAAO,WAAW;CAC3C,MAAM,eAAeC,eAAAA,4BAA4B,MAAM;CAEvD,QADiBC,aAAAA,gBAAgB,cAAc,SAChC,GAAf;EACE,KAAK,OACH,OAAOC,cAAAA;EACT,KAAK,OACH,OAAOC,cAAAA;EACT,SACE,OAAOA,cAAAA;CACX;AACF"}
1
+ {"version":3,"file":"node.cjs","names":["BaseChatGoogle","getGoogleChatModelParams","applyGeminiGatewayParams","getEnvironmentVariable","ensureAuthScopes","NodeApiClient","convertParamsToPlatformType","getPlatformType","GENERATIVE_AI_AUTH_SCOPES","VERTEX_AI_AUTH_SCOPES"],"sources":["../../src/chat_models/node.ts"],"sourcesContent":["import { getEnvironmentVariable } from \"@langchain/core/utils/env\";\nimport { ChatGoogleParams } from \"./index.js\";\nimport {\n applyGeminiGatewayParams,\n BaseChatGoogle,\n getGoogleChatModelParams,\n getPlatformType,\n} from \"./base.js\";\nimport { GENERATIVE_AI_AUTH_SCOPES, VERTEX_AI_AUTH_SCOPES } from \"../const.js\";\nimport {\n ensureAuthScopes,\n NodeApiClient,\n NodeApiClientParams,\n} from \"../clients/node.js\";\nimport { convertParamsToPlatformType } from \"../converters/params.js\";\n\ninterface ChatGoogleNodeParams extends NodeApiClientParams, ChatGoogleParams {}\n\nclass ChatGoogleNode extends BaseChatGoogle {\n constructor(model: string, params?: Omit<ChatGoogleNodeParams, \"model\">);\n constructor(params: ChatGoogleNodeParams);\n constructor(\n modelOrParams: string | ChatGoogleNodeParams,\n paramsArg?: Omit<ChatGoogleNodeParams, \"model\">\n ) {\n let params = getGoogleChatModelParams(modelOrParams, paramsArg);\n if (!params.googleAuthOptions) {\n // Route through the LangSmith gateway (Gemini Developer API path) when\n // configured, before falling back to the provider API-key env var so the\n // gateway key can take precedence. Skipped when Vertex OAuth\n // (`googleAuthOptions`) is used, which the gateway does not proxy.\n params = applyGeminiGatewayParams(params);\n params.apiKey = params.apiKey ?? getEnvironmentVariable(\"GOOGLE_API_KEY\");\n }\n const requiredScopes: string[] = getRequiredAuthScopes(params);\n const usesImplicitGoogleAuth =\n !params.apiClient &&\n !params.apiKey &&\n !params.credentials &&\n !getEnvironmentVariable(\"GOOGLE_CLOUD_CREDENTIALS\");\n if (params.googleAuthOptions || usesImplicitGoogleAuth) {\n params.googleAuthOptions = ensureAuthScopes(\n params.googleAuthOptions ?? {},\n requiredScopes\n );\n }\n const apiClient = params?.apiClient ?? new NodeApiClient(params);\n super({ ...params, apiClient });\n }\n}\n\nfunction getRequiredAuthScopes(params: ChatGoogleNodeParams): string[] {\n const hasApiKey = typeof params.apiKey !== \"undefined\";\n const platformType = convertParamsToPlatformType(params);\n const platform = getPlatformType(platformType, hasApiKey);\n switch (platform) {\n case \"gai\":\n return GENERATIVE_AI_AUTH_SCOPES;\n case \"gcp\":\n return VERTEX_AI_AUTH_SCOPES;\n default:\n return VERTEX_AI_AUTH_SCOPES;\n }\n}\n\nexport {\n type ChatGoogleNodeParams as ChatGoogleParams,\n ChatGoogleNode as ChatGoogle,\n};\n"],"mappings":";;;;;;AAkBA,IAAM,iBAAN,cAA6BA,aAAAA,eAAe;CAG1C,YACE,eACA,WACA;EACA,IAAI,SAASC,aAAAA,yBAAyB,eAAe,SAAS;EAC9D,IAAI,CAAC,OAAO,mBAAmB;GAK7B,SAASC,aAAAA,yBAAyB,MAAM;GACxC,OAAO,SAAS,OAAO,WAAA,GAAUC,0BAAAA,uBAAAA,CAAuB,gBAAgB;EAC1E;EACA,MAAM,iBAA2B,sBAAsB,MAAM;EAC7D,MAAM,yBACJ,CAAC,OAAO,aACR,CAAC,OAAO,UACR,CAAC,OAAO,eACR,EAAA,GAACA,0BAAAA,uBAAAA,CAAuB,0BAA0B;EACpD,IAAI,OAAO,qBAAqB,wBAC9B,OAAO,oBAAoBC,aAAAA,iBACzB,OAAO,qBAAqB,CAAC,GAC7B,cACF;EAEF,MAAM,YAAY,QAAQ,aAAa,IAAIC,aAAAA,cAAc,MAAM;EAC/D,MAAM;GAAE,GAAG;GAAQ;EAAU,CAAC;CAChC;AACF;AAEA,SAAS,sBAAsB,QAAwC;CACrE,MAAM,YAAY,OAAO,OAAO,WAAW;CAC3C,MAAM,eAAeC,eAAAA,4BAA4B,MAAM;CAEvD,QADiBC,aAAAA,gBAAgB,cAAc,SAChC,GAAf;EACE,KAAK,OACH,OAAOC,cAAAA;EACT,KAAK,OACH,OAAOC,cAAAA;EACT,SACE,OAAOA,cAAAA;CACX;AACF"}
@@ -12,7 +12,8 @@ var ChatGoogleNode = class extends BaseChatGoogle {
12
12
  params.apiKey = params.apiKey ?? getEnvironmentVariable("GOOGLE_API_KEY");
13
13
  }
14
14
  const requiredScopes = getRequiredAuthScopes(params);
15
- if (params.googleAuthOptions) params.googleAuthOptions = ensureAuthScopes(params.googleAuthOptions, requiredScopes);
15
+ const usesImplicitGoogleAuth = !params.apiClient && !params.apiKey && !params.credentials && !getEnvironmentVariable("GOOGLE_CLOUD_CREDENTIALS");
16
+ if (params.googleAuthOptions || usesImplicitGoogleAuth) params.googleAuthOptions = ensureAuthScopes(params.googleAuthOptions ?? {}, requiredScopes);
16
17
  const apiClient = params?.apiClient ?? new NodeApiClient(params);
17
18
  super({
18
19
  ...params,
@@ -1 +1 @@
1
- {"version":3,"file":"node.js","names":[],"sources":["../../src/chat_models/node.ts"],"sourcesContent":["import { getEnvironmentVariable } from \"@langchain/core/utils/env\";\nimport { ChatGoogleParams } from \"./index.js\";\nimport {\n applyGeminiGatewayParams,\n BaseChatGoogle,\n getGoogleChatModelParams,\n getPlatformType,\n} from \"./base.js\";\nimport { GENERATIVE_AI_AUTH_SCOPES, VERTEX_AI_AUTH_SCOPES } from \"../const.js\";\nimport {\n ensureAuthScopes,\n NodeApiClient,\n NodeApiClientParams,\n} from \"../clients/node.js\";\nimport { convertParamsToPlatformType } from \"../converters/params.js\";\n\ninterface ChatGoogleNodeParams extends NodeApiClientParams, ChatGoogleParams {}\n\nclass ChatGoogleNode extends BaseChatGoogle {\n constructor(model: string, params?: Omit<ChatGoogleNodeParams, \"model\">);\n constructor(params: ChatGoogleNodeParams);\n constructor(\n modelOrParams: string | ChatGoogleNodeParams,\n paramsArg?: Omit<ChatGoogleNodeParams, \"model\">\n ) {\n let params = getGoogleChatModelParams(modelOrParams, paramsArg);\n if (!params.googleAuthOptions) {\n // Route through the LangSmith gateway (Gemini Developer API path) when\n // configured, before falling back to the provider API-key env var so the\n // gateway key can take precedence. Skipped when Vertex OAuth\n // (`googleAuthOptions`) is used, which the gateway does not proxy.\n params = applyGeminiGatewayParams(params);\n params.apiKey = params.apiKey ?? getEnvironmentVariable(\"GOOGLE_API_KEY\");\n }\n const requiredScopes: string[] = getRequiredAuthScopes(params);\n if (params.googleAuthOptions) {\n params.googleAuthOptions = ensureAuthScopes(\n params.googleAuthOptions,\n requiredScopes\n );\n }\n const apiClient = params?.apiClient ?? new NodeApiClient(params);\n super({ ...params, apiClient });\n }\n}\n\nfunction getRequiredAuthScopes(params: ChatGoogleNodeParams): string[] {\n const hasApiKey = typeof params.apiKey !== \"undefined\";\n const platformType = convertParamsToPlatformType(params);\n const platform = getPlatformType(platformType, hasApiKey);\n switch (platform) {\n case \"gai\":\n return GENERATIVE_AI_AUTH_SCOPES;\n case \"gcp\":\n return VERTEX_AI_AUTH_SCOPES;\n default:\n return VERTEX_AI_AUTH_SCOPES;\n }\n}\n\nexport {\n type ChatGoogleNodeParams as ChatGoogleParams,\n ChatGoogleNode as ChatGoogle,\n};\n"],"mappings":";;;;;;AAkBA,IAAM,iBAAN,cAA6B,eAAe;CAG1C,YACE,eACA,WACA;EACA,IAAI,SAAS,yBAAyB,eAAe,SAAS;EAC9D,IAAI,CAAC,OAAO,mBAAmB;GAK7B,SAAS,yBAAyB,MAAM;GACxC,OAAO,SAAS,OAAO,UAAU,uBAAuB,gBAAgB;EAC1E;EACA,MAAM,iBAA2B,sBAAsB,MAAM;EAC7D,IAAI,OAAO,mBACT,OAAO,oBAAoB,iBACzB,OAAO,mBACP,cACF;EAEF,MAAM,YAAY,QAAQ,aAAa,IAAI,cAAc,MAAM;EAC/D,MAAM;GAAE,GAAG;GAAQ;EAAU,CAAC;CAChC;AACF;AAEA,SAAS,sBAAsB,QAAwC;CACrE,MAAM,YAAY,OAAO,OAAO,WAAW;CAC3C,MAAM,eAAe,4BAA4B,MAAM;CAEvD,QADiB,gBAAgB,cAAc,SAChC,GAAf;EACE,KAAK,OACH,OAAO;EACT,KAAK,OACH,OAAO;EACT,SACE,OAAO;CACX;AACF"}
1
+ {"version":3,"file":"node.js","names":[],"sources":["../../src/chat_models/node.ts"],"sourcesContent":["import { getEnvironmentVariable } from \"@langchain/core/utils/env\";\nimport { ChatGoogleParams } from \"./index.js\";\nimport {\n applyGeminiGatewayParams,\n BaseChatGoogle,\n getGoogleChatModelParams,\n getPlatformType,\n} from \"./base.js\";\nimport { GENERATIVE_AI_AUTH_SCOPES, VERTEX_AI_AUTH_SCOPES } from \"../const.js\";\nimport {\n ensureAuthScopes,\n NodeApiClient,\n NodeApiClientParams,\n} from \"../clients/node.js\";\nimport { convertParamsToPlatformType } from \"../converters/params.js\";\n\ninterface ChatGoogleNodeParams extends NodeApiClientParams, ChatGoogleParams {}\n\nclass ChatGoogleNode extends BaseChatGoogle {\n constructor(model: string, params?: Omit<ChatGoogleNodeParams, \"model\">);\n constructor(params: ChatGoogleNodeParams);\n constructor(\n modelOrParams: string | ChatGoogleNodeParams,\n paramsArg?: Omit<ChatGoogleNodeParams, \"model\">\n ) {\n let params = getGoogleChatModelParams(modelOrParams, paramsArg);\n if (!params.googleAuthOptions) {\n // Route through the LangSmith gateway (Gemini Developer API path) when\n // configured, before falling back to the provider API-key env var so the\n // gateway key can take precedence. Skipped when Vertex OAuth\n // (`googleAuthOptions`) is used, which the gateway does not proxy.\n params = applyGeminiGatewayParams(params);\n params.apiKey = params.apiKey ?? getEnvironmentVariable(\"GOOGLE_API_KEY\");\n }\n const requiredScopes: string[] = getRequiredAuthScopes(params);\n const usesImplicitGoogleAuth =\n !params.apiClient &&\n !params.apiKey &&\n !params.credentials &&\n !getEnvironmentVariable(\"GOOGLE_CLOUD_CREDENTIALS\");\n if (params.googleAuthOptions || usesImplicitGoogleAuth) {\n params.googleAuthOptions = ensureAuthScopes(\n params.googleAuthOptions ?? {},\n requiredScopes\n );\n }\n const apiClient = params?.apiClient ?? new NodeApiClient(params);\n super({ ...params, apiClient });\n }\n}\n\nfunction getRequiredAuthScopes(params: ChatGoogleNodeParams): string[] {\n const hasApiKey = typeof params.apiKey !== \"undefined\";\n const platformType = convertParamsToPlatformType(params);\n const platform = getPlatformType(platformType, hasApiKey);\n switch (platform) {\n case \"gai\":\n return GENERATIVE_AI_AUTH_SCOPES;\n case \"gcp\":\n return VERTEX_AI_AUTH_SCOPES;\n default:\n return VERTEX_AI_AUTH_SCOPES;\n }\n}\n\nexport {\n type ChatGoogleNodeParams as ChatGoogleParams,\n ChatGoogleNode as ChatGoogle,\n};\n"],"mappings":";;;;;;AAkBA,IAAM,iBAAN,cAA6B,eAAe;CAG1C,YACE,eACA,WACA;EACA,IAAI,SAAS,yBAAyB,eAAe,SAAS;EAC9D,IAAI,CAAC,OAAO,mBAAmB;GAK7B,SAAS,yBAAyB,MAAM;GACxC,OAAO,SAAS,OAAO,UAAU,uBAAuB,gBAAgB;EAC1E;EACA,MAAM,iBAA2B,sBAAsB,MAAM;EAC7D,MAAM,yBACJ,CAAC,OAAO,aACR,CAAC,OAAO,UACR,CAAC,OAAO,eACR,CAAC,uBAAuB,0BAA0B;EACpD,IAAI,OAAO,qBAAqB,wBAC9B,OAAO,oBAAoB,iBACzB,OAAO,qBAAqB,CAAC,GAC7B,cACF;EAEF,MAAM,YAAY,QAAQ,aAAa,IAAI,cAAc,MAAM;EAC/D,MAAM;GAAE,GAAG;GAAQ;EAAU,CAAC;CAChC;AACF;AAEA,SAAS,sBAAsB,QAAwC;CACrE,MAAM,YAAY,OAAO,OAAO,WAAW;CAC3C,MAAM,eAAe,4BAA4B,MAAM;CAEvD,QADiB,gBAAgB,cAAc,SAChC,GAAf;EACE,KAAK,OACH,OAAO;EACT,KAAK,OACH,OAAO;EACT,SACE,OAAO;CACX;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/google",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "Google integrations for LangChain.js",
5
5
  "author": "LangChain",
6
6
  "license": "MIT",
@@ -19,7 +19,7 @@
19
19
  "jose": "^6.2.10"
20
20
  },
21
21
  "peerDependencies": {
22
- "@langchain/core": "^1.2.11"
22
+ "@langchain/core": "^1.2.12"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@tsconfig/recommended": "^1.0.10",
@@ -30,7 +30,7 @@
30
30
  "vitest": "^4.1.11",
31
31
  "zod": "^3.25.76 || ^4",
32
32
  "zod-to-json-schema": "^3.25.2",
33
- "@langchain/core": "^1.2.11",
33
+ "@langchain/core": "^1.2.12",
34
34
  "@langchain/standard-tests": "0.0.23"
35
35
  },
36
36
  "publishConfig": {