feat: add ai-request-rewrite plugin#12036
Conversation
membphis
left a comment
There was a problem hiding this comment.
LGTM, pls fix some minor issues
| error_msg = error_msg .. ", err: " .. err | ||
| end | ||
| return HTTP_BAD_REQUEST, error_msg | ||
| core.log.error("LLM service returned error status: ", res.status, ", ", resp_body) |
There was a problem hiding this comment.
i think we need to remove resp_body, it is big
There was a problem hiding this comment.
i think we need to remove
resp_body, it is big
Logging the response body would make it easier to identify issues. For example, a 400 error can occur for various reasons, and the returned message can help pinpoint the problem.
There was a problem hiding this comment.
The main identification here is the response code, which has nothing to do with the response body. So, recording the response body in the log will not provide any other obvious help.
In addition, the response body itself is relatively large and may contain sensitive business information, which is not suitable for recording in the error log.
| function _M.access(conf, ctx) | ||
| local client_request_body, err = core.request.get_body() | ||
| if err then | ||
| core.log.info("failed to get request body: ", err) |
| local client_request_body, err = core.request.get_body() | ||
| if err then | ||
| core.log.info("failed to get request body: ", err) | ||
| return HTTP_BAD_REQUEST, err |
Description
The
ai-request-rewriteplugin leverages predefined prompts and AI services to intelligently modify client requests, enabling AI-powered content transformation before forwarding to upstream services.Checklist