@langchain/google-genai 0.0.7 → 0.0.9
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/README.md +1 -1
- package/dist/utils.cjs +5 -4
- package/dist/utils.js +5 -4
- package/index.d.cts +1 -0
- package/package.json +24 -13
package/README.md
CHANGED
|
@@ -160,4 +160,4 @@ yarn lint && yarn format
|
|
|
160
160
|
|
|
161
161
|
### Adding new entrypoints
|
|
162
162
|
|
|
163
|
-
If you add a new file to be exported, either import & re-export from `src/index.ts`, or add it to `
|
|
163
|
+
If you add a new file to be exported, either import & re-export from `src/index.ts`, or add it to the `entrypoints` field in the `config` variable located inside `langchain.config.js` and run `yarn build` to generate the new entrypoint.
|
package/dist/utils.cjs
CHANGED
|
@@ -24,6 +24,7 @@ function convertAuthorToRole(author) {
|
|
|
24
24
|
* we will convert them to human messages and merge with following
|
|
25
25
|
* */
|
|
26
26
|
case "ai":
|
|
27
|
+
case "model": // getMessageAuthor returns message.name. code ex.: return message.name ?? type;
|
|
27
28
|
return "model";
|
|
28
29
|
case "system":
|
|
29
30
|
case "human":
|
|
@@ -122,12 +123,12 @@ function mapGenerateContentResultToChatResult(response) {
|
|
|
122
123
|
}
|
|
123
124
|
const [candidate] = response.candidates;
|
|
124
125
|
const { content, ...generationInfo } = candidate;
|
|
125
|
-
const text = content
|
|
126
|
+
const text = content?.parts[0]?.text ?? "";
|
|
126
127
|
const generation = {
|
|
127
128
|
text,
|
|
128
129
|
message: new messages_1.AIMessage({
|
|
129
130
|
content: text,
|
|
130
|
-
name: content
|
|
131
|
+
name: !content ? undefined : content.role,
|
|
131
132
|
additional_kwargs: generationInfo,
|
|
132
133
|
}),
|
|
133
134
|
generationInfo,
|
|
@@ -143,12 +144,12 @@ function convertResponseContentToChatGenerationChunk(response) {
|
|
|
143
144
|
}
|
|
144
145
|
const [candidate] = response.candidates;
|
|
145
146
|
const { content, ...generationInfo } = candidate;
|
|
146
|
-
const text = content
|
|
147
|
+
const text = content?.parts[0]?.text ?? "";
|
|
147
148
|
return new outputs_1.ChatGenerationChunk({
|
|
148
149
|
text,
|
|
149
150
|
message: new messages_1.AIMessageChunk({
|
|
150
151
|
content: text,
|
|
151
|
-
name: content
|
|
152
|
+
name: !content ? undefined : content.role,
|
|
152
153
|
// Each chunk can have unique "generationInfo", and merging strategy is unclear,
|
|
153
154
|
// so leave blank for now.
|
|
154
155
|
additional_kwargs: {},
|
package/dist/utils.js
CHANGED
|
@@ -20,6 +20,7 @@ export function convertAuthorToRole(author) {
|
|
|
20
20
|
* we will convert them to human messages and merge with following
|
|
21
21
|
* */
|
|
22
22
|
case "ai":
|
|
23
|
+
case "model": // getMessageAuthor returns message.name. code ex.: return message.name ?? type;
|
|
23
24
|
return "model";
|
|
24
25
|
case "system":
|
|
25
26
|
case "human":
|
|
@@ -115,12 +116,12 @@ export function mapGenerateContentResultToChatResult(response) {
|
|
|
115
116
|
}
|
|
116
117
|
const [candidate] = response.candidates;
|
|
117
118
|
const { content, ...generationInfo } = candidate;
|
|
118
|
-
const text = content
|
|
119
|
+
const text = content?.parts[0]?.text ?? "";
|
|
119
120
|
const generation = {
|
|
120
121
|
text,
|
|
121
122
|
message: new AIMessage({
|
|
122
123
|
content: text,
|
|
123
|
-
name: content
|
|
124
|
+
name: !content ? undefined : content.role,
|
|
124
125
|
additional_kwargs: generationInfo,
|
|
125
126
|
}),
|
|
126
127
|
generationInfo,
|
|
@@ -135,12 +136,12 @@ export function convertResponseContentToChatGenerationChunk(response) {
|
|
|
135
136
|
}
|
|
136
137
|
const [candidate] = response.candidates;
|
|
137
138
|
const { content, ...generationInfo } = candidate;
|
|
138
|
-
const text = content
|
|
139
|
+
const text = content?.parts[0]?.text ?? "";
|
|
139
140
|
return new ChatGenerationChunk({
|
|
140
141
|
text,
|
|
141
142
|
message: new AIMessageChunk({
|
|
142
143
|
content: text,
|
|
143
|
-
name: content
|
|
144
|
+
name: !content ? undefined : content.role,
|
|
144
145
|
// Each chunk can have unique "generationInfo", and merging strategy is unclear,
|
|
145
146
|
// so leave blank for now.
|
|
146
147
|
additional_kwargs: {},
|
package/index.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/index.js'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/google-genai",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "Sample integration for LangChain.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -12,33 +12,39 @@
|
|
|
12
12
|
"type": "git",
|
|
13
13
|
"url": "git@github.com:langchain-ai/langchainjs.git"
|
|
14
14
|
},
|
|
15
|
+
"homepage": "https://github.com/langchain-ai/langchainjs/tree/main/libs/langchain-google-genai/",
|
|
15
16
|
"scripts": {
|
|
16
17
|
"build": "yarn run build:deps && yarn clean && yarn build:esm && yarn build:cjs && yarn build:scripts",
|
|
17
18
|
"build:deps": "yarn run turbo:command build --filter=@langchain/core",
|
|
18
19
|
"build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rm -rf dist/tests dist/**/tests",
|
|
19
|
-
"build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json &&
|
|
20
|
-
"build:watch": "
|
|
21
|
-
"build:scripts": "
|
|
22
|
-
"lint": "NODE_OPTIONS=--max-old-space-size=4096 eslint
|
|
23
|
-
"lint:
|
|
24
|
-
"
|
|
20
|
+
"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",
|
|
21
|
+
"build:watch": "yarn create-entrypoints && tsc --outDir dist/ --watch",
|
|
22
|
+
"build:scripts": "yarn create-entrypoints && yarn check-tree-shaking",
|
|
23
|
+
"lint:eslint": "NODE_OPTIONS=--max-old-space-size=4096 eslint --cache --ext .ts,.js src/",
|
|
24
|
+
"lint:dpdm": "dpdm --exit-code circular:1 --no-warning --no-tree src/*.ts src/**/*.ts",
|
|
25
|
+
"lint": "yarn lint:eslint && yarn lint:dpdm",
|
|
26
|
+
"lint:fix": "yarn lint:eslint --fix && yarn lint:dpdm",
|
|
27
|
+
"clean": "rm -rf dist/ && NODE_OPTIONS=--max-old-space-size=4096 yarn create-entrypoints -- --pre",
|
|
25
28
|
"prepack": "yarn build",
|
|
26
29
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest --testPathIgnorePatterns=\\.int\\.test.ts --testTimeout 30000 --maxWorkers=50%",
|
|
27
30
|
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch --testPathIgnorePatterns=\\.int\\.test.ts",
|
|
28
31
|
"test:single": "NODE_OPTIONS=--experimental-vm-modules yarn run jest --config jest.config.cjs --testTimeout 100000",
|
|
29
32
|
"test:int": "NODE_OPTIONS=--experimental-vm-modules jest --testPathPattern=\\.int\\.test.ts --testTimeout 100000 --maxWorkers=50%",
|
|
30
|
-
"format": "prettier --write \"src\"",
|
|
31
|
-
"format:check": "prettier --check \"src\""
|
|
33
|
+
"format": "prettier --config .prettierrc --write \"src\"",
|
|
34
|
+
"format:check": "prettier --config .prettierrc --check \"src\"",
|
|
35
|
+
"move-cjs-to-dist": "yarn lc-build --config ./langchain.config.js --move-cjs-dist",
|
|
36
|
+
"create-entrypoints": "yarn lc-build --config ./langchain.config.js --create-entrypoints",
|
|
37
|
+
"check-tree-shaking": "yarn lc-build --config ./langchain.config.js --tree-shaking"
|
|
32
38
|
},
|
|
33
39
|
"author": "LangChain",
|
|
34
40
|
"license": "MIT",
|
|
35
41
|
"dependencies": {
|
|
36
|
-
"@google/generative-ai": "^0.1.
|
|
42
|
+
"@google/generative-ai": "^0.1.3",
|
|
37
43
|
"@langchain/core": "~0.1.5"
|
|
38
44
|
},
|
|
39
45
|
"devDependencies": {
|
|
40
46
|
"@jest/globals": "^29.5.0",
|
|
41
|
-
"@langchain/
|
|
47
|
+
"@langchain/scripts": "~0.0",
|
|
42
48
|
"@swc/core": "^1.3.90",
|
|
43
49
|
"@swc/jest": "^0.2.29",
|
|
44
50
|
"@tsconfig/recommended": "^1.0.3",
|
|
@@ -66,7 +72,11 @@
|
|
|
66
72
|
},
|
|
67
73
|
"exports": {
|
|
68
74
|
".": {
|
|
69
|
-
"types":
|
|
75
|
+
"types": {
|
|
76
|
+
"import": "./index.d.ts",
|
|
77
|
+
"require": "./index.d.cts",
|
|
78
|
+
"default": "./index.d.ts"
|
|
79
|
+
},
|
|
70
80
|
"import": "./index.js",
|
|
71
81
|
"require": "./index.cjs"
|
|
72
82
|
},
|
|
@@ -76,6 +86,7 @@
|
|
|
76
86
|
"dist/",
|
|
77
87
|
"index.cjs",
|
|
78
88
|
"index.js",
|
|
79
|
-
"index.d.ts"
|
|
89
|
+
"index.d.ts",
|
|
90
|
+
"index.d.cts"
|
|
80
91
|
]
|
|
81
92
|
}
|