Skip to content

Commit cf9a5f2

Browse files
authored
Python: Fix onnx pkg by pinning. Pin openai < 2.0. (#13284)
### Motivation and Context For the latest onnxruntime 1.23.2 pkg: our GitHub Actions run is failing because uv is not matching the macOS wheel tag. Pinning to last-known-good until it's sorted out. - Pin openai pkg < 2.0 until we can investigate if 2.0 brings in other breaking changes. ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [ ] The code builds clean without any errors or warnings - [ ] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄
1 parent 3bc2a64 commit cf9a5f2

File tree

7 files changed

+3310
-2794
lines changed

7 files changed

+3310
-2794
lines changed

python/pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ dependencies = [
3737
"numpy >= 1.25.0; python_version < '3.12'",
3838
"numpy >= 1.26.0; python_version >= '3.12'",
3939
# openai connector
40-
"openai >= 1.98.0",
40+
"openai >= 1.98.0, < 2.0.0",
4141
# openapi and swagger
4242
"openapi_core >= 0.18,<0.20",
4343
"websockets >= 13, < 16",
@@ -121,7 +121,9 @@ ollama = [
121121
"ollama ~= 0.4"
122122
]
123123
onnx = [
124-
"onnxruntime-genai ~= 0.7"
124+
# Pinning due to uv tag-resolution issues on macOS.
125+
"onnxruntime==1.22.1",
126+
"onnxruntime-genai==0.9.0"
125127
]
126128
pandas = [
127129
"pandas ~= 2.2"

python/semantic_kernel/agents/open_ai/assistant_thread_actions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
from collections.abc import AsyncIterable, Iterable, Sequence
66
from typing import TYPE_CHECKING, Any, ClassVar, Literal, TypeVar, cast
77

8-
from openai import NOT_GIVEN, AsyncOpenAI, NotGiven
8+
from openai import AsyncOpenAI
9+
from openai._types import Omit, omit
910
from openai.types.beta.code_interpreter_tool import CodeInterpreterTool
1011
from openai.types.beta.file_search_tool import FileSearchTool
1112
from openai.types.beta.threads.run_create_params import AdditionalMessage, AdditionalMessageAttachment
@@ -597,7 +598,7 @@ async def get_messages(
597598
An async iterable of ChatMessageContent.
598599
"""
599600
agent_names: dict[str, Any] = {}
600-
last_id: str | NotGiven = NOT_GIVEN
601+
last_id: str | Omit = omit
601602

602603
while True:
603604
messages = await client.beta.threads.messages.list(

python/semantic_kernel/agents/open_ai/openai_assistant_agent.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
from copy import copy, deepcopy
88
from typing import TYPE_CHECKING, Any, ClassVar, Literal, TypeVar
99

10-
from openai import NOT_GIVEN, AsyncOpenAI, NotGiven
10+
from openai import AsyncOpenAI
11+
from openai._types import Omit, omit
1112
from openai.lib._parsing._completions import type_to_response_format_param
1213
from openai.types.beta.assistant import Assistant
1314
from openai.types.beta.assistant_create_params import (
@@ -138,9 +139,9 @@ def __init__(
138139
self,
139140
client: AsyncOpenAI,
140141
thread_id: str | None = None,
141-
messages: Iterable["ThreadCreateMessage"] | NotGiven = NOT_GIVEN,
142-
metadata: dict[str, Any] | NotGiven = NOT_GIVEN,
143-
tool_resources: ToolResources | NotGiven = NOT_GIVEN,
142+
messages: Iterable["ThreadCreateMessage"] | Omit = omit,
143+
metadata: dict[str, Any] | Omit = omit,
144+
tool_resources: ToolResources | Omit = omit,
144145
) -> None:
145146
"""Initialize the OpenAI Assistant Thread.
146147

python/semantic_kernel/agents/open_ai/openai_responses_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ def configure_web_search_tool(
706706
A WebSearchToolParam dictionary with any passed-in parameters.
707707
"""
708708
tool: WebSearchToolParam = {
709-
"type": "web_search_preview",
709+
"type": "web_search",
710710
}
711711
if context_size is not None:
712712
tool["search_context_size"] = context_size

python/semantic_kernel/connectors/ai/open_ai/services/open_ai_handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import Any, Union
66

77
from openai import AsyncOpenAI, AsyncStream, BadRequestError, _legacy_response
8-
from openai._types import NOT_GIVEN, FileTypes, NotGiven
8+
from openai._types import FileTypes, Omit, omit
99
from openai.lib._parsing._completions import type_to_response_format_param
1010
from openai.types import Completion, CreateEmbeddingResponse
1111
from openai.types.audio import Transcription
@@ -135,7 +135,7 @@ async def _send_image_edit_request(
135135
self,
136136
image: list[FileTypes],
137137
settings: OpenAITextToImageExecutionSettings,
138-
mask: FileTypes | NotGiven = NOT_GIVEN,
138+
mask: FileTypes | Omit = omit,
139139
) -> ImagesResponse:
140140
"""Send a request to the OpenAI image edit endpoint.
141141

python/semantic_kernel/connectors/ai/open_ai/services/open_ai_text_to_image_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import IO, Any
55
from warnings import warn
66

7-
from openai._types import NOT_GIVEN, FileTypes, NotGiven
7+
from openai._types import FileTypes, Omit, omit
88
from openai.types.images_response import ImagesResponse
99

1010
from semantic_kernel.connectors.ai.open_ai.prompt_execution_settings.open_ai_text_to_image_execution_settings import (
@@ -217,7 +217,7 @@ async def edit_image(
217217
elif image_files is not None:
218218
images = list(image_files)
219219

220-
mask: FileTypes | NotGiven = NOT_GIVEN
220+
mask: FileTypes | Omit = omit
221221
if mask_path is not None:
222222
mask = Path(mask_path)
223223
elif mask_file is not None:

0 commit comments

Comments
 (0)