Fix type errors

This commit is contained in:
2026-02-20 05:06:56 +00:00
parent 595abd6cd3
commit d663394106
5 changed files with 32 additions and 24 deletions

View File

@@ -69,16 +69,16 @@ class Notification(BaseModel):
New Notification instance with current timestamp
"""
return cls(
idNotificacion=id_notificacion,
telefono=telefono,
timestampCreacion=datetime.now(UTC),
texto=texto,
nombreEventoDialogflow=nombre_evento_dialogflow,
codigoIdiomaDialogflow=codigo_idioma_dialogflow,
parametros=parametros or {},
status=status,
)
return cls.model_validate({
"idNotificacion": id_notificacion,
"telefono": telefono,
"timestampCreacion": datetime.now(UTC),
"texto": texto,
"nombreEventoDialogflow": nombre_evento_dialogflow,
"codigoIdiomaDialogflow": codigo_idioma_dialogflow,
"parametros": parametros or {},
"status": status,
})
class NotificationSession(BaseModel):

View File

@@ -105,7 +105,7 @@ async def start_quick_reply_session(
pantalla_contexto,
)
return QuickReplyScreenResponse(
response_id=session_id, quick_replies=quick_replies,
responseId=session_id, quick_replies=quick_replies,
)
except ValueError as e:

View File

@@ -84,16 +84,16 @@ class ConversationManagerService:
await self.redis_service.save_session(session)
# Step 2: Check for pantallaContexto in existing session
if session.pantallaContexto:
if session.pantalla_contexto:
# Check if pantallaContexto is stale (10 minutes)
if self._is_pantalla_context_valid(session.last_modified):
logger.info(
"Detected 'pantallaContexto' in session: %s. "
"Delegating to QuickReplies flow.",
session.pantallaContexto,
session.pantalla_contexto,
)
response = await self._manage_quick_reply_conversation(
request, session.pantallaContexto,
request, session.pantalla_contexto,
)
if response:
# Save user message to Firestore
@@ -214,9 +214,9 @@ class ConversationManagerService:
# Step 3i: Return response object
return DetectIntentResponse(
response_id=str(uuid4()),
query_result=QueryResult(
response_text=assistant_response,
responseId=str(uuid4()),
queryResult=QueryResult(
responseText=assistant_response,
parameters=None,
),
quick_replies=None,
@@ -265,8 +265,8 @@ class ConversationManagerService:
# Create response with the matched quick reply answer
return DetectIntentResponse(
response_id=str(uuid4()),
query_result=QueryResult(response_text=matched_answer, parameters=None),
responseId=str(uuid4()),
queryResult=QueryResult(responseText=matched_answer, parameters=None),
quick_replies=quick_reply_screen,
)

View File

@@ -39,7 +39,7 @@ class FirestoreService:
self.db.close()
logger.info("Firestore client closed")
def _session_ref(self, session_id: str) -> firestore.DocumentReference:
def _session_ref(self, session_id: str) -> firestore.AsyncDocumentReference:
"""Get Firestore document reference for session."""
return self.db.collection(self.conversations_collection).document(session_id)
@@ -284,7 +284,9 @@ class FirestoreService:
# ====== Notification Methods ======
def _notification_ref(self, notification_id: str) -> firestore.DocumentReference:
def _notification_ref(
self, notification_id: str,
) -> firestore.AsyncDocumentReference:
"""Get Firestore document reference for notification."""
return self.db.collection(self.notifications_collection).document(
notification_id,
@@ -370,6 +372,12 @@ class FirestoreService:
return
session_data = doc.to_dict()
if not session_data:
logger.warning(
"Notification session %s has no data in Firestore",
session_id,
)
return
notifications = session_data.get("notificaciones", [])
# Update status for all notifications

View File

@@ -291,10 +291,10 @@ class RedisService:
else:
# Create new session
updated_session = NotificationSession(
session_id=notification_session_id,
sessionId=notification_session_id,
telefono=phone_number,
fecha_creacion=datetime.now(UTC),
ultima_actualizacion=datetime.now(UTC),
fechaCreacion=datetime.now(UTC),
ultimaActualizacion=datetime.now(UTC),
notificaciones=[new_entry],
)