Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions python/packages/autogen-studio/autogenstudio/web/routes/ws.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# api/ws.py
import asyncio
import json
from datetime import datetime
from datetime import datetime, timezone

from fastapi import APIRouter, Depends, WebSocket, WebSocketDisconnect
from fastapi.websockets import WebSocketState
Expand Down Expand Up @@ -55,7 +55,7 @@ async def run_websocket(
{
"type": "error",
"error": "Authentication failed",
"timestamp": datetime.utcnow().isoformat(),
"timestamp": datetime.now(timezone.utc).isoformat(),
}
)
# Close the connection with a specific code
Expand All @@ -67,7 +67,7 @@ async def run_websocket(
{
"type": "error",
"error": "Authentication failed",
"timestamp": datetime.utcnow().isoformat(),
"timestamp": datetime.now(timezone.utc).isoformat(),
}
)
logger.warning(f"User {user.id} not authorized to access run {run_id}")
Expand Down Expand Up @@ -97,7 +97,7 @@ async def run_websocket(
{
"type": "error",
"error": "Invalid start message format",
"timestamp": datetime.utcnow().isoformat(),
"timestamp": datetime.now(timezone.utc).isoformat(),
}
)

Expand All @@ -108,7 +108,7 @@ async def run_websocket(
break

elif message.get("type") == "ping":
await websocket.send_json({"type": "pong", "timestamp": datetime.utcnow().isoformat()})
await websocket.send_json({"type": "pong", "timestamp": datetime.now(timezone.utc).isoformat()})

elif message.get("type") == "input_response":
# Handle input response from client
Expand All @@ -121,7 +121,7 @@ async def run_websocket(
except json.JSONDecodeError:
logger.warning(f"Invalid JSON received: {raw_message}")
await websocket.send_json(
{"type": "error", "error": "Invalid message format", "timestamp": datetime.utcnow().isoformat()}
{"type": "error", "error": "Invalid message format", "timestamp": datetime.now(timezone.utc).isoformat()}
)

except WebSocketDisconnect:
Expand Down