mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-14 00:27:55 +00:00
Docs: Update benchmark for openrouter/bert-nebulon-alpha
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
const validateJSON = async (json, schema) => {
|
||||
try {
|
||||
const { default: Ajv } = await import('https://cdn.jsdelivr.net/npm/ajv@8.12.0/+esm')
|
||||
const { default: addFormats } = await import('https://cdn.jsdelivr.net/npm/ajv-formats@2.1.1/+esm')
|
||||
|
||||
const ajv = new Ajv({
|
||||
allErrors: true,
|
||||
strict: false,
|
||||
validateSchema: true
|
||||
})
|
||||
|
||||
addFormats(ajv)
|
||||
|
||||
const validate = ajv.compile(schema)
|
||||
const valid = validate(json)
|
||||
|
||||
return {
|
||||
valid,
|
||||
errors: valid ? [] : validate.errors.map(err => ({
|
||||
message: err.message,
|
||||
instancePath: err.instancePath,
|
||||
schemaPath: err.schemaPath,
|
||||
params: err.params
|
||||
}))
|
||||
}
|
||||
} catch (error) {
|
||||
return {
|
||||
valid: false,
|
||||
errors: [{
|
||||
message: error.message,
|
||||
stack: error.stack
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
export default validateJSON;
|
||||
Reference in New Issue
Block a user