refactor(workers): 优化AI和LSP工作者的错误处理和日志输出
This commit is contained in:
parent
be83757074
commit
21296b7878
2 changed files with 5 additions and 2 deletions
|
@ -83,7 +83,7 @@ func (a *AI) GetMsg() string {
|
||||||
log.Println("PROMRT 未配置")
|
log.Println("PROMRT 未配置")
|
||||||
PROMPT = ""
|
PROMPT = ""
|
||||||
}
|
}
|
||||||
println("PROMPT:", PROMPT)
|
// println("PROMPT:", PROMPT)
|
||||||
requestBody := map[string]interface{}{
|
requestBody := map[string]interface{}{
|
||||||
"model": MODEL,
|
"model": MODEL,
|
||||||
"messages": []map[string]string{{
|
"messages": []map[string]string{{
|
||||||
|
|
|
@ -18,10 +18,13 @@ func (a *Lsp) GetMsg() string {
|
||||||
url := "https://api.lolicon.app/setu/v2?r18=0&size=small"
|
url := "https://api.lolicon.app/setu/v2?r18=0&size=small"
|
||||||
resp, err := http.Get(url)
|
resp, err := http.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "获取失败"
|
return "请求图片失败"
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
budy, err := io.ReadAll(resp.Body)
|
budy, err := io.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return "读取失败"
|
||||||
|
}
|
||||||
var res map[string]interface{}
|
var res map[string]interface{}
|
||||||
err = json.Unmarshal(budy, &res)
|
err = json.Unmarshal(budy, &res)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue