fix: Fix a bug in openaiCustomUrl support (#1790)

This commit is contained in:
Kent Dong
2025-02-22 12:12:49 +08:00
committed by GitHub
parent fabc22f218
commit 2328e19c9d
3 changed files with 13 additions and 7 deletions

View File

@@ -2,7 +2,6 @@ package provider
import (
"encoding/json"
"fmt"
"net/http"
"path"
"strings"
@@ -58,10 +57,10 @@ func (m *openaiProviderInitializer) CreateProvider(config ProviderConfig) (Provi
}
customUrl := strings.TrimPrefix(strings.TrimPrefix(config.openaiCustomUrl, "http://"), "https://")
pairs := strings.SplitN(customUrl, "/", 2)
if len(pairs) != 2 {
return nil, fmt.Errorf("invalid openaiCustomUrl:%s", config.openaiCustomUrl)
customPath := "/"
if len(pairs) == 2 {
customPath += pairs[1]
}
customPath := "/" + pairs[1]
isDirectCustomPath := isDirectPath(customPath)
capabilities := m.DefaultCapabilities()
if !isDirectCustomPath {