Skip to content

Commit 703fc32

Browse files
committed
Strip down to minimum test
1 parent 84565a7 commit 703fc32

File tree

5 files changed

+13
-31
lines changed

5 files changed

+13
-31
lines changed

temporalio/contrib/openai_agents/__init__.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77
This module is experimental and may change in future versions.
88
Use with caution in production environments.
99
"""
10-
11-
import importlib
12-
import inspect
13-
import pkgutil
14-
15-
from pydantic import BaseModel
16-
1710
from temporalio.contrib.openai_agents._invoke_model_activity import ModelActivity
1811
from temporalio.contrib.openai_agents._model_parameters import ModelActivityParameters
1912
from temporalio.contrib.openai_agents._trace_interceptor import (
@@ -37,22 +30,3 @@
3730
"TestModelProvider",
3831
]
3932

40-
41-
def _reload_models(module_name: str) -> None:
42-
"""Recursively walk through modules and rebuild BaseModel classes."""
43-
module = importlib.import_module(module_name)
44-
45-
# Process classes in the current module
46-
for _, obj in inspect.getmembers(module, inspect.isclass):
47-
if issubclass(obj, BaseModel) and obj is not BaseModel:
48-
obj.model_rebuild()
49-
50-
# Recursively process submodules
51-
if hasattr(module, "__path__"):
52-
for _, submodule_name, _ in pkgutil.iter_modules(module.__path__):
53-
full_submodule_name = f"{module_name}.{submodule_name}"
54-
_reload_models(full_submodule_name)
55-
56-
57-
# Recursively call model_rebuild() on all BaseModel classes in openai.types
58-
_reload_models("openai.types")

temporalio/contrib/openai_agents/_invoke_model_activity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import enum
77
import json
8-
from dataclasses import dataclass
8+
from pydantic.dataclasses import dataclass
99
from typing import Any, Optional, Union, cast
1010

1111
from agents import (

temporalio/contrib/pydantic.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
from typing import Any, Optional, Type
1717

18+
import pydantic.dataclasses
1819
from pydantic import TypeAdapter
1920
from pydantic_core import to_json
2021

tests/contrib/openai_agents/test_openai.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1747,4 +1747,11 @@ async def test_response_serialization():
17471747
b'{"id": "msg_68757ec43348819d86709f0fcb70316301a1194a3e05b38c","type": "image_generation_call","status": "completed"}'
17481748
)
17491749
call = TypeAdapter(ImageGenerationCall).validate_python(data)
1750-
encoded = await pydantic_data_converter.encode([call])
1750+
model_response = ModelResponse(
1751+
output=[
1752+
call,
1753+
],
1754+
usage=Usage(),
1755+
response_id="",
1756+
)
1757+
encoded = await pydantic_data_converter.encode([model_response])

uv.lock

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

0 commit comments

Comments
 (0)