diff --git a/kong/llm/drivers/llama2.lua b/kong/llm/drivers/llama2.lua index b2c41db77768..02b65818bd3a 100644 --- a/kong/llm/drivers/llama2.lua +++ b/kong/llm/drivers/llama2.lua @@ -264,7 +264,7 @@ function _M.configure_request(conf) local parsed_url = socket_url.parse(conf.model.options.upstream_url) -- 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) diff --git a/kong/llm/drivers/mistral.lua b/kong/llm/drivers/mistral.lua index 8a98ef6258fb..566ad903f6fc 100644 --- a/kong/llm/drivers/mistral.lua +++ b/kong/llm/drivers/mistral.lua @@ -148,7 +148,7 @@ function _M.configure_request(conf) local parsed_url = socket_url.parse(conf.model.options.upstream_url) -- 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)