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
@@ -7,7 +7,7 @@ import { AgentStep } from '@langchain/core/agents'
import { renderTemplate, MessagesPlaceholder, HumanMessagePromptTemplate, PromptTemplate } from '@langchain/core/prompts'
import { RunnableSequence } from '@langchain/core/runnables'
import { ChatConversationalAgent } from 'langchain/agents'
import { getBaseClasses } from '../../../src/utils'
import { getBaseClasses, transformBracesWithColon } from '../../../src/utils'
import { ConsoleCallbackHandler, CustomChainHandler, additionalCallbacks } from '../../../src/handler'
import {
IVisionChatModal,
@@ -218,7 +218,7 @@ const prepareAgent = async (
let tools = nodeData.inputs?.tools as Tool[]
tools = flatten(tools)
const memory = nodeData.inputs?.memory as FlowiseMemory
const systemMessage = nodeData.inputs?.systemMessage as string
let systemMessage = nodeData.inputs?.systemMessage as string
const memoryKey = memory.memoryKey ? memory.memoryKey : 'chat_history'
const inputKey = memory.inputKey ? memory.inputKey : 'input'
const prependMessages = options?.prependMessages
@@ -228,6 +228,8 @@ const prepareAgent = async (
toolNames: tools.map((tool) => tool.name)
})
systemMessage = transformBracesWithColon(systemMessage)
const prompt = ChatConversationalAgent.createPrompt(tools, {
systemMessage: systemMessage ? systemMessage : DEFAULT_PREFIX,
outputParser