Skip to content

Commit 71c7140

Browse files
Change to factory method
1 parent e5b9733 commit 71c7140

File tree

2 files changed

+73
-85
lines changed

2 files changed

+73
-85
lines changed

temporalio/contrib/openai_agents/testing.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -154,23 +154,11 @@ def stream_response(
154154
"""Get a streamed response from the model. Unimplemented."""
155155
raise NotImplementedError()
156156

157-
158-
class StaticTestModel(TestModel):
159-
"""Static test model for use mocking model responses.
160-
Set a responses attribute to a list of model responses, which will be returned sequentially.
161-
162-
.. warning::
163-
This API is experimental and may change in the future."""
164-
165-
__test__ = False
166-
responses: list[ModelResponse] = []
167-
168-
def __init__(
169-
self,
170-
) -> None:
171-
"""Initialize the static test model with predefined responses.
157+
@staticmethod
158+
def returning_responses(responses: list[ModelResponse]) -> "TestModel":
159+
"""Create a mock model which sequentially returns responses from a list.
172160
173161
.. warning::
174162
This API is experimental and may change in the future."""
175-
self._responses = iter(self.responses)
176-
super().__init__(lambda: next(self._responses))
163+
i = iter(responses)
164+
return TestModel(lambda: next(i))

0 commit comments

Comments
 (0)