From d4077390a914a8192dc63e9c95b460ebbeab0332 Mon Sep 17 00:00:00 2001 From: JustSong Date: Sat, 19 Aug 2023 17:22:50 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"=E5=85=BC=E5=AE=B9=E8=AE=AF=E9=A3=9Ev?= =?UTF-8?q?2=E6=8E=A5=E5=8F=A3"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 21f05d1294b8693d0a21664a23ec04f028b9b117. --- controller/relay-text.go | 9 +++------ controller/relay-xunfei.go | 5 +---- web/src/pages/Channel/EditChannel.js | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/controller/relay-text.go b/controller/relay-text.go index 8ee707af..761ca86f 100644 --- a/controller/relay-text.go +++ b/controller/relay-text.go @@ -501,14 +501,11 @@ func relayTextHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode { auth := c.Request.Header.Get("Authorization") auth = strings.TrimPrefix(auth, "Bearer ") splits := strings.Split(auth, "|") - if len(splits) < 3 || len(splits) > 4 { + if len(splits) != 3 { return errorWrapper(errors.New("invalid auth"), "invalid_auth", http.StatusBadRequest) } - if len(splits) == 3 { - splits[3] = "" - } - err, usage := xunfeiStreamHandler(c, textRequest, splits[0], splits[1], splits[2], splits[3]) - if err != nil { + err, usage := xunfeiStreamHandler(c, textRequest, splits[0], splits[1], splits[2]) + if err != nil { return err } if usage != nil { diff --git a/controller/relay-xunfei.go b/controller/relay-xunfei.go index 2aba2e88..87037e34 100644 --- a/controller/relay-xunfei.go +++ b/controller/relay-xunfei.go @@ -176,15 +176,12 @@ func buildXunfeiAuthUrl(hostUrl string, apiKey, apiSecret string) string { return callUrl } -func xunfeiStreamHandler(c *gin.Context, textRequest GeneralOpenAIRequest, appId string, apiSecret string, apiKey string, version string) (*OpenAIErrorWithStatusCode, *Usage) { +func xunfeiStreamHandler(c *gin.Context, textRequest GeneralOpenAIRequest, appId string, apiSecret string, apiKey string) (*OpenAIErrorWithStatusCode, *Usage) { var usage Usage d := websocket.Dialer{ HandshakeTimeout: 5 * time.Second, } hostUrl := "wss://aichat.xf-yun.com/v1/chat" - if version != "" { //换成新版的,支持v2 - hostUrl = "wss://spark-api.xf-yun.com/" + version + "/chat" - } conn, resp, err := d.Dial(buildXunfeiAuthUrl(hostUrl, apiKey, apiSecret), nil) if err != nil || resp.StatusCode != 101 { return errorWrapper(err, "dial_failed", http.StatusInternalServerError), nil diff --git a/web/src/pages/Channel/EditChannel.js b/web/src/pages/Channel/EditChannel.js index 2912c5ed..b5fb524e 100644 --- a/web/src/pages/Channel/EditChannel.js +++ b/web/src/pages/Channel/EditChannel.js @@ -355,7 +355,7 @@ const EditChannel = () => { label='密钥' name='key' required - placeholder={inputs.type === 15 ? '按照如下格式输入:APIKey|SecretKey' : (inputs.type === 18 ? '按照如下格式输入:APPID|APISecret|APIKey|v1.1或v2.1' : '请输入渠道对应的鉴权密钥')} + placeholder={inputs.type === 15 ? '按照如下格式输入:APIKey|SecretKey' : (inputs.type === 18 ? '按照如下格式输入:APPID|APISecret|APIKey' : '请输入渠道对应的鉴权密钥')} onChange={handleInputChange} value={inputs.key} autoComplete='new-password'