Skip to content

Commit 40f1624

Browse files
authored
Fixing issues with openai integration on python 3.9 (#918)
* Fixing issues with openai integration on python 3.9 * Restrict eval_type to python 3.9
1 parent 4a18f1f commit 40f1624

File tree

4 files changed

+27
-16
lines changed

4 files changed

+27
-16
lines changed

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ opentelemetry = [
2424
"opentelemetry-sdk>=1.11.1,<2",
2525
]
2626
pydantic = ["pydantic>=2.0.0,<3"]
27-
openai-agents = ["openai-agents >= 0.0.19"]
27+
openai-agents = [
28+
"openai-agents >= 0.0.19,<0.1",
29+
"eval-type-backport>=0.2.2; python_version < '3.10'"
30+
]
2831

2932
[project.urls]
3033
Homepage = "https://github.com/temporalio/sdk-python"

temporalio/contrib/openai_agents/invoke_model_activity.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import enum
77
import json
88
from dataclasses import dataclass
9-
from typing import Any, Optional, TypedDict, Union, cast
9+
from typing import Any, Optional, Union, cast
1010

1111
from agents import (
1212
AgentOutputSchemaBase,
@@ -24,7 +24,7 @@
2424
WebSearchTool,
2525
)
2626
from agents.models.multi_provider import MultiProvider
27-
from typing_extensions import Required
27+
from typing_extensions import Required, TypedDict
2828

2929
from temporalio import activity, workflow
3030
from temporalio.contrib.openai_agents._heartbeat_decorator import _auto_heartbeater

tests/contrib/test_openai.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,9 @@ async def run(self, prompt: str) -> str:
140140

141141

142142
async def test_hello_world_agent(client: Client):
143-
if sys.version_info < (3, 11):
144-
pytest.skip("Open AI support has type errors on 3.9 and 3.11")
143+
new_config = client.config()
144+
new_config["data_converter"] = open_ai_data_converter
145+
client = Client(**new_config)
145146

146147
with set_open_ai_agent_temporal_overrides(
147148
start_to_close_timeout=timedelta(seconds=10)
@@ -237,8 +238,9 @@ async def run(self, question: str) -> str:
237238

238239

239240
async def test_tool_workflow(client: Client):
240-
if sys.version_info < (3, 11):
241-
pytest.skip("Open AI support has type errors on 3.9 and 3.11")
241+
new_config = client.config()
242+
new_config["data_converter"] = open_ai_data_converter
243+
client = Client(**new_config)
242244

243245
with set_open_ai_agent_temporal_overrides(
244246
start_to_close_timeout=timedelta(seconds=10)
@@ -455,8 +457,9 @@ async def run(self, query: str):
455457

456458

457459
async def test_research_workflow(client: Client):
458-
if sys.version_info < (3, 11):
459-
pytest.skip("Open AI support has type errors on 3.9 and 3.11")
460+
new_config = client.config()
461+
new_config["data_converter"] = open_ai_data_converter
462+
client = Client(**new_config)
460463

461464
global response_index
462465
response_index = 0
@@ -668,9 +671,6 @@ class AgentAsToolsModel(TestModel):
668671

669672

670673
async def test_agents_as_tools_workflow(client: Client):
671-
if sys.version_info < (3, 11):
672-
pytest.skip("Open AI support has type errors on 3.9 and 3.10")
673-
674674
new_config = client.config()
675675
new_config["data_converter"] = open_ai_data_converter
676676
client = Client(**new_config)
@@ -1027,9 +1027,6 @@ def validate_process_user_message(self, input: ProcessUserMessageInput) -> None:
10271027

10281028

10291029
async def test_customer_service_workflow(client: Client):
1030-
if sys.version_info < (3, 11):
1031-
pytest.skip("Open AI support has type errors on 3.9 and 3.11")
1032-
10331030
new_config = client.config()
10341031
new_config["data_converter"] = open_ai_data_converter
10351032
client = Client(**new_config)

uv.lock

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)