mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-22 05:41:39 +03:00
e931d29017
* feat: new classes * chore: private llm refactor and enable streaming * fix: validation errors in pytest * fix: default brain behavior * Update backend/llm/base.py * chore: remove 🪦 * fix: remove 🪦
39 lines
982 B
Python
39 lines
982 B
Python
from logger import get_logger
|
|
from models.chat import ChatHistory
|
|
from models.settings import common_dependencies
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
|
|
def update_message_by_id(
|
|
message_id: str, user_message: str = None, assistant: str = None
|
|
) -> ChatHistory:
|
|
commons = common_dependencies()
|
|
|
|
if not message_id:
|
|
logger.error("No message_id provided")
|
|
return
|
|
|
|
updates = {}
|
|
|
|
if user_message is not None:
|
|
updates["user_message"] = user_message
|
|
|
|
if assistant is not None:
|
|
updates["assistant"] = assistant
|
|
|
|
updated_message = None
|
|
|
|
if updates:
|
|
updated_message = (
|
|
commons["supabase"]
|
|
.table("chat_history")
|
|
.update(updates)
|
|
.match({"message_id": message_id})
|
|
.execute()
|
|
).data[0]
|
|
logger.info(f"Message {message_id} updated")
|
|
else:
|
|
logger.info(f"No updates to apply for message {message_id}")
|
|
return ChatHistory(updated_message)
|