Download policies/codex-final-enumeration/multi-answer-enumeration.mjs from failproofai/fire-runtime-policy-reliability: direct link, hf CLI and curl.
- Browser
- Download file 1.59 kB
-
https://huggingface.co/datasets/failproofai/fire-runtime-policy-reliability/resolve/main/policies/codex-final-enumeration/multi-answer-enumeration.mjs
- Command line
-
hf download hf://datasets/failproofai/fire-runtime-policy-reliability/policies/codex-final-enumeration/multi-answer-enumeration.mjs
-
curl -L -o multi-answer-enumeration.mjs https://huggingface.co/datasets/failproofai/fire-runtime-policy-reliability/resolve/main/policies/codex-final-enumeration/multi-answer-enumeration.mjs
1.59 kB
| // Narrow successor to the generic quantifier policy. It targets tasks that | |
| // explicitly require every valid/winning answer as separate output records. | |
| import { customPolicies, allow, instruct } from "failproofai"; | |
| import { load, save, promptOf, shouldNudge } from "../_lib/state.mjs"; | |
| const MULTIPLE = /\b(?:multiple|more than one|all|every)\b[^.\n]{0,100}\b(?:winning|valid|correct|acceptable)\b[^.\n]{0,80}\b(?:moves?|answers?|solutions?|results?)\b/i; | |
| const OUTPUT_EACH = /\b(?:one per line|each on (?:a|its own) line|print them all|write them all|output them all)\b/i; | |
| customPolicies.add({ | |
| name: "final-multi-answer-track", | |
| match: { events: ["UserPromptSubmit"] }, | |
| fn: async (ctx) => { | |
| const s = load(ctx); | |
| const prompt = promptOf(ctx); | |
| if (prompt && MULTIPLE.test(prompt) && OUTPUT_EACH.test(prompt)) s.finalMultiAnswer = true; | |
| save(ctx, s); | |
| return allow(); | |
| }, | |
| }); | |
| customPolicies.add({ | |
| name: "final-multi-answer-enumeration", | |
| match: { events: ["Stop"] }, | |
| fn: async (ctx) => { | |
| const s = load(ctx); | |
| if (!s.finalMultiAnswer || !shouldNudge(s, "final-multi-answer", 1)) return allow(); | |
| save(ctx, s); | |
| return instruct( | |
| `The output contract requires every valid answer, not one witness. Enumerate the complete candidate ` + | |
| `set, test each candidate against the task's winning or validity condition, remove duplicates, and emit ` + | |
| `all surviving answers in the exact requested one-record-per-line format. Before stopping, verify that ` + | |
| `no additional candidate satisfies the same condition.` | |
| ); | |
| }, | |
| }); | |