|
18 | 18 | ) from _e |
19 | 19 |
|
20 | 20 | from openai import NOT_GIVEN, AsyncStream, NotGiven |
21 | | -from openai.types.chat import ChatCompletionChunk, ChatCompletionMessageFunctionToolCall |
| 21 | +from openai.types.chat import ( |
| 22 | + ChatCompletionChunk, |
| 23 | + ChatCompletionMessageFunctionToolCall, |
| 24 | +) |
22 | 25 | from openai.types.chat.chat_completion_message import ( |
23 | 26 | Annotation, |
24 | 27 | AnnotationURLCitation, |
25 | 28 | ChatCompletionMessage, |
26 | 29 | ) |
27 | | -from openai.types.chat.chat_completion_message_function_tool_call import ( |
28 | | - ChatCompletionMessageFunctionToolCall, |
29 | | -) |
| 30 | +from openai.types.chat.chat_completion_message_function_tool_call import Function |
| 31 | +from openai.types.chat.chat_completion_message_tool_call import ChatCompletionMessageToolCall |
30 | 32 | from openai.types.responses import Response |
31 | 33 |
|
32 | 34 | from ... import _debug |
@@ -364,7 +366,7 @@ def convert_message_to_openai( |
364 | 366 | if message.role != "assistant": |
365 | 367 | raise ModelBehaviorError(f"Unsupported role: {message.role}") |
366 | 368 |
|
367 | | - tool_calls = ( |
| 369 | + tool_calls: list[ChatCompletionMessageToolCall] | None = ( |
368 | 370 | [LitellmConverter.convert_tool_call_to_openai(tool) for tool in message.tool_calls] |
369 | 371 | if message.tool_calls |
370 | 372 | else None |
@@ -419,7 +421,8 @@ def convert_tool_call_to_openai( |
419 | 421 | return ChatCompletionMessageFunctionToolCall( |
420 | 422 | id=tool_call.id, |
421 | 423 | type="function", |
422 | | - function=ChatCompletionMessageFunctionToolCall( |
423 | | - name=tool_call.function.name or "", arguments=tool_call.function.arguments |
| 424 | + function=Function( |
| 425 | + name=tool_call.function.name or "", |
| 426 | + arguments=tool_call.function.arguments, |
424 | 427 | ), |
425 | 428 | ) |
0 commit comments