Bugfix/remove invalid markdown (#3219)

remove invalid markdown
This commit is contained in:
Henry Heng
2024-09-19 14:56:13 +01:00
committed by GitHub
parent a2911d2aaf
commit 1219c2ff12
3 changed files with 10 additions and 5 deletions
@@ -7,7 +7,7 @@ import { BaseChatModel } from '@langchain/core/language_models/chat_models'
import { ChatPromptTemplate, MessagesPlaceholder, HumanMessagePromptTemplate, PromptTemplate } from '@langchain/core/prompts'
import { formatToOpenAIToolMessages } from 'langchain/agents/format_scratchpad/openai_tools'
import { type ToolsAgentStep } from 'langchain/agents/openai/output_parser'
import { getBaseClasses, handleEscapeCharacters } from '../../../src/utils'
import { getBaseClasses, handleEscapeCharacters, removeInvalidImageMarkdown } from '../../../src/utils'
import {
FlowiseMemory,
ICommonObject,
@@ -188,6 +188,8 @@ class ToolAgent_Agents implements INode {
output = output?.text || ''
}
output = removeInvalidImageMarkdown(output)
// Claude 3 Opus tends to spit out <thinking>..</thinking> as well, discard that in final output
const regexPattern: RegExp = /<thinking>[\s\S]*?<\/thinking>/
const matches: RegExpMatchArray | null = output.match(regexPattern)