mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-22 05:41:39 +03:00
8af6d61e76
* reorganize import level * add __init__, reorganize import from __init__ * reorganize import level * reorganize import level * fix circular import error by keep the import deep as "from models.settings" * fix the relative import * restor unwanted staged files * add backend/venv and backend/.env to gitignore * clean importing
38 lines
976 B
Python
38 lines
976 B
Python
from dataclasses import dataclass
|
|
from typing import Optional
|
|
|
|
from logger import get_logger
|
|
from models import Chat, get_supabase_db
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
|
|
@dataclass
|
|
class ChatUpdatableProperties:
|
|
chat_name: Optional[str] = None
|
|
|
|
def __init__(self, chat_name: Optional[str]):
|
|
self.chat_name = chat_name
|
|
|
|
|
|
def update_chat(chat_id, chat_data: ChatUpdatableProperties) -> Chat:
|
|
supabase_db = get_supabase_db()
|
|
|
|
if not chat_id:
|
|
logger.error("No chat_id provided")
|
|
return # pyright: ignore reportPrivateUsage=none
|
|
|
|
updates = {}
|
|
|
|
if chat_data.chat_name is not None:
|
|
updates["chat_name"] = chat_data.chat_name
|
|
|
|
updated_chat = None
|
|
|
|
if updates:
|
|
updated_chat = (supabase_db.update_chat(chat_id, updates)).data[0]
|
|
logger.info(f"Chat {chat_id} updated")
|
|
else:
|
|
logger.info(f"No updates to apply for chat {chat_id}")
|
|
return updated_chat # pyright: ignore reportPrivateUsage=none
|