mixle.substrate.answer module¶
Answer a question from substrate evidence with citations.
Given a question and a pluggable answerer callable, this module retrieves
evidence, assembles a budgeted context packet, and either returns an answer from
that evidence or abstains when the evidence is too thin. The result carries the
evidence chain and citations back to substrate items.
- class Answer(question, answer, abstained, confidence, context, note='', evidence=<factory>)[source]
Bases:
objectA cited answer or abstention with the evidence it rests on and a confidence.
- Parameters:
- question: str
- abstained: bool
- confidence: float
- context: ContextPacket
- note: str = ''
- evidence: list[SubstrateItem]
- citations()[source]
Where the answer’s evidence came from – the provenance the answer must be checkable against.
- answer_from_substrate(substrate, question, answerer, *, budget=None, hops=1, min_evidence=1, min_confidence=0.1, compress=True, scope=None, telemetry=None)[source]
Answer
questionfromsubstrateviaanswerer, or abstain when evidence is too thin.- Parameters:
answerer (Callable[[str, str], str]) –
(question, context_text) -> answer_str– any model/rule; called ONLY when there is enough evidence above the confidence floor (so a weak retrieval never fabricates).budget (ContextBudget | None) – the context budget handed to the answerer (default 2000 chars).
hops (int) – 1 = single-shot
retrieve(); >1 =multihop()chaining that many hops.min_evidence (int) – minimum retrieved items required to attempt an answer.
min_confidence (float) – retrieval-strength floor below which it abstains rather than guess.
compress (bool) – compress the context to fit more sources under budget.
scope (str | None) – restrict to a team/access scope.
substrate (Substrate)
question (str)
telemetry (Any)
- Return type:
Answer