mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -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');
|
||||
return new WikipediaQueryRun();`;
|
||||
|
||||
const langchainModules = ['langchain', '@langchain/*'];
|
||||
export const vmResolver = makeResolverFromLegacyOptions({
|
||||
external: {
|
||||
modules: external ? ['langchain', ...external.split(',')] : ['langchain'],
|
||||
modules: external ? [...langchainModules, ...external.split(',')] : [...langchainModules],
|
||||
transitive: false,
|
||||
},
|
||||
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`, {
|
||||
paths: [parentDirname],
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue