class documentation

Test model for use mocking model responses.

Warning

This API is experimental and may change in the future.

Static Method returning_responses Create a mock model which sequentially returns responses from a list.
Method __init__ Initialize a test model with a callable.
Async Method get_response Get a response from the mocked model, by calling the callable passed to the constructor.
Method stream_response Get a streamed response from the model. Unimplemented.
Class Variable __test__ Undocumented
Instance Variable fn Undocumented
@staticmethod
def returning_responses(responses: list[ModelResponse]) -> TestModel: (source)

Create a mock model which sequentially returns responses from a list.

Warning

This API is experimental and may change in the future.

def __init__(self, fn: Callable[[], ModelResponse]): (source)

Initialize a test model with a callable.

Warning

This API is experimental and may change in the future.

async def get_response(self, system_instructions: str | None, input: str | list[TResponseInputItem], model_settings: ModelSettings, tools: list[Tool], output_schema: AgentOutputSchemaBase | None, handoffs: list[Handoff], tracing: ModelTracing, **kwargs) -> ModelResponse: (source)

Get a response from the mocked model, by calling the callable passed to the constructor.

def stream_response(self, system_instructions: str | None, input: str | list[TResponseInputItem], model_settings: ModelSettings, tools: list[Tool], output_schema: AgentOutputSchemaBase | None, handoffs: list[Handoff], tracing: ModelTracing, **kwargs) -> AsyncIterator[TResponseStreamEvent]: (source)

Get a streamed response from the model. Unimplemented.

__test__: bool = (source)

Undocumented

Undocumented