@@ -26,14 +26,16 @@ class ResponseBuilders:
2626 """Builders for creating model responses for testing.
2727
2828 .. warning::
29- This API is experimental and may change in the future."""
29+ This API is experimental and may change in the future.
30+ """
3031
3132 @staticmethod
3233 def model_response (output : TResponseOutputItem ) -> ModelResponse :
3334 """Create a ModelResponse with the given output.
3435
3536 .. warning::
36- This API is experimental and may change in the future."""
37+ This API is experimental and may change in the future.
38+ """
3739 return ModelResponse (
3840 output = [output ],
3941 usage = Usage (),
@@ -45,7 +47,8 @@ def response_output_message(text: str) -> ResponseOutputMessage:
4547 """Create a ResponseOutputMessage with text content.
4648
4749 .. warning::
48- This API is experimental and may change in the future."""
50+ This API is experimental and may change in the future.
51+ """
4952 return ResponseOutputMessage (
5053 id = "" ,
5154 content = [
@@ -65,7 +68,8 @@ def tool_call(arguments: str, name: str) -> ModelResponse:
6568 """Create a ModelResponse with a function tool call.
6669
6770 .. warning::
68- This API is experimental and may change in the future."""
71+ This API is experimental and may change in the future.
72+ """
6973 return ResponseBuilders .model_response (
7074 ResponseFunctionToolCall (
7175 arguments = arguments ,
@@ -82,7 +86,8 @@ def output_message(text: str) -> ModelResponse:
8286 """Create a ModelResponse with an output message.
8387
8488 .. warning::
85- This API is experimental and may change in the future."""
89+ This API is experimental and may change in the future.
90+ """
8691 return ResponseBuilders .model_response (
8792 ResponseBuilders .response_output_message (text )
8893 )
@@ -92,38 +97,43 @@ class TestModelProvider(ModelProvider):
9297 """Test model provider which simply returns the given module.
9398
9499 .. warning::
95- This API is experimental and may change in the future."""
100+ This API is experimental and may change in the future.
101+ """
96102
97103 __test__ = False
98104
99105 def __init__ (self , model : Model ):
100106 """Initialize a test model provider with a model.
101107
102108 .. warning::
103- This API is experimental and may change in the future."""
109+ This API is experimental and may change in the future.
110+ """
104111 self ._model = model
105112
106113 def get_model (self , model_name : Union [str , None ]) -> Model :
107114 """Get a model from the model provider.
108115
109116 .. warning::
110- This API is experimental and may change in the future."""
117+ This API is experimental and may change in the future.
118+ """
111119 return self ._model
112120
113121
114122class TestModel (Model ):
115123 """Test model for use mocking model responses.
116124
117125 .. warning::
118- This API is experimental and may change in the future."""
126+ This API is experimental and may change in the future.
127+ """
119128
120129 __test__ = False
121130
122131 def __init__ (self , fn : Callable [[], ModelResponse ]) -> None :
123132 """Initialize a test model with a callable.
124133
125134 .. warning::
126- This API is experimental and may change in the future."""
135+ This API is experimental and may change in the future.
136+ """
127137 self .fn = fn
128138
129139 async def get_response (
@@ -159,6 +169,7 @@ def returning_responses(responses: list[ModelResponse]) -> "TestModel":
159169 """Create a mock model which sequentially returns responses from a list.
160170
161171 .. warning::
162- This API is experimental and may change in the future."""
172+ This API is experimental and may change in the future.
173+ """
163174 i = iter (responses )
164175 return TestModel (lambda : next (i ))
0 commit comments