We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 06fcd59 commit 6e728abCopy full SHA for 6e728ab
CHANGELOG.md
@@ -10,6 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
10
11
### Fixed
12
13
+## [0.59.1]
14
+
15
+### Fixed
16
+- Fixed a bug in multi-turn tool calls for OpenAI models where an empty tools array could have been, which causes an API error.
17
18
## [0.59.0]
19
20
### Breaking Changes
Project.toml
@@ -1,7 +1,7 @@
1
name = "PromptingTools"
2
uuid = "670122d1-24a8-4d70-bfce-740807c42192"
3
authors = ["J S @svilupp and contributors"]
4
-version = "0.59.0"
+version = "0.59.1"
5
6
[deps]
7
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
src/llm_openai.jl
@@ -56,11 +56,17 @@ function render(schema::AbstractOpenAISchema,
56
end
57
Dict("role" => role4render(schema, msg), "content" => content)
58
elseif isaitoolrequest(msg)
59
- Dict("role" => role4render(schema, msg), "content" => msg.content,
60
- "tool_calls" => [Dict("id" => tool.tool_call_id, "type" => "function",
61
- "function" => Dict("name" => tool.name,
62
- "arguments" => tool.raw))
63
- for tool in msg.tool_calls])
+ output = Dict{String, Any}(
+ "role" => role4render(schema, msg),
+ "content" => msg.content)
+ if !isempty(msg.tool_calls)
+ output["tool_calls"] = [Dict("id" => tool.tool_call_id,
64
+ "type" => "function",
65
+ "function" => Dict("name" => tool.name,
66
+ "arguments" => tool.raw))
67
+ for tool in msg.tool_calls]
68
+ end
69
+ output
70
elseif istoolmessage(msg)
71
content = msg.content isa AbstractString ? msg.content : string(msg.content)
72
Dict("role" => role4render(schema, msg), "content" => content,
test/llm_openai.jl
@@ -196,6 +196,20 @@ using PromptingTools: pick_tokenizer, OPENAI_TOKEN_IDS_GPT35_GPT4, OPENAI_TOKEN_
196
]
197
@test conversation == expected_output
198
199
+ # With empty tools
200
+ messages = [
201
+ SystemMessage("System message"),
202
+ UserMessage("User message"),
203
+ AIToolRequest(;content="content")
204
+ ]
205
+ conversation = render(schema, messages)
206
+ expected_output = Dict{String, Any}[
207
+ Dict("role" => "system", "content" => "System message"),
208
+ Dict("role" => "user", "content" => "User message"),
209
+ Dict("role" => "assistant", "content" => "content")
210
211
+ @test conversation == expected_output
212
213
# With a list of images and detail="low"
214
messages = [
215
SystemMessage("System message 2"),
0 commit comments