entidi2608 commited on
Commit
d627b5f
·
1 Parent(s): 159387f
Files changed (3) hide show
  1. routers/chat.py +1 -1
  2. services/chat_service.py +2 -2
  3. utils/utils.py +1 -1
routers/chat.py CHANGED
@@ -129,7 +129,7 @@ async def delete_chat(chat_id: str, request: Request, user: UserOut = Depends(ge
129
  if user_in_chat is None:
130
  raise HTTPException(status_code=404, detail="Chat not found")
131
 
132
- if user_in_chat.decode() != user.email:
133
  raise HTTPException(status_code=403, detail="Unauthorized")
134
 
135
  # Xóa chat
 
129
  if user_in_chat is None:
130
  raise HTTPException(status_code=404, detail="Chat not found")
131
 
132
+ if user_in_chat != user.email:
133
  raise HTTPException(status_code=403, detail="Unauthorized")
134
 
135
  # Xóa chat
services/chat_service.py CHANGED
@@ -30,7 +30,7 @@ async def ask_question_service(app_state, request: QueryRequest, user: UserOut =
30
  raise HTTPException(status_code=404, detail="Chat metadata corrupted.")
31
 
32
  if user_in_redis != user.email:
33
- logger.warning(f"User {user.email} không được phép truy cập chat {chat_id} (thuộc về {user_in_redis.decode()}).")
34
  raise HTTPException(status_code=403, detail="Unauthorized to access this chat.")
35
 
36
  start_time = time.time()
@@ -187,7 +187,7 @@ async def stream_chat_generator(
187
  yield f"event: error\ndata: {json.dumps(error_payload)}\n\n"
188
  return
189
 
190
- user_in_redis = user_in_redis_bytes.decode()
191
  if user_in_redis != user_email:
192
  logger.warning(f"Stream: User {user_email} không được phép truy cập chat {chat_id}.")
193
  error_payload = {"error": "Unauthorized to access this chat."}
 
30
  raise HTTPException(status_code=404, detail="Chat metadata corrupted.")
31
 
32
  if user_in_redis != user.email:
33
+ logger.warning(f"User {user.email} không được phép truy cập chat {chat_id} (thuộc về {user_in_redis}).")
34
  raise HTTPException(status_code=403, detail="Unauthorized to access this chat.")
35
 
36
  start_time = time.time()
 
187
  yield f"event: error\ndata: {json.dumps(error_payload)}\n\n"
188
  return
189
 
190
+ user_in_redis = user_in_redis_bytes
191
  if user_in_redis != user_email:
192
  logger.warning(f"Stream: User {user_email} không được phép truy cập chat {chat_id}.")
193
  error_payload = {"error": "Unauthorized to access this chat."}
utils/utils.py CHANGED
@@ -429,7 +429,7 @@ async def get_langchain_chat_history(app_state, chat_id: str) -> RedisChatMessag
429
  langchain_chat_history.clear() # Cho bản đồng bộ
430
 
431
  for msg_json_bytes in raw_messages_from_our_redis:
432
- msg_data = json.loads(msg_json_bytes.decode()) # decode bytes to str
433
  message = Message(**msg_data) # Validate
434
 
435
  if message.role == "user":
 
429
  langchain_chat_history.clear() # Cho bản đồng bộ
430
 
431
  for msg_json_bytes in raw_messages_from_our_redis:
432
+ msg_data = json.loads(msg_json_bytes)
433
  message = Message(**msg_data) # Validate
434
 
435
  if message.role == "user":