quivr/backend/repository/chat/update_chat_history.py

16 lines
601 B
Python
Raw Normal View History

from typing import List
from fastapi import HTTPException
from models.databases.supabase.chats import CreateChatHistory
from models import ChatHistory, get_supabase_db
def update_chat_history(chat_history: CreateChatHistory) -> ChatHistory:
supabase_db = get_supabase_db()
response: List[ChatHistory] = (supabase_db.update_chat_history(chat_history)).data
if len(response) == 0:
raise HTTPException(
status_code=500, detail="An exception occurred while updating chat history."
)
return ChatHistory(response[0]) # pyright: ignore reportPrivateUsage=none