knowledge: typed outputs for all 5 remaining signatures (block PR)
The typed-output migration completes: every knowledge signature now declares its structure as Python types and dspy renders/parses it. - TranslateSignature: queries/entities as list[str] — the 'QUERIES:'/'ENTITIES:' line protocol and its prefix-scraping parser are gone - AnswerFromKG: confidence is a local Confidence(str, Enum) (knowledge stays decoupled from floop) - SelectTableSignature: chosen is TableChoice | None (index int, column, set_name) — 'NONE' string handling gone; origin_question dropped (it duplicated the input) - SkimPromoteSignature: decisions as list[PromotionDecision] (table_index int, promote bool, column) — the 'idx: YES col' regex parser gone - VerifyCountSignature: unchanged shape (quote str + NOQUOTE convention predates typed migration; kept — it is an answer-shaped field, not a format protocol) Callers consume typed objects directly. Test fakes updated to the new contracts (promote/store/guards). VERIFIED: - suite 14/14 green (84 tests) - live E2E (ollama-cloud glm-5.3-flash, Italy rivers, fresh KG): correct answer 2014 m3/s (Po 1540 + Adige 235 + Tiber 239) with verified join; wire prompts show list[str]/TableChoice/Confidence/ list[Fact] schemas rendered natively
This commit is contained in:
@@ -13,6 +13,7 @@ from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) # code/
|
||||
|
||||
from knowledge.wiki import WikiPage, parse_tables
|
||||
from knowledge.extract import TableChoice
|
||||
from knowledge.expert import (KnowledgeExpert, KnowledgeConfig,
|
||||
_tokens, _term_hits, _proper_nouns)
|
||||
from knowledge.store import KnowledgeStore
|
||||
@@ -118,10 +119,8 @@ def test_subject_guard_list():
|
||||
e2 = make_expert(KnowledgeStore(f"{tmp2}/kg.sqlite"))
|
||||
|
||||
class Pred:
|
||||
table_index = "1"
|
||||
column = "River"
|
||||
set_name = "longest rivers of Italy"
|
||||
origin_question = q
|
||||
chosen = TableChoice(table_index=1, column="River",
|
||||
set_name="longest rivers of Italy")
|
||||
|
||||
e2.select_table = lambda **kw: Pred()
|
||||
ans2 = e2._list_from_page(italy_page(), q, None)
|
||||
|
||||
Reference in New Issue
Block a user