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

perf: Make sure to release IO after consumption

Clémence Lesné094e22d50cca
diff --git a/helpers/llm_worker.py b/helpers/llm_worker.py
index ebec92b..f949da5 100644
--- a/helpers/llm_worker.py
+++ b/helpers/llm_worker.py
@@ -479,7 +479,7 @@ async def _contentsafety_analysis(text: str) -> AnalyzeTextResult:
Catch errors for a maximum of 3 times (internal + `HttpResponseError`), then raise the error.
"""
async with _use_contentsafety() as client:
- return await client.analyze_text(
+ res = await client.analyze_text(
AnalyzeTextOptions(
blocklist_names=CONFIG.content_safety.blocklists,
halt_on_blocklist_hit=False,
@@ -487,6 +487,7 @@ async def _contentsafety_analysis(text: str) -> AnalyzeTextResult:
text=text,
)
)
+ return res
def _contentsafety_category_test(