fix(workers): 修复AI回复切片越界问题
由于在获取AI回复时错误地使用了字符串切片,导致当RawMsg为空或仅有一个字符时会出现越界错误。现在修正了索引的计算方法,确保在任何情况下都不会出现越界。
This commit is contained in:
parent
8e4ad23278
commit
b0bf290731
1 changed files with 1 additions and 1 deletions
|
@ -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,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue