autogen
autogen.OpenAIWrapper
OpenAIWrapper
A wrapper class for openai client.
Initialize the OpenAIWrapper.
Name | Description |
---|---|
config_list | Type: Optional[list[dict[str, Any]]] Default: None |
**base_config | Type: Any |
Class Attributes
actual_usage_summary
extra_kwargs
total_usage_summary
Static Methods
extract_text_or_completion_object
Extract the text or ChatCompletion objects from a completion or chat response.
Name | Description |
---|---|
response | The response from openai. Type: ModelClientResponseProtocol |
Type | Description |
---|---|
list[str]Â |Â list[autogen.oai.client.ModelClient.ModelClientResponseProtocol.Choice.Message] | A list of text, or a list of ChatCompletion objects if function_call/tool_calls are present. |
instantiate
Name | Description |
---|---|
template | Type: Optional[Union[str, Callable[[dict[str, Any]], str]]] |
context | Type: Optional[dict[str, Any]] Default: None |
allow_format_str_template | Type: Optional[bool] Default: False |
Instance Attributes
openai_kwargs
Instance Methods
clear_usage_summary
Clear the usage summary.
create
Make a completion for a given config using available clients.
Besides the kwargs allowed in openai’s [or other] client, we allow the following additional kwargs.
The config in each client will be overridden by the config.
Name | Description |
---|---|
**config | Type: Any |
print_usage_summary
Print the usage summary.
Parameters:Name | Description |
---|---|
mode | Type: Union[str, list[str]] Default: [‘actual’, ‘total’] |
register_model_client
Register a model client.
Name | Description |
---|---|
model_client_cls | A custom client class that follows the ModelClient interface Type: ModelClient |
**kwargs | The kwargs for the custom client class to be initialized with |