add info log of ai-search plugin (#2323)

This commit is contained in:
澄潭
2025-05-26 16:23:59 +08:00
committed by GitHub
parent 647c961f51
commit 76f76a70ab
2 changed files with 5 additions and 1 deletions

View File

@@ -362,7 +362,8 @@ func onHttpRequestBody(ctx wrapper.HttpContext, config Config, body []byte, log
}, rewriteBody,
func(statusCode int, responseHeaders http.Header, responseBody []byte) {
if statusCode != http.StatusOK {
log.Errorf("search rewrite failed, status: %d", statusCode)
log.Errorf("search rewrite failed, status: %d, request url: %s, request cluster: %s, search rewrite model: %s",
statusCode, searchRewrite.url, searchRewrite.client.ClusterName(), searchRewrite.modelName)
// After a rewrite failure, no further search is performed, thus quickly identifying the failure.
proxywasm.ResumeHttpRequest()
return

View File

@@ -38,6 +38,7 @@ type HttpClient interface {
Connect(rawURL string, headers [][2]string, body []byte, cb ResponseCallback, timeoutMillisecond ...uint32) error
Trace(rawURL string, headers [][2]string, body []byte, cb ResponseCallback, timeoutMillisecond ...uint32) error
Call(method, rawURL string, headers [][2]string, body []byte, cb ResponseCallback, timeoutMillisecond ...uint32) error
ClusterName() string
}
type ClusterClient[C Cluster] struct {
@@ -80,6 +81,8 @@ func (c ClusterClient[C]) Call(method, rawURL string, headers [][2]string, body
return HttpCall(c.cluster, method, rawURL, headers, body, cb, timeoutMillisecond...)
}
func (c ClusterClient[C]) ClusterName() string { return c.cluster.ClusterName() }
func HttpCall(cluster Cluster, method, rawURL string, headers [][2]string, body []byte,
callback ResponseCallback, timeoutMillisecond ...uint32) error {
for i := len(headers) - 1; i >= 0; i-- {