contradiction="llm" raises a raw pydantic error after the insert is written
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- backend-api-design, databases
Direzione di ricerca
Read src/selfgraph/contradiction.py at judge_contradictions and compare its verdict handling with extraction's error handling. Reproduce the malformed reply using the provided embedded Kuzu example, then inspect the existing tests for contradiction judging and partial failures. Done means malformed or client-error replies are handled consistently and do not leave the newly inserted relation and source in an unintended current state.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What happens
With contradiction="llm", the judge's reply is checked with _Verdict.model_validate(verdict) and nothing catches the result. A malformed reply raises a raw pydantic_core.ValidationError out of insert.facts, with no code or hint. The judge runs after upsert_relations, so on an auto-commit backend the new relation and its source are already written: both relations stay current and no judgment is applied.
Other replies that do this:
None,"[1]",{"retired": None},{"retired": ["x"]}.- An object with a
retiredattribute (extraction accepts attribute objects; the judge does not). - An exception raised by the client itself. Extraction turns that into
extraction_partial_failure; the judge lets it escape. - A
_Verdict.model_construct(retired=["0"])reply skips validation and fails withTypeErrorat the1 <= numbercomparison.
Lax coercion also means {"retired": [True]} and {"retired": ["1"]} retire fact 1.
Reproduce
On main (5a277c9), embedded Kuzu:
import asyncio, tempfile
from selfgraph import KuzuStore, SelfGraph
class LLM:
async def generate(self, *, system, user, output):
return {"retired": None} if output.__name__ == "_Verdict" else output()
SCHEMA = {"entities": [{"name": "Person"}, {"name": "Company"}], "relations": [{"type": "WORKS_AT"}]}
async def main():
with tempfile.TemporaryDirectory() as tmp:
async with SelfGraph(store=KuzuStore(f"{tmp}/g.kuzu"), llm=LLM(), schema=SCHEMA, contradiction="llm") as g:
await g.insert.facts({
"entities": [{"type": "Person", "name": "Ann"}, {"type": "Company", "name": "Acme"},
{"type": "Company", "name": "Globex"}],
"relations": [{"from_entity": "person:ann", "type": "WORKS_AT", "to_entity": "company:acme",
"event_time": "2020-01-01"}],
})
try:
await g.insert.facts({"relations": [{"from_entity": "person:ann", "type": "WORKS_AT",
"to_entity": "company:globex", "event_time": "2021-01-01"}]},
source_id="doc2")
except Exception as exc:
print(type(exc).__module__, type(exc).__name__)
rels = (await g.relations.list(include_invalidated=True)).items
print([(r.to_entity, r.is_current, r.source_count) for r in rels])
asyncio.run(main())
Output:
pydantic_core._pydantic_core ValidationError
[('company:acme', True, 0), ('company:globex', True, 1)]
Cause
src/selfgraph/contradiction.py, judge_contradictions: verdict = verdict if isinstance(verdict, _Verdict) else _Verdict.model_validate(verdict), with no error mapping, no from_attributes, no handling of client exceptions, and an isinstance shortcut that trusts unvalidated instances.
- Lingua principale
- TypeScript
- Stelle
- 173
- Fork
- 58
- Merge medio
- 6h
- PR unite (30g)
- 120
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di hydra-db/selfgraph
-
approved-for-pr area: cli-mcp area: errors bug effort: S P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
hydra-db/selfgraph#401 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
approved-for-pr area: errors area: store bug effort: S P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
hydra-db/selfgraph#398 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
approved-for-pr area: errors area: write bug effort: S P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
hydra-db/selfgraph#392 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
approved-for-pr area: parity area: write bug effort: S P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
hydra-db/selfgraph#391 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di hydra-db/selfgraph
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
code-yeongyu/senpi#7139 ·
I maintainer di solito rispondono entro 1 giorno
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficoltà 1/5 1-3 ore Idoneità per principianti 72/100
lingdojo/kana-dojo#34395 · 1 commento · 5 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
bug status: needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
mastra-ai/mastra#31093 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
area:web p2 product:business triage:active type:bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 89/100
cuadrao-ai/argus#2328 ·
I maintainer di solito rispondono entro 1 giorno
-
bug frontend good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
nikhilb2/simple_invoicing#907 ·