|
9 | 9 | from .mock_async_stream import MockAsyncStream |
10 | 10 |
|
11 | 11 | with try_import() as imports_successful: |
12 | | - from openai import NOT_GIVEN, AsyncOpenAI |
| 12 | + from openai import AsyncOpenAI |
13 | 13 | from openai.types import chat, responses |
14 | 14 | from openai.types.chat.chat_completion import Choice, ChoiceLogprobs |
15 | 15 | from openai.types.chat.chat_completion_message import ChatCompletionMessage |
16 | 16 | from openai.types.completion_usage import CompletionUsage |
17 | 17 | from openai.types.responses.response import ResponseUsage |
18 | 18 | from openai.types.responses.response_output_item import ResponseOutputItem |
19 | 19 |
|
| 20 | + from pydantic_ai.models.openai import NOT_GIVEN, OMIT |
| 21 | + |
20 | 22 | MockChatCompletion = chat.ChatCompletion | Exception |
21 | 23 | MockChatCompletionChunk = chat.ChatCompletionChunk | Exception |
22 | 24 | MockResponse = responses.Response | Exception |
@@ -50,7 +52,7 @@ def create_mock_stream( |
50 | 52 | async def chat_completions_create( # pragma: lax no cover |
51 | 53 | self, *_args: Any, stream: bool = False, **kwargs: Any |
52 | 54 | ) -> chat.ChatCompletion | MockAsyncStream[MockChatCompletionChunk]: |
53 | | - self.chat_completion_kwargs.append({k: v for k, v in kwargs.items() if v is not NOT_GIVEN}) |
| 55 | + self.chat_completion_kwargs.append({k: v for k, v in kwargs.items() if v not in (NOT_GIVEN, OMIT)}) |
54 | 56 |
|
55 | 57 | if stream: |
56 | 58 | assert self.stream is not None, 'you can only used `stream=True` if `stream` is provided' |
|
0 commit comments