diff --git a/e2e/node/smoke.e2e.ts b/e2e/node/smoke.e2e.ts index 149174edad4d0a6a724128974216414ffc2c629b..5aa83bf54450c29a5ae39b09322590215a16c81b 100644 --- a/e2e/node/smoke.e2e.ts +++ b/e2e/node/smoke.e2e.ts @@ -16,17 +16,17 @@ const { Document, MetadataMode, VectorStoreIndex } = require('llamaindex') const { OpenAIEmbedding } = require('@llamaindex/openai') const { Settings } = require('@llamaindex/core/global')`; const mainCode = ` -async function main() { - Settings.embedModel = new OpenAIEmbedding({ - model: 'text-embedding-3-small', - apiKey: '${process.env.OPENAI_API_KEY}', - }) - const model = Settings.embedModel - if (model == null) { - process.exit(-1) - } +Settings.embedModel = new OpenAIEmbedding({ + model: 'text-embedding-3-small', + apiKey: '${process.env.OPENAI_API_KEY}', +}) +const model = Settings.embedModel +if (model == null) { + process.exit(-1) } -main().catch(console.error)`; +const document = new Document({ text: 'Hello, world!' }) +const index = await VectorStoreIndex.fromDocuments([document]) +`; t.before(async () => { await mkdir(resolve(testRootDir, ".temp"), { recursive: true, diff --git a/examples/package.json b/examples/package.json index 8c5a0d6161a884fa112ef48cca2dc4636e386ec3..8f38f7072cbb4ed3b414d94dc8e17a1c2c607886 100644 --- a/examples/package.json +++ b/examples/package.json @@ -18,6 +18,7 @@ "@llamaindex/clip": "^0.0.36", "@llamaindex/cloud": "^3.0.0", "@llamaindex/cohere": "^0.0.5", + "@llamaindex/core": "^0.5.0", "@llamaindex/deepinfra": "^0.0.36", "@llamaindex/env": "^0.1.27", "@llamaindex/google": "^0.0.7", diff --git a/package.json b/package.json index b55b1a45f975be190be3ef438670ca67eba9b55e..b6eedeccc94a77c1d336c976c719af3ee2338c09 100644 --- a/package.json +++ b/package.json @@ -43,5 +43,10 @@ "eslint" ], "*.{json,md}": "prettier --check" + }, + "pnpm": { + "patchedDependencies": { + "bunchee@6.3.4": "patches/bunchee@6.3.4.patch" + } } } diff --git a/packages/core/src/vector-store/index.ts b/packages/core/src/vector-store/index.ts index 2cec54f211ff1360b6fe2347de45ee4207847d1d..c884c2d3b5f237047d96b5fe6593f616b009a3ca 100644 --- a/packages/core/src/vector-store/index.ts +++ b/packages/core/src/vector-store/index.ts @@ -1,6 +1,6 @@ -import type { BaseEmbedding } from "../embeddings/base.js"; +import type { BaseEmbedding } from "../embeddings"; import { Settings } from "../global"; -import type { BaseNode, ModalityType } from "../schema/node.js"; +import type { BaseNode, ModalityType } from "../schema"; /** * should compatible with npm:pg and npm:postgres diff --git a/patches/bunchee@6.3.4.patch b/patches/bunchee@6.3.4.patch new file mode 100644 index 0000000000000000000000000000000000000000..bb3b400597e2f98d0c0b6401ac376ec77865ee42 --- /dev/null +++ b/patches/bunchee@6.3.4.patch @@ -0,0 +1,134 @@ +diff --git a/dist/bin/cli.js b/dist/bin/cli.js +old mode 100755 +new mode 100644 +index e74abd6fc8bd1853b82e9b84691d433a5152f6f5..d6c4f2a94346c29c0e65708e91cbfba1bb424998 +--- a/dist/bin/cli.js ++++ b/dist/bin/cli.js +@@ -1082,7 +1082,7 @@ Options: + --runtime <runtime> build runtime (nodejs, browser). default: browser + --env <env> inlined process env variables, separate by comma. default: NODE_ENV + --cwd <cwd> specify current working directory +- --sourcemap enable sourcemap generation, default: false ++ --sourcemap enable sourcemap generation + --no-dts do not generate types, default: undefined + --tsconfig path to tsconfig file, default: tsconfig.json + --dts-bundle bundle type declaration files, default: false +@@ -1141,7 +1141,7 @@ async function parseCliArgs(argv) { + description: 'js features target: swc target es versions' + }).option('sourcemap', { + type: 'boolean', +- default: false, ++ default: undefined, + description: 'enable sourcemap generation' + }).option('env', { + type: 'string', +@@ -1196,6 +1196,10 @@ async function parseCliArgs(argv) { + env: args['env'], + tsconfig: args['tsconfig'] + }; ++ // When minify is enabled, sourcemap should be enabled by default, unless explicitly opted out ++ if (parsedArgs.minify && typeof args['sourcemap'] === 'undefined') { ++ parsedArgs.sourcemap = true; ++ } + return parsedArgs; + } + async function run(args) { +diff --git a/dist/index.js b/dist/index.js +index 66c0eba9bbbb68ec7308e7a7fe528c6a764e09e7..c1301712afee9c637013756b151c1c07b0f066c1 100644 +--- a/dist/index.js ++++ b/dist/index.js +@@ -1308,7 +1308,7 @@ function hasNoSpecialCondition(conditionNames) { + ...conditionNames + ].every((name)=>!specialExportConventions.has(name)); + } +-function findJsBundlePathCallback({ format, bundlePath, conditionNames }, specialCondition) { ++function findJsBundlePathCallback({ format, bundlePath, conditionNames }, specialCondition, defaultFormat) { + const hasBundle = bundlePath != null; + const formatCond = format === 'cjs' ? 'require' : 'import'; + const isTypesCondName = conditionNames.has('types'); +@@ -1317,8 +1317,9 @@ function findJsBundlePathCallback({ format, bundlePath, conditionNames }, specia + // if there's condition existed, check if the format condition is matched; + // if there's no condition, just return true, assuming format doesn't matter; + const isMatchedFormat = hasFormatCond ? conditionNames.has(formatCond) : true; ++ const isDefaultMatch = conditionNames.size === 1 && conditionNames.has('default') ? defaultFormat === format : true; + const isMatchedConditionWithFormat = conditionNames.has(specialCondition) || !conditionNames.has('default') && hasNoSpecialCondition(conditionNames); +- const match = isMatchedConditionWithFormat && !isTypesCondName && hasBundle && isMatchedFormat; ++ const match = isMatchedConditionWithFormat && !isTypesCondName && hasBundle && isMatchedFormat && isDefaultMatch; + if (!match) { + const fallback = runtimeExportConventionsFallback.get(specialCondition); + if (!fallback) { +@@ -1341,17 +1342,37 @@ function findTypesFileCallback({ format, bundlePath, conditionNames }) { + return isTypesCondName && hasCondition && (formatCond ? conditionNames.has(formatCond) : true); + } + // Alias entry key to dist bundle path +-function aliasEntries({ entry: sourceFilePath, conditionNames, entries, format, dts, cwd }) { ++function aliasEntries({ entry: sourceFilePath, conditionNames, entries, defaultFormat, format, dts, cwd }) { + // <imported source file path>: <relative path to source's bundle> + const sourceToRelativeBundleMap = new Map(); + const specialCondition = getSpecialExportTypeFromConditionNames(conditionNames); + for (const [, exportCondition] of Object.entries(entries)){ + const exportDistMaps = exportCondition.export; +- const exportMapEntries = Object.entries(exportDistMaps).map(([composedKey, bundlePath])=>({ +- conditionNames: new Set(composedKey.split('.')), ++ const exportMapEntries = Object.entries(exportDistMaps).map(([composedKey, bundlePath])=>{ ++ const conditionNames = new Set(composedKey.split('.')); ++ return { ++ conditionNames, + bundlePath, +- format +- })); ++ format, ++ isFallback: conditionNames.size === 1 && conditionNames.has('default') ++ }; ++ }).sort((a, b)=>{ ++ // Always put special condition after the general condition (default, cjs, esm) ++ if (a.conditionNames.has(specialCondition)) { ++ return -1; ++ } else if (b.conditionNames.has(specialCondition)) { ++ return 1; ++ } ++ // Always put default condition at the end. ++ // In the case of cjs resolves default(esm) ++ if (a.isFallback) { ++ return 1; ++ } ++ if (b.isFallback) { ++ return -1; ++ } ++ return 0; ++ }); + let matchedBundlePath; + if (dts) { + var _exportMapEntries_find; +@@ -1369,19 +1390,10 @@ function aliasEntries({ entry: sourceFilePath, conditionNames, entries, format, + })) == null ? undefined : _exportMapEntries_find1.bundlePath; + } + } else { +- var _exportMapEntries_sort_find; +- matchedBundlePath = (_exportMapEntries_sort_find = exportMapEntries.sort(// always put special condition after the general condition (default, cjs, esm) +- (a, b)=>{ +- if (a.conditionNames.has(specialCondition)) { +- return -1; +- } +- if (b.conditionNames.has(specialCondition)) { +- return 1; +- } +- return 0; +- }).find((item)=>{ +- return findJsBundlePathCallback(item, specialCondition); +- })) == null ? undefined : _exportMapEntries_sort_find.bundlePath; ++ var _exportMapEntries_find2; ++ matchedBundlePath = (_exportMapEntries_find2 = exportMapEntries.find((item)=>{ ++ return findJsBundlePathCallback(item, specialCondition, defaultFormat); ++ })) == null ? undefined : _exportMapEntries_find2.bundlePath; + } + if (matchedBundlePath) { + if (!sourceToRelativeBundleMap.has(exportCondition.source)) sourceToRelativeBundleMap.set(exportCondition.source, matchedBundlePath); +@@ -1546,6 +1558,7 @@ async function buildInputConfig(entry, bundleConfig, exportCondition, buildConte + entry, + entries, + format: aliasFormat, ++ defaultFormat: isESModulePackage(pkg.type) ? 'esm' : 'cjs', + conditionNames: new Set(currentConditionNames.split('.')), + dts, + cwd diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1948ad898f3056ffab89e876f75fa1f72ca26e88..3115f0cb6b944362bbd484754e464c8f7d977adf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,11 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +patchedDependencies: + bunchee@6.3.4: + hash: pavboztthlgni7m5gzw7643oru + path: patches/bunchee@6.3.4.patch + importers: .: @@ -592,6 +597,9 @@ importers: '@llamaindex/cohere': specifier: ^0.0.5 version: link:../packages/providers/cohere + '@llamaindex/core': + specifier: ^0.5.0 + version: link:../packages/core '@llamaindex/deepinfra': specifier: ^0.0.36 version: link:../packages/providers/deepinfra @@ -747,7 +755,7 @@ importers: version: 2.10.2(@types/react@18.3.12)(react@19.0.0-rc-5c56b873-20241107) openai: specifier: ^4 - version: 4.83.0(ws@8.18.0)(zod@3.24.2) + version: 4.83.0(ws@8.18.0(bufferutil@4.0.9))(zod@3.24.2) typedoc: specifier: ^0.26.11 version: 0.26.11(typescript@5.7.2) @@ -766,7 +774,7 @@ importers: version: 22.9.0 bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.2) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.2) llamaindex: specifier: workspace:* version: link:../llamaindex @@ -894,7 +902,7 @@ importers: version: link:../env bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) packages/community: dependencies: @@ -916,7 +924,7 @@ importers: version: 22.9.0 bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) packages/core: dependencies: @@ -944,7 +952,7 @@ importers: version: 8.17.1 bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) happy-dom: specifier: ^15.11.6 version: 15.11.7 @@ -981,7 +989,7 @@ importers: version: 4.0.18 bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) gpt-tokenizer: specifier: ^2.6.2 version: 2.8.1 @@ -1110,7 +1118,7 @@ importers: version: 22.9.0 bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) tree-sitter: specifier: ^0.22.1 version: 0.22.4 @@ -1135,7 +1143,7 @@ importers: devDependencies: bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) vitest: specifier: ^2.1.5 version: 2.1.5(@edge-runtime/vm@4.0.4)(@types/node@22.9.0)(happy-dom@15.11.7)(msw@2.7.0(@types/node@22.9.0)(typescript@5.7.3))(terser@5.38.2) @@ -1157,7 +1165,7 @@ importers: devDependencies: bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) packages/providers/cohere: dependencies: @@ -1173,7 +1181,7 @@ importers: devDependencies: bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) packages/providers/deepinfra: dependencies: @@ -1189,7 +1197,7 @@ importers: devDependencies: bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) packages/providers/google: dependencies: @@ -1208,7 +1216,7 @@ importers: devDependencies: bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) packages/providers/groq: dependencies: @@ -1224,7 +1232,7 @@ importers: devDependencies: bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) packages/providers/huggingface: dependencies: @@ -1246,7 +1254,7 @@ importers: devDependencies: bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) packages/providers/mistral: dependencies: @@ -1262,7 +1270,7 @@ importers: devDependencies: bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) packages/providers/mixedbread: dependencies: @@ -1278,7 +1286,7 @@ importers: devDependencies: bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) packages/providers/ollama: dependencies: @@ -1297,7 +1305,7 @@ importers: devDependencies: bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) packages/providers/openai: dependencies: @@ -1313,7 +1321,7 @@ importers: devDependencies: bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) packages/providers/portkey-ai: dependencies: @@ -1332,7 +1340,7 @@ importers: devDependencies: bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) packages/providers/replicate: dependencies: @@ -1348,7 +1356,7 @@ importers: devDependencies: bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) packages/providers/storage/astra: dependencies: @@ -1364,7 +1372,7 @@ importers: devDependencies: bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) packages/providers/storage/azure: dependencies: @@ -1395,7 +1403,7 @@ importers: version: 22.9.0 bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) dotenv: specifier: ^16.4.7 version: 16.4.7 @@ -1420,7 +1428,7 @@ importers: devDependencies: bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) packages/providers/storage/milvus: dependencies: @@ -1442,7 +1450,7 @@ importers: version: link:../../openai bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) vitest: specifier: ^2.1.5 version: 2.1.5(@edge-runtime/vm@4.0.4)(@types/node@22.9.0)(happy-dom@15.11.7)(msw@2.7.0(@types/node@22.9.0)(typescript@5.7.3))(terser@5.38.2) @@ -1461,7 +1469,7 @@ importers: devDependencies: bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) packages/providers/storage/pinecone: dependencies: @@ -1477,7 +1485,7 @@ importers: devDependencies: bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) packages/providers/storage/postgres: dependencies: @@ -1502,7 +1510,7 @@ importers: version: 0.10.0 bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) pgvector: specifier: 0.2.0 version: 0.2.0 @@ -1527,7 +1535,7 @@ importers: version: link:../../openai bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) vitest: specifier: ^2.1.5 version: 2.1.5(@edge-runtime/vm@4.0.4)(@types/node@22.9.0)(happy-dom@15.11.7)(msw@2.7.0(@types/node@22.9.0)(typescript@5.7.3))(terser@5.38.2) @@ -1546,7 +1554,7 @@ importers: devDependencies: bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) packages/providers/storage/weaviate: dependencies: @@ -1562,7 +1570,7 @@ importers: devDependencies: bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) packages/providers/vercel: dependencies: @@ -1578,7 +1586,7 @@ importers: devDependencies: bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) packages/providers/vllm: dependencies: @@ -1588,7 +1596,7 @@ importers: devDependencies: bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) packages/readers: dependencies: @@ -1637,7 +1645,7 @@ importers: version: 22.9.0 bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) p-limit: specifier: ^6.1.0 version: 6.2.0 @@ -1677,7 +1685,7 @@ importers: version: 22.9.0 bunchee: specifier: 6.3.4 - version: 6.3.4(typescript@5.7.3) + version: 6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3) unit: dependencies: @@ -16411,7 +16419,7 @@ snapshots: dependencies: node-gyp-build: 4.8.4 - bunchee@6.3.4(typescript@5.7.2): + bunchee@6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.2): dependencies: '@rollup/plugin-commonjs': 28.0.2(rollup@4.34.6) '@rollup/plugin-json': 6.1.0(rollup@4.34.6) @@ -16436,7 +16444,7 @@ snapshots: optionalDependencies: typescript: 5.7.2 - bunchee@6.3.4(typescript@5.7.3): + bunchee@6.3.4(patch_hash=pavboztthlgni7m5gzw7643oru)(typescript@5.7.3): dependencies: '@rollup/plugin-commonjs': 28.0.2(rollup@4.34.6) '@rollup/plugin-json': 6.1.0(rollup@4.34.6) @@ -20768,21 +20776,6 @@ snapshots: transitivePeerDependencies: - encoding - openai@4.83.0(ws@8.18.0)(zod@3.24.2): - dependencies: - '@types/node': 18.19.75 - '@types/node-fetch': 2.6.12 - abort-controller: 3.0.0 - agentkeepalive: 4.6.0 - form-data-encoder: 1.7.2 - formdata-node: 4.4.1 - node-fetch: 2.7.0 - optionalDependencies: - ws: 8.18.0(bufferutil@4.0.9) - zod: 3.24.2 - transitivePeerDependencies: - - encoding - openapi-sampler@1.6.1: dependencies: '@types/json-schema': 7.0.15