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

qyality: Code quality

Clémence Lesné7379cd3c318a
diff --git a/helpers/call_events.py b/helpers/call_events.py
index 59a9278..014d2a1 100644
--- a/helpers/call_events.py
+++ b/helpers/call_events.py
@@ -428,6 +428,7 @@ async def _intelligence_sms(call: CallStateModel) -> None:
"""
Send an SMS report to the customer.
"""
+
def _validate(req: Optional[str]) -> tuple[bool, Optional[str], Optional[str]]:
if not req:
return False, "No SMS content", None
diff --git a/persistence/ai_search.py b/persistence/ai_search.py
index af52a3a..b351685 100644
--- a/persistence/ai_search.py
+++ b/persistence/ai_search.py
@@ -53,9 +53,9 @@ class AiSearchSearch(ISearch):
await client.get_document_count()
return ReadinessEnum.OK
except HttpResponseError as e:
- logger.error(f"Error requesting AI Search, {e}")
+ logger.error(f"Error requesting AI Search: {e}")
except ServiceRequestError as e:
- logger.error(f"Error connecting to AI Search, {e}")
+ logger.error(f"Error connecting to AI Search: {e}")
return ReadinessEnum.FAIL
@retry(
@@ -134,9 +134,9 @@ class AiSearchSearch(ISearch):
except ValidationError as e:
logger.debug(f"Parsing error: {e.errors()}")
except HttpResponseError as e:
- logger.error(f"Error requesting AI Search, {e}")
+ logger.error(f"Error requesting AI Search: {e}")
except ServiceRequestError as e:
- logger.error(f"Error connecting to AI Search, {e}")
+ logger.error(f"Error connecting to AI Search: {e}")
# Update cache
if trainings:
diff --git a/persistence/cosmos_db.py b/persistence/cosmos_db.py
index d772950..0045a4d 100644
--- a/persistence/cosmos_db.py
+++ b/persistence/cosmos_db.py
@@ -63,7 +63,7 @@ class CosmosDbStore(IStore):
except AssertionError:
logger.error("Readiness test failed", exc_info=True)
except CosmosHttpResponseError as e:
- logger.error(f"Error requesting CosmosDB, {e}")
+ logger.error(f"Error requesting CosmosDB: {e}")
return ReadinessEnum.FAIL
async def _item_exists(self, test_id: str, partition_key: str) -> bool:
@@ -74,7 +74,7 @@ class CosmosDbStore(IStore):
exist = True
except CosmosHttpResponseError as e:
if e.status_code != 404:
- logger.error(f"Error requesting CosmosDB, {e}")
+ logger.error(f"Error requesting CosmosDB: {e}")
exist = True
return exist
@@ -106,7 +106,7 @@ class CosmosDbStore(IStore):
except StopAsyncIteration:
pass
except CosmosHttpResponseError as e:
- logger.error(f"Error accessing CosmosDB, {e}")
+ logger.error(f"Error accessing CosmosDB: {e}")
# Update cache
if call:
@@ -233,7 +233,7 @@ class CosmosDbStore(IStore):
except ValidationError as e:
logger.debug(f"Parsing error: {e.errors()}")
except CosmosHttpResponseError as e:
- logger.error(f"Error accessing CosmosDB, {e}")
+ logger.error(f"Error accessing CosmosDB: {e}")
return calls
async def _call_asearch_all_total_worker(
@@ -258,7 +258,7 @@ class CosmosDbStore(IStore):
)
total: int = await anext(items) # type: ignore
except CosmosHttpResponseError as e:
- logger.error(f"Error accessing CosmosDB, {e}")
+ logger.error(f"Error accessing CosmosDB: {e}")
return total if total else 0
@asynccontextmanager
diff --git a/persistence/redis.py b/persistence/redis.py
index e054221..1171219 100644
--- a/persistence/redis.py
+++ b/persistence/redis.py
@@ -64,9 +64,9 @@ class RedisCache(ICache):
assert await self._client.get(test_name) is None
return ReadinessEnum.OK
except AssertionError as e:
- logger.error(f"Readiness test failed, {e}")
+ logger.error(f"Readiness test failed: {e}")
except RedisError as e:
- logger.error(f"Error requesting Redis, {e}")
+ logger.error(f"Error requesting Redis: {e}")
return ReadinessEnum.FAIL
async def aget(self, key: str) -> Optional[bytes]:
@@ -82,7 +82,7 @@ class RedisCache(ICache):
try:
res = await self._client.get(sha_key)
except RedisError as e:
- logger.error(f"Error getting value, {e}")
+ logger.error(f"Error getting value: {e}")
return res
async def aset(self, key: str, value: Union[str, bytes, None]) -> bool:
@@ -97,7 +97,7 @@ class RedisCache(ICache):
try:
await self._client.set(sha_key, value if value else "")
except RedisError as e:
- logger.error(f"Error setting value, {e}")
+ logger.error(f"Error setting value: {e}")
return False
return True
@@ -111,7 +111,7 @@ class RedisCache(ICache):
try:
await self._client.delete(sha_key)
except RedisError as e:
- logger.error(f"Error deleting value, {e}")
+ logger.error(f"Error deleting value: {e}")
return False
return True
diff --git a/persistence/sqlite.py b/persistence/sqlite.py
index 53b97c1..d115309 100644
--- a/persistence/sqlite.py
+++ b/persistence/sqlite.py
@@ -50,7 +50,7 @@ class SqliteStore(IStore):
await db.execute("SELECT 1")
return ReadinessEnum.OK
except Exception as e:
- logger.error(f"Error requesting SQLite, {e}")
+ logger.error(f"Error requesting SQLite: {e}")
return ReadinessEnum.FAIL
async def call_aget(self, call_id: UUID) -> Optional[CallStateModel]: