Bugfix/Escape JSON in Prompt Message (#3901)

add fix to only get variables when there is no colon
This commit is contained in:
Henry Heng
2025-01-20 19:18:28 +00:00
committed by GitHub
parent 4c9d46d7e5
commit 4aa97b0c9a
16 changed files with 148 additions and 46 deletions
@@ -1,5 +1,5 @@
import { ICommonObject, INode, INodeData, INodeParams, PromptTemplate } from '../../../src/Interface'
import { getBaseClasses, getInputVariables } from '../../../src/utils'
import { getBaseClasses, getInputVariables, transformBracesWithColon } from '../../../src/utils'
import { PromptTemplateInput } from '@langchain/core/prompts'
class PromptTemplate_Prompts implements INode {
@@ -42,7 +42,7 @@ class PromptTemplate_Prompts implements INode {
}
async init(nodeData: INodeData): Promise<any> {
const template = nodeData.inputs?.template as string
let template = nodeData.inputs?.template as string
const promptValuesStr = nodeData.inputs?.promptValues
let promptValues: ICommonObject = {}
@@ -55,6 +55,7 @@ class PromptTemplate_Prompts implements INode {
}
const inputVariables = getInputVariables(template)
template = transformBracesWithColon(template)
try {
const options: PromptTemplateInput = {