Skip to content

Commit

Permalink
fix(rebase): solve conflicts with #12792
Browse files Browse the repository at this point in the history
  • Loading branch information
tysoekong committed Apr 14, 2024
1 parent 26b5eb4 commit 142eb5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
14 changes: 1 addition & 13 deletions kong/llm/drivers/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,6 @@ function _M.post_request(conf, response_object)
body_string = response_object.response or "ERROR__NOT_SET"
end

local provider_length = conf.model.provider and #conf.model.provider or 0

if conf.logging and conf.logging.log_payloads then
kong.log.set_serialize_value(conf.model.provider[provider_length].log_entry_keys.RESPONSE_BODY, body_string)
end

-- analytics and logging
if conf.logging and conf.logging.log_statistics then
-- check if we already have analytics in this context
Expand Down Expand Up @@ -335,12 +329,6 @@ function _M.post_request(conf, response_object)
-- Get the current try count
local try_count = request_analytics_provider.number_of_instances

-- Decode the response string
local response_object, err = cjson.decode(response_string)
if err then
return nil, "failed to decode response from JSON"
end

-- Set the model, response, and provider names in the current try context
current_try[log_entry_keys.META_CONTAINER][log_entry_keys.REQUEST_MODEL] = conf.model.name
current_try[log_entry_keys.META_CONTAINER][log_entry_keys.RESPONSE_MODEL] = response_object.model or conf.model.name
Expand All @@ -365,7 +353,7 @@ function _M.post_request(conf, response_object)

-- Log response body if logging payloads is enabled
if conf.logging and conf.logging.log_payloads then
current_try[log_entry_keys.RESPONSE_BODY] = response_string
current_try[log_entry_keys.RESPONSE_BODY] = body_string
end

-- Store the split key data in instances
Expand Down
5 changes: 4 additions & 1 deletion kong/plugins/ai-proxy/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ function _M:body_filter(conf)
end

-- call with replacement body, or original body if nothing changed
ai_shared.post_request(conf, original_request)
local _, err = ai_shared.post_request(conf, original_request)
if err then
kong.log.warn("analytics phase failed for request, ", err)
end
end

kong.ctx.plugin.body_called = true
Expand Down

0 comments on commit 142eb5f

Please sign in to comment.