Skip to content

Commit 67cc70a

Browse files
zxhlyhhjlarryautofix-ci[bot]
authored
fix: model credential name (#25081)
Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent a384ae9 commit 67cc70a

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

api/core/entities/provider_configuration.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,9 @@ def create_provider_credential(self, credentials: dict, credential_name: str | N
410410
:return:
411411
"""
412412
with Session(db.engine) as session:
413-
if credential_name and self._check_provider_credential_name_exists(
414-
credential_name=credential_name, session=session
415-
):
416-
raise ValueError(f"Credential with name '{credential_name}' already exists.")
413+
if credential_name:
414+
if self._check_provider_credential_name_exists(credential_name=credential_name, session=session):
415+
raise ValueError(f"Credential with name '{credential_name}' already exists.")
417416
else:
418417
credential_name = self._generate_provider_credential_name(session)
419418

@@ -890,10 +889,11 @@ def create_custom_model_credential(
890889
:return:
891890
"""
892891
with Session(db.engine) as session:
893-
if credential_name and self._check_custom_model_credential_name_exists(
894-
model=model, model_type=model_type, credential_name=credential_name, session=session
895-
):
896-
raise ValueError(f"Model credential with name '{credential_name}' already exists for {model}.")
892+
if credential_name:
893+
if self._check_custom_model_credential_name_exists(
894+
model=model, model_type=model_type, credential_name=credential_name, session=session
895+
):
896+
raise ValueError(f"Model credential with name '{credential_name}' already exists for {model}.")
897897
else:
898898
credential_name = self._generate_custom_model_credential_name(
899899
model=model, model_type=model_type, session=session

web/app/components/header/account-setting/model-provider-page/model-modal/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ const ModelModal: FC<ModelModalProps> = ({
115115
const [selectedCredential, setSelectedCredential] = useState<Credential & { addNewCredential?: boolean } | undefined>()
116116
const formRef2 = useRef<FormRefObject>(null)
117117
const isEditMode = !!Object.keys(formValues).filter((key) => {
118-
return key !== '__model_name' && key !== '__model_type'
118+
return key !== '__model_name' && key !== '__model_type' && !!formValues[key]
119119
}).length && isCurrentWorkspaceManager
120120

121121
const handleSave = useCallback(async () => {
@@ -167,7 +167,7 @@ const ModelModal: FC<ModelModalProps> = ({
167167
__authorization_name__,
168168
...rest
169169
} = values
170-
if (__model_name && __model_type && __authorization_name__) {
170+
if (__model_name && __model_type) {
171171
await handleSaveCredential({
172172
credential_id: credential?.credential_id,
173173
credentials: rest,

0 commit comments

Comments
 (0)