Skip to content

Commit 36828d1

Browse files
committed
Merge branch 'master' of https://github.com/lordgreg/kong
2 parents 6bdaab0 + a2a110f commit 36828d1

17 files changed

+213
-76
lines changed

.requirements

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ LIBEXPAT_SHA256=fd03b7172b3bd7427a3e7a812063f74754f24542429b634e0db6511b53fb2278
1515

1616
# Note: git repositories can be loaded from local path if path is set as value
1717

18-
LUA_KONG_NGINX_MODULE=cd41aaa260eb54ec8f4c55b755b62351853b20fb # 0.15.1
18+
LUA_KONG_NGINX_MODULE=3f305911823301a98a12ec6ecdd9070b8ebe499b # 0.18.0
1919
LUA_RESTY_LMDB=9da0e9f3313960d06e2d8e718b7ac494faa500f1 # 1.6.0
2020
LUA_RESTY_EVENTS=bc85295b7c23eda2dbf2b4acec35c93f77b26787 # 0.3.1
2121
LUA_RESTY_SIMDJSON=176755a45f128fd4b3069c1bdee24d14bfb6900a # 1.2.0

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ limitations under the License.
127127

128128
[kong-url]: https://konghq.com/
129129
[kong-logo]: https://konghq.com/wp-content/uploads/2018/05/kong-logo-github-readme.png
130-
[kong-diagram]: https://assets.prd.mktg.konghq.com/images/2025/09/68cc1bfd-kong-diagram.png
130+
[kong-diagram]: https://assets.prd.mktg.konghq.com/images/2025/09/68cc1bfd-kong-diagram.png?v=2
131131
[kong-benefits]: https://konghq.com/wp-content/uploads/2018/05/kong-benefits-github-readme.png
132132
[kong-master-builds]: https://hub.docker.com/r/kong/kong/tags
133133
[badge-action-url]: https://github.com/Kong/kong/actions

build/openresty/patches/nginx-1.27.1_10-ssl-disable-h2-alpn.patch

Lines changed: 0 additions & 27 deletions
This file was deleted.

build/openresty/patches/ngx_lua-0.10.28_02-ssl-disable-h2-alpn.patch

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
message: >
2+
**ai-proxy**: Fixed an issue where OpenAI chat completion's tool_choice was not converted to Anthropic's.
3+
type: bugfix
4+
scope: Plugin

kong/llm/drivers/anthropic.lua

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,33 @@ local function to_tools(in_tools)
128128
return out_tools
129129
end
130130

131+
local function to_tool_choice(openai_tool_choice)
132+
-- See https://docs.anthropic.com/en/api/messages#body-tool-choice and
133+
-- https://platform.openai.com/docs/api-reference/chat/create#chat-create-tool_choice
134+
if type(openai_tool_choice) == "string" then
135+
if openai_tool_choice == "required" then
136+
return {type = "any"}
137+
elseif openai_tool_choice == "none" or openai_tool_choice == "auto" then
138+
return {type = openai_tool_choice}
139+
else
140+
kong.log.warn("invalid tool choice string: ", openai_tool_choice, ", expected 'required', 'none', or 'auto'")
141+
return nil
142+
end
143+
end
144+
145+
if type(openai_tool_choice) == "table" then
146+
if openai_tool_choice.type == "function" and openai_tool_choice["function"].name then
147+
return {type = "tool", name = openai_tool_choice["function"].name}
148+
end
149+
150+
kong.log.warn("invalid tool choice table: ", cjson.encode(openai_tool_choice))
151+
return nil
152+
end
153+
154+
kong.log.warn("invalid tool choice type: ", type(openai_tool_choice), ", expected string or table")
155+
return nil
156+
end
157+
131158
local transformers_to = {
132159
["llm/v1/chat"] = function(request_table, model)
133160
local messages = {}
@@ -145,7 +172,7 @@ local transformers_to = {
145172

146173
-- handle function calling translation from OpenAI format
147174
messages.tools = request_table.tools and to_tools(request_table.tools)
148-
messages.tool_choice = request_table.tool_choice
175+
messages.tool_choice = request_table.tool_choice and to_tool_choice(request_table.tool_choice)
149176

150177
return messages, "application/json", nil
151178
end,

0 commit comments

Comments
 (0)