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为空") }