Improve Error Messaging for Missing LLM Node Input Variables and Optimize Lodash Imports (#4167)

enhance input error logging
This commit is contained in:
Egor Kopylov 2025-04-02 20:08:42 +03:00 committed by GitHub
parent 0e1b1ee251
commit cb06df4584
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 3 deletions

View File

@ -1,4 +1,4 @@
import { flatten, uniq } from 'lodash'
import { difference, flatten, uniq } from 'lodash'
import { DataSource } from 'typeorm'
import { z } from 'zod'
import { RunnableSequence, RunnablePassthrough, RunnableConfig } from '@langchain/core/runnables'
@ -430,8 +430,15 @@ class LLMNode_SeqAgents implements INode {
const abortControllerSignal = options.signal as AbortController
const llmNodeInputVariables = uniq([...getInputVariables(systemPrompt), ...getInputVariables(humanPrompt)])
if (!llmNodeInputVariables.every((element) => Object.keys(llmNodeInputVariablesValues).includes(element))) {
throw new Error('LLM Node input variables values are not provided!')
const missingInputVars = difference(llmNodeInputVariables, Object.keys(llmNodeInputVariablesValues)).join(' ')
const allVariablesSatisfied = missingInputVars.length === 0
if (!allVariablesSatisfied) {
const nodeInputVars = llmNodeInputVariables.join(' ')
const providedInputVars = Object.keys(llmNodeInputVariablesValues).join(' ')
throw new Error(
`LLM Node input variables values are not provided! Required: ${nodeInputVars}, Provided: ${providedInputVars}. Missing: ${missingInputVars}`
)
}
const workerNode = async (state: ISeqAgentsState, config: RunnableConfig) => {