mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 05:04:05 -08:00
fix(LangChain Code Node): Fix resolution of scoped langchain modules (#9258)
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
This commit is contained in:
parent
f6c9493355
commit
445c05dca4
|
@ -48,13 +48,14 @@ return [ {json: { output } } ];`;
|
||||||
const defaultCodeSupplyData = `const { WikipediaQueryRun } = require('langchain/tools');
|
const defaultCodeSupplyData = `const { WikipediaQueryRun } = require('langchain/tools');
|
||||||
return new WikipediaQueryRun();`;
|
return new WikipediaQueryRun();`;
|
||||||
|
|
||||||
|
const langchainModules = ['langchain', '@langchain/*'];
|
||||||
export const vmResolver = makeResolverFromLegacyOptions({
|
export const vmResolver = makeResolverFromLegacyOptions({
|
||||||
external: {
|
external: {
|
||||||
modules: external ? ['langchain', ...external.split(',')] : ['langchain'],
|
modules: external ? [...langchainModules, ...external.split(',')] : [...langchainModules],
|
||||||
transitive: false,
|
transitive: false,
|
||||||
},
|
},
|
||||||
resolve(moduleName, parentDirname) {
|
resolve(moduleName, parentDirname) {
|
||||||
if (moduleName.match(/^langchain\//)) {
|
if (moduleName.match(/^langchain\//) ?? moduleName.match(/^@langchain\//)) {
|
||||||
return require.resolve(`@n8n/n8n-nodes-langchain/node_modules/${moduleName}.cjs`, {
|
return require.resolve(`@n8n/n8n-nodes-langchain/node_modules/${moduleName}.cjs`, {
|
||||||
paths: [parentDirname],
|
paths: [parentDirname],
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue