From d7aa4076c9972b8e881c311dfdc4f2aa17277a3f Mon Sep 17 00:00:00 2001 From: kurokobo Date: Tue, 27 Aug 2024 13:40:44 +0900 Subject: [PATCH] feat: display account name on the logs page for the apps (#7668) Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> --- api/fields/conversation_fields.py | 2 ++ api/models/model.py | 10 +++++++++- web/app/components/app/log/list.tsx | 2 +- web/app/components/app/workflow-log/list.tsx | 2 +- web/i18n/de-DE/app-log.ts | 2 +- web/i18n/en-US/app-log.ts | 4 ++-- web/i18n/es-ES/app-log.ts | 4 ++-- web/i18n/fa-IR/app-log.ts | 4 ++-- web/i18n/fr-FR/app-log.ts | 4 ++-- web/i18n/hi-IN/app-log.ts | 4 ++-- web/i18n/it-IT/app-log.ts | 4 ++-- web/i18n/ja-JP/app-log.ts | 4 ++-- web/i18n/ko-KR/app-log.ts | 4 ++-- web/i18n/pl-PL/app-log.ts | 4 ++-- web/i18n/pt-BR/app-log.ts | 4 ++-- web/i18n/ro-RO/app-log.ts | 4 ++-- web/i18n/tr-TR/app-log.ts | 4 ++-- web/i18n/uk-UA/app-log.ts | 4 ++-- web/i18n/vi-VN/app-log.ts | 4 ++-- web/i18n/zh-Hans/app-log.ts | 4 ++-- web/i18n/zh-Hant/app-log.ts | 4 ++-- 21 files changed, 46 insertions(+), 36 deletions(-) diff --git a/api/fields/conversation_fields.py b/api/fields/conversation_fields.py index 3a64801e18..9207314fc2 100644 --- a/api/fields/conversation_fields.py +++ b/api/fields/conversation_fields.py @@ -111,6 +111,7 @@ conversation_fields = { "from_end_user_id": fields.String, "from_end_user_session_id": fields.String(), "from_account_id": fields.String, + "from_account_name": fields.String, "read_at": TimestampField, "created_at": TimestampField, "annotation": fields.Nested(annotation_fields, allow_null=True), @@ -146,6 +147,7 @@ conversation_with_summary_fields = { "from_end_user_id": fields.String, "from_end_user_session_id": fields.String, "from_account_id": fields.String, + "from_account_name": fields.String, "name": fields.String, "summary": fields.String(attribute="summary_or_query"), "read_at": TimestampField, diff --git a/api/models/model.py b/api/models/model.py index 7301629771..83c56363e3 100644 --- a/api/models/model.py +++ b/api/models/model.py @@ -490,7 +490,6 @@ class InstalledApp(db.Model): return tenant - class Conversation(db.Model): __tablename__ = 'conversations' __table_args__ = ( @@ -623,6 +622,15 @@ class Conversation(db.Model): return None + @property + def from_account_name(self): + if self.from_account_id: + account = db.session.query(Account).filter(Account.id == self.from_account_id).first() + if account: + return account.name + + return None + @property def in_debug_mode(self): return self.override_model_configs is not None diff --git a/web/app/components/app/log/list.tsx b/web/app/components/app/log/list.tsx index 2258b69394..0bc118c46f 100644 --- a/web/app/components/app/log/list.tsx +++ b/web/app/components/app/log/list.tsx @@ -678,7 +678,7 @@ const ConversationList: FC = ({ logs, appDetail, onRefresh }) {logs.data.map((log: any) => { - const endUser = log.from_end_user_session_id + const endUser = log.from_end_user_session_id || log.from_account_name const leftValue = get(log, isChatMode ? 'name' : 'message.inputs.query') || (!isChatMode ? (get(log, 'message.query') || get(log, 'message.inputs.default_input')) : '') || '' const rightValue = get(log, isChatMode ? 'message_count' : 'message.answer') return = ({ logs, appDetail, onRefresh }) => { {logs.data.map((log: WorkflowAppLogDetail) => { - const endUser = log.created_by_end_user ? log.created_by_end_user.session_id : defaultValue + const endUser = log.created_by_end_user ? log.created_by_end_user.session_id : log.created_by_account ? log.created_by_account.name : defaultValue return