Download source.py from ShinyUser/sn99-miner3-v1: direct link, hf CLI and curl.
- Browser
- Download file 3.73 kB
-
https://huggingface.co/ShinyUser/sn99-miner3-v1/resolve/main/source.py
- Command line
-
hf download hf://ShinyUser/sn99-miner3-v1/source.py
-
curl -L -o source.py https://huggingface.co/ShinyUser/sn99-miner3-v1/resolve/main/source.py
3.73 kB
| """Miner3 v1: one-call, task-general independent review for ThirtySpokes SN99.""" | |
| import json | |
| _MODEL = "openai/gpt-5.6-luna" | |
| _FORMAT = "miner3-independent-review-v1" | |
| _EFFORTS = ("low", "medium", "high") | |
| _SENTINEL = 271828182845904523536 | |
| _PROGRAM_REQUEST = ( | |
| "Before writing the program, privately perform two independent reviews. First translate every " | |
| "requirement and maximum constraint into invariants, state transitions, and a complexity bound. " | |
| "Then try to falsify the planned algorithm using boundaries, operation order, repeated updates, " | |
| "and every published sample. Reconcile any conflict before answering. Return only complete raw " | |
| "Python 3 source, without Markdown or explanation." | |
| ) | |
| def _is_program(text): | |
| value = str(text) | |
| return ( | |
| "Write a complete Python 3 program" in value | |
| and "standard input" in value | |
| and "standard output" in value | |
| ) | |
| def _is_multiple_choice(text): | |
| value = "\n" + str(text) | |
| return all("\n" + option + ")" in value for option in "ABCD") | |
| def _load_policy(weights): | |
| try: | |
| policy = json.loads(bytes(weights).decode("utf-8")) | |
| except Exception as exc: | |
| raise ValueError("miner3-v1 weights are not valid JSON") from exc | |
| fields = { | |
| "format", | |
| "model", | |
| "code_effort", | |
| "floor_effort", | |
| "max_tokens", | |
| "prompt_revision", | |
| "provenance_sentinel", | |
| } | |
| if not isinstance(policy, dict) or set(policy) != fields: | |
| raise ValueError("miner3-v1 policy schema is malformed") | |
| if policy.get("format") != _FORMAT or policy.get("model") != _MODEL: | |
| raise ValueError("miner3-v1 policy identity is malformed") | |
| if policy.get("code_effort") != "low" or policy.get("floor_effort") != "medium": | |
| raise ValueError("miner3-v1 effort policy is malformed") | |
| if policy["code_effort"] not in _EFFORTS or policy["floor_effort"] not in _EFFORTS: | |
| raise ValueError("miner3-v1 effort value is malformed") | |
| if type(policy.get("max_tokens")) is not int or policy["max_tokens"] != 16384: | |
| raise ValueError("miner3-v1 token limit is malformed") | |
| if type(policy.get("prompt_revision")) is not int or policy["prompt_revision"] != 1: | |
| raise ValueError("miner3-v1 prompt revision is malformed") | |
| if ( | |
| type(policy.get("provenance_sentinel")) is not int | |
| or policy["provenance_sentinel"] != _SENTINEL | |
| ): | |
| raise ValueError("miner3-v1 provenance policy is malformed") | |
| return policy | |
| def build_agent(weights): | |
| policy = _load_policy(weights) | |
| def parameters(effort): | |
| return { | |
| "max_tokens": policy["max_tokens"], | |
| "reasoning": {"effort": effort}, | |
| } | |
| def request(call_model, content, effort): | |
| return call_model( | |
| _MODEL, | |
| [{"role": "user", "content": content}], | |
| parameters(effort), | |
| ) | |
| def agent(prompt, call_model): | |
| original = str(prompt) | |
| if _is_program(original): | |
| return request( | |
| call_model, | |
| original + "\n\n" + _PROGRAM_REQUEST, | |
| policy["code_effort"], | |
| ) | |
| if _is_multiple_choice(original): | |
| return request(call_model, original, policy["floor_effort"]) | |
| numeric_request = ( | |
| original | |
| + "\n\nSolve in the requested units and place the final numeric answer alone on the " | |
| "last line. The following fixed provenance sentinel is unrelated to the problem and " | |
| "must not appear in the response: %d" % policy["provenance_sentinel"] | |
| ) | |
| return request(call_model, numeric_request, policy["floor_effort"]) | |
| return agent | |