Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!
Python
chore: Remove the use of jsonable_encoder
Clémence Lesné0073729cc8f3
diff --git a/main.py b/main.pyindex caf233f..6356106 100644--- a/main.py+++ b/main.py@@ -21,7 +21,6 @@ from azure.core.credentials import AzureKeyCredentialfrom azure.core.messaging import CloudEventfrom azure.eventgrid import EventGridEvent, SystemEventNamesfrom fastapi import FastAPI, status, Request, HTTPException, BackgroundTasks, Response-from fastapi.encoders import jsonable_encoderfrom fastapi.responses import JSONResponse, HTMLResponsefrom fastapi.staticfiles import StaticFilesfrom jinja2 import Environment, FileSystemLoader, select_autoescape@@ -138,7 +137,7 @@ async def health_readiness_get() -> JSONResponse:status_code = status.HTTP_503_SERVICE_UNAVAILABLEbreakreturn JSONResponse(- content=jsonable_encoder(readiness),+ content=readiness.model_dump(mode="json"),status_code=status_code,)diff --git a/persistence/cosmos_db.py b/persistence/cosmos_db.pyindex a3e7035..bed7495 100644--- a/persistence/cosmos_db.py+++ b/persistence/cosmos_db.py@@ -2,7 +2,6 @@ from azure.core.exceptions import ServiceResponseErrorfrom azure.cosmos.aio import CosmosClient, ContainerProxyfrom azure.cosmos.exceptions import CosmosHttpResponseErrorfrom contextlib import asynccontextmanager-from fastapi.encoders import jsonable_encoderfrom helpers.config import CONFIGfrom helpers.config_models.database import CosmosDbModelfrom helpers.logging import build_logger@@ -114,7 +113,7 @@ class CosmosDbStore(IStore):wait=wait_random_exponential(multiplier=0.5, max=30),)async def call_aset(self, call: CallModel) -> bool:- data = jsonable_encoder(call.model_dump(), exclude_none=True)+ data = call.model_dump(mode="json", exclude_none=True)data["id"] = str(call.call_id) # CosmosDB requires an id field_logger.debug(f"Saving call {call.call_id}: {data}")try:diff --git a/persistence/sqlite.py b/persistence/sqlite.pyindex 0171a4a..299e058 100644--- a/persistence/sqlite.py+++ b/persistence/sqlite.py@@ -1,6 +1,5 @@from aiosqlite import connect as sqlite_connect, Connection as SQLiteConnectionfrom contextlib import asynccontextmanager-from fastapi.encoders import jsonable_encoderfrom helpers.config import CONFIGfrom helpers.config_models.database import SqliteModelfrom helpers.logging import build_logger@@ -62,7 +61,7 @@ class SqliteStore(IStore):async def call_aset(self, call: CallModel) -> bool:# TODO: Catch exceptions and return False if something goes wrong- data = jsonable_encoder(call.model_dump(), exclude_none=True)+ data = call.model_dump(mode="json", exclude_none=True)_logger.debug(f"Saving call {call.call_id}: {data}")async with self._use_db() as db:await db.execute(