mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 11:42:29 +08:00
credentials of models
This commit is contained in:
parent
72ef04d3e4
commit
2ed73b763d
|
@ -229,6 +229,7 @@ const ModelModal: FC<ModelModalProps> = ({
|
|||
setLoading(true)
|
||||
const res = await saveCredentials(
|
||||
providerFormSchemaPredefined,
|
||||
provider.plugin_id,
|
||||
provider.provider,
|
||||
encodeSecretValues(value),
|
||||
{
|
||||
|
@ -255,6 +256,7 @@ const ModelModal: FC<ModelModalProps> = ({
|
|||
|
||||
const res = await removeCredentials(
|
||||
providerFormSchemaPredefined,
|
||||
provider.plugin_id,
|
||||
provider.provider,
|
||||
value,
|
||||
)
|
||||
|
|
|
@ -26,14 +26,15 @@ export const isNullOrUndefined = (value: any) => {
|
|||
return value === undefined || value === null
|
||||
}
|
||||
|
||||
export const validateCredentials = async (predefined: boolean, provider: string, v: FormValue) => {
|
||||
// deprecated ???
|
||||
export const validateCredentials = async (predefined: boolean, pluginID: string, provider: string, v: FormValue) => {
|
||||
let body, url
|
||||
|
||||
if (predefined) {
|
||||
body = {
|
||||
credentials: v,
|
||||
}
|
||||
url = `/workspaces/current/model-providers/${provider}/credentials/validate`
|
||||
url = `/workspaces/current/model-providers/${pluginID}/${provider}/credentials/validate`
|
||||
}
|
||||
else {
|
||||
const { __model_name, __model_type, ...credentials } = v
|
||||
|
@ -42,7 +43,7 @@ export const validateCredentials = async (predefined: boolean, provider: string,
|
|||
model_type: __model_type,
|
||||
credentials,
|
||||
}
|
||||
url = `/workspaces/current/model-providers/${provider}/models/credentials/validate`
|
||||
url = `/workspaces/current/model-providers/${pluginID}/${provider}/models/credentials/validate`
|
||||
}
|
||||
try {
|
||||
const res = await validateModelProvider({ url, body })
|
||||
|
@ -80,7 +81,7 @@ export const validateLoadBalancingCredentials = async (predefined: boolean, plug
|
|||
}
|
||||
}
|
||||
|
||||
export const saveCredentials = async (predefined: boolean, provider: string, v: FormValue, loadBalancing?: ModelLoadBalancingConfig) => {
|
||||
export const saveCredentials = async (predefined: boolean, pluginID: string, provider: string, v: FormValue, loadBalancing?: ModelLoadBalancingConfig) => {
|
||||
let body, url
|
||||
|
||||
if (predefined) {
|
||||
|
@ -89,7 +90,7 @@ export const saveCredentials = async (predefined: boolean, provider: string, v:
|
|||
credentials: v,
|
||||
load_balancing: loadBalancing,
|
||||
}
|
||||
url = `/workspaces/current/model-providers/${provider}`
|
||||
url = `/workspaces/current/model-providers/${pluginID}/${provider}`
|
||||
}
|
||||
else {
|
||||
const { __model_name, __model_type, ...credentials } = v
|
||||
|
@ -99,7 +100,7 @@ export const saveCredentials = async (predefined: boolean, provider: string, v:
|
|||
credentials,
|
||||
load_balancing: loadBalancing,
|
||||
}
|
||||
url = `/workspaces/current/model-providers/${provider}/models`
|
||||
url = `/workspaces/current/model-providers/${pluginID}/${provider}/models`
|
||||
}
|
||||
|
||||
return setModelProvider({ url, body })
|
||||
|
@ -119,12 +120,12 @@ export const savePredefinedLoadBalancingConfig = async (provider: string, v: For
|
|||
return setModelProvider({ url, body })
|
||||
}
|
||||
|
||||
export const removeCredentials = async (predefined: boolean, provider: string, v: FormValue) => {
|
||||
export const removeCredentials = async (predefined: boolean, pluginID: string, provider: string, v: FormValue) => {
|
||||
let url = ''
|
||||
let body
|
||||
|
||||
if (predefined) {
|
||||
url = `/workspaces/current/model-providers/${provider}`
|
||||
url = `/workspaces/current/model-providers/${pluginID}/${provider}`
|
||||
}
|
||||
else {
|
||||
if (v) {
|
||||
|
@ -133,7 +134,7 @@ export const removeCredentials = async (predefined: boolean, provider: string, v
|
|||
model: __model_name,
|
||||
model_type: __model_type,
|
||||
}
|
||||
url = `/workspaces/current/model-providers/${provider}/models`
|
||||
url = `/workspaces/current/model-providers/${pluginID}/${provider}/models`
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user