Initial commit: add .gitignore and README
This commit is contained in:
21
fusionagi/verification/contradiction.py
Normal file
21
fusionagi/verification/contradiction.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from typing import Any, Protocol
|
||||
|
||||
class SemanticLike(Protocol):
|
||||
def query(self, domain, limit): ...
|
||||
|
||||
class ContradictionDetector:
|
||||
def __init__(self, semantic=None):
|
||||
self._semantic = semantic
|
||||
def check(self, claim, context=None):
|
||||
out = []
|
||||
if not claim or not claim.strip():
|
||||
return out
|
||||
ctx = context or {}
|
||||
domain = ctx.get("domain", "")
|
||||
if self._semantic:
|
||||
facts = self._semantic.query(domain or None, 50)
|
||||
for f in facts:
|
||||
st = f.get("statement", "")
|
||||
if st and "not " in claim.lower() and st.lower() in claim.lower():
|
||||
out.append("Contradicts: " + st[:100])
|
||||
return out
|
||||
Reference in New Issue
Block a user