File tree Expand file tree Collapse file tree 4 files changed +8
-7
lines changed Expand file tree Collapse file tree 4 files changed +8
-7
lines changed Original file line number Diff line number Diff line change 4
4
import logging
5
5
import struct
6
6
from contextlib import asynccontextmanager
7
- from typing import TYPE_CHECKING , Any , assert_never
7
+ from typing import TYPE_CHECKING , Any
8
8
9
9
from fastapi import FastAPI , WebSocket , WebSocketDisconnect
10
10
from fastapi .responses import FileResponse
11
11
from fastapi .staticfiles import StaticFiles
12
+ from typing_extensions import assert_never
12
13
13
14
from agents .realtime import RealtimeRunner , RealtimeSession , RealtimeSessionEvent
14
15
Original file line number Diff line number Diff line change 20
20
from openai import NOT_GIVEN , AsyncStream , NotGiven
21
21
from openai .types .chat import (
22
22
ChatCompletionChunk ,
23
+ ChatCompletionMessageCustomToolCall ,
23
24
ChatCompletionMessageFunctionToolCall ,
24
25
)
25
26
from openai .types .chat .chat_completion_message import (
28
29
ChatCompletionMessage ,
29
30
)
30
31
from openai .types .chat .chat_completion_message_function_tool_call import Function
31
- from openai .types .chat .chat_completion_message_tool_call import ChatCompletionMessageToolCall
32
32
from openai .types .responses import Response
33
33
34
34
from ... import _debug
@@ -366,7 +366,7 @@ def convert_message_to_openai(
366
366
if message .role != "assistant" :
367
367
raise ModelBehaviorError (f"Unsupported role: { message .role } " )
368
368
369
- tool_calls : list [ChatCompletionMessageToolCall ] | None = (
369
+ tool_calls : list [ChatCompletionMessageFunctionToolCall | ChatCompletionMessageCustomToolCall ] | None = (
370
370
[LitellmConverter .convert_tool_call_to_openai (tool ) for tool in message .tool_calls ]
371
371
if message .tool_calls
372
372
else None
Original file line number Diff line number Diff line change @@ -291,7 +291,7 @@ def function_schema(
291
291
# Default factory to empty list
292
292
fields [name ] = (
293
293
ann ,
294
- Field (default_factory = list , description = field_description ), # type: ignore
294
+ Field (default_factory = list , description = field_description ),
295
295
)
296
296
297
297
elif param .kind == param .VAR_KEYWORD :
@@ -309,7 +309,7 @@ def function_schema(
309
309
310
310
fields [name ] = (
311
311
ann ,
312
- Field (default_factory = dict , description = field_description ), # type: ignore
312
+ Field (default_factory = dict , description = field_description ),
313
313
)
314
314
315
315
else :
Original file line number Diff line number Diff line change @@ -175,10 +175,10 @@ async def _apply_dynamic_tool_filter(
175
175
) -> list [MCPTool ]:
176
176
"""Apply dynamic tool filtering using a callable filter function."""
177
177
178
- # Ensure we have a callable filter and cast to help mypy
178
+ # Ensure we have a callable filter
179
179
if not callable (self .tool_filter ):
180
180
raise ValueError ("Tool filter must be callable for dynamic filtering" )
181
- tool_filter_func = cast ( ToolFilterCallable , self .tool_filter )
181
+ tool_filter_func = self .tool_filter
182
182
183
183
# Create filter context
184
184
filter_context = ToolFilterContext (
You can’t perform that action at this time.
0 commit comments