Merge branch 'feature/sunanzhi/1.6' into 'main'

Feature/sunanzhi/1.6

See merge request apipark/APIPark!260
This commit is contained in:
孙安智
2025-03-11 20:36:38 +08:00
37 changed files with 271 additions and 58 deletions
@@ -31,12 +31,12 @@ provider_credential_schema:
en_US: Enter your API Key
- variable: anthropic_api_url
label:
en_US: API URL
en_US: https://api.anthropic.com/v1/
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 API URL
en_US: Enter your API URL
address: https://api.anthropic.com
address: https://api.anthropic.com/v1/
recommend: true
sort: 2
@@ -27,4 +27,12 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
address: https://api.baichuan-ai.com
- variable: base_url
label:
en_US: https://api.baichuan-ai.com/v1
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 Base URL
en_US: Enter your Base URL
address: https://api.baichuan-ai.com/v1
@@ -21,7 +21,7 @@ configurate_methods:
- customizable-model
provider_credential_schema:
credential_form_schemas:
- variable: dashscope_api_key
- variable: api_key
label:
en_US: API Key
type: secret-input
@@ -29,4 +29,12 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
address: https://dashscope.aliyuncs.com
- variable: base_url
label:
en_US: https://dashscope.aliyuncs.com/compatible-mode/v1
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 Base URL
en_US: Enter your Base URL
address: https://dashscope.aliyuncs.com/compatible-mode/v1
@@ -18,12 +18,20 @@ configurate_methods:
- predefined-model
provider_credential_schema:
credential_form_schemas:
- variable: api_base
- variable: api_key
label:
en_US: API URL
type: text-input
en_US: API Key
type: secret-input
required: true
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
- variable: base_url
label:
en_US: https://open.bigmodel.cn/api/paas/v4/
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 API URL
en_US: Enter your API URL
address: https://api.openai.com
address: https://open.bigmodel.cn/api/paas/v4/
@@ -32,4 +32,12 @@ provider_credential_schema:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
show_on: [ ]
address: https://api.cohere.com
- variable: base_url
label:
en_US: https://api.cohere.ai/compatibility/v1
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 Base URL
en_US: Enter your Base URL
address: https://api.cohere.ai/compatibility/v1
@@ -30,4 +30,12 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
address: https://api.deepseek.com
- variable: base_url
label:
en_US: https://api.deepseek.com/v1
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 Base URL
en_US: Enter your Base URL
address: https://api.deepseek.com/v1
@@ -28,4 +28,12 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
address: https://api.fireworks.ai
- variable: base_url
label:
en_US: https://generativelanguage.googleapis.com/v1beta/openai
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 Base URL
en_US: Enter your Base URL
address: https://api.fireworks.ai/inference/v1
@@ -32,12 +32,12 @@ provider_credential_schema:
- variable: google_api_base
label:
zh_Hans: API Base
en_US: API Base
en_US: https://generativelanguage.googleapis.com/v1beta/openai
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 API Base, 如:https://api.google.com
en_US: Enter your API Base, e.g. https://api.google.com
address: https://generativelanguage.googleapis.com
address: https://generativelanguage.googleapis.com/v1beta/openai
recommend: true
sort: 3
@@ -30,4 +30,12 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
address: https://api.groq.com
- variable: base_url
label:
en_US: https://router.huggingface.co/hf-inference/v1
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 Base URL
en_US: Enter your Base URL
address: https://api.groq.com/openai/v1
@@ -100,4 +100,22 @@ model_credential_schema:
show_on:
- variable: huggingfacehub_api_type
value: inference_endpoints
address: https://api-inference.huggingface.co
provider_credential_schema:
credential_form_schemas:
- variable: api_key
label:
en_US: API Key
type: secret-input
required: true
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
- variable: base_url
label:
en_US: https://router.huggingface.co/hf-inference/v1
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 Base URL
en_US: Enter your Base URL
address: https://router.huggingface.co/hf-inference/v1
@@ -23,20 +23,36 @@ configurate_methods:
- predefined-model
provider_credential_schema:
credential_form_schemas:
- variable: secret_id
# - variable: secret_id
# label:
# en_US: Secret ID
# type: secret-input
# required: true
# placeholder:
# zh_Hans: 在此输入您的 Secret ID
# en_US: Enter your Secret ID
# - variable: secret_key
# label:
# en_US: Secret Key
# type: secret-input
# required: true
# placeholder:
# zh_Hans: 在此输入您的 Secret Key
# en_US: Enter your Secret Key
- variable: api_key
label:
en_US: Secret ID
en_US: API Key
type: secret-input
required: true
placeholder:
zh_Hans: 在此输入您的 Secret ID
en_US: Enter your Secret ID
- variable: secret_key
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
- variable: base_url
label:
en_US: Secret Key
type: secret-input
required: true
en_US: https://api.hunyuan.cloud.tencent.com/v1
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 Secret Key
en_US: Enter your Secret Key
address: https://hunyuan.tencentcloudapi.com
zh_Hans: 在此输入您的 Base URL
en_US: Enter your Base URL
address: https://api.hunyuan.cloud.tencent.com/v1
@@ -96,4 +96,14 @@ model_credential_schema:
label:
en_US: 'No'
zh_Hans:
provider_credential_schema:
credential_form_schemas:
- variable: base_url
label:
en_US: https://lmstudio.ai
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 Base URL
en_US: Enter your Base URL
address: https://lmstudio.ai
@@ -27,6 +27,14 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
address: https://api.minimax.chat
- variable: base_url
label:
en_US: https://api.minimax.chat/v1
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 Base URL
en_US: Enter your Base URL
address: https://api.minimax.chat/v1
recommend: true
sort: 5
@@ -29,4 +29,12 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
- variable: base_url
label:
en_US: https://api.mistral.ai
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 Base URL
en_US: Enter your Base URL
address: https://api.mistral.ai
@@ -31,6 +31,14 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
address: https://api.moonshot.cn
- variable: base_url
label:
en_US: https://api.moonshot.cn/v1
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 Base URL
en_US: Enter your Base URL
address: https://api.moonshot.cn/v1
recommend: true
sort: 6
@@ -29,4 +29,12 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
address: https://api.novita.ai
- variable: base_url
label:
en_US: https://api.novita.ai/v3/openai
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 Base URL
en_US: Enter your Base URL
address: https://api.novita.ai/v3/openai
@@ -31,4 +31,12 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
- variable: base_url
label:
en_US: https://integrate.api.nvidia.com
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 Base URL
en_US: Enter your Base URL
address: https://integrate.api.nvidia.com
@@ -78,6 +78,6 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Base, 如:https://api.openai.com
en_US: Enter your API Base, e.g. https://api.openai.com
address: https://api.openai.com
address: https://api.openai.com/v1
recommend: true
sort: 1
@@ -103,4 +103,12 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
address: https://openrouter.ai
- variable: base_url
label:
en_US: https://openrouter.ai/api/v1
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 Base URL
en_US: Enter your Base URL
address: https://openrouter.ai/api/v1
@@ -31,4 +31,12 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
address: https://cloud.perfxlab.cn
- variable: base_url
label:
en_US: https://perfxcloud.io/v1
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 Base URL
en_US: Enter your Base URL
address: https://perfxcloud.io/v1
@@ -30,4 +30,12 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
address: https://api.openai.com
- variable: base_url
label:
en_US: https://perfxcloud.io/v1
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 Base URL
en_US: Enter your Base URL
address: https://api.siliconflow.cn/v1
@@ -28,5 +28,4 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 APIPassword
en_US: Enter your APIPassword
address: https://spark-api-open.xf-yun.com
@@ -31,6 +31,14 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
- variable: base_url
label:
en_US: https://api.stepfun.com/v1
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 Base URL
en_US: Enter your Base URL
model_credential_schema:
model:
label:
@@ -79,4 +87,4 @@ model_credential_schema:
label:
en_US: Tool Call
zh_Hans: Tool Call
address: https://api.stepfun.com
address: https://api.stepfun.com/v1
@@ -29,4 +29,12 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
address: https://dashscope.aliyuncs.com
- variable: base_url
label:
en_US: https://api.baichuan-ai.com/v1
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 Base URL
en_US: Enter your Base URL
address: https://api.baichuan-ai.com/v1
@@ -47,4 +47,12 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
address: https://api.upstage.ai
- variable: base_url
label:
en_US: https://api.upstage.ai/v1/solar
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 Base URL
en_US: Enter your Base URL
address: https://api.upstage.ai/v1/solar
@@ -349,7 +349,7 @@ provider_credential_schema:
en_US: Enter your APIKey
- variable: base_url
label:
en_US: Base URL
en_US: https://ark.cn-beijing.volces.com/api/v3
required: true
placeholder:
zh_Hans: 在此输入您的 Base url
@@ -30,14 +30,14 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
- variable: secret_key
- variable: base_url
label:
en_US: Secret Key
type: secret-input
required: true
en_US: https://qianfan.baidubce.com/v2
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 Secret Key
en_US: Enter your Secret Key
address: https://aip.baidubce.com
zh_Hans: 在此输入您的 Base URL
en_US: Enter your Base URL
address: https://qianfan.baidubce.com/v2
recommend: true
sort: 7
@@ -76,4 +76,14 @@ model_credential_schema:
placeholder:
zh_Hans: 在此输入调用重试次数
en_US: Enter max retries
provider_credential_schema:
credential_form_schemas:
- variable: base_url
label:
en_US: Base URL
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 Base URL
en_US: Enter your Base URL
address: https://xinference.ai
@@ -30,4 +30,12 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
address: https://api.lingyiwanwu.com
- variable: base_url
label:
en_US: https://api.lingyiwanwu.com/v1
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 Base URL
en_US: Enter your Base URL
address: https://api.lingyiwanwu.com/v1
@@ -30,4 +30,12 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
- variable: base_url
label:
en_US: Base URL
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的 Base URL
en_US: Enter your Base URL
address: https://api.360.cn
@@ -31,9 +31,9 @@ provider_credential_schema:
en_US: Enter your APIKey
- variable: base_url
label:
en_US: Base URL
en_US: https://open.bigmodel.cn/api/paas/v4/
required: true
placeholder:
zh_Hans: 在此输入您的 Base url
en_US: Enter your Base url
address: https://open.bigmodel.cn
address: https://open.bigmodel.cn/api/paas/v4/
+1 -1
View File
@@ -26,7 +26,7 @@ const (
// CheckPathIPPortExp (scheme://)?ip:port
CheckPathIPPortExp = `([a-zA-z]+://)?((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}:[0-9]+`
// EnglishOrNumberOrSpecialChars a-zA-Z0-9-_.:
EnglishOrNumberOrSpecialChars = `^(?i)[-:._a-z0-9]+$`
EnglishOrNumberOrSpecialChars = `^(?i)[-/:._a-z0-9]+$`
)
var (
+2 -2
View File
@@ -54,7 +54,7 @@ func (i *imlAPIController) Create(ctx *gin.Context, serviceId string, input *ai_
}
plugins["ai_formatter"] = api.PluginSetting{
Config: plugin_model.ConfigType{
"model": input.AiModel.Id,
"model": input.AiModel.Name,
"provider": provider,
"config": input.AiModel.Config,
},
@@ -113,7 +113,7 @@ func (i *imlAPIController) Edit(ctx *gin.Context, serviceId string, apiId string
}
proxy.Plugins["ai_formatter"] = api.PluginSetting{
Config: plugin_model.ConfigType{
"model": input.AiModel.Id,
"model": input.AiModel.Name,
"provider": provider,
"config": input.AiModel.Config,
},
+2 -2
View File
@@ -24,7 +24,7 @@ func (i *imlProviderModelController) GetModelParametersTemplate(ctx *gin.Context
func (i *imlProviderModelController) UpdateProviderModel(ctx *gin.Context, provider string, input *model_dto.EditModel) error {
if !common.ModelNameValid(input.Name) {
return fmt.Errorf("model name is invalid(a-zA-Z0-9-_.:)")
return fmt.Errorf("model name is invalid(a-zA-Z0-9-_.:/)")
}
if strings.TrimSpace(input.Id) == "" {
return fmt.Errorf("id is empty")
@@ -56,7 +56,7 @@ func (i *imlProviderModelController) DeleteProviderModel(ctx *gin.Context, provi
func (i *imlProviderModelController) AddProviderModel(ctx *gin.Context, provider string, input *model_dto.Model) (*model_dto.SimpleModel, error) {
if !common.ModelNameValid(input.Name) {
return nil, fmt.Errorf("model name illegal(a-zA-Z0-9-_.:)")
return nil, fmt.Errorf("model name illegal(a-zA-Z0-9-_.:/)")
}
if strings.TrimSpace(provider) == "" {
return nil, fmt.Errorf("provider is empty")
+1 -1
View File
@@ -26,7 +26,7 @@ func (i *imlProviderController) Delete(ctx *gin.Context, id string) error {
func (i *imlProviderController) AddProvider(ctx *gin.Context, input *ai_dto.NewProvider) (*ai_dto.SimpleProvider, error) {
if !common.ModelNameValid(input.Name) {
return nil, fmt.Errorf("name illegal(a-zA-Z0-9-_.:)")
return nil, fmt.Errorf("name illegal(a-zA-Z0-9-_.:/)")
}
return i.module.AddProvider(ctx, input)
}
+1 -1
View File
@@ -279,7 +279,7 @@ func (i *imlBalanceModule) getLocalBalances(ctx context.Context, v string) ([]*g
if !has {
continue
}
base = fmt.Sprintf("%s://%s", p.URI().Scheme(), p.URI().Host())
base = fmt.Sprintf("%s://%s%s", p.URI().Scheme(), p.URI().Host(), p.URI().Path())
}
releases = append(releases, newRelease(item, base))
}
+2 -2
View File
@@ -671,9 +671,9 @@ func (i *imlProviderModule) UpdateProviderConfig(ctx context.Context, id string,
}
cfg := make(map[string]interface{})
cfg["provider"] = info.Id
cfg["model"] = info.DefaultLLM
cfg["model"] = model.Name()
cfg["model_config"] = model.DefaultConfig()
cfg["base"] = fmt.Sprintf("%s://%s", p.URI().Scheme(), p.URI().Host())
cfg["base"] = fmt.Sprintf("%s://%s%s", p.URI().Scheme(), p.URI().Host(), p.URI().Path())
return i.syncGateway(ctx, cluster.DefaultClusterID, []*gateway.DynamicRelease{
{
BasicItem: &gateway.BasicItem{