fix(workers): 修复AI回复切片越界问题

由于在获取AI回复时错误地使用了字符串切片,导致当RawMsg为空或仅有一个字符时会出现越界错误。现在修正了索引的计算方法,确保在任何情况下都不会出现越界。
This commit is contained in:
liyp 2024-07-03 17:01:00 +08:00
parent 8e4ad23278
commit b0bf290731

View file

@ -127,7 +127,7 @@ func (a *AI) GetMsg() string {
"role": "system", "role": "system",
"content": PROMPT, "content": PROMPT,
}, },
{"role": "user", "content": ask}}, {"role": "user", "content": a.RawMsg[strings.Index(a.RawMsg, " ")+1:]}},
// "max_tokens": 200, // "max_tokens": 200,
"temperature": 0.7, "temperature": 0.7,
} }