mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-03-17 03:11:01 +00:00
Docs: Update benchmark for openai/gpt-5.3-codex
This commit is contained in:
@@ -1,4 +1,33 @@
|
||||
let ajvReady;
|
||||
|
||||
const getAjv = () =>
|
||||
ajvReady ??= (async () => {
|
||||
const { default: Ajv } = await import("https://esm.sh/ajv@8");
|
||||
return new Ajv({ allErrors: true, strict: false });
|
||||
})();
|
||||
|
||||
async function validateJSON(data, schema) {
|
||||
if (!schema || typeof schema !== "object" || Array.isArray(schema)) {
|
||||
return { valid: false, errors: ["Schema must be a JSON object"] };
|
||||
}
|
||||
|
||||
let validate;
|
||||
try {
|
||||
const ajv = await getAjv();
|
||||
validate = ajv.compile(schema);
|
||||
} catch (e) {
|
||||
return { valid: false, errors: [`Invalid schema: ${e?.message || String(e)}`] };
|
||||
}
|
||||
|
||||
const valid = !!validate(data);
|
||||
const errors = valid
|
||||
? []
|
||||
: (validate.errors || []).map(
|
||||
e => `${e.instancePath || "/"} ${e.message || "is invalid"}`
|
||||
);
|
||||
|
||||
return { valid, errors };
|
||||
}
|
||||
export default validateJSON;
|
||||
// Generation time: 0.319s
|
||||
// Result: FAIL
|
||||
// Generation time: 20.276s
|
||||
// Result: PASS
|
||||
Reference in New Issue
Block a user