Skip to content

Commit dd92ce6

Browse files
Merge remote-tracking branch 'upstream/v2' into PR/fix-throw-exception
2 parents e503d09 + 974aafa commit dd92ce6

38 files changed

Lines changed: 1532 additions & 699 deletions

File tree

apps/application/flow/tools.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,8 @@ async def anext_async(agen):
845845
},
846846
'KNOWLEDGE': {'search-knowledge-node': lambda n: n.get('properties').get('node_data').get('knowledge_id_list')},
847847
'APPLICATION': {
848-
'application-node': lambda n: [n.get('properties').get('node_data').get('application_id')]
848+
'application-node': lambda n: [n.get('properties').get('node_data').get('application_id')],
849+
'ai-chat-node': lambda n: [*(n.get('properties').get('node_data').get('application_ids') or [])],
849850
}
850851
}
851852

apps/common/constants/permission_constants.py

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -708,15 +708,15 @@ class PermissionConstants(Enum):
708708
parent_group=[WorkspaceGroup.KNOWLEDGE, UserGroup.KNOWLEDGE]
709709
)
710710
KNOWLEDGE_BATCH_DELETE = Permission(group=Group.KNOWLEDGE, operate=Operate.BATCH_DELETE,
711-
role_list=[RoleConstants.ADMIN, RoleConstants.USER],
712-
resource_permission_group_list=[ResourcePermissionConst.KNOWLEDGE_MANGE],
713-
parent_group=[WorkspaceGroup.KNOWLEDGE, UserGroup.KNOWLEDGE],
714-
)
711+
role_list=[RoleConstants.ADMIN, RoleConstants.USER],
712+
resource_permission_group_list=[ResourcePermissionConst.KNOWLEDGE_MANGE],
713+
parent_group=[WorkspaceGroup.KNOWLEDGE, UserGroup.KNOWLEDGE],
714+
)
715715
KNOWLEDGE_BATCH_MOVE = Permission(group=Group.KNOWLEDGE, operate=Operate.BATCH_MOVE,
716-
role_list=[RoleConstants.ADMIN, RoleConstants.USER],
717-
resource_permission_group_list=[ResourcePermissionConst.KNOWLEDGE_MANGE],
718-
parent_group=[WorkspaceGroup.KNOWLEDGE, UserGroup.KNOWLEDGE],
719-
)
716+
role_list=[RoleConstants.ADMIN, RoleConstants.USER],
717+
resource_permission_group_list=[ResourcePermissionConst.KNOWLEDGE_MANGE],
718+
parent_group=[WorkspaceGroup.KNOWLEDGE, UserGroup.KNOWLEDGE],
719+
)
720720
KNOWLEDGE_RESOURCE_AUTHORIZATION = Permission(
721721
group=Group.KNOWLEDGE, operate=Operate.AUTH, role_list=[RoleConstants.ADMIN, RoleConstants.USER],
722722
resource_permission_group_list=[ResourcePermissionConst.KNOWLEDGE_MANGE],
@@ -1055,21 +1055,26 @@ class PermissionConstants(Enum):
10551055
parent_group=[WorkspaceGroup.APPLICATION, UserGroup.APPLICATION],
10561056
)
10571057
APPLICATION_BATCH_DELETE = Permission(group=Group.APPLICATION, operate=Operate.BATCH_DELETE,
1058-
role_list=[RoleConstants.ADMIN, RoleConstants.USER],
1059-
resource_permission_group_list=[ResourcePermissionConst.APPLICATION_MANGE],
1060-
parent_group=[WorkspaceGroup.APPLICATION, UserGroup.APPLICATION],
1061-
)
1058+
role_list=[RoleConstants.ADMIN, RoleConstants.USER],
1059+
resource_permission_group_list=[ResourcePermissionConst.APPLICATION_MANGE],
1060+
parent_group=[WorkspaceGroup.APPLICATION, UserGroup.APPLICATION],
1061+
)
10621062
APPLICATION_BATCH_MOVE = Permission(group=Group.APPLICATION, operate=Operate.BATCH_MOVE,
1063-
role_list=[RoleConstants.ADMIN, RoleConstants.USER],
1064-
resource_permission_group_list=[ResourcePermissionConst.APPLICATION_MANGE],
1065-
parent_group=[WorkspaceGroup.APPLICATION, UserGroup.APPLICATION],
1066-
)
1063+
role_list=[RoleConstants.ADMIN, RoleConstants.USER],
1064+
resource_permission_group_list=[ResourcePermissionConst.APPLICATION_MANGE],
1065+
parent_group=[WorkspaceGroup.APPLICATION, UserGroup.APPLICATION],
1066+
)
10671067
APPLICATION_RESOURCE_AUTHORIZATION = Permission(group=Group.APPLICATION, operate=Operate.AUTH,
10681068
role_list=[RoleConstants.ADMIN, RoleConstants.USER],
10691069
parent_group=[WorkspaceGroup.APPLICATION, UserGroup.APPLICATION],
10701070
resource_permission_group_list=[
10711071
ResourcePermissionConst.APPLICATION_MANGE],
10721072
)
1073+
APPLICATION_RELATE_RESOURCE_VIEW = Permission(
1074+
group=Group.APPLICATION, operate=Operate.RELATE_VIEW, role_list=[RoleConstants.ADMIN, RoleConstants.USER],
1075+
parent_group=[WorkspaceGroup.APPLICATION, UserGroup.APPLICATION],
1076+
resource_permission_group_list=[ResourcePermissionConst.APPLICATION_MANGE]
1077+
)
10731078
APPLICATION_TRIGGER_READ = Permission(
10741079
group=Group.APPLICATION, operate=Operate.TRIGGER_READ, role_list=[RoleConstants.ADMIN, RoleConstants.USER],
10751080
parent_group=[WorkspaceGroup.APPLICATION, UserGroup.APPLICATION],
@@ -1592,6 +1597,10 @@ class PermissionConstants(Enum):
15921597
group=Group.SYSTEM_RES_APPLICATION, operate=Operate.TRIGGER_DELETE, role_list=[RoleConstants.ADMIN],
15931598
parent_group=[SystemGroup.RESOURCE_APPLICATION], is_ee=settings.edition == "EE"
15941599
)
1600+
RESOURCE_APPLICATION_RELATE_RESOURCE_VIEW = Permission(
1601+
group=Group.SYSTEM_RES_APPLICATION, operate=Operate.RELATE_VIEW, role_list=[RoleConstants.ADMIN],
1602+
parent_group=[SystemGroup.RESOURCE_APPLICATION], is_ee=settings.edition == "EE"
1603+
)
15951604
RESOURCE_APPLICATION_OVERVIEW_READ = Permission(
15961605
group=Group.SYSTEM_RES_APPLICATION_OVERVIEW, operate=Operate.READ, role_list=[RoleConstants.ADMIN],
15971606
parent_group=[SystemGroup.RESOURCE_APPLICATION], is_ee=settings.edition == "EE"

apps/locales/en_US/LC_MESSAGES/django.po

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9237,4 +9237,13 @@ msgid "Batch move"
92379237
msgstr "Batch move"
92389238

92399239
msgid "There is a circular dependency in the tool workflow"
9240-
msgstr "There is a circular dependency in the tool workflow"
9240+
msgstr "There is a circular dependency in the tool workflow"
9241+
9242+
msgid "model_params_form must be a list"
9243+
msgstr ""
9244+
9245+
msgid "The {index}th item in model_params_form must be a dictionary"
9246+
msgstr ""
9247+
9248+
msgid "The label field is required for the {index}th item in model_params_form"
9249+
msgstr ""

apps/locales/zh_CN/LC_MESSAGES/django.po

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9360,4 +9360,13 @@ msgid "Batch move"
93609360
msgstr "批量移动"
93619361

93629362
msgid "There is a circular dependency in the tool workflow"
9363-
msgstr "工具工作流存在循环依赖"
9363+
msgstr "工具工作流存在循环依赖"
9364+
9365+
msgid "model_params_form must be a list"
9366+
msgstr "model_params_form 必须是一个列表"
9367+
9368+
msgid "The {index}th item in model_params_form must be a dictionary"
9369+
msgstr "model_params_form 中的第 {index} 项必须是一个字典"
9370+
9371+
msgid "The label field is required for the {index}th item in model_params_form"
9372+
msgstr "model_params_form 中的第 {index} 项的 label 字段是必填项"

apps/locales/zh_Hant/LC_MESSAGES/django.po

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9357,4 +9357,13 @@ msgid "Batch move"
93579357
msgstr "批量移動"
93589358

93599359
msgid "There is a circular dependency in the tool workflow"
9360-
msgstr "工具工作流存在迴圈依賴"
9360+
msgstr "工具工作流存在迴圈依賴"
9361+
9362+
msgid "model_params_form must be a list"
9363+
msgstr "model_params_form 必须是一个列表"
9364+
9365+
msgid "The {index}th item in model_params_form must be a dictionary"
9366+
msgstr "model_params_form 中的第 {index} 项必须是一个字典"
9367+
9368+
msgid "The label field is required for the {index}th item in model_params_form"
9369+
msgstr "model_params_form 中的第 {index} 项的 label 字段是必填项"

apps/models_provider/impl/aliyun_bai_lian_model_provider/credential/tts.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
from django.utils.translation import gettext_lazy as _, gettext
66

7+
from common import forms
78
from common.exception.app_exception import AppApiException
89
from common.forms import BaseForm, PasswordInputField, SingleSelect, SliderField, TooltipLabel
910
from models_provider.base_model_provider import BaseModelCredential, ValidCode
1011
from common.utils.logger import maxkb_logger
1112

13+
1214
class AliyunBaiLianTTSModelGeneralParams(BaseForm):
1315
"""
1416
Parameters class for the Aliyun BaiLian TTS (Text-to-Speech) model.
@@ -60,17 +62,18 @@ class AliyunBaiLianTTSModelCredential(BaseForm, BaseModelCredential):
6062
Credential class for the Aliyun BaiLian TTS (Text-to-Speech) model.
6163
Provides validation and encryption for the model credentials.
6264
"""
65+
api_base = forms.TextInputField(_('API URL'), required=True, default_value='https://dashscope.aliyuncs.com/api/v1')
6366

6467
api_key = PasswordInputField("API Key", required=True)
6568

6669
def is_valid(
67-
self,
68-
model_type: str,
69-
model_name: str,
70-
model_credential: Dict[str, object],
71-
model_params,
72-
provider,
73-
raise_exception: bool = False
70+
self,
71+
model_type: str,
72+
model_name: str,
73+
model_credential: Dict[str, object],
74+
model_params,
75+
provider,
76+
raise_exception: bool = False
7477
) -> bool:
7578
"""
7679
Validate the model credentials.
@@ -90,7 +93,7 @@ def is_valid(
9093
gettext('{model_type} Model type is not supported').format(model_type=model_type)
9194
)
9295

93-
required_keys = ['api_key']
96+
required_keys = ['api_key', 'api_base']
9497
for key in required_keys:
9598
if key not in model_credential:
9699
if raise_exception:

apps/models_provider/impl/aliyun_bai_lian_model_provider/credential/ttv.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
from django.utils.translation import gettext_lazy as _, gettext
66

7+
from common import forms
78
from common.exception.app_exception import AppApiException
89
from common.forms import BaseForm, PasswordInputField, SingleSelect, SliderField, TooltipLabel
910
from common.forms.switch_field import SwitchField
1011
from models_provider.base_model_provider import BaseModelCredential, ValidCode
1112
from common.utils.logger import maxkb_logger
1213

14+
1315
class QwenModelParams(BaseForm):
1416
"""
1517
Parameters class for the Qwen Text-to-Video model.
@@ -42,7 +44,7 @@ class TextToVideoModelCredential(BaseForm, BaseModelCredential):
4244
Credential class for the Qwen Text-to-Video model.
4345
Provides validation and encryption for the model credentials.
4446
"""
45-
47+
api_base = forms.TextInputField(_('API URL'), required=True, default_value='https://dashscope.aliyuncs.com/api/v1')
4648
api_key = PasswordInputField('API Key', required=True)
4749

4850
def is_valid(
@@ -72,7 +74,7 @@ def is_valid(
7274
gettext('{model_type} Model type is not supported').format(model_type=model_type)
7375
)
7476

75-
required_keys = ['api_key']
77+
required_keys = ['api_key', 'api_base']
7678
for key in required_keys:
7779
if key not in model_credential:
7880
if raise_exception:

apps/models_provider/impl/aliyun_bai_lian_model_provider/model/tts.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111

1212
class AliyunBaiLianTextToSpeech(MaxKBBaseModel, BaseTextToSpeech):
1313
api_key: str
14+
base_url: str
1415
model: str
1516
params: dict
1617

1718
def __init__(self, **kwargs):
1819
super().__init__(**kwargs)
1920
self.api_key = kwargs.get('api_key')
21+
self.base_url = kwargs.get('base_url')
2022
self.model = kwargs.get('model')
2123
self.params = kwargs.get('params')
2224

@@ -34,6 +36,7 @@ def new_instance(model_type, model_name, model_credential: Dict[str, object], **
3436
return AliyunBaiLianTextToSpeech(
3537
model=model_name,
3638
api_key=model_credential.get('api_key'),
39+
base_url=model_credential.get('api_base', "https://dashscope.aliyuncs.com/api/v1"),
3740
**optional_params,
3841
)
3942

@@ -42,6 +45,7 @@ def check_auth(self):
4245

4346
def text_to_speech(self, text):
4447
dashscope.api_key = self.api_key
48+
dashscope.base_http_api_url = self.base_url
4549
text = _remove_empty_lines(text)
4650
if 'sambert' in self.model:
4751
from dashscope.audio.tts import SpeechSynthesizer
@@ -55,4 +59,3 @@ def text_to_speech(self, text):
5559
if type(audio) == str:
5660
raise Exception(audio)
5761
return audio
58-

apps/models_provider/impl/aliyun_bai_lian_model_provider/model/ttv.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
class GenerationVideoModel(MaxKBBaseModel, BaseGenerationVideo):
1414
api_key: str
15+
api_base: str
1516
model_name: str
1617
params: dict
1718
max_retries: int = 3
@@ -20,6 +21,7 @@ class GenerationVideoModel(MaxKBBaseModel, BaseGenerationVideo):
2021
def __init__(self, **kwargs):
2122
super().__init__(**kwargs)
2223
self.api_key = kwargs.get('api_key')
24+
self.api_base = kwargs.get('api_base')
2325
self.model_name = kwargs.get('model_name')
2426
self.params = kwargs.get('params', {})
2527
self.max_retries = kwargs.get('max_retries', 3)
@@ -35,9 +37,13 @@ def new_instance(model_type, model_name, model_credential: Dict[str, object], **
3537
for key, value in model_kwargs.items():
3638
if key not in ['model_id', 'use_local', 'streaming']:
3739
optional_params['params'][key] = value
40+
api_base = model_credential.get('api_base')
41+
if api_base is None:
42+
api_base = 'https://dashscope.aliyuncs.com/api/v1'
3843
return GenerationVideoModel(
3944
model_name=model_name,
4045
api_key=model_credential.get('api_key'),
46+
api_base=api_base,
4147
**optional_params,
4248
)
4349

@@ -66,6 +72,8 @@ def generate_video(self, prompt, negative_prompt=None, first_frame_url=None, las
6672
last_frame_url: 结束关键帧图片 URL (KF2V 必填)
6773
如果没有提供last_frame_url,则表示只提供了first_frame_url,生成的是单关键帧视频(KFV) 参数是img_url
6874
"""
75+
import dashscope
76+
dashscope.base_http_api_url = self.api_base
6977

7078
# 构建基础参数
7179
params = {"api_key": self.api_key, "prompt": prompt, "model": self.model_name,

apps/models_provider/impl/gemini_model_provider/credential/image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ class GeminiImageModelParams(BaseForm):
3131

3232

3333
class GeminiImageModelCredential(BaseForm, BaseModelCredential):
34-
api_key = forms.PasswordInputField('API Key', required=True)
3534
base_url = forms.TextInputField('Base URL', required=True, default_value='https://generativelanguage.googleapis.com')
35+
api_key = forms.PasswordInputField('API Key', required=True)
3636

3737
def is_valid(self, model_type: str, model_name, model_credential: Dict[str, object], model_params, provider,
3838
raise_exception=False):

0 commit comments

Comments
 (0)