Skip to content

Commit 5bf8eda

Browse files
committed
feat: Add user group information in global field
1 parent 7230daa commit 5bf8eda

8 files changed

Lines changed: 27 additions & 2 deletions

File tree

‎apps/application/flow/step_node/start_node/impl/base_start_node.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ def get_global_variable(node):
3434
'history_context': history_context, 'chat_id': str(chat_id), **node.workflow_manage.form_data,
3535
'chat_user_id': body.get('chat_user_id'),
3636
'chat_user_type': body.get('chat_user_type'),
37-
'chat_user': body.get('chat_user')}
37+
'chat_user': body.get('chat_user'),
38+
'chat_user_group': body.get('chat_user_group')
39+
}
3840

3941

4042
class BaseStartStepNode(IStarNode):

‎apps/application/serializers/common.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from knowledge.models import Document
2323
from models_provider.models import Model
2424
from models_provider.tools import get_model_credential
25+
from system_manage.models import UserGroupRelation
2526

2627

2728
class ChatInfo:
@@ -114,6 +115,21 @@ def get_chat_user(self, asker=None):
114115
self.chat_user = {'username': '游客'}
115116
return self.chat_user
116117

118+
def get_chat_user_group(self, asker=None):
119+
chat_user = self.get_chat_user(asker=asker)
120+
chat_user_id = chat_user.get('id')
121+
122+
if not chat_user_id:
123+
return []
124+
125+
user_group_relation_model = DatabaseModelManage.get_model("user_group_relation")
126+
if user_group_relation_model:
127+
return [{
128+
'id': user_group_relation.group_id,
129+
'name': user_group_relation.group.name
130+
} for user_group_relation in QuerySet(user_group_relation_model).select_related('group').filter(user_id=chat_user_id)]
131+
return []
132+
117133
def to_base_pipeline_manage_params(self):
118134
self.get_application()
119135
self.get_chat_user()

‎apps/chat/serializers/chat.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ def chat_work_flow(self, chat_info: ChatInfo, instance: dict, base_to_response):
403403
'workspace_id': workspace_id,
404404
'debug': debug,
405405
'chat_user': chat_info.get_chat_user(),
406+
'chat_user_group': chat_info.get_chat_user_group(),
406407
'application_id': str(chat_info.application_id)},
407408
WorkFlowPostHandler(chat_info),
408409
base_to_response, form_data, image_list, document_list, audio_list,

‎ui/src/api/knowledge/knowledge.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import type { Dict, pageRequest } from '@/api/type/common'
55
import type { knowledgeData } from '@/api/type/knowledge'
66

77
import useStore from '@/stores'
8-
import knowledge from '../system-shared/knowledge'
98
const prefix: any = { _value: '/workspace/' }
109
Object.defineProperty(prefix, 'value', {
1110
get: function () {

‎ui/src/locales/lang/en-US/ai-chat.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default {
1515
chatId: 'Chat ID',
1616
chatUserId: 'Chat User ID',
1717
chatUserType: 'Chat User Type',
18+
chatUserGroup: 'Chat User Group',
1819
userInput: 'User Input',
1920
quote: 'Quote',
2021
download: 'Click to Download',

‎ui/src/locales/lang/zh-CN/ai-chat.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default {
1515
chatId: '对话 ID',
1616
chatUserId: '对话用户 ID',
1717
chatUserType: '对话用户类型',
18+
chatUserGroup: '对话用户组',
1819
userInput: '用户输入',
1920
quote: '引用',
2021
download: '点击下载文件',

‎ui/src/locales/lang/zh-Hant/ai-chat.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default {
1515
chatId: '對話 ID',
1616
chatUserId: '對話用戶 ID',
1717
chatUserType: '對話用戶類型',
18+
chatUserGroup: '聊天使用者群組',
1819
userInput: '用戶輸入',
1920
quote: '引用',
2021
download: '點擊下載文件',

‎ui/src/workflow/nodes/start-node/index.vue‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ const globalFields = [
6868
label: t('chat.chatUserType'),
6969
value: 'chat_user_type',
7070
},
71+
{
72+
label: t('chat.chatUserGroup'),
73+
value: 'chat_user_group',
74+
},
7175
{
7276
label: t('views.chatUser.title'),
7377
value: 'chat_user',

0 commit comments

Comments
 (0)