Skip to content

Commit

Permalink
fix(ai-prompr-decorator): fix unable to modify request
Browse files Browse the repository at this point in the history
  • Loading branch information
fffonion authored and oowl committed Dec 3, 2024
1 parent a2295e6 commit 901280d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kong/plugins/ai-prompt-decorator/filters/decorate-prompt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
-- [ END OF LICENSE 0867164ffc95e54f04670b5169c09574bdbd9bba ]

local new_tab = require("table.new")
local deep_copy = require("kong.tools.table").deep_copy
local ai_plugin_ctx = require("kong.llm.plugin.ctx")

local _M = {
Expand Down Expand Up @@ -36,6 +37,9 @@ local function execute(request, conf)
local prepend = conf.prompts.prepend or EMPTY
local append = conf.prompts.append or EMPTY

-- ensure we don't modify the original request
request = deep_copy(request)

local old_messages = request.messages
local new_messages = new_tab(#append + #prepend + #old_messages, 0)
request.messages = new_messages
Expand Down Expand Up @@ -84,4 +88,4 @@ function _M:run(conf)
return true
end

return _M
return _M

0 comments on commit 901280d

Please sign in to comment.