Spaces:
Running
Running
File size: 748 Bytes
570f7bd c1bc4eb 570f7bd c1bc4eb 570f7bd c1bc4eb 570f7bd 1fa9a31 c1bc4eb 570f7bd c1bc4eb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
from nl2sql.ambiguity_detector import AmbiguityDetector
from nl2sql.types import StageResult
def test_detects_ambiguous_terms():
det = AmbiguityDetector()
res = det.detect("Show me recent top singers", "table: singer(id,name,age)")
assert len(res) >= 1
assert "recent" in res[0].lower()
def test_not_false_positive():
det = AmbiguityDetector()
res = det.detect("List all singers older than 30", "table: singer(id, name, age)")
assert res == []
def test_ambiguity_response():
from app.routers import nl2sql
fake_result = StageResult(
ok=True, data={"ambiguous": True, "questions": ["Clarify column?"]}
)
response = nl2sql._to_dict(fake_result.data)
assert response["ambiguous"] is True
|