Release 12.0 (full): one browser harness that converses, writes from held sources and builds what you describe, keeping each request through corrections and restarts. No language model. (part 5)
d9b105f verified Download workbench/kernel/kernel_v9.py from psiloceyeben/oracle7: direct link, hf CLI and curl.
- Browser
- Download file 3.48 kB
-
https://huggingface.co/psiloceyeben/oracle7/resolve/main/workbench/kernel/kernel_v9.py
- Command line
-
hf download hf://psiloceyeben/oracle7/workbench/kernel/kernel_v9.py
-
curl -L -o kernel_v9.py https://huggingface.co/psiloceyeben/oracle7/resolve/main/workbench/kernel/kernel_v9.py
3.48 kB
| #!/usr/bin/env python3 | |
| """The Oracle7 kernel, v9: v8's reader fixes (units with "/" read whole, never short; articles never goal units), WITHOUT | |
| v8's IDF cue filter (it cost right answers on every sealed set), and three structural laws found by v8's OpenStax run. | |
| Reading more questions surfaced more weak paths, the 09-30 law in action (dimensional analysis can't see hidden | |
| factors: 1/2, 2, pi, geometry). So the law changes in structure, not by item: | |
| 1. AN IMPLICIT GOAL COMES FROM A PART THAT GIVES IT. When the question doesn't state the unit it wants ("What minimum | |
| force...", "What is the coefficient of performance..."), the answer must be produced directly by a formula part or a | |
| specialist face whose output is that quantity; core arithmetic may not finish the chain by combining leftover | |
| givens. An explicit unit goal ("in kWh") keeps the arithmetic finish: the everyday unit-chain family where it has | |
| held (every sealed set). | |
| 2. ONE QUESTION PER TURN. A turn that asks two things (two sentences ending in "?") is declined, not half-answered. | |
| 3. THE WANTED QUANTITY IS THE HEAD OF THE ASKING PHRASE: the first part-declared noun after "what is the / what / how | |
| much", up to "of / for / when / if / that / ,", not any quantity noun elsewhere in the sentence. | |
| usage: module (Kernel9, a drop-in for Kernel8)""" | |
| from __future__ import annotations | |
| import re | |
| import kernel_v4 | |
| import kernel_v5 | |
| from kernel_v8 import Kernel8 | |
| reader = kernel_v5.reader | |
| HEAD = re.compile(r"\b(?:what is the|what are the|what was the|what's the|find the|calculate the|determine the|what|how much)\s+" | |
| r"(.+?)(?:\s+(?:of|for|when|if|that|which|in|at|on|to|does|do|is|was|must|would|will|can)\b|[,?.]|$)", re.I) | |
| class Kernel9(Kernel8): | |
| def _cues(self, f): | |
| return kernel_v4.Kernel4._cues(self, f) # v8's IDF filter removed | |
| def _wanted(self, text): | |
| ask = self._asking(text) | |
| m = HEAD.search(ask) | |
| span = (m.group(1) if m else ask).lower() | |
| for n in self.nouns: # longest first, inside the asking phrase's head only | |
| if re.search(r"\b%s\b" % re.escape(n), span): | |
| return n | |
| return None | |
| def solve(self, text, session="kernel"): | |
| t = reader.normalise(text) | |
| if len([s for s in re.split(r"(?<=[.?!])\s+", t.strip()) if s.strip().endswith("?")]) > 1: | |
| h = self.head_chat(text, session) | |
| if h.get("status") == "answered": | |
| return {"status": "answered", "answer": h.get("response"), "reading": "head", "head": h, | |
| "path": [str(h.get("path"))]} | |
| return {"status": "declined", "reason": "two questions in one turn: ask them one at a time", | |
| "check": "one question per turn"} | |
| explicit = reader.read_goal(self._asking(t)) is not None | |
| r = super().solve(text, session) | |
| if r.get("status") == "answered" and r.get("reading") not in ("declared", "head") and not explicit: | |
| tr = r.get("trace", []) | |
| last = tr[-1] if tr else {} | |
| if last.get("node") == "core_math" and len([x for x in str(last.get("formula", "")).split("×") if x.strip()]) > 1: | |
| return {"status": "declined", "reason": "an implicit goal must come from a part that gives it, not from " | |
| "arithmetic over leftover givens", "check": "implicit goal from a part"} | |
| return r | |