MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / validateHistorySchema

Function validateHistorySchema

packages/server/src/utils/index.ts:2120–2143  ·  view source on GitHub ↗
(history: any[])

Source from the content-addressed store, hash-verified

2118 * @returns {boolean} - True if all items are valid, false otherwise
2119 */
2120export const validateHistorySchema = (history: any[]): boolean => {
2121 if (!Array.isArray(history)) {
2122 return false
2123 }
2124
2125 return history.every((item) => {
2126 // Check if item is an object
2127 if (typeof item !== 'object' || item === null) {
2128 return false
2129 }
2130
2131 // Check if role exists and is valid
2132 if (typeof item.role !== 'string' || !['apiMessage', 'userMessage'].includes(item.role)) {
2133 return false
2134 }
2135
2136 // Check if content exists and is a string
2137 if (typeof item.content !== 'string') {
2138 return false
2139 }
2140
2141 return true
2142 })
2143}

Callers 1

executeAgentFlowFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected