From 9fb1ce73adb1d7d5cfeface6cecb3dfd052efc83 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Thu, 5 Nov 2026 14:24:07 +0800 Subject: [PATCH] feat: Add conversation topic information --- apps/chat/serializers/chat_authentication.py | 50 +++++++++++++++---- ui/src/conversation-panel/view/chat/index.vue | 1 - 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/apps/chat/serializers/chat_authentication.py b/apps/chat/serializers/chat_authentication.py index e3ef58d5ac9..47eafcf157a 100644 --- a/apps/chat/serializers/chat_authentication.py +++ b/apps/chat/serializers/chat_authentication.py @@ -72,11 +72,23 @@ def profile(self): if application_access_token.authentication: if "LOCAL" not in login_value: login_value.insert(0, "LOCAL") + application_setting_model = DatabaseModelManage.get_model("application_setting") + application_setting = None + if application_setting_model is not None: + application_setting = ( + QuerySet(application_setting_model) + .filter(application_id=application_access_token.application_id) + .first() + ) return { "max_attempts": application_access_token.authentication_value.get("max_attempts", 1), "enable_auth": application_access_token.authentication, "login_value": login_value, "rsa_key": get_key_pair_by_sql().get("key"), + "custom_theme": application_setting.custom_theme + if application_setting + else {"theme_color": "", "header_font_color": ""}, + "logo": application_setting.avatar if application_setting else "./favicon.ico", "meta": { "application_name": application_access_token.application.name, "application_id": str(application_access_token.application_id), @@ -84,27 +96,45 @@ def profile(self): } +keys_mapping = {"theme": "theme_color"} + + class PortalAuthProfileSerializer(serializers.Serializer): @staticmethod def profile(): portal = Portal.objects.first() + auth_setting = DatabaseModelManage.get_model("auth_setting") + result = {} + if auth_setting is not None: + system_params = QuerySet(auth_setting).filter(param_key__in=keys_mapping.keys()) + result["custom_theme"] = {keys_mapping[sp.param_key]: sp.param_value for sp in system_params} + else: + result["custom_theme"] = {"theme_color": ""} if portal is None: return { - "max_attempts": 1, - "enable_auth": False, - "login_value": ["LOCAL"], - "rsa_key": get_key_pair_by_sql().get("key"), - "meta": {}, + **{ + "max_attempts": 1, + "enable_auth": False, + "login_value": ["LOCAL"], + "rsa_key": get_key_pair_by_sql().get("key"), + "meta": {}, + "logo": "./favicon.ico", + }, + **result, } if not portal.enable_public_access: raise NotFound404(404, _("Invalid access_token")) auth_config = portal.auth_config return { - "max_attempts": auth_config.get("max_attempts", 1), - "enable_auth": portal.enable_auth, - "login_value": auth_config.get("login_value", []), - "rsa_key": get_key_pair_by_sql().get("key"), - "meta": {}, + **{ + "max_attempts": auth_config.get("max_attempts", 1), + "enable_auth": portal.enable_auth, + "login_value": auth_config.get("login_value", []), + "rsa_key": get_key_pair_by_sql().get("key"), + "meta": {}, + "logo": portal.logo or "./favicon.ico", + }, + **result, } diff --git a/ui/src/conversation-panel/view/chat/index.vue b/ui/src/conversation-panel/view/chat/index.vue index c5082b02f8e..d1814c2547b 100644 --- a/ui/src/conversation-panel/view/chat/index.vue +++ b/ui/src/conversation-panel/view/chat/index.vue @@ -15,7 +15,6 @@ import { EXECUTION_DETAIL_KEY } from '../../right-sidebar/execution-detail/index import { SHARE_PANEL_KEY, SHARE_PANEL_CONTENT_KEY } from '../../main/share-panel/index' import { createChatConversation, createChatUserProfileGetter } from './index' import { VIEW_KEY, VIEW_TYPE, DEVICE_KEY, CHAT_USER_PROFILE_KEY, createDeviceType } from '../index.ts' - const bundle = createChatConversation() // 动态表单上传使用当前会话,兼容文件字段的地址包装与取消操作。