Skip to content

Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!

Python

fix: Use built-in Pydantic mechanism for parsing models from dict

Clémence Lesnéfd67d1559119
diff --git a/persistence/cosmos_db.py b/persistence/cosmos_db.py
index c811422..0b81944 100644
--- a/persistence/cosmos_db.py
+++ b/persistence/cosmos_db.py
@@ -85,7 +85,7 @@ class CosmosDbStore(IStore):
)
raw = await anext(items)
try:
- call = CallModel(**raw)
+ call = CallModel.model_validate(raw)
except ValidationError as e:
_logger.debug(f"Parsing error: {e.errors()}")
except StopAsyncIteration:
@@ -123,7 +123,7 @@ class CosmosDbStore(IStore):
)
raw = await anext(items)
try:
- call = CallModel(**raw)
+ call = CallModel.model_validate(raw)
except ValidationError as e:
_logger.debug(f"Parsing error: {e.errors()}")
except StopAsyncIteration:
@@ -150,7 +150,7 @@ class CosmosDbStore(IStore):
if not raw:
continue
try:
- calls.append(CallModel(**raw))
+ calls.append(CallModel.model_validate(raw))
except ValidationError as e:
_logger.debug(f"Parsing error: {e.errors()}")
except CosmosHttpResponseError as e: