mirascope.core.base.call_factory | Mirascope
MirascopeLilypad

mirascope.core.base.call_factory

call_factory

Function call_factory

A factory method for creating provider-specific call decorators.

Parameters

NameTypeDescription
TCallResponsetype[_BaseCallResponseT]The provider-specific `BaseCallResponse` type.
TCallResponseChunktype[_BaseCallResponseChunkT]The provider-specific `BaseCallResponseChunk` type.
TToolTypetype[_BaseToolT]The provider-specific `BaseTool` type.
TStreamtype[_BaseStreamT]The provider-specific `BaseStream` type.
default_call_paramsBaseCallParamsThe default call parameters to use, which must match the `TCallParams` type if provided.
setup_callSameSyncAndAsyncClientSetupCall[_SameSyncAndAsyncClientT, _BaseDynamicConfigT, _AsyncBaseDynamicConfigT, _BaseCallParamsT, _ResponseT, _ResponseChunkT, _AsyncResponseT, _AsyncResponseChunkT, _BaseToolT] | SetupCall[_SyncBaseClientT, _AsyncBaseClientT, _BaseDynamicConfigT, _AsyncBaseDynamicConfigT, _BaseCallParamsT, _ResponseT, _ResponseChunkT, _AsyncResponseT, _AsyncResponseChunkT, _BaseToolT]The helper method for setting up a call, which returns the configured create function, the prompt template, the list of provider-specific messages, the list of provider-specific tool types, and the finalized `call_kwargs` with which to make the API call with the create function.
get_json_outputGetJsonOutput[_BaseCallResponseT | _BaseCallResponseChunkT]The helper method for getting JSON output from a call response.
handle_streamHandleStream[_ResponseChunkT, _BaseCallResponseChunkT, _BaseToolT]The helper method for converting a provider's original stream generator into a generator that returns tuples of `(chunk, tool)` where `chunk` and `tool` are provider-specific `BaseCallResponseChunk` and `BaseTool` instances, respectively.
handle_stream_asyncHandleStreamAsync[_AsyncResponseChunkT, _BaseCallResponseChunkT, _BaseToolT]The same helper method as `handle_stream` except for handling asynchronous streaming.

Returns

TypeDescription
CallDecorator[_BaseCallResponseT, _BaseCallResponseChunkT, _BaseDynamicConfigT, _AsyncBaseDynamicConfigT, _BaseCallParamsT, _BaseStreamT, _SyncBaseClientT, _AsyncBaseClientT, _SameSyncAndAsyncClientT]-