From 81053db6c3f562005d298e44fba09c7c234eabbe Mon Sep 17 00:00:00 2001 From: yi Date: Mon, 4 Mar 2024 21:13:55 +0800 Subject: [PATCH] =?UTF-8?q?feat(AI):=20=E7=99=BE=E5=BA=A6=E5=8D=83?= =?UTF-8?q?=E5=B8=86=E4=BF=AE=E6=94=B9=E4=B8=BA=E7=9B=B4=E6=8E=A5=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=EF=BC=8C=E4=B8=8D=E4=BD=BF=E7=94=A8=E6=B5=81=E5=BC=8F?= =?UTF-8?q?=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wclient/aichat/baidu.go | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/wclient/aichat/baidu.go b/wclient/aichat/baidu.go index b3930f58..6d23c599 100644 --- a/wclient/aichat/baidu.go +++ b/wclient/aichat/baidu.go @@ -3,7 +3,6 @@ package aichat import ( "context" "errors" - "io" "strings" "github.com/liudding/go-llm-api/baidu" @@ -53,26 +52,13 @@ func BaiDuText(id, rid, ask string) (string, error) { }) // 请求模型接口 + res, err := client.CreateChatCompletion(context.Background(), req) - stream, err := client.CreateChatCompletionStream(context.Background(), req) if err != nil { return "", err } - defer stream.Close() - - reply := "" - - for { - response, err := stream.Recv() - if err != nil { - if errors.Is(err, io.EOF) { - break - } - return reply, err - } - reply += response.Result - } + reply := res.Result if reply == "" { return "", errors.New("未得到预期的结果")