mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-18 14:44:40 +00:00
add prompt schema validation debug logs (#17812)
This commit is contained in:
@@ -1318,6 +1318,31 @@ export namespace SessionPrompt {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const parsedInfo = MessageV2.Info.safeParse(info)
|
||||||
|
if (!parsedInfo.success) {
|
||||||
|
log.error("invalid user message before save", {
|
||||||
|
sessionID: input.sessionID,
|
||||||
|
messageID: info.id,
|
||||||
|
agent: info.agent,
|
||||||
|
model: info.model,
|
||||||
|
issues: parsedInfo.error.issues,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
parts.forEach((part, index) => {
|
||||||
|
const parsedPart = MessageV2.Part.safeParse(part)
|
||||||
|
if (parsedPart.success) return
|
||||||
|
log.error("invalid user part before save", {
|
||||||
|
sessionID: input.sessionID,
|
||||||
|
messageID: info.id,
|
||||||
|
partID: part.id,
|
||||||
|
partType: part.type,
|
||||||
|
index,
|
||||||
|
issues: parsedPart.error.issues,
|
||||||
|
part,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
await Session.updateMessage(info)
|
await Session.updateMessage(info)
|
||||||
for (const part of parts) {
|
for (const part of parts) {
|
||||||
await Session.updatePart(part)
|
await Session.updatePart(part)
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ export function fn<T extends z.ZodType, Result>(schema: T, cb: (input: z.infer<T
|
|||||||
parsed = schema.parse(input)
|
parsed = schema.parse(input)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.trace("schema validation failure stack trace:")
|
console.trace("schema validation failure stack trace:")
|
||||||
|
if (e instanceof z.ZodError) {
|
||||||
|
console.error("schema validation issues:", JSON.stringify(e.issues, null, 2))
|
||||||
|
}
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user