from pydantic import ValidationError
raw = '{"answer": "Paris", "confidence": 1.7}'
try:
ans = Answer.model_validate_json(raw)
except ValidationError as e:
print(e) # confidence must be <= 1 -> retry the LLM call with the errorLoading…
from pydantic import ValidationError
raw = '{"answer": "Paris", "confidence": 1.7}'
try:
ans = Answer.model_validate_json(raw)
except ValidationError as e:
print(e) # confidence must be <= 1 -> retry the LLM call with the error