MCPcopy
hub / github.com/FlowiseAI/Flowise / validateHistorySchema

Function validateHistorySchema

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

Source from the content-addressed store, hash-verified

2109 * @returns {boolean} - True if all items are valid, false otherwise
2110 */
2111export const validateHistorySchema = (history: any[]): boolean => {
2112 if (!Array.isArray(history)) {
2113 return false
2114 }
2115
2116 return history.every((item) => {
2117 // Check if item is an object
2118 if (typeof item !== 'object' || item === null) {
2119 return false
2120 }
2121
2122 // Check if role exists and is valid
2123 if (typeof item.role !== 'string' || !['apiMessage', 'userMessage'].includes(item.role)) {
2124 return false
2125 }
2126
2127 // Check if content exists and is a string
2128 if (typeof item.content !== 'string') {
2129 return false
2130 }
2131
2132 return true
2133 })
2134}

Callers 1

executeAgentFlowFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected