1+ """Testing utilities for OpenAI agents."""
2+
13from typing import AsyncIterator , Callable , Optional , Union
24
35from agents import (
2123
2224
2325class ResponseBuilders :
24- """
25- Builders for creating model responses for testing.
26- """
26+ """Builders for creating model responses for testing."""
2727
2828 @staticmethod
2929 def model_response (output : TResponseOutputItem ) -> ModelResponse :
30+ """Create a ModelResponse with the given output."""
3031 return ModelResponse (
3132 output = [output ],
3233 usage = Usage (),
@@ -35,6 +36,7 @@ def model_response(output: TResponseOutputItem) -> ModelResponse:
3536
3637 @staticmethod
3738 def response_output_message (text : str ) -> ResponseOutputMessage :
39+ """Create a ResponseOutputMessage with text content."""
3840 return ResponseOutputMessage (
3941 id = "" ,
4042 content = [
@@ -51,6 +53,7 @@ def response_output_message(text: str) -> ResponseOutputMessage:
5153
5254 @staticmethod
5355 def tool_call (arguments : str , name : str ) -> ModelResponse :
56+ """Create a ModelResponse with a function tool call."""
5457 return ResponseBuilders .model_response (
5558 ResponseFunctionToolCall (
5659 arguments = arguments ,
@@ -64,6 +67,7 @@ def tool_call(arguments: str, name: str) -> ModelResponse:
6467
6568 @staticmethod
6669 def output_message (text : str ) -> ModelResponse :
70+ """Create a ModelResponse with an output message."""
6771 return ResponseBuilders .model_response (
6872 ResponseBuilders .response_output_message (text )
6973 )
@@ -132,5 +136,6 @@ class StaticTestModel(TestModel):
132136 def __init__ (
133137 self ,
134138 ) -> None :
139+ """Initialize the static test model with predefined responses."""
135140 self ._responses = iter (self .responses )
136141 super ().__init__ (lambda : next (self ._responses ))
0 commit comments