2323
2424
2525class ResponseBuilders :
26- """Builders for creating model responses for testing."""
26+ """Builders for creating model responses for testing.
27+
28+ .. warning::
29+ This API is experimental and may change in the future."""
2730
2831 @staticmethod
2932 def model_response (output : TResponseOutputItem ) -> ModelResponse :
30- """Create a ModelResponse with the given output."""
33+ """Create a ModelResponse with the given output.
34+
35+ .. warning::
36+ This API is experimental and may change in the future."""
3137 return ModelResponse (
3238 output = [output ],
3339 usage = Usage (),
@@ -36,7 +42,10 @@ def model_response(output: TResponseOutputItem) -> ModelResponse:
3642
3743 @staticmethod
3844 def response_output_message (text : str ) -> ResponseOutputMessage :
39- """Create a ResponseOutputMessage with text content."""
45+ """Create a ResponseOutputMessage with text content.
46+
47+ .. warning::
48+ This API is experimental and may change in the future."""
4049 return ResponseOutputMessage (
4150 id = "" ,
4251 content = [
@@ -53,7 +62,10 @@ def response_output_message(text: str) -> ResponseOutputMessage:
5362
5463 @staticmethod
5564 def tool_call (arguments : str , name : str ) -> ModelResponse :
56- """Create a ModelResponse with a function tool call."""
65+ """Create a ModelResponse with a function tool call.
66+
67+ .. warning::
68+ This API is experimental and may change in the future."""
5769 return ResponseBuilders .model_response (
5870 ResponseFunctionToolCall (
5971 arguments = arguments ,
@@ -67,33 +79,51 @@ def tool_call(arguments: str, name: str) -> ModelResponse:
6779
6880 @staticmethod
6981 def output_message (text : str ) -> ModelResponse :
70- """Create a ModelResponse with an output message."""
82+ """Create a ModelResponse with an output message.
83+
84+ .. warning::
85+ This API is experimental and may change in the future."""
7186 return ResponseBuilders .model_response (
7287 ResponseBuilders .response_output_message (text )
7388 )
7489
7590
7691class TestModelProvider (ModelProvider ):
77- """Test model provider which simply returns the given module."""
92+ """Test model provider which simply returns the given module.
93+
94+ .. warning::
95+ This API is experimental and may change in the future."""
7896
7997 __test__ = False
8098
8199 def __init__ (self , model : Model ):
82- """Initialize a test model provider with a model."""
100+ """Initialize a test model provider with a model.
101+
102+ .. warning::
103+ This API is experimental and may change in the future."""
83104 self ._model = model
84105
85106 def get_model (self , model_name : Union [str , None ]) -> Model :
86- """Get a model from the model provider."""
107+ """Get a model from the model provider.
108+
109+ .. warning::
110+ This API is experimental and may change in the future."""
87111 return self ._model
88112
89113
90114class TestModel (Model ):
91- """Test model for use mocking model responses."""
115+ """Test model for use mocking model responses.
116+
117+ .. warning::
118+ This API is experimental and may change in the future."""
92119
93120 __test__ = False
94121
95122 def __init__ (self , fn : Callable [[], ModelResponse ]) -> None :
96- """Initialize a test model with a callable."""
123+ """Initialize a test model with a callable.
124+
125+ .. warning::
126+ This API is experimental and may change in the future."""
97127 self .fn = fn
98128
99129 async def get_response (
@@ -107,7 +137,7 @@ async def get_response(
107137 tracing : ModelTracing ,
108138 ** kwargs ,
109139 ) -> ModelResponse :
110- """Get a response from the model."""
140+ """Get a response from the mocked model, by calling the callable passed to the constructor ."""
111141 return self .fn ()
112142
113143 def stream_response (
@@ -128,14 +158,19 @@ def stream_response(
128158class StaticTestModel (TestModel ):
129159 """Static test model for use mocking model responses.
130160 Set a responses attribute to a list of model responses, which will be returned sequentially.
131- """
161+
162+ .. warning::
163+ This API is experimental and may change in the future."""
132164
133165 __test__ = False
134166 responses : list [ModelResponse ] = []
135167
136168 def __init__ (
137169 self ,
138170 ) -> None :
139- """Initialize the static test model with predefined responses."""
171+ """Initialize the static test model with predefined responses.
172+
173+ .. warning::
174+ This API is experimental and may change in the future."""
140175 self ._responses = iter (self .responses )
141176 super ().__init__ (lambda : next (self ._responses ))
0 commit comments