langchain 0.1.14 → 0.1.15

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.
@@ -171,7 +171,6 @@ exports.optionalImportEntrypoints = [
171
171
  "langchain/graphs/neo4j_graph",
172
172
  "langchain/hub",
173
173
  "langchain/util/convex",
174
- "langchain/util/migrations/0_1",
175
174
  "langchain/experimental/multimodal_embeddings/googlevertexai",
176
175
  "langchain/experimental/chat_models/anthropic_functions",
177
176
  "langchain/experimental/llms/bittensor",
@@ -168,7 +168,6 @@ export const optionalImportEntrypoints = [
168
168
  "langchain/graphs/neo4j_graph",
169
169
  "langchain/hub",
170
170
  "langchain/util/convex",
171
- "langchain/util/migrations/0_1",
172
171
  "langchain/experimental/multimodal_embeddings/googlevertexai",
173
172
  "langchain/experimental/chat_models/anthropic_functions",
174
173
  "langchain/experimental/llms/bittensor",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langchain",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "Typescript bindings for langchain",
5
5
  "type": "module",
6
6
  "engines": {
@@ -1082,10 +1082,6 @@
1082
1082
  "util/time.js",
1083
1083
  "util/time.d.ts",
1084
1084
  "util/time.d.cts",
1085
- "util/migrations/0_1.cjs",
1086
- "util/migrations/0_1.js",
1087
- "util/migrations/0_1.d.ts",
1088
- "util/migrations/0_1.d.cts",
1089
1085
  "experimental/autogpt.cjs",
1090
1086
  "experimental/autogpt.js",
1091
1087
  "experimental/autogpt.d.ts",
@@ -1259,7 +1255,6 @@
1259
1255
  "eslint-plugin-no-instanceof": "^1.0.1",
1260
1256
  "eslint-plugin-prettier": "^4.2.1",
1261
1257
  "fast-xml-parser": "^4.2.7",
1262
- "glob": "^10.3.10",
1263
1258
  "google-auth-library": "^8.9.0",
1264
1259
  "handlebars": "^4.7.8",
1265
1260
  "html-to-text": "^9.0.5",
@@ -1286,7 +1281,6 @@
1286
1281
  "sonix-speech-recognition": "^2.1.1",
1287
1282
  "srt-parser-2": "^1.2.3",
1288
1283
  "ts-jest": "^29.1.0",
1289
- "ts-morph": "^21.0.1",
1290
1284
  "typeorm": "^0.3.12",
1291
1285
  "typescript": "~5.1.6",
1292
1286
  "vectordb": "^0.1.4",
@@ -1320,7 +1314,6 @@
1320
1314
  "d3-dsv": "^2.0.0",
1321
1315
  "epub2": "^3.0.1",
1322
1316
  "fast-xml-parser": "^4.2.7",
1323
- "glob": "^10.3.10",
1324
1317
  "google-auth-library": "^8.9.0",
1325
1318
  "handlebars": "^4.7.8",
1326
1319
  "html-to-text": "^9.0.5",
@@ -1340,7 +1333,6 @@
1340
1333
  "redis": "^4.6.4",
1341
1334
  "sonix-speech-recognition": "^2.1.1",
1342
1335
  "srt-parser-2": "^1.2.3",
1343
- "ts-morph": "^21.0.1",
1344
1336
  "typeorm": "^0.3.12",
1345
1337
  "vectordb": "^0.1.4",
1346
1338
  "weaviate-ts-client": "^1.4.0",
@@ -1425,9 +1417,6 @@
1425
1417
  "fast-xml-parser": {
1426
1418
  "optional": true
1427
1419
  },
1428
- "glob": {
1429
- "optional": true
1430
- },
1431
1420
  "google-auth-library": {
1432
1421
  "optional": true
1433
1422
  },
@@ -1485,9 +1474,6 @@
1485
1474
  "srt-parser-2": {
1486
1475
  "optional": true
1487
1476
  },
1488
- "ts-morph": {
1489
- "optional": true
1490
- },
1491
1477
  "typeorm": {
1492
1478
  "optional": true
1493
1479
  },
@@ -1513,7 +1499,7 @@
1513
1499
  "dependencies": {
1514
1500
  "@anthropic-ai/sdk": "^0.9.1",
1515
1501
  "@langchain/community": "~0.0.20",
1516
- "@langchain/core": "~0.1.24",
1502
+ "@langchain/core": "~0.1.25",
1517
1503
  "@langchain/openai": "~0.0.12",
1518
1504
  "binary-extensions": "^2.2.0",
1519
1505
  "expr-eval": "^2.0.2",
@@ -3960,15 +3946,6 @@
3960
3946
  "import": "./util/time.js",
3961
3947
  "require": "./util/time.cjs"
3962
3948
  },
3963
- "./util/migrations/0_1": {
3964
- "types": {
3965
- "import": "./util/migrations/0_1.d.ts",
3966
- "require": "./util/migrations/0_1.d.cts",
3967
- "default": "./util/migrations/0_1.d.ts"
3968
- },
3969
- "import": "./util/migrations/0_1.js",
3970
- "require": "./util/migrations/0_1.cjs"
3971
- },
3972
3949
  "./experimental/autogpt": {
3973
3950
  "types": {
3974
3951
  "import": "./experimental/autogpt.d.ts",
@@ -1,208 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.updateEntrypointsFrom0_0_xTo0_1_x = void 0;
7
- const ts_morph_1 = require("ts-morph");
8
- const glob_1 = require("glob");
9
- const node_path_1 = __importDefault(require("node:path"));
10
- /**
11
- * @param {string} packagePath
12
- * @param {Project} project
13
- * @returns {Array<EntrypointAndSymbols> }
14
- */
15
- async function getEntrypointsFromFile(packagePath, project) {
16
- // @TODO replace any with LangChainConfig from `@langchain/scripts`
17
- const { config } = await import(node_path_1.default.join(packagePath, "langchain.config.js"));
18
- const { entrypoints, deprecatedNodeOnly } = config;
19
- const result = Object.entries(entrypoints).flatMap(([key, value]) => {
20
- if (deprecatedNodeOnly.includes(key)) {
21
- return [];
22
- }
23
- const newFile = project.addSourceFileAtPath(node_path_1.default.join(packagePath, "src", `${value}.ts`));
24
- const exportedSymbolsMap = newFile.getExportedDeclarations();
25
- const exportedSymbols = Array.from(exportedSymbolsMap.entries()).map(([symbol, declarations]) => ({
26
- kind: declarations[0].getKind(),
27
- symbol,
28
- }));
29
- return {
30
- entrypoint: key,
31
- exportedSymbols,
32
- };
33
- });
34
- return result;
35
- }
36
- /**
37
- * Finds a matching symbol in the array of exported symbols.
38
- * @param {{ symbol: string, kind: SyntaxKind }} target - The target symbol and its kind to find.
39
- * @param {Array<EntrypointAndSymbols>} exportedSymbols - The array of exported symbols to search.
40
- * @param {string} packageSuffix - The suffix of the package to import from. Eg, core
41
- * @returns {{ entrypoint: string, foundSymbol: string } | undefined} The matching symbol or undefined if not found.
42
- */
43
- function findMatchingSymbol(target, exportedSymbols, packageSuffix) {
44
- for (const entry of exportedSymbols) {
45
- const foundSymbol = entry.exportedSymbols.find(({ symbol, kind }) => symbol === target.symbol && kind === target.kind);
46
- if (foundSymbol) {
47
- return {
48
- entrypoint: entry.entrypoint,
49
- foundSymbol: foundSymbol.symbol,
50
- packageSuffix,
51
- }; // Return the matching entry object
52
- }
53
- }
54
- return undefined;
55
- }
56
- /**
57
- * @param {Array<EntrypointAndSymbols>} entrypoints
58
- * @returns {Array<EntrypointAndSymbols>}
59
- */
60
- function removeLoad(entrypoints) {
61
- return entrypoints.flatMap((entrypoint) => {
62
- const newEntrypoint = entrypoint.entrypoint === "index" ? "" : `/${entrypoint.entrypoint}`;
63
- const withoutLoadOrIndex = entrypoint.exportedSymbols.filter((item) => {
64
- if (item.symbol === "load" && newEntrypoint === "load") {
65
- return false;
66
- }
67
- return true;
68
- });
69
- return {
70
- entrypoint: newEntrypoint,
71
- exportedSymbols: withoutLoadOrIndex,
72
- };
73
- });
74
- }
75
- function updateImport({ matchingSymbols, namedImport, projectFile, namedImportText, }) {
76
- const firstMatchingSymbol = matchingSymbols.find((matchingSymbol) => matchingSymbol);
77
- if (firstMatchingSymbol) {
78
- console.debug(`Found matching symbol in the "@langchain/${firstMatchingSymbol.packageSuffix}" package.`, {
79
- matchingSymbol: firstMatchingSymbol,
80
- });
81
- namedImport.remove();
82
- projectFile.addImportDeclaration({
83
- moduleSpecifier: `@langchain/${firstMatchingSymbol.packageSuffix}${firstMatchingSymbol.entrypoint}`,
84
- namedImports: [namedImportText],
85
- });
86
- return true;
87
- }
88
- return false;
89
- }
90
- /**
91
- * Find imports from deprecated pre 0.1 LangChain modules and update them to import
92
- * from the new LangChain packages.
93
- */
94
- async function updateEntrypointsFrom0_0_xTo0_1_x({ localLangChainPath, codePath, customGlobPattern, customIgnorePattern, skipCheck, }) {
95
- const project = new ts_morph_1.Project();
96
- const langchainCorePackageEntrypoints = removeLoad(await getEntrypointsFromFile(node_path_1.default.join(localLangChainPath, "langchain-core"), project));
97
- const langchainCommunityPackageEntrypoints = removeLoad(await getEntrypointsFromFile(node_path_1.default.join(localLangChainPath, "libs", "langchain-community"), project));
98
- const langchainOpenAIPackageEntrypoints = removeLoad(await getEntrypointsFromFile(node_path_1.default.join(localLangChainPath, "libs", "langchain-openai"), project));
99
- const langchainCoherePackageEntrypoints = !skipCheck?.includes("cohere" /* UpgradingModule.COHERE */)
100
- ? removeLoad(await getEntrypointsFromFile(node_path_1.default.join(localLangChainPath, "libs", "langchain-cohere"), project))
101
- : null;
102
- const langchainPineconePackageEntrypoints = !skipCheck?.includes("pinecone" /* UpgradingModule.PINECONE */)
103
- ? removeLoad(await getEntrypointsFromFile(node_path_1.default.join(localLangChainPath, "libs", "langchain-pinecone"), project))
104
- : null;
105
- const globPattern = customGlobPattern || "/**/*.ts";
106
- const ignorePattern = customIgnorePattern;
107
- const allCodebaseFiles = (await (0, glob_1.glob)(node_path_1.default.join(codePath, globPattern), {
108
- ignore: ignorePattern,
109
- }))
110
- .map((filePath) => node_path_1.default.resolve(filePath))
111
- .filter((filePath) => !filePath.includes("node_modules/"));
112
- for await (const filePath of allCodebaseFiles) {
113
- let projectFile;
114
- try {
115
- projectFile = project.addSourceFileAtPath(filePath);
116
- if (!projectFile) {
117
- throw new Error(`Failed to add source file at path: ${filePath}`);
118
- }
119
- }
120
- catch (error) {
121
- console.error({
122
- filePath,
123
- error,
124
- }, "Error occurred while trying to add source file. Continuing");
125
- return;
126
- }
127
- try {
128
- const imports = projectFile.getImportDeclarations();
129
- imports.forEach((importItem) => {
130
- // Get all imports
131
- const module = importItem.getModuleSpecifierValue();
132
- // Get only the named imports. Eg: import { foo } from "langchain/util";
133
- const namedImports = importItem.getNamedImports();
134
- if (!module.startsWith("langchain/")) {
135
- return;
136
- }
137
- // look at each import and see if it exists in
138
- let didUpdate = false;
139
- namedImports.forEach((namedImport) => {
140
- const namedImportText = namedImport.getText();
141
- let namedImportKind = null;
142
- const symbol = namedImport.getSymbol();
143
- if (symbol) {
144
- // Resolve alias symbol to its original symbol
145
- const aliasedSymbol = symbol.getAliasedSymbol() || symbol;
146
- // Get the original declarations of the symbol
147
- const declarations = aliasedSymbol.getDeclarations();
148
- if (declarations.length > 0) {
149
- // Assuming the first declaration is the original one
150
- const originalDeclarationKind = declarations[0].getKind();
151
- namedImportKind = originalDeclarationKind;
152
- }
153
- }
154
- // If we couldn't find the kind of the named imports kind, skip it
155
- if (!namedImportKind) {
156
- return;
157
- }
158
- const matchingSymbolCore = findMatchingSymbol({ symbol: namedImportText, kind: namedImportKind }, langchainCorePackageEntrypoints, "core");
159
- const matchingSymbolCommunity = findMatchingSymbol({ symbol: namedImportText, kind: namedImportKind }, langchainCommunityPackageEntrypoints, "community");
160
- const matchingSymbolOpenAI = findMatchingSymbol({ symbol: namedImportText, kind: namedImportKind }, langchainOpenAIPackageEntrypoints, "openai");
161
- const matchingSymbolCohere = langchainCoherePackageEntrypoints
162
- ? findMatchingSymbol({ symbol: namedImportText, kind: namedImportKind }, langchainCoherePackageEntrypoints, "cohere")
163
- : undefined;
164
- const matchingSymbolPinecone = langchainPineconePackageEntrypoints
165
- ? findMatchingSymbol({ symbol: namedImportText, kind: namedImportKind }, langchainPineconePackageEntrypoints, "pinecone")
166
- : undefined;
167
- didUpdate = updateImport({
168
- matchingSymbols: [
169
- matchingSymbolCore,
170
- matchingSymbolOpenAI,
171
- matchingSymbolCohere,
172
- matchingSymbolPinecone,
173
- matchingSymbolCommunity,
174
- ],
175
- namedImport,
176
- projectFile,
177
- namedImportText,
178
- });
179
- });
180
- if (didUpdate) {
181
- projectFile.saveSync();
182
- // Check if all named imports were removed, and only a file import remains.
183
- // eg: import { foo } from "langchain/anthropic"; -> import "langchain/anthropic";
184
- // if so, remove the import entirely
185
- const importClause = importItem.getImportClause();
186
- if (!importClause ||
187
- (!importClause.getDefaultImport() &&
188
- importClause.getNamedImports().length === 0)) {
189
- importItem.remove();
190
- projectFile.saveSync();
191
- }
192
- }
193
- });
194
- }
195
- catch (error) {
196
- console.error({
197
- filePath,
198
- error,
199
- }, "Error occurred while trying to read file. Continuing");
200
- }
201
- // Remove source file from the project after we're done with it
202
- // to prevent OOM errors.
203
- if (projectFile) {
204
- project.removeSourceFile(projectFile);
205
- }
206
- }
207
- }
208
- exports.updateEntrypointsFrom0_0_xTo0_1_x = updateEntrypointsFrom0_0_xTo0_1_x;
@@ -1,44 +0,0 @@
1
- declare const enum UpgradingModule {
2
- COHERE = "cohere",
3
- PINECONE = "pinecone"
4
- }
5
- /**
6
- * Find imports from deprecated pre 0.1 LangChain modules and update them to import
7
- * from the new LangChain packages.
8
- */
9
- export declare function updateEntrypointsFrom0_0_xTo0_1_x({ localLangChainPath, codePath, customGlobPattern, customIgnorePattern, skipCheck, }: {
10
- /**
11
- * The absolute path to the locally cloned LangChain repo root.
12
- * @example "/Users/username/code/langchainjs"
13
- */
14
- localLangChainPath: string;
15
- /**
16
- * The absolute path to the source directory of the codebase to update.
17
- * @example "/Users/username/code/my-project/src"
18
- */
19
- codePath: string;
20
- /**
21
- * Optionally, pass in a custom glob pattern to match files.
22
- * The backslash included in the example and default is only for
23
- * JSDoc to escape the asterisk. Do not include unless intentionally.
24
- * @example "/*.d.ts"
25
- * @default "**\/*.ts"
26
- */
27
- customGlobPattern?: string;
28
- /**
29
- * A custom ignore pattern for ignoring files.
30
- * The backslash included in the example and default is only for
31
- * JSDoc to escape the asterisk. Do not include unless intentionally.
32
- * @example ["**\/node_modules/**", "**\/dist/**", "**\/*.d.ts"]
33
- * @default node_modules/**
34
- */
35
- customIgnorePattern?: string[] | string;
36
- /**
37
- * Optionally skip checking the passed modules for imports to
38
- * update.
39
- * @example [UpgradingModule.COHERE]
40
- * @default undefined
41
- */
42
- skipCheck?: Array<UpgradingModule>;
43
- }): Promise<void>;
44
- export {};
@@ -1,201 +0,0 @@
1
- import { Project } from "ts-morph";
2
- import { glob } from "glob";
3
- import path from "node:path";
4
- /**
5
- * @param {string} packagePath
6
- * @param {Project} project
7
- * @returns {Array<EntrypointAndSymbols> }
8
- */
9
- async function getEntrypointsFromFile(packagePath, project) {
10
- // @TODO replace any with LangChainConfig from `@langchain/scripts`
11
- const { config } = await import(path.join(packagePath, "langchain.config.js"));
12
- const { entrypoints, deprecatedNodeOnly } = config;
13
- const result = Object.entries(entrypoints).flatMap(([key, value]) => {
14
- if (deprecatedNodeOnly.includes(key)) {
15
- return [];
16
- }
17
- const newFile = project.addSourceFileAtPath(path.join(packagePath, "src", `${value}.ts`));
18
- const exportedSymbolsMap = newFile.getExportedDeclarations();
19
- const exportedSymbols = Array.from(exportedSymbolsMap.entries()).map(([symbol, declarations]) => ({
20
- kind: declarations[0].getKind(),
21
- symbol,
22
- }));
23
- return {
24
- entrypoint: key,
25
- exportedSymbols,
26
- };
27
- });
28
- return result;
29
- }
30
- /**
31
- * Finds a matching symbol in the array of exported symbols.
32
- * @param {{ symbol: string, kind: SyntaxKind }} target - The target symbol and its kind to find.
33
- * @param {Array<EntrypointAndSymbols>} exportedSymbols - The array of exported symbols to search.
34
- * @param {string} packageSuffix - The suffix of the package to import from. Eg, core
35
- * @returns {{ entrypoint: string, foundSymbol: string } | undefined} The matching symbol or undefined if not found.
36
- */
37
- function findMatchingSymbol(target, exportedSymbols, packageSuffix) {
38
- for (const entry of exportedSymbols) {
39
- const foundSymbol = entry.exportedSymbols.find(({ symbol, kind }) => symbol === target.symbol && kind === target.kind);
40
- if (foundSymbol) {
41
- return {
42
- entrypoint: entry.entrypoint,
43
- foundSymbol: foundSymbol.symbol,
44
- packageSuffix,
45
- }; // Return the matching entry object
46
- }
47
- }
48
- return undefined;
49
- }
50
- /**
51
- * @param {Array<EntrypointAndSymbols>} entrypoints
52
- * @returns {Array<EntrypointAndSymbols>}
53
- */
54
- function removeLoad(entrypoints) {
55
- return entrypoints.flatMap((entrypoint) => {
56
- const newEntrypoint = entrypoint.entrypoint === "index" ? "" : `/${entrypoint.entrypoint}`;
57
- const withoutLoadOrIndex = entrypoint.exportedSymbols.filter((item) => {
58
- if (item.symbol === "load" && newEntrypoint === "load") {
59
- return false;
60
- }
61
- return true;
62
- });
63
- return {
64
- entrypoint: newEntrypoint,
65
- exportedSymbols: withoutLoadOrIndex,
66
- };
67
- });
68
- }
69
- function updateImport({ matchingSymbols, namedImport, projectFile, namedImportText, }) {
70
- const firstMatchingSymbol = matchingSymbols.find((matchingSymbol) => matchingSymbol);
71
- if (firstMatchingSymbol) {
72
- console.debug(`Found matching symbol in the "@langchain/${firstMatchingSymbol.packageSuffix}" package.`, {
73
- matchingSymbol: firstMatchingSymbol,
74
- });
75
- namedImport.remove();
76
- projectFile.addImportDeclaration({
77
- moduleSpecifier: `@langchain/${firstMatchingSymbol.packageSuffix}${firstMatchingSymbol.entrypoint}`,
78
- namedImports: [namedImportText],
79
- });
80
- return true;
81
- }
82
- return false;
83
- }
84
- /**
85
- * Find imports from deprecated pre 0.1 LangChain modules and update them to import
86
- * from the new LangChain packages.
87
- */
88
- export async function updateEntrypointsFrom0_0_xTo0_1_x({ localLangChainPath, codePath, customGlobPattern, customIgnorePattern, skipCheck, }) {
89
- const project = new Project();
90
- const langchainCorePackageEntrypoints = removeLoad(await getEntrypointsFromFile(path.join(localLangChainPath, "langchain-core"), project));
91
- const langchainCommunityPackageEntrypoints = removeLoad(await getEntrypointsFromFile(path.join(localLangChainPath, "libs", "langchain-community"), project));
92
- const langchainOpenAIPackageEntrypoints = removeLoad(await getEntrypointsFromFile(path.join(localLangChainPath, "libs", "langchain-openai"), project));
93
- const langchainCoherePackageEntrypoints = !skipCheck?.includes("cohere" /* UpgradingModule.COHERE */)
94
- ? removeLoad(await getEntrypointsFromFile(path.join(localLangChainPath, "libs", "langchain-cohere"), project))
95
- : null;
96
- const langchainPineconePackageEntrypoints = !skipCheck?.includes("pinecone" /* UpgradingModule.PINECONE */)
97
- ? removeLoad(await getEntrypointsFromFile(path.join(localLangChainPath, "libs", "langchain-pinecone"), project))
98
- : null;
99
- const globPattern = customGlobPattern || "/**/*.ts";
100
- const ignorePattern = customIgnorePattern;
101
- const allCodebaseFiles = (await glob(path.join(codePath, globPattern), {
102
- ignore: ignorePattern,
103
- }))
104
- .map((filePath) => path.resolve(filePath))
105
- .filter((filePath) => !filePath.includes("node_modules/"));
106
- for await (const filePath of allCodebaseFiles) {
107
- let projectFile;
108
- try {
109
- projectFile = project.addSourceFileAtPath(filePath);
110
- if (!projectFile) {
111
- throw new Error(`Failed to add source file at path: ${filePath}`);
112
- }
113
- }
114
- catch (error) {
115
- console.error({
116
- filePath,
117
- error,
118
- }, "Error occurred while trying to add source file. Continuing");
119
- return;
120
- }
121
- try {
122
- const imports = projectFile.getImportDeclarations();
123
- imports.forEach((importItem) => {
124
- // Get all imports
125
- const module = importItem.getModuleSpecifierValue();
126
- // Get only the named imports. Eg: import { foo } from "langchain/util";
127
- const namedImports = importItem.getNamedImports();
128
- if (!module.startsWith("langchain/")) {
129
- return;
130
- }
131
- // look at each import and see if it exists in
132
- let didUpdate = false;
133
- namedImports.forEach((namedImport) => {
134
- const namedImportText = namedImport.getText();
135
- let namedImportKind = null;
136
- const symbol = namedImport.getSymbol();
137
- if (symbol) {
138
- // Resolve alias symbol to its original symbol
139
- const aliasedSymbol = symbol.getAliasedSymbol() || symbol;
140
- // Get the original declarations of the symbol
141
- const declarations = aliasedSymbol.getDeclarations();
142
- if (declarations.length > 0) {
143
- // Assuming the first declaration is the original one
144
- const originalDeclarationKind = declarations[0].getKind();
145
- namedImportKind = originalDeclarationKind;
146
- }
147
- }
148
- // If we couldn't find the kind of the named imports kind, skip it
149
- if (!namedImportKind) {
150
- return;
151
- }
152
- const matchingSymbolCore = findMatchingSymbol({ symbol: namedImportText, kind: namedImportKind }, langchainCorePackageEntrypoints, "core");
153
- const matchingSymbolCommunity = findMatchingSymbol({ symbol: namedImportText, kind: namedImportKind }, langchainCommunityPackageEntrypoints, "community");
154
- const matchingSymbolOpenAI = findMatchingSymbol({ symbol: namedImportText, kind: namedImportKind }, langchainOpenAIPackageEntrypoints, "openai");
155
- const matchingSymbolCohere = langchainCoherePackageEntrypoints
156
- ? findMatchingSymbol({ symbol: namedImportText, kind: namedImportKind }, langchainCoherePackageEntrypoints, "cohere")
157
- : undefined;
158
- const matchingSymbolPinecone = langchainPineconePackageEntrypoints
159
- ? findMatchingSymbol({ symbol: namedImportText, kind: namedImportKind }, langchainPineconePackageEntrypoints, "pinecone")
160
- : undefined;
161
- didUpdate = updateImport({
162
- matchingSymbols: [
163
- matchingSymbolCore,
164
- matchingSymbolOpenAI,
165
- matchingSymbolCohere,
166
- matchingSymbolPinecone,
167
- matchingSymbolCommunity,
168
- ],
169
- namedImport,
170
- projectFile,
171
- namedImportText,
172
- });
173
- });
174
- if (didUpdate) {
175
- projectFile.saveSync();
176
- // Check if all named imports were removed, and only a file import remains.
177
- // eg: import { foo } from "langchain/anthropic"; -> import "langchain/anthropic";
178
- // if so, remove the import entirely
179
- const importClause = importItem.getImportClause();
180
- if (!importClause ||
181
- (!importClause.getDefaultImport() &&
182
- importClause.getNamedImports().length === 0)) {
183
- importItem.remove();
184
- projectFile.saveSync();
185
- }
186
- }
187
- });
188
- }
189
- catch (error) {
190
- console.error({
191
- filePath,
192
- error,
193
- }, "Error occurred while trying to read file. Continuing");
194
- }
195
- // Remove source file from the project after we're done with it
196
- // to prevent OOM errors.
197
- if (projectFile) {
198
- project.removeSourceFile(projectFile);
199
- }
200
- }
201
- }
@@ -1 +0,0 @@
1
- module.exports = require('../../dist/util/migrations/0_0-0_1-migrate-imports.cjs');
@@ -1 +0,0 @@
1
- export * from '../../dist/util/migrations/0_0-0_1-migrate-imports.js'
@@ -1 +0,0 @@
1
- export * from '../../dist/util/migrations/0_0-0_1-migrate-imports.js'
@@ -1 +0,0 @@
1
- export * from '../../dist/util/migrations/0_0-0_1-migrate-imports.js'