Skip to content

Commit 613c544

Browse files
daavooseratch
authored andcommitted
chore(deps): Bump "openai>=1.99.2,<2".
- fix(litellm_model): Replace `Function` with `ChatCompletionMessageFunctionToolCall`. - Breaking change coming from https://github.com/openai/openai-python/releases/tag/v1.99.2 Co-authored-by: daavoo <[email protected]>
1 parent cb0125c commit 613c544

File tree

6 files changed

+20
-18
lines changed

6 files changed

+20
-18
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ requires-python = ">=3.9"
77
license = "MIT"
88
authors = [{ name = "OpenAI", email = "[email protected]" }]
99
dependencies = [
10-
"openai>=1.97.1,<2",
10+
"openai>=1.99.6,<2",
1111
"pydantic>=2.10, <3",
1212
"griffe>=1.5.6, <2",
1313
"typing-extensions>=4.12.2, <5",

src/agents/extensions/models/litellm_model.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
) from _e
1919

2020
from openai import NOT_GIVEN, AsyncStream, NotGiven
21-
from openai.types.chat import ChatCompletionChunk, ChatCompletionMessageToolCall
21+
from openai.types.chat import ChatCompletionChunk, ChatCompletionMessageFunctionToolCall
2222
from openai.types.chat.chat_completion_message import (
2323
Annotation,
2424
AnnotationURLCitation,
2525
ChatCompletionMessage,
2626
)
27-
from openai.types.chat.chat_completion_message_tool_call import Function
27+
from openai.types.chat.chat_completion_message_function_tool_call import (
28+
ChatCompletionMessageFunctionToolCall,
29+
)
2830
from openai.types.responses import Response
2931

3032
from ... import _debug
@@ -413,11 +415,11 @@ def convert_annotations_to_openai(
413415
@classmethod
414416
def convert_tool_call_to_openai(
415417
cls, tool_call: litellm.types.utils.ChatCompletionMessageToolCall
416-
) -> ChatCompletionMessageToolCall:
417-
return ChatCompletionMessageToolCall(
418+
) -> ChatCompletionMessageFunctionToolCall:
419+
return ChatCompletionMessageFunctionToolCall(
418420
id=tool_call.id,
419421
type="function",
420-
function=Function(
422+
function=ChatCompletionMessageFunctionToolCall(
421423
name=tool_call.function.name or "", arguments=tool_call.function.arguments
422424
),
423425
)

src/agents/models/chatcmpl_converter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
ChatCompletionContentPartTextParam,
1313
ChatCompletionDeveloperMessageParam,
1414
ChatCompletionMessage,
15+
ChatCompletionMessageFunctionToolCallParam,
1516
ChatCompletionMessageParam,
16-
ChatCompletionMessageToolCallParam,
1717
ChatCompletionSystemMessageParam,
1818
ChatCompletionToolChoiceOptionParam,
1919
ChatCompletionToolMessageParam,
@@ -420,7 +420,7 @@ def ensure_assistant_message() -> ChatCompletionAssistantMessageParam:
420420
elif file_search := cls.maybe_file_search_call(item):
421421
asst = ensure_assistant_message()
422422
tool_calls = list(asst.get("tool_calls", []))
423-
new_tool_call = ChatCompletionMessageToolCallParam(
423+
new_tool_call = ChatCompletionMessageFunctionToolCallParam(
424424
id=file_search["id"],
425425
type="function",
426426
function={
@@ -440,7 +440,7 @@ def ensure_assistant_message() -> ChatCompletionAssistantMessageParam:
440440
asst = ensure_assistant_message()
441441
tool_calls = list(asst.get("tool_calls", []))
442442
arguments = func_call["arguments"] if func_call["arguments"] else "{}"
443-
new_tool_call = ChatCompletionMessageToolCallParam(
443+
new_tool_call = ChatCompletionMessageFunctionToolCallParam(
444444
id=func_call["call_id"],
445445
type="function",
446446
function={

tests/test_openai_chatcompletions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from openai.types.chat.chat_completion_chunk import ChatCompletionChunk
1111
from openai.types.chat.chat_completion_message import ChatCompletionMessage
1212
from openai.types.chat.chat_completion_message_tool_call import (
13-
ChatCompletionMessageToolCall,
13+
ChatCompletionMessageFunctionToolCall,
1414
Function,
1515
)
1616
from openai.types.completion_usage import (
@@ -152,7 +152,7 @@ async def test_get_response_with_tool_call(monkeypatch) -> None:
152152
should append corresponding `ResponseFunctionToolCall` items after the
153153
assistant message item with matching name/arguments.
154154
"""
155-
tool_call = ChatCompletionMessageToolCall(
155+
tool_call = ChatCompletionMessageFunctionToolCall(
156156
id="call-id",
157157
type="function",
158158
function=Function(name="do_thing", arguments="{'x':1}"),

tests/test_openai_chatcompletions_converter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from typing import Literal, cast
2727

2828
import pytest
29-
from openai.types.chat import ChatCompletionMessage, ChatCompletionMessageToolCall
29+
from openai.types.chat import ChatCompletionMessage, ChatCompletionMessageFunctionToolCall
3030
from openai.types.chat.chat_completion_message_tool_call import Function
3131
from openai.types.responses import (
3232
ResponseFunctionToolCall,
@@ -87,7 +87,7 @@ def test_message_to_output_items_with_tool_call():
8787
be reflected as separate `ResponseFunctionToolCall` items appended after
8888
the message item.
8989
"""
90-
tool_call = ChatCompletionMessageToolCall(
90+
tool_call = ChatCompletionMessageFunctionToolCall(
9191
id="tool1",
9292
type="function",
9393
function=Function(name="myfn", arguments='{"x":1}'),
@@ -185,7 +185,7 @@ def test_items_to_messages_with_output_message_and_function_call():
185185
# Refusal in output message should be represented in assistant message
186186
assert "refusal" in assistant
187187
assert assistant["refusal"] == refusal.refusal
188-
# Tool calls list should contain one ChatCompletionMessageToolCall dict
188+
# Tool calls list should contain one ChatCompletionMessageFunctionToolCall dict
189189
tool_calls = assistant.get("tool_calls")
190190
assert isinstance(tool_calls, list)
191191
assert len(tool_calls) == 1

uv.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)