diff --git a/backend/main.py b/backend/main.py index cd933dc..d87b464 100644 --- a/backend/main.py +++ b/backend/main.py @@ -71,7 +71,7 @@ async def get_current_user(token: str = Depends(oauth2_scheme)) -> User: @app.post("/chat/new") async def chat_new(current_user: User = Depends(get_current_user)) -> dict: chat_id = str(uuid4()) - timestamp = datetime.now().isoformat() + timestamp = datetime.utcnow().isoformat() user_id = current_user.email with Database() as connection: connection.execute( @@ -177,7 +177,7 @@ async def log_response_to_db(chat_id: str, full_response: str): with Database() as connection: connection.execute( "INSERT INTO message (id, timestamp, chat_id, sender, content) VALUES (?, ?, ?, ?, ?)", - (response_id, datetime.now().isoformat(), chat_id, "assistant", full_response), + (response_id, datetime.utcnow().isoformat(), chat_id, "assistant", full_response), ) async def memorize_response(rag_config: RagConfig, chat_id: str, question: str, answer: str): diff --git a/frontend/lib/chat.py b/frontend/lib/chat.py index f4c6141..f07294f 100644 --- a/frontend/lib/chat.py +++ b/frontend/lib/chat.py @@ -18,8 +18,7 @@ class Message: def __post_init__(self): self.id = str(uuid4()) if self.id is None else self.id - self.timestamp = datetime.now().isoformat() if self.timestamp is None else self.timestamp - + self.timestamp = datetime.utcnow().isoformat() if self.timestamp is None else self.timestamp def chat(): prompt = st.chat_input("Say something") diff --git a/frontend/lib/sidebar.py b/frontend/lib/sidebar.py index 8490742..40e2a90 100644 --- a/frontend/lib/sidebar.py +++ b/frontend/lib/sidebar.py @@ -20,7 +20,7 @@ def sidebar(): chats_by_time_ago = {} for chat in chat_list: chat_id, timestamp = chat["id"], chat["timestamp"] - time_ago = humanize.naturaltime(datetime.now() - datetime.fromisoformat(timestamp)) + time_ago = humanize.naturaltime(datetime.utcnow() - datetime.fromisoformat(timestamp)) if time_ago not in chats_by_time_ago: chats_by_time_ago[time_ago] = [] chats_by_time_ago[time_ago].append(chat)