feat(workers): 改进AI回复格式

This commit is contained in:
liyp 2024-07-01 00:26:26 +08:00
parent 21296b7878
commit eedb68a282
3 changed files with 13 additions and 5 deletions

3
.gitignore vendored
View file

@ -1,4 +1,5 @@
data.db data.db
test.json test.json
config.toml
*.exe *.exe
config.toml

View file

@ -1,8 +1,7 @@
[Server]
APIURL = "0.0.0.0:5580" APIURL = "0.0.0.0:5580"
POSTURL = "http://0.0.0.0:5700" POSTURL = "http://0.0.0.0:5700"
[Group]
AllowGroup = [] AllowGroup = []
AllowUser = [] AllowUser = []
AllowRole = [] AllowRole = []

View file

@ -65,7 +65,13 @@ func (a *AI) GetMsg() string {
if len(choices) > 0 { if len(choices) > 0 {
msg = "支持的模型列表:\n" msg = "支持的模型列表:\n"
for _, choice := range choices { for _, choice := range choices {
msg = msg + choice.(map[string]interface{})["id"].(string) + "\n" models := choice.(map[string]interface{})["id"].(string)
if models == MODEL {
msg = msg + models + "\t ✔\n"
} else {
msg = msg + models + "\n"
}
} }
} else { } else {
msg = "没查到支持模型列表" msg = "没查到支持模型列表"
@ -86,11 +92,13 @@ func (a *AI) GetMsg() string {
// println("PROMPT:", PROMPT) // println("PROMPT:", PROMPT)
requestBody := map[string]interface{}{ requestBody := map[string]interface{}{
"model": MODEL, "model": MODEL,
"stream": false,
"messages": []map[string]string{{ "messages": []map[string]string{{
"role": "system", "role": "system",
"content": PROMPT, "content": PROMPT,
}, },
{"role": "user", "content": ask}}, {"role": "user", "content": ask}},
"max_tokens": 75,
"temperature": 0.7, "temperature": 0.7,
} }
request := gorequest.New() request := gorequest.New()