mirror of
https://github.com/alibaba/higress.git
synced 2026-06-07 03:37:28 +08:00
Fix log import (#1957)
This commit is contained in:
@@ -12,7 +12,6 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/alibaba/higress/plugins/wasm-go/pkg/log"
|
||||
"github.com/alibaba/higress/plugins/wasm-go/pkg/wrapper"
|
||||
"github.com/higress-group/proxy-wasm-go-sdk/proxywasm"
|
||||
"github.com/higress-group/proxy-wasm-go-sdk/proxywasm/types"
|
||||
@@ -101,7 +100,7 @@ type KVExtractor struct {
|
||||
ResponseBody string `required:"false" yaml:"responseBody" json:"responseBody"`
|
||||
}
|
||||
|
||||
func parseConfig(json gjson.Result, c *PluginConfig, log log.Log) error {
|
||||
func parseConfig(json gjson.Result, c *PluginConfig, log wrapper.Log) error {
|
||||
log.Infof("config:%s", json.Raw)
|
||||
// init scene
|
||||
c.SceneInfo.Category = json.Get("scene.category").String()
|
||||
@@ -195,14 +194,14 @@ func parseConfig(json gjson.Result, c *PluginConfig, log log.Log) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func onHttpRequestHeaders(ctx wrapper.HttpContext, config PluginConfig, log log.Log) types.Action {
|
||||
func onHttpRequestHeaders(ctx wrapper.HttpContext, config PluginConfig, log wrapper.Log) types.Action {
|
||||
log.Debug("start onHttpRequestHeaders function.")
|
||||
|
||||
log.Debug("end onHttpRequestHeaders function.")
|
||||
return types.HeaderStopIteration
|
||||
}
|
||||
|
||||
func onHttpRequestBody(ctx wrapper.HttpContext, config PluginConfig, body []byte, log log.Log) types.Action {
|
||||
func onHttpRequestBody(ctx wrapper.HttpContext, config PluginConfig, body []byte, log wrapper.Log) types.Action {
|
||||
log.Debug("start onHttpRequestBody function.")
|
||||
bodyJson := gjson.ParseBytes(body)
|
||||
TempKey := strings.Trim(bodyJson.Get(config.KeyFrom.RequestBody).Raw, `"`)
|
||||
@@ -260,21 +259,21 @@ func onHttpRequestBody(ctx wrapper.HttpContext, config PluginConfig, body []byte
|
||||
return types.ActionPause
|
||||
}
|
||||
|
||||
func onHttpResponseHeaders(ctx wrapper.HttpContext, config PluginConfig, log log.Log) types.Action {
|
||||
func onHttpResponseHeaders(ctx wrapper.HttpContext, config PluginConfig, log wrapper.Log) types.Action {
|
||||
log.Debug("start onHttpResponseHeaders function.")
|
||||
|
||||
log.Debug("end onHttpResponseHeaders function.")
|
||||
return types.ActionContinue
|
||||
}
|
||||
|
||||
func onStreamingResponseBody(ctx wrapper.HttpContext, config PluginConfig, chunk []byte, isLastChunk bool, log log.Log) []byte {
|
||||
func onStreamingResponseBody(ctx wrapper.HttpContext, config PluginConfig, chunk []byte, isLastChunk bool, log wrapper.Log) []byte {
|
||||
log.Debug("start onStreamingResponseBody function.")
|
||||
|
||||
log.Debug("end onStreamingResponseBody function.")
|
||||
return chunk
|
||||
}
|
||||
|
||||
func onHttpResponseBody(ctx wrapper.HttpContext, config PluginConfig, body []byte, log log.Log) types.Action {
|
||||
func onHttpResponseBody(ctx wrapper.HttpContext, config PluginConfig, body []byte, log wrapper.Log) types.Action {
|
||||
log.Debug("start onHttpResponseBody function.")
|
||||
|
||||
log.Debug("end onHttpResponseBody function.")
|
||||
@@ -291,7 +290,7 @@ type ProxyRequestMessage struct {
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
func generateProxyRequest(c *PluginConfig, texts []string, log log.Log) (string, []byte, [][2]string) {
|
||||
func generateProxyRequest(c *PluginConfig, texts []string, log wrapper.Log) (string, []byte, [][2]string) {
|
||||
url := c.LLMInfo.ProxyPath
|
||||
var userMessage ProxyRequestMessage
|
||||
userMessage.Role = "user"
|
||||
@@ -339,7 +338,7 @@ type ProxyResponseOutputChoicesMessage struct {
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
func proxyResponseHandler(responseBody []byte, log log.Log) (*ProxyResponse, error) {
|
||||
func proxyResponseHandler(responseBody []byte, log wrapper.Log) (*ProxyResponse, error) {
|
||||
var response ProxyResponse
|
||||
err := json.Unmarshal(responseBody, &response)
|
||||
if err != nil {
|
||||
@@ -349,7 +348,7 @@ func proxyResponseHandler(responseBody []byte, log log.Log) (*ProxyResponse, err
|
||||
return &response, nil
|
||||
}
|
||||
|
||||
func getProxyResponseByExtractor(c *PluginConfig, responseBody []byte, log log.Log) string {
|
||||
func getProxyResponseByExtractor(c *PluginConfig, responseBody []byte, log wrapper.Log) string {
|
||||
bodyJson := gjson.ParseBytes(responseBody)
|
||||
responseContent := strings.Trim(bodyJson.Get(c.KeyFrom.ResponseBody).Raw, `"`)
|
||||
// llm返回的结果
|
||||
|
||||
Reference in New Issue
Block a user