Skip to content

Commit

Permalink
fix(llm): fix error when upstream_url missing trailing slash
Browse files Browse the repository at this point in the history
  • Loading branch information
fffonion committed Jan 17, 2025
1 parent 443c075 commit 1a3f012
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
message: |
**AI Plugins**: fix AI upstream URL trailing being empty
type: bugfix
scope: Plugin
2 changes: 1 addition & 1 deletion kong/llm/drivers/anthropic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ function _M.configure_request(conf)
ai_shared.override_upstream_url(parsed_url, conf)

-- if the path is read from a URL capture, ensure that it is valid
parsed_url.path = string_gsub(parsed_url.path, "^/*", "/")
parsed_url.path = (parsed_url.path and string_gsub(parsed_url.path, "^/*", "/")) or "/"

kong.service.request.set_path(parsed_url.path)
kong.service.request.set_scheme(parsed_url.scheme)
Expand Down
2 changes: 1 addition & 1 deletion kong/llm/drivers/azure.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function _M.configure_request(conf)
ai_shared.override_upstream_url(parsed_url, conf)

-- if the path is read from a URL capture, 3re that it is valid
parsed_url.path = string_gsub(parsed_url.path, "^/*", "/")
parsed_url.path = (parsed_url.path and string_gsub(parsed_url.path, "^/*", "/")) or "/"

kong.service.request.set_path(parsed_url.path)
kong.service.request.set_scheme(parsed_url.scheme)
Expand Down
2 changes: 1 addition & 1 deletion kong/llm/drivers/bedrock.lua
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ function _M.configure_request(conf, aws_sdk)
end

-- if the path is read from a URL capture, ensure that it is valid
parsed_url.path = string_gsub(parsed_url.path, "^/*", "/")
parsed_url.path = (parsed_url.path and string_gsub(parsed_url.path, "^/*", "/")) or "/"

ai_shared.override_upstream_url(parsed_url, conf)

Expand Down
2 changes: 1 addition & 1 deletion kong/llm/drivers/cohere.lua
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ function _M.configure_request(conf)


-- if the path is read from a URL capture, ensure that it is valid
parsed_url.path = string_gsub(parsed_url.path, "^/*", "/")
parsed_url.path = (parsed_url.path and string_gsub(parsed_url.path, "^/*", "/")) or "/"

kong.service.request.set_path(parsed_url.path)
kong.service.request.set_scheme(parsed_url.scheme)
Expand Down
2 changes: 1 addition & 1 deletion kong/llm/drivers/gemini.lua
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ function _M.configure_request(conf, identity_interface)


-- if the path is read from a URL capture, ensure that it is valid
parsed_url.path = string_gsub(parsed_url.path, "^/*", "/")
parsed_url.path = (parsed_url.path and string_gsub(parsed_url.path, "^/*", "/")) or "/"

kong.service.request.set_path(parsed_url.path)
kong.service.request.set_scheme(parsed_url.scheme)
Expand Down
2 changes: 1 addition & 1 deletion kong/llm/drivers/openai.lua
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function _M.configure_request(conf)
ai_shared.override_upstream_url(parsed_url, conf)

-- if the path is read from a URL capture, ensure that it is valid
parsed_url.path = string_gsub(parsed_url.path, "^/*", "/")
parsed_url.path = (parsed_url.path and string_gsub(parsed_url.path, "^/*", "/")) or "/"

kong.service.request.set_path(parsed_url.path)
kong.service.request.set_scheme(parsed_url.scheme)
Expand Down

0 comments on commit 1a3f012

Please sign in to comment.