-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(plugins): move shared ctx usage of ai plugins to use a prope…
…r API To make typo more obvious to be catched
- Loading branch information
Showing
11 changed files
with
153 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
local _M = {} | ||
|
||
function _M.disable_ai_proxy_response_transform() | ||
kong.ctx.shared.llm_disable_ai_proxy_response_transform = true | ||
end | ||
|
||
function _M.should_disable_ai_proxy_response_transform() | ||
return kong.ctx.shared.llm_disable_ai_proxy_response_transform == true | ||
end | ||
|
||
function _M.set_prompt_decorated() | ||
kong.ctx.shared.llm_prompt_decorated = true | ||
end | ||
|
||
function _M.is_prompt_decorated() | ||
return kong.ctx.shared.llm_prompt_decorated == true | ||
end | ||
|
||
function _M.set_prompt_guarded() | ||
kong.ctx.shared.llm_prompt_guarded = true | ||
end | ||
|
||
function _M.is_prompt_guarded() | ||
return kong.ctx.shared.llm_prompt_guarded == true | ||
end | ||
|
||
function _M.set_prompt_templated() | ||
kong.ctx.shared.llm_prompt_templated = true | ||
end | ||
|
||
function _M.is_prompt_templated() | ||
return kong.ctx.shared.llm_prompt_templated == true | ||
end | ||
|
||
function _M.set_streaming_mode() | ||
kong.ctx.shared.llm_streaming_mode = true | ||
end | ||
|
||
function _M.is_streaming_mode() | ||
return kong.ctx.shared.llm_streaming_mode == true | ||
end | ||
|
||
function _M.set_parsed_response(response) | ||
kong.ctx.shared.llm_parsed_response = response | ||
end | ||
|
||
function _M.get_parsed_response() | ||
return kong.ctx.shared.llm_parsed_response | ||
end | ||
|
||
function _M.set_request_body_table(body_t) | ||
kong.ctx.shared.llm_request_body_t = body_t | ||
end | ||
|
||
function _M.get_request_body_table() | ||
return kong.ctx.shared.llm_request_body_t | ||
end | ||
|
||
function _M.set_replacement_response(response) | ||
kong.ctx.shared.llm_replacement_response = response | ||
end | ||
|
||
function _M.get_replacement_response() | ||
return kong.ctx.shared.llm_replacement_response | ||
end | ||
|
||
function _M.set_request_analytics(tbl) | ||
kong.ctx.shared.llm_request_analytics = tbl | ||
end | ||
|
||
function _M.get_request_analytics() | ||
return kong.ctx.shared.llm_request_analytics | ||
end | ||
|
||
function _M.increase_prompt_tokens_count(by) | ||
local count = (kong.ctx.shared.llm_prompt_tokens_count or 0) + by | ||
kong.ctx.shared.llm_prompt_tokens_count = count | ||
return count | ||
end | ||
|
||
function _M.get_prompt_tokens_count() | ||
return kong.ctx.shared.llm_prompt_tokens_count | ||
end | ||
|
||
function _M.increase_response_tokens_count(by) | ||
local count = (kong.ctx.shared.llm_response_tokens_count or 0) + by | ||
kong.ctx.shared.llm_response_tokens_count = count | ||
return count | ||
end | ||
|
||
function _M.get_response_tokens_count() | ||
return kong.ctx.shared.llm_response_tokens_count | ||
end | ||
|
||
return _M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.