Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ai): caching use deep copy for request table #13566

Merged
merged 4 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/unreleased/kong/ai-proxy-add-deep-copy-lib.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
message: |
**AI-proxy-plugin**: Replace the lib and use cycle_aware_deep_copy for the `request_table` object.
scope: Plugin
type: feature
3 changes: 2 additions & 1 deletion kong/llm/proxy/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ local cjson = require("cjson.safe")
local kong_utils = require("kong.tools.gzip")
local buffer = require "string.buffer"
local strip = require("kong.tools.utils").strip
local cycle_aware_deep_copy = require("kong.tools.table").cycle_aware_deep_copy


local EMPTY = require("kong.tools.table").EMPTY
Expand Down Expand Up @@ -346,7 +347,7 @@ function _M:access(conf)
end

request_table = kong.request.get_body(content_type, nil, conf.max_request_body_size)
llm_state.set_request_body_table(request_table)
llm_state.set_request_body_table(cycle_aware_deep_copy(request_table))
end

if not request_table then
Expand Down
Loading