diff --git a/pyproject.toml b/pyproject.toml index 8a0f14f79..d5a9f71e1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,10 @@ opentelemetry = [ "opentelemetry-sdk>=1.11.1,<2", ] pydantic = ["pydantic>=2.0.0,<3"] -openai-agents = ["openai-agents >= 0.0.19"] +openai-agents = [ + "openai-agents >= 0.0.19,<0.1", + "eval-type-backport>=0.2.2; python_version < '3.10'" +] [project.urls] Homepage = "https://github.com/temporalio/sdk-python" diff --git a/temporalio/contrib/openai_agents/invoke_model_activity.py b/temporalio/contrib/openai_agents/invoke_model_activity.py index b7a370ad8..10b7370cb 100644 --- a/temporalio/contrib/openai_agents/invoke_model_activity.py +++ b/temporalio/contrib/openai_agents/invoke_model_activity.py @@ -6,7 +6,7 @@ import enum import json from dataclasses import dataclass -from typing import Any, Optional, TypedDict, Union, cast +from typing import Any, Optional, Union, cast from agents import ( AgentOutputSchemaBase, @@ -24,7 +24,7 @@ WebSearchTool, ) from agents.models.multi_provider import MultiProvider -from typing_extensions import Required +from typing_extensions import Required, TypedDict from temporalio import activity, workflow from temporalio.contrib.openai_agents._heartbeat_decorator import _auto_heartbeater diff --git a/tests/contrib/test_openai.py b/tests/contrib/test_openai.py index e0adcad97..be1dbf91f 100644 --- a/tests/contrib/test_openai.py +++ b/tests/contrib/test_openai.py @@ -140,8 +140,9 @@ async def run(self, prompt: str) -> str: async def test_hello_world_agent(client: Client): - if sys.version_info < (3, 11): - pytest.skip("Open AI support has type errors on 3.9 and 3.11") + new_config = client.config() + new_config["data_converter"] = open_ai_data_converter + client = Client(**new_config) with set_open_ai_agent_temporal_overrides( start_to_close_timeout=timedelta(seconds=10) @@ -237,8 +238,9 @@ async def run(self, question: str) -> str: async def test_tool_workflow(client: Client): - if sys.version_info < (3, 11): - pytest.skip("Open AI support has type errors on 3.9 and 3.11") + new_config = client.config() + new_config["data_converter"] = open_ai_data_converter + client = Client(**new_config) with set_open_ai_agent_temporal_overrides( start_to_close_timeout=timedelta(seconds=10) @@ -455,8 +457,9 @@ async def run(self, query: str): async def test_research_workflow(client: Client): - if sys.version_info < (3, 11): - pytest.skip("Open AI support has type errors on 3.9 and 3.11") + new_config = client.config() + new_config["data_converter"] = open_ai_data_converter + client = Client(**new_config) global response_index response_index = 0 @@ -668,9 +671,6 @@ class AgentAsToolsModel(TestModel): async def test_agents_as_tools_workflow(client: Client): - if sys.version_info < (3, 11): - pytest.skip("Open AI support has type errors on 3.9 and 3.10") - new_config = client.config() new_config["data_converter"] = open_ai_data_converter client = Client(**new_config) @@ -1027,9 +1027,6 @@ def validate_process_user_message(self, input: ProcessUserMessageInput) -> None: async def test_customer_service_workflow(client: Client): - if sys.version_info < (3, 11): - pytest.skip("Open AI support has type errors on 3.9 and 3.11") - new_config = client.config() new_config["data_converter"] = open_ai_data_converter client = Client(**new_config) diff --git a/uv.lock b/uv.lock index 6a88d50ab..9d80402aa 100644 --- a/uv.lock +++ b/uv.lock @@ -355,6 +355,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/8f/d7/9322c609343d929e75e7e5e6255e614fcc67572cfd083959cdef3b7aad79/docutils-0.21.2-py3-none-any.whl", hash = "sha256:dafca5b9e384f0e419294eb4d2ff9fa826435bf15f15b7bd45723e8ad76811b2", size = 587408, upload-time = "2024-04-23T18:57:14.835Z" }, ] +[[package]] +name = "eval-type-backport" +version = "0.2.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/30/ea/8b0ac4469d4c347c6a385ff09dc3c048c2d021696664e26c7ee6791631b5/eval_type_backport-0.2.2.tar.gz", hash = "sha256:f0576b4cf01ebb5bd358d02314d31846af5e07678387486e2c798af0e7d849c1", size = 9079, upload-time = "2024-12-21T20:09:46.005Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ce/31/55cd413eaccd39125368be33c46de24a1f639f2e12349b0361b4678f3915/eval_type_backport-0.2.2-py3-none-any.whl", hash = "sha256:cb6ad7c393517f476f96d456d0412ea80f0a8cf96f6892834cd9340149111b0a", size = 5830, upload-time = "2024-12-21T20:09:44.175Z" }, +] + [[package]] name = "exceptiongroup" version = "1.3.0" @@ -1608,6 +1617,7 @@ grpc = [ { name = "grpcio" }, ] openai-agents = [ + { name = "eval-type-backport", marker = "python_full_version < '3.10'" }, { name = "openai-agents" }, ] opentelemetry = [ @@ -1640,8 +1650,9 @@ dev = [ [package.metadata] requires-dist = [ + { name = "eval-type-backport", marker = "python_full_version < '3.10' and extra == 'openai-agents'", specifier = ">=0.2.2" }, { name = "grpcio", marker = "extra == 'grpc'", specifier = ">=1.48.2,<2" }, - { name = "openai-agents", marker = "extra == 'openai-agents'", specifier = ">=0.0.19" }, + { name = "openai-agents", marker = "extra == 'openai-agents'", specifier = ">=0.0.19,<0.1" }, { name = "opentelemetry-api", marker = "extra == 'opentelemetry'", specifier = ">=1.11.1,<2" }, { name = "opentelemetry-sdk", marker = "extra == 'opentelemetry'", specifier = ">=1.11.1,<2" }, { name = "protobuf", specifier = ">=3.20,<6" },