Skip to content

Commit 3d94303

Browse files
fix openai tool calls (#20831)
1 parent ca37072 commit 3d94303

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

llama-index-integrations/llms/llama-index-llms-openai/llama_index/llms/openai/base.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,16 +1010,20 @@ def _prepare_chat_with_tools(
10101010
if user_msg:
10111011
messages.append(user_msg)
10121012

1013-
return {
1013+
kwargs = {
10141014
"messages": messages,
10151015
"tools": tool_specs or None,
10161016
"tool_choice": resolve_tool_choice(tool_choice, tool_required)
10171017
if tool_specs
10181018
else None,
1019-
"parallel_tool_calls": allow_parallel_tool_calls if tool_specs else None,
10201019
**kwargs,
10211020
}
10221021

1022+
if tool_specs:
1023+
kwargs["parallel_tool_calls"] = allow_parallel_tool_calls
1024+
1025+
return kwargs
1026+
10231027
def _validate_chat_with_tools_response(
10241028
self,
10251029
response: ChatResponse,

llama-index-integrations/llms/llama-index-llms-openai/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ dev = [
2727

2828
[project]
2929
name = "llama-index-llms-openai"
30-
version = "0.6.22"
30+
version = "0.6.23"
3131
description = "llama-index llms openai integration"
3232
authors = [{name = "llama-index"}]
3333
requires-python = ">=3.9,<4.0"

llama-index-integrations/llms/llama-index-llms-openai/tests/test_llms_openai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def test_prepare_chat_with_tools_no_tools():
125125
assert "messages" in result
126126
assert result["tools"] is None
127127
assert result["tool_choice"] is None
128-
assert result["parallel_tool_calls"] is None
128+
assert "parallel_tool_calls" not in result
129129

130130

131131
def test_prepare_chat_with_tools_explicit_tool_choice_overrides_tool_required():

0 commit comments

Comments
 (0)