Bugfix/Anthropic messages in agentflow (#3801)

fix anthropic messages in agentflow
This commit is contained in:
Henry Heng
2025-01-03 22:47:46 +00:00
committed by GitHub
parent e22c60115e
commit 1111101cff
4 changed files with 31 additions and 9 deletions
+15
View File
@@ -1001,6 +1001,21 @@ export const removeInvalidImageMarkdown = (output: string): string => {
return typeof output === 'string' ? output.replace(/!\[.*?\]\((?!https?:\/\/).*?\)/g, '') : output
}
/**
* Extract output from array
* @param {any} output
* @returns {string}
*/
export const extractOutputFromArray = (output: any): string => {
if (Array.isArray(output)) {
return output.map((o) => o.text).join('\n')
} else if (typeof output === 'object') {
if (output.text) return output.text
else return JSON.stringify(output)
}
return output
}
/**
* Loop through the object and replace the key with the value
* @param {any} obj