@langchain/google-common 0.0.16 → 0.0.18
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/dist/chat_models.cjs +11 -0
- package/dist/chat_models.d.ts +2 -1
- package/dist/chat_models.js +11 -0
- package/dist/connection.cjs +1 -2
- package/dist/connection.js +1 -2
- package/dist/types.d.ts +1 -0
- package/dist/utils/zod_to_gemini_parameters.cjs +3 -0
- package/dist/utils/zod_to_gemini_parameters.js +3 -0
- package/package.json +5 -4
package/dist/chat_models.cjs
CHANGED
|
@@ -202,6 +202,17 @@ class ChatGoogleBase extends chat_models_1.BaseChatModel {
|
|
|
202
202
|
const client = this.buildClient(fields);
|
|
203
203
|
this.buildConnection(fields ?? {}, client);
|
|
204
204
|
}
|
|
205
|
+
getLsParams(options) {
|
|
206
|
+
const params = this.invocationParams(options);
|
|
207
|
+
return {
|
|
208
|
+
ls_provider: "google_vertexai",
|
|
209
|
+
ls_model_name: this.model,
|
|
210
|
+
ls_model_type: "chat",
|
|
211
|
+
ls_temperature: params.temperature ?? undefined,
|
|
212
|
+
ls_max_tokens: params.maxOutputTokens ?? undefined,
|
|
213
|
+
ls_stop: options.stop,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
205
216
|
buildApiKeyClient(apiKey) {
|
|
206
217
|
return new auth_js_1.ApiKeyGoogleAuth(apiKey);
|
|
207
218
|
}
|
package/dist/chat_models.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type BaseMessage } from "@langchain/core/messages";
|
|
2
2
|
import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager";
|
|
3
|
-
import { BaseChatModel, type BaseChatModelParams } from "@langchain/core/language_models/chat_models";
|
|
3
|
+
import { BaseChatModel, LangSmithParams, type BaseChatModelParams } from "@langchain/core/language_models/chat_models";
|
|
4
4
|
import { ChatGenerationChunk, ChatResult } from "@langchain/core/outputs";
|
|
5
5
|
import { AIMessageChunk } from "@langchain/core/messages";
|
|
6
6
|
import { BaseLanguageModelInput, StructuredOutputMethodOptions } from "@langchain/core/language_models/base";
|
|
@@ -47,6 +47,7 @@ export declare abstract class ChatGoogleBase<AuthOptions> extends BaseChatModel<
|
|
|
47
47
|
protected connection: ChatConnection<AuthOptions>;
|
|
48
48
|
protected streamedConnection: ChatConnection<AuthOptions>;
|
|
49
49
|
constructor(fields?: ChatGoogleBaseInput<AuthOptions>);
|
|
50
|
+
getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
|
|
50
51
|
abstract buildAbstractedClient(fields?: GoogleAIBaseLLMInput<AuthOptions>): GoogleAbstractedClient;
|
|
51
52
|
buildApiKeyClient(apiKey: string): GoogleAbstractedClient;
|
|
52
53
|
buildApiKey(fields?: GoogleAIBaseLLMInput<AuthOptions>): string | undefined;
|
package/dist/chat_models.js
CHANGED
|
@@ -199,6 +199,17 @@ export class ChatGoogleBase extends BaseChatModel {
|
|
|
199
199
|
const client = this.buildClient(fields);
|
|
200
200
|
this.buildConnection(fields ?? {}, client);
|
|
201
201
|
}
|
|
202
|
+
getLsParams(options) {
|
|
203
|
+
const params = this.invocationParams(options);
|
|
204
|
+
return {
|
|
205
|
+
ls_provider: "google_vertexai",
|
|
206
|
+
ls_model_name: this.model,
|
|
207
|
+
ls_model_type: "chat",
|
|
208
|
+
ls_temperature: params.temperature ?? undefined,
|
|
209
|
+
ls_max_tokens: params.maxOutputTokens ?? undefined,
|
|
210
|
+
ls_stop: options.stop,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
202
213
|
buildApiKeyClient(apiKey) {
|
|
203
214
|
return new ApiKeyGoogleAuth(apiKey);
|
|
204
215
|
}
|
package/dist/connection.cjs
CHANGED
|
@@ -195,8 +195,7 @@ class GoogleAIConnection extends GoogleHostConnection {
|
|
|
195
195
|
exports.GoogleAIConnection = GoogleAIConnection;
|
|
196
196
|
class AbstractGoogleLLMConnection extends GoogleAIConnection {
|
|
197
197
|
async buildUrlMethodGemini() {
|
|
198
|
-
|
|
199
|
-
return "streamGenerateContent";
|
|
198
|
+
return this.streaming ? "streamGenerateContent" : "generateContent";
|
|
200
199
|
}
|
|
201
200
|
async buildUrlMethod() {
|
|
202
201
|
switch (this.modelFamily) {
|
package/dist/connection.js
CHANGED
|
@@ -189,8 +189,7 @@ export class GoogleAIConnection extends GoogleHostConnection {
|
|
|
189
189
|
}
|
|
190
190
|
export class AbstractGoogleLLMConnection extends GoogleAIConnection {
|
|
191
191
|
async buildUrlMethodGemini() {
|
|
192
|
-
|
|
193
|
-
return "streamGenerateContent";
|
|
192
|
+
return this.streaming ? "streamGenerateContent" : "generateContent";
|
|
194
193
|
}
|
|
195
194
|
async buildUrlMethod() {
|
|
196
195
|
switch (this.modelFamily) {
|
package/dist/types.d.ts
CHANGED
|
@@ -221,6 +221,7 @@ export type GeminiJsonSchema = Record<string, unknown> & {
|
|
|
221
221
|
type: GeminiFunctionSchemaType;
|
|
222
222
|
};
|
|
223
223
|
export interface GeminiJsonSchemaDirty extends GeminiJsonSchema {
|
|
224
|
+
items?: GeminiJsonSchemaDirty;
|
|
224
225
|
properties?: Record<string, GeminiJsonSchemaDirty>;
|
|
225
226
|
additionalProperties?: boolean;
|
|
226
227
|
}
|
|
@@ -12,6 +12,9 @@ function removeAdditionalProperties(schema) {
|
|
|
12
12
|
const keys = Object.keys(updatedSchema.properties);
|
|
13
13
|
removeProperties(updatedSchema.properties, keys, 0);
|
|
14
14
|
}
|
|
15
|
+
if (Object.hasOwn(updatedSchema, "items") && updatedSchema.items) {
|
|
16
|
+
updatedSchema.items = removeAdditionalProperties(updatedSchema.items);
|
|
17
|
+
}
|
|
15
18
|
return updatedSchema;
|
|
16
19
|
}
|
|
17
20
|
function removeProperties(properties, keys, index) {
|
|
@@ -9,6 +9,9 @@ function removeAdditionalProperties(schema) {
|
|
|
9
9
|
const keys = Object.keys(updatedSchema.properties);
|
|
10
10
|
removeProperties(updatedSchema.properties, keys, 0);
|
|
11
11
|
}
|
|
12
|
+
if (Object.hasOwn(updatedSchema, "items") && updatedSchema.items) {
|
|
13
|
+
updatedSchema.items = removeAdditionalProperties(updatedSchema.items);
|
|
14
|
+
}
|
|
12
15
|
return updatedSchema;
|
|
13
16
|
}
|
|
14
17
|
function removeProperties(properties, keys, index) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/google-common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"description": "Core types and classes for Google services.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-google-common/",
|
|
16
16
|
"scripts": {
|
|
17
|
-
"build": "yarn
|
|
17
|
+
"build": "yarn turbo:command build:internal --filter=@langchain/google-common",
|
|
18
|
+
"build:internal": "yarn lc-build:v2 --create-entrypoints --pre --tree-shaking",
|
|
18
19
|
"build:deps": "yarn run turbo:command build --filter=@langchain/core",
|
|
19
20
|
"build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests",
|
|
20
21
|
"build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rm -rf dist-cjs",
|
|
@@ -24,7 +25,7 @@
|
|
|
24
25
|
"lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts",
|
|
25
26
|
"lint": "yarn lint:eslint && yarn lint:dpdm",
|
|
26
27
|
"lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm",
|
|
27
|
-
"clean": "rm -rf dist/
|
|
28
|
+
"clean": "rm -rf .turbo dist/",
|
|
28
29
|
"prepack": "yarn build",
|
|
29
30
|
"test": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
|
|
30
31
|
"test:watch": "yarn run build:deps && NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@jest/globals": "^29.5.0",
|
|
48
|
-
"@langchain/scripts": "~0.0",
|
|
49
|
+
"@langchain/scripts": "~0.0.14",
|
|
49
50
|
"@swc/core": "^1.3.90",
|
|
50
51
|
"@swc/jest": "^0.2.29",
|
|
51
52
|
"@tsconfig/recommended": "^1.0.3",
|