From 82f93e455b5e7f534f37c1c68507ceb659742ede Mon Sep 17 00:00:00 2001 From: liyp Date: Mon, 1 Jul 2024 21:04:22 +0800 Subject: [PATCH] =?UTF-8?q?chore(workers):=20=E7=A7=BB=E9=99=A4=E6=97=A0?= =?UTF-8?q?=E7=94=A8=E6=B3=A8=E9=87=8A=E5=B9=B6=E6=B7=BB=E5=8A=A0=E8=B0=83?= =?UTF-8?q?=E8=AF=95=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- workers/ai.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/workers/ai.go b/workers/ai.go index a6426c8..1f2f32a 100644 --- a/workers/ai.go +++ b/workers/ai.go @@ -19,6 +19,7 @@ func (a *AI) GetMsg() string { } ask := a.Parms[1] + if ask == "" { return "不问问题你说个屁!" } @@ -48,6 +49,7 @@ func (a *AI) GetMsg() string { if strings.ToLower(a.Parms[1]) == "models" { OPENAI_BaseURL = OPENAI_BaseURL + "/models" + request := gorequest.New() resp, body, errs := request.Get(OPENAI_BaseURL). Set("Content-Type", "application/json"). @@ -63,6 +65,7 @@ func (a *AI) GetMsg() string { log.Println(err) return "解析模型列表失败" } + choices := responseBody["data"].([]interface{}) var models []interface{} if len(choices) > 0 { @@ -113,7 +116,8 @@ func (a *AI) GetMsg() string { PROMPT = "" } // PROMPT = "" - // println("PROMPT:", PROMPT) + println("PROMPT:", PROMPT) + println("ask:", ask) requestBody := map[string]interface{}{ "model": MODEL, "stream": false, @@ -123,7 +127,7 @@ func (a *AI) GetMsg() string { "content": PROMPT, }, {"role": "user", "content": ask}}, - "max_tokens": 200, + // "max_tokens": 200, "temperature": 0.7, } request := gorequest.New() @@ -146,6 +150,8 @@ func (a *AI) GetMsg() string { if len(choices) > 0 { choice := choices[0].(map[string]interface{}) msg = choice["message"].(map[string]interface{})["content"].(string) + // println("msg:", msg) + } else { log.Println("choices为空") }