coai/addition/web/search.go
Deng Junhai 401de5ace7 feat: better stop signal (#181)
feat: better stop signal (#181)
Co-Authored-By: Minghan Zhang <112773885+zmh-program@users.noreply.github.com>
2024-06-27 22:57:17 +08:00

20 lines
421 B
Go

package web
import (
"chat/globals"
"chat/utils"
"fmt"
)
func SearchWebResult(q string) string {
res, err := CallDuckDuckGoAPI(q)
if err != nil {
globals.Warn(fmt.Sprintf("[web] failed to get search result: %s (query: %s)", err.Error(), q))
return ""
}
content := formatResponse(res)
globals.Debug(fmt.Sprintf("[web] search result: %s (query: %s)", utils.Extract(content, 50, "..."), q))
return content
}