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

dev: Add span "trainings"

Clémence Lesné562cd4ff2025
diff --git a/models/call.py b/models/call.py
index 04b782e..df32d7f 100644
--- a/models/call.py
+++ b/models/call.py
@@ -65,19 +65,21 @@ class CallModel(BaseModel):
Is using query expansion from last messages. Then, data is sorted by score.
"""
from helpers.config import CONFIG
+ from helpers.logging import TRACER
- search = CONFIG.ai_search.instance()
- trainings_tasks = await asyncio.gather(
- *[
- search.training_asearch_all(message.content, self)
- for message in self.messages[-CONFIG.ai_search.expansion_k :]
- ],
- ) # Get trainings from last messages
- trainings = sorted(
- set(
- training
- for trainings in trainings_tasks
- for training in trainings or []
- )
- ) # Flatten, remove duplicates, and sort by score
- return trainings
+ with TRACER.start_as_current_span("trainings"):
+ search = CONFIG.ai_search.instance()
+ trainings_tasks = await asyncio.gather(
+ *[
+ search.training_asearch_all(message.content, self)
+ for message in self.messages[-CONFIG.ai_search.expansion_k :]
+ ],
+ ) # Get trainings from last messages
+ trainings = sorted(
+ set(
+ training
+ for trainings in trainings_tasks
+ for training in trainings or []
+ )
+ ) # Flatten, remove duplicates, and sort by score
+ return trainings