fix: messagefeedbackapi support content (#11716)

Signed-off-by: weiyang <24080293@smb956101.com>
Co-authored-by: weiyang <24080293@smb956101.com>
This commit is contained in:
liuhaoran
2024-12-22 10:45:55 +08:00
committed by GitHub
parent 03ddee3663
commit 6b49889041
11 changed files with 64 additions and 20 deletions

View File

@@ -151,7 +151,12 @@ class MessageService:
@classmethod
def create_feedback(
cls, app_model: App, message_id: str, user: Optional[Union[Account, EndUser]], rating: Optional[str]
cls,
app_model: App,
message_id: str,
user: Optional[Union[Account, EndUser]],
rating: Optional[str],
content: Optional[str],
) -> MessageFeedback:
if not user:
raise ValueError("user cannot be None")
@@ -164,6 +169,7 @@ class MessageService:
db.session.delete(feedback)
elif rating and feedback:
feedback.rating = rating
feedback.content = content
elif not rating and not feedback:
raise ValueError("rating cannot be None when feedback not exists")
else:
@@ -172,6 +178,7 @@ class MessageService:
conversation_id=message.conversation_id,
message_id=message.id,
rating=rating,
content=content,
from_source=("user" if isinstance(user, EndUser) else "admin"),
from_end_user_id=(user.id if isinstance(user, EndUser) else None),
from_account_id=(user.id if isinstance(user, Account) else None),