Feat/vllm provider (#3067)

This commit is contained in:
woody
2025-10-29 14:31:38 +08:00
committed by GitHub
parent 268cf717fb
commit 5e4c262814
2 changed files with 196 additions and 0 deletions

View File

@@ -135,6 +135,7 @@ const (
providerTypeOpenRouter = "openrouter"
providerTypeLongcat = "longcat"
providerTypeFireworks = "fireworks"
providerTypeVllm = "vllm"
protocolOpenAI = "openai"
protocolOriginal = "original"
@@ -217,6 +218,7 @@ var (
providerTypeOpenRouter: &openrouterProviderInitializer{},
providerTypeLongcat: &longcatProviderInitializer{},
providerTypeFireworks: &fireworksProviderInitializer{},
providerTypeVllm: &vllmProviderInitializer{},
}
)
@@ -408,6 +410,12 @@ type ProviderConfig struct {
// @Title zh-CN Triton Server 部署的 Domain
// @Description 仅适用于 NVIDIA Triton Interference Server :path 中的 modelVersion 参考:"https://docs.nvidia.com/deeplearning/triton-inference-server/user-guide/docs/protocol/extension_generate.html"
tritonDomain string `required:"false" yaml:"tritonDomain" json:"tritonDomain"`
// @Title zh-CN vLLM自定义后端URL
// @Description zh-CN 仅适用于vLLM服务。vLLM服务的完整URL包含协议、域名、端口等
vllmCustomUrl string `required:"false" yaml:"vllmCustomUrl" json:"vllmCustomUrl"`
// @Title zh-CN vLLM主机地址
// @Description zh-CN 仅适用于vLLM服务指定vLLM服务器的主机地址例如vllm-service.cluster.local
vllmServerHost string `required:"false" yaml:"vllmServerHost" json:"vllmServerHost"`
}
func (c *ProviderConfig) GetId() string {
@@ -422,6 +430,14 @@ func (c *ProviderConfig) GetProtocol() string {
return c.protocol
}
func (c *ProviderConfig) GetVllmCustomUrl() string {
return c.vllmCustomUrl
}
func (c *ProviderConfig) GetVllmServerHost() string {
return c.vllmServerHost
}
func (c *ProviderConfig) IsOpenAIProtocol() bool {
return c.protocol == protocolOpenAI
}
@@ -591,6 +607,8 @@ func (c *ProviderConfig) FromJson(json gjson.Result) {
if c.basePath != "" && c.basePathHandling == "" {
c.basePathHandling = basePathHandlingRemovePrefix
}
c.vllmServerHost = json.Get("vllmServerHost").String()
c.vllmCustomUrl = json.Get("vllmCustomUrl").String()
}
func (c *ProviderConfig) Validate() error {