Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ opentelemetry = [
]
pydantic = ["pydantic>=2.0.0,<3"]
openai-agents = [
"openai-agents >= 0.1,<0.2",
"openai-agents >= 0.2.3,<0.3",
"eval-type-backport>=0.2.2; python_version < '3.10'"
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def make_tool(tool: ToolInput) -> Tool:
raise UserError(f"Unknown tool type: {tool.name}")

tools = [make_tool(x) for x in input.get("tools", [])]
handoffs = [
handoffs: list[Handoff[Any, Any]] = [
Handoff(
tool_name=x.tool_name,
tool_description=x.tool_description,
Expand Down
22 changes: 21 additions & 1 deletion tests/contrib/openai_agents/test_openai.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import os
import uuid
from dataclasses import dataclass
Expand Down Expand Up @@ -45,7 +46,7 @@
)
from openai.types.responses.response_function_web_search import ActionSearch
from openai.types.responses.response_prompt_param import ResponsePromptParam
from pydantic import ConfigDict, Field
from pydantic import ConfigDict, Field, TypeAdapter

from temporalio import activity, workflow
from temporalio.client import Client, WorkflowFailureError, WorkflowHandle
Expand All @@ -55,6 +56,7 @@
TestModel,
TestModelProvider,
)
from temporalio.contrib.pydantic import pydantic_data_converter
from temporalio.exceptions import CancelledError
from temporalio.testing import WorkflowEnvironment
from tests.contrib.openai_agents.research_agents.research_manager import (
Expand Down Expand Up @@ -1757,3 +1759,21 @@ async def test_workflow_method_tools(client: Client):
execution_timeout=timedelta(seconds=10),
)
await workflow_handle.result()


async def test_response_serialization():
# This should not be used in another test, or this test needs to change to use another unloaded type
from openai.types.responses.response_output_item import ImageGenerationCall

data = json.loads(
b'{"id": "msg_68757ec43348819d86709f0fcb70316301a1194a3e05b38c","type": "image_generation_call","status": "completed"}'
)
call = TypeAdapter(ImageGenerationCall).validate_python(data)
model_response = ModelResponse(
output=[
call,
],
usage=Usage(),
response_id="",
)
encoded = await pydantic_data_converter.encode([model_response])
Loading
Loading