2023-08-10 11:25:08 +03:00
|
|
|
from typing import List
|
2023-06-30 11:10:59 +03:00
|
|
|
|
2023-06-23 11:36:55 +03:00
|
|
|
from fastapi import HTTPException
|
2023-08-10 11:25:08 +03:00
|
|
|
from models.databases.supabase.chats import CreateChatHistory
|
2023-08-21 13:25:16 +03:00
|
|
|
from models import ChatHistory, get_supabase_db
|
2023-06-22 18:50:06 +03:00
|
|
|
|
|
|
|
|
2023-08-10 11:25:08 +03:00
|
|
|
def update_chat_history(chat_history: CreateChatHistory) -> ChatHistory:
|
2023-08-03 21:24:42 +03:00
|
|
|
supabase_db = get_supabase_db()
|
2023-08-10 11:25:08 +03:00
|
|
|
response: List[ChatHistory] = (supabase_db.update_chat_history(chat_history)).data
|
2023-06-22 18:50:06 +03:00
|
|
|
if len(response) == 0:
|
2023-06-23 11:36:55 +03:00
|
|
|
raise HTTPException(
|
|
|
|
status_code=500, detail="An exception occurred while updating chat history."
|
|
|
|
)
|
2023-07-10 15:27:49 +03:00
|
|
|
return ChatHistory(response[0]) # pyright: ignore reportPrivateUsage=none
|