Update commonUtils.ts (#3470)

Fixed a bug in `restructureMessages` leading to blowing up of the message content with escape characters and eventually crashing the flow with "repetitive patterns" error
This commit is contained in:
serhiy-matoffo 2024-11-06 18:30:45 +02:00 committed by GitHub
parent afd2ddbdde
commit 99f28a2dff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 1 deletions

View File

@ -212,7 +212,7 @@ export const restructureMessages = (llm: BaseChatModel, state: ISeqAgentsState)
const messages: BaseMessage[] = [] const messages: BaseMessage[] = []
for (const message of state.messages as unknown as BaseMessage[]) { for (const message of state.messages as unknown as BaseMessage[]) {
// Sometimes Anthropic can return a message with content types of array, ignore that EXECEPT when tool calls are present // Sometimes Anthropic can return a message with content types of array, ignore that EXECEPT when tool calls are present
if ((message as any).tool_calls?.length) { if ((message as any).tool_calls?.length && message.content !== '') {
message.content = JSON.stringify(message.content) message.content = JSON.stringify(message.content)
} }