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
test.json
*.exe
config.toml
*.exe

View file

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

View file

@ -65,7 +65,13 @@ func (a *AI) GetMsg() string {
if len(choices) > 0 {
msg = "支持的模型列表:\n"
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 {
msg = "没查到支持模型列表"
@ -85,12 +91,14 @@ func (a *AI) GetMsg() string {
}
// println("PROMPT:", PROMPT)
requestBody := map[string]interface{}{
"model": MODEL,
"model": MODEL,
"stream": false,
"messages": []map[string]string{{
"role": "system",
"content": PROMPT,
},
{"role": "user", "content": ask}},
"max_tokens": 75,
"temperature": 0.7,
}
request := gorequest.New()