remove returnJSONStr function

This commit is contained in:
chungyau97 2023-06-27 23:07:31 +08:00
parent 4e36be3214
commit b6a5cd0cb3
1 changed files with 3 additions and 4 deletions

View File

@ -1,5 +1,5 @@
import { ICommonObject, INode, INodeData, INodeParams, PromptTemplate } from '../../../src/Interface' import { ICommonObject, INode, INodeData, INodeParams, PromptTemplate } from '../../../src/Interface'
import { getBaseClasses, getInputVariables, returnJSONStr } from '../../../src/utils' import { getBaseClasses, getInputVariables } from '../../../src/utils'
import { PromptTemplateInput } from 'langchain/prompts' import { PromptTemplateInput } from 'langchain/prompts'
class PromptTemplate_Prompts implements INode { class PromptTemplate_Prompts implements INode {
@ -46,12 +46,11 @@ class PromptTemplate_Prompts implements INode {
async init(nodeData: INodeData): Promise<any> { async init(nodeData: INodeData): Promise<any> {
const template = nodeData.inputs?.template as string const template = nodeData.inputs?.template as string
let promptValuesStr = nodeData.inputs?.promptValues as string const promptValuesStr = nodeData.inputs?.promptValues as string
let promptValues: ICommonObject = {} let promptValues: ICommonObject = {}
if (promptValuesStr) { if (promptValuesStr) {
promptValuesStr = promptValuesStr.replace(/\s/g, '') promptValues = JSON.parse(promptValuesStr.replace(/\s/g, ''))
promptValues = JSON.parse(returnJSONStr(promptValuesStr))
} }
const inputVariables = getInputVariables(template) const inputVariables = getInputVariables(template)