mirror of
https://github.com/StanGirard/quivr.git
synced 2024-11-24 14:08:09 +03:00
9e9f531c99
* feat: add static analysis * chore: update Makefile add static analysis script * chore: add vscode extensions recommandations
27 lines
831 B
Python
27 lines
831 B
Python
from typing import List # For type hinting
|
|
|
|
from fastapi import HTTPException
|
|
from models.chat import ChatHistory
|
|
from models.settings import common_dependencies
|
|
|
|
|
|
def update_chat_history(chat_id: str, user_message: str, assistant: str) -> ChatHistory:
|
|
commons = common_dependencies()
|
|
response: List[ChatHistory] = (
|
|
commons["supabase"]
|
|
.table("chat_history")
|
|
.insert(
|
|
{
|
|
"chat_id": str(chat_id),
|
|
"user_message": user_message,
|
|
"assistant": assistant,
|
|
}
|
|
)
|
|
.execute()
|
|
).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
|