Skip to content

Commit 1996dfe

Browse files
committed
fix lint and mypy errors
1 parent dec9fec commit 1996dfe

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

src/agents/models/chatcmpl_converter.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
from ..tool import FunctionTool, Tool
5252
from .fake_id import FAKE_RESPONSES_ID
5353

54+
ResponseInputContentWithAudioParam = Union[ResponseInputContentParam, ResponseInputAudioParam]
55+
5456

5557
class Converter:
5658
@classmethod
@@ -248,7 +250,7 @@ def maybe_reasoning_message(cls, item: Any) -> ResponseReasoningItemParam | None
248250

249251
@classmethod
250252
def extract_text_content(
251-
cls, content: str | Iterable[ResponseInputContentParam]
253+
cls, content: str | Iterable[ResponseInputContentWithAudioParam]
252254
) -> str | list[ChatCompletionContentPartTextParam]:
253255
all_content = cls.extract_all_content(content)
254256
if isinstance(all_content, str):
@@ -261,7 +263,7 @@ def extract_text_content(
261263

262264
@classmethod
263265
def extract_all_content(
264-
cls, content: str | Iterable[ResponseInputContentParam]
266+
cls, content: str | Iterable[ResponseInputContentWithAudioParam]
265267
) -> str | list[ChatCompletionContentPartParam]:
266268
if isinstance(content, str):
267269
return content
@@ -537,7 +539,7 @@ def ensure_assistant_message() -> ChatCompletionAssistantMessageParam:
537539
elif func_output := cls.maybe_function_tool_call_output(item):
538540
flush_assistant_message()
539541
output_content = cast(
540-
Union[str, Iterable[ResponseInputContentParam]], func_output["output"]
542+
Union[str, Iterable[ResponseInputContentWithAudioParam]], func_output["output"]
541543
)
542544
msg: ChatCompletionToolMessageParam = {
543545
"role": "tool",

tests/extensions/memory/test_sqlalchemy_session.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def _make_message_item(item_id: str, text_value: str) -> TResponseInputItem:
3636
"type": "output_text",
3737
"text": text_value,
3838
"annotations": [],
39+
"logprobs": [],
3940
}
4041
message: ResponseOutputMessageParam = {
4142
"id": item_id,

tests/test_items_helpers.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,14 @@ def test_input_to_new_input_list_copies_the_ones_produced_by_pydantic() -> None:
321321
# Given a list of message dictionaries, ensure the returned list is a deep copy.
322322
original = ResponseOutputMessageParam(
323323
id="a75654dc-7492-4d1c-bce0-89e8312fbdd7",
324-
content=[
325-
ResponseOutputTextParam(
326-
type="output_text",
327-
text="Hey, what's up?",
328-
annotations=[],
329-
)
330-
],
324+
content=[
325+
ResponseOutputTextParam(
326+
type="output_text",
327+
text="Hey, what's up?",
328+
annotations=[],
329+
logprobs=[],
330+
)
331+
],
331332
role="assistant",
332333
status="completed",
333334
type="message",

tests/utils/test_json.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def test_to_dump_compatible():
1616
type="output_text",
1717
text="Hey, what's up?",
1818
annotations=[],
19+
logprobs=[],
1920
)
2021
].__iter__(),
2122
role="assistant",
@@ -28,5 +29,5 @@ def test_to_dump_compatible():
2829
result = json.dumps(_to_dump_compatible(input_iter))
2930
assert (
3031
result
31-
== """[{"id": "a75654dc-7492-4d1c-bce0-89e8312fbdd7", "content": [{"type": "output_text", "text": "Hey, what's up?", "annotations": []}], "role": "assistant", "status": "completed", "type": "message"}]""" # noqa: E501
32+
== """[{"id": "a75654dc-7492-4d1c-bce0-89e8312fbdd7", "content": [{"type": "output_text", "text": "Hey, what's up?", "annotations": [], "logprobs": []}], "role": "assistant", "status": "completed", "type": "message"}]""" # noqa: E501
3233
)

0 commit comments

Comments
 (0)