Describe the problem/error/question
See the workflow below. It’s basically the default code that comes with the node, but with a empty line at the beginning. The point is that if that line is not empty, the code reads as empty and I get the No code for "Execute" set on node "LangChain Code
error.
If the first line is not empty, in this case, I can’t even copy here, because it would render the workflow as empty on the visualization.
I can let the first line be the require
one, if (and only if) the next line is not empty.
So in summary:
This gives me No code for "Execute" set on node "LangChain Code
error
const { PromptTemplate } = require('@langchain/core/prompts');
const query = 'Tell me a joke';
const prompt = PromptTemplate.fromTemplate(query);
const llm = await this.getInputConnectionData('ai_languageModel', 0);
let chain = prompt.pipe(llm);
const output = await chain.invoke();
return [ {json: { output } } ];
This DOES NOT give me No code for "Execute" set on node "LangChain Code
error
//Empty Line
const { PromptTemplate } = require('@langchain/core/prompts');
const query = 'Tell me a joke';
const prompt = PromptTemplate.fromTemplate(query);
const llm = await this.getInputConnectionData('ai_languageModel', 0);
let chain = prompt.pipe(llm);
const output = await chain.invoke();
return [ {json: { output } } ];
This also DOES NOT give me No code for "Execute" set on node "LangChain Code
error
const { PromptTemplate } = require('@langchain/core/prompts');
const query = 'Tell me a joke';
const prompt = PromptTemplate.fromTemplate(query);
const llm = await this.getInputConnectionData('ai_languageModel', 0);
let chain = prompt.pipe(llm);
const output = await chain.invoke();
return [ {json: { output } } ];
When the node code executes, I get another error Expected a Runnable, function or object. [line 7]
, regarding the let chain = prompt.pipe(llm)
line, but that’s subject for another topic.
Please share your workflow
Share the output returned by the last node
Information on your n8n setup
- n8n version: 1.38.1
- Database (default: SQLite): SQLite
- n8n EXECUTIONS_PROCESS setting (default: own, main): own
- Running n8n via (Docker, npm, n8n cloud, desktop app): k8s
- Operating system: ubuntu