Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def get_global_variable(node):
'history_context': history_context, 'chat_id': str(chat_id), **node.workflow_manage.form_data,
'chat_user_id': body.get('chat_user_id'),
'chat_user_type': body.get('chat_user_type'),
'chat_user': body.get('chat_user')}
'chat_user': body.get('chat_user'),
'chat_user_group': body.get('chat_user_group')
}


class BaseStartStepNode(IStarNode):
Expand Down
16 changes: 16 additions & 0 deletions apps/application/serializers/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from knowledge.models import Document
from models_provider.models import Model
from models_provider.tools import get_model_credential
from system_manage.models import UserGroupRelation


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

def get_chat_user_group(self, asker=None):
chat_user = self.get_chat_user(asker=asker)
chat_user_id = chat_user.get('id')

if not chat_user_id:
return []

user_group_relation_model = DatabaseModelManage.get_model("user_group_relation")
if user_group_relation_model:
return [{
'id': user_group_relation.group_id,
'name': user_group_relation.group.name
} for user_group_relation in QuerySet(user_group_relation_model).select_related('group').filter(user_id=chat_user_id)]
return []

def to_base_pipeline_manage_params(self):
self.get_application()
self.get_chat_user()
Expand Down
1 change: 1 addition & 0 deletions apps/chat/serializers/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ def chat_work_flow(self, chat_info: ChatInfo, instance: dict, base_to_response):
'workspace_id': workspace_id,
'debug': debug,
'chat_user': chat_info.get_chat_user(),
'chat_user_group': chat_info.get_chat_user_group(),
'application_id': str(chat_info.application_id)},
WorkFlowPostHandler(chat_info),
base_to_response, form_data, image_list, document_list, audio_list,
Expand Down
1 change: 0 additions & 1 deletion ui/src/api/knowledge/knowledge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type { Dict, pageRequest } from '@/api/type/common'
import type { knowledgeData } from '@/api/type/knowledge'

import useStore from '@/stores'
import knowledge from '../system-shared/knowledge'
const prefix: any = { _value: '/workspace/' }
Object.defineProperty(prefix, 'value', {
get: function () {
Expand Down
1 change: 1 addition & 0 deletions ui/src/locales/lang/en-US/ai-chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default {
chatId: 'Chat ID',
chatUserId: 'Chat User ID',
chatUserType: 'Chat User Type',
chatUserGroup: 'Chat User Group',
userInput: 'User Input',
quote: 'Quote',
download: 'Click to Download',
Expand Down
1 change: 1 addition & 0 deletions ui/src/locales/lang/zh-CN/ai-chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default {
chatId: '对话 ID',
chatUserId: '对话用户 ID',
chatUserType: '对话用户类型',
chatUserGroup: '对话用户组',
userInput: '用户输入',
quote: '引用',
download: '点击下载文件',
Expand Down
1 change: 1 addition & 0 deletions ui/src/locales/lang/zh-Hant/ai-chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default {
chatId: '對話 ID',
chatUserId: '對話用戶 ID',
chatUserType: '對話用戶類型',
chatUserGroup: '聊天使用者群組',
userInput: '用戶輸入',
quote: '引用',
download: '點擊下載文件',
Expand Down
4 changes: 4 additions & 0 deletions ui/src/workflow/nodes/start-node/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ const globalFields = [
label: t('chat.chatUserType'),
value: 'chat_user_type',
},
{
label: t('chat.chatUserGroup'),
value: 'chat_user_group',
},
{
label: t('views.chatUser.title'),
value: 'chat_user',
Expand Down
Loading