当使用Cloudflare AI Gateway时,支持openai渠道测试

This commit is contained in:
wood chen 2023-10-27 01:24:05 +08:00 committed by GitHub
parent 89d458b9cf
commit 23e097d87d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,7 @@ import (
"strconv" "strconv"
"sync" "sync"
"time" "time"
"strings"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
@ -47,8 +48,11 @@ func testChannel(channel *model.Channel, request ChatRequest) (err error, openai
} else { } else {
if channel.GetBaseURL() != "" { if channel.GetBaseURL() != "" {
requestURL = channel.GetBaseURL() requestURL = channel.GetBaseURL()
if !strings.HasPrefix(requestURL, "https://gateway.ai.cloudflare.com") {
requestURL += "/v1"
} }
requestURL += "/v1/chat/completions" }
requestURL += "/chat/completions"
} }
jsonData, err := json.Marshal(request) jsonData, err := json.Marshal(request)