From 23e097d87df484b2f8d15f097b4da3c430e1c72c Mon Sep 17 00:00:00 2001 From: wood chen <95951386+woodchen-ink@users.noreply.github.com> Date: Fri, 27 Oct 2023 01:24:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=93=E4=BD=BF=E7=94=A8Cloudflare=20AI=20Ga?= =?UTF-8?q?teway=E6=97=B6=EF=BC=8C=E6=94=AF=E6=8C=81openai=E6=B8=A0?= =?UTF-8?q?=E9=81=93=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/channel-test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/controller/channel-test.go b/controller/channel-test.go index ae4ab7d5..1950ac51 100644 --- a/controller/channel-test.go +++ b/controller/channel-test.go @@ -11,6 +11,7 @@ import ( "strconv" "sync" "time" + "strings" "github.com/gin-gonic/gin" ) @@ -47,8 +48,11 @@ func testChannel(channel *model.Channel, request ChatRequest) (err error, openai } else { if 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)