Fix type errors

This commit is contained in:
2026-02-20 05:06:56 +00:00
parent 58393a538e
commit 2c722c1166
5 changed files with 32 additions and 24 deletions

View File

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

View File

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

View File

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

View File

@@ -39,7 +39,7 @@ class FirestoreService:
self.db.close() self.db.close()
logger.info("Firestore client closed") 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.""" """Get Firestore document reference for session."""
return self.db.collection(self.conversations_collection).document(session_id) return self.db.collection(self.conversations_collection).document(session_id)
@@ -284,7 +284,9 @@ class FirestoreService:
# ====== Notification Methods ====== # ====== 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.""" """Get Firestore document reference for notification."""
return self.db.collection(self.notifications_collection).document( return self.db.collection(self.notifications_collection).document(
notification_id, notification_id,
@@ -370,6 +372,12 @@ class FirestoreService:
return return
session_data = doc.to_dict() 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", []) notifications = session_data.get("notificaciones", [])
# Update status for all notifications # Update status for all notifications

View File

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