@ai2070/l0
Version:
L0: The Missing Reliability Substrate for AI
41 lines (40 loc) • 1.03 kB
JavaScript
function runAsyncGuardrailCheck(engine, context, onComplete) {
if (context.delta && context.delta.length < 1e3) {
const quickContext = {
...context,
content: context.delta
// Only check the delta
};
const quickResult = engine.check(quickContext);
if (quickResult.violations.length > 0) {
return quickResult;
}
if (context.content.length < 5e3) {
return engine.check(context);
}
}
setImmediate(() => {
try {
const result = engine.check(context);
onComplete(result);
} catch {
onComplete({ violations: [], shouldHalt: false, shouldRetry: false });
}
});
return void 0;
}
function runGuardrailCheckAsync(engine, context, onComplete) {
setImmediate(() => {
try {
const result = engine.check(context);
onComplete(result);
} catch {
onComplete({ violations: [], shouldHalt: false, shouldRetry: false });
}
});
}
export {
runAsyncGuardrailCheck,
runGuardrailCheckAsync
};
//# sourceMappingURL=async.js.map