修改视频相关调用相关问题

This commit is contained in:
Connor
2026-01-14 02:59:32 +08:00
parent 23b45efae9
commit c3eae5dd7c
4 changed files with 213 additions and 38 deletions

View File

@@ -71,7 +71,18 @@ func (s *AIService) CreateConfig(req *CreateAIConfigRequest) (*models.AIServiceC
} else if req.ServiceType == "image" {
endpoint = "/v1beta/models/{model}:generateContent"
}
case "openai", "chatfire":
case "openai":
if req.ServiceType == "text" {
endpoint = "/chat/completions"
} else if req.ServiceType == "image" {
endpoint = "/images/generations"
} else if req.ServiceType == "video" {
endpoint = "/videos"
if queryEndpoint == "" {
queryEndpoint = "/videos/{taskId}"
}
}
case "chatfire":
if req.ServiceType == "text" {
endpoint = "/chat/completions"
} else if req.ServiceType == "image" {
@@ -79,7 +90,14 @@ func (s *AIService) CreateConfig(req *CreateAIConfigRequest) (*models.AIServiceC
} else if req.ServiceType == "video" {
endpoint = "/video/generations"
if queryEndpoint == "" {
queryEndpoint = "/v1/video/task/{taskId}"
queryEndpoint = "/video/task/{taskId}"
}
}
case "doubao", "volcengine", "volces":
if req.ServiceType == "video" {
endpoint = "/contents/generations/tasks"
if queryEndpoint == "" {
queryEndpoint = "/generations/tasks/{taskId}"
}
}
default:
@@ -188,13 +206,23 @@ func (s *AIService) UpdateConfig(configID uint, req *UpdateAIConfigRequest) (*mo
if serviceType == "text" || serviceType == "image" {
updates["endpoint"] = "/v1beta/models/{model}:generateContent"
}
case "openai", "chatfire":
case "openai":
if serviceType == "text" {
updates["endpoint"] = "/chat/completions"
} else if serviceType == "image" {
updates["endpoint"] = "/images/generations"
} else if serviceType == "video" {
updates["endpoint"] = "/videos"
updates["query_endpoint"] = "/videos/{taskId}"
}
case "chatfire":
if serviceType == "text" {
updates["endpoint"] = "/chat/completions"
} else if serviceType == "image" {
updates["endpoint"] = "/images/generations"
} else if serviceType == "video" {
updates["endpoint"] = "/video/generations"
updates["query_endpoint"] = "/video/task/{taskId}"
}
}
} else if req.Endpoint != "" {

View File

@@ -419,14 +419,14 @@ func (s *VideoGenerationService) getVideoClient(provider string, modelName strin
model = config.Model[0]
}
// 根据 provider 自动设置默认端点
// 根据配置中的 provider 创建对应的客户端
var endpoint string
var queryEndpoint string
switch provider {
switch config.Provider {
case "chatfire":
endpoint = "/video/generations"
queryEndpoint = "/v1/video/task/{taskId}"
queryEndpoint = "/video/task/{taskId}"
return video.NewChatfireClient(baseURL, apiKey, model, endpoint, queryEndpoint), nil
case "doubao", "volcengine", "volces":
endpoint = "/contents/generations/tasks"

View File

@@ -297,11 +297,11 @@ func (s *VideoMergeService) getVideoClient(provider string) (video.VideoClient,
model = config.Model[0]
}
// 根据 provider 自动设置默认端点
// 根据配置中的 provider 创建对应的客户端
var endpoint string
var queryEndpoint string
switch provider {
switch config.Provider {
case "runway":
return video.NewRunwayClient(config.BaseURL, config.APIKey, model), nil
case "pika":
@@ -312,7 +312,7 @@ func (s *VideoMergeService) getVideoClient(provider string) (video.VideoClient,
return video.NewMinimaxClient(config.BaseURL, config.APIKey, model), nil
case "chatfire":
endpoint = "/video/generations"
queryEndpoint = "/v1/video/task/{taskId}"
queryEndpoint = "/video/task/{taskId}"
return video.NewChatfireClient(config.BaseURL, config.APIKey, model, endpoint, queryEndpoint), nil
case "doubao", "volces", "ark":
endpoint = "/contents/generations/tasks"