mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-14 00:27:55 +00:00
Docs: Update benchmark for openrouter/sherlock-think-alpha
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
const getAjv = async () => {
|
||||
if (!getAjv.instance) {
|
||||
const { default: Ajv } = await import('https://cdn.skypack.dev/ajv@8');
|
||||
getAjv.instance = new Ajv({ allErrors: true });
|
||||
}
|
||||
return getAjv.instance;
|
||||
};
|
||||
|
||||
const validateJSON = async (data, schema) => {
|
||||
try {
|
||||
const ajv = await getAjv();
|
||||
const validate = ajv.compile(schema);
|
||||
const valid = validate(data);
|
||||
const errors = valid ? [] : ajv.errorsText(ajv.errors, { separator: '\n' }).split('\n').filter(s => s.trim());
|
||||
return { valid, errors };
|
||||
} catch (e) {
|
||||
return { valid: false, errors: [`Validation error: ${e.message}`] };
|
||||
}
|
||||
};
|
||||
export default validateJSON;
|
||||
Reference in New Issue
Block a user