Skip to content

Commit

Permalink
fix: fix Cloudflare AI Gateway channel test support (lobehub#639)
Browse files Browse the repository at this point in the history
* 当使用Cloudflare AI Gateway时,支持openai渠道测试

* refactor: change logic

---------

Co-authored-by: JustSong <songquanpeng@foxmail.com>
  • Loading branch information
woodchen-ink and songquanpeng authored Nov 5, 2023
1 parent c70c614 commit 3fe76c8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions controller/channel-test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/gin-gonic/gin"
"net/http"
"one-api/common"
"one-api/model"
"strconv"
"strings"
"sync"
"time"

"github.com/gin-gonic/gin"
)

func testChannel(channel *model.Channel, request ChatRequest) (err error, openaiErr *OpenAIError) {
Expand Down Expand Up @@ -50,6 +50,8 @@ func testChannel(channel *model.Channel, request ChatRequest) (err error, openai
}
requestURL += "/v1/chat/completions"
}
// for Cloudflare AI gateway: https://github.com/songquanpeng/one-api/pull/639
requestURL = strings.Replace(requestURL, "/v1/v1", "/v1", 1)

jsonData, err := json.Marshal(request)
if err != nil {
Expand Down

0 comments on commit 3fe76c8

Please sign in to comment.