Interoperability - AG2

Interoperability

``autogen.interop.Interoperability #

A class to handle interoperability between different tool types.

This class allows the conversion of tools to various interoperability classes and provides functionality for retrieving and registering interoperability classes.

registry`class-attributeinstance-attribute`#

registry = get_instance()

``convert_toolclassmethod#

convert_tool(*, tool, type, **kwargs)

Converts a given tool to an instance of a specified interoperability type.

PARAMETER DESCRIPTION
tool The tool object to be converted.
TYPE:Any
type The type of interoperability to convert the tool to.
TYPE:str
**kwargs Additional arguments to be passed during conversion.
TYPE:AnyDEFAULT:{}
RETURNS DESCRIPTION
Tool The converted tool.
TYPE:Tool
RAISES DESCRIPTION
ValueError If the interoperability class for the provided type is not found.

Source code in autogen/interop/interoperability.py

<br>24<br>25<br>26<br>27<br>28<br>29<br>30<br>31<br>32<br>33<br>34<br>35<br>36<br>37<br>38<br>39<br>40<br> <br>@classmethod<br>def convert_tool(cls, *, tool: Any, type: str, **kwargs: Any) -> Tool:<br> """Converts a given tool to an instance of a specified interoperability type.<br> Args:<br> tool (Any): The tool object to be converted.<br> type (str): The type of interoperability to convert the tool to.<br> **kwargs (Any): Additional arguments to be passed during conversion.<br> Returns:<br> Tool: The converted tool.<br> Raises:<br> ValueError: If the interoperability class for the provided type is not found.<br> """<br> interop = cls.get_interoperability_class(type)<br> return interop.convert_tool(tool, **kwargs)<br>

``get_interoperability_classclassmethod#

get_interoperability_class(type)

Retrieves the interoperability class corresponding to the specified type.

PARAMETER DESCRIPTION
type The type of the interoperability class to retrieve.
TYPE:str
RETURNS DESCRIPTION
type[Interoperable] type[Interoperable]: The interoperability class type.
RAISES DESCRIPTION
ValueError If no interoperability class is found for the provided type.

Source code in autogen/interop/interoperability.py

<br>42<br>43<br>44<br>45<br>46<br>47<br>48<br>49<br>50<br>51<br>52<br>53<br>54<br>55<br>56<br>57<br>58<br>59<br>60<br>61<br>62<br> <br>@classmethod<br>def get_interoperability_class(cls, type: str) -> type[Interoperable]:<br> """Retrieves the interoperability class corresponding to the specified type.<br> Args:<br> type (str): The type of the interoperability class to retrieve.<br> Returns:<br> type[Interoperable]: The interoperability class type.<br> Raises:<br> ValueError: If no interoperability class is found for the provided type.<br> """<br> supported_types = cls.registry.get_supported_types()<br> if type not in supported_types:<br> supported_types_formatted = ", ".join(["'t'" for t in supported_types])<br> raise ValueError(<br> f"Interoperability class {type} is not supported, supported types: {supported_types_formatted}"<br> )<br> return cls.registry.get_class(type)<br>

``get_supported_typesclassmethod#

get_supported_types()

Returns a sorted list of all supported interoperability types.

RETURNS DESCRIPTION
list[str] List[str]: A sorted list of strings representing the supported interoperability types.

Source code in autogen/interop/interoperability.py

<br>64<br>65<br>66<br>67<br>68<br>69<br>70<br>71<br> <br>@classmethod<br>def get_supported_types(cls) -> list[str]:<br> """Returns a sorted list of all supported interoperability types.<br> Returns:<br> List[str]: A sorted list of strings representing the supported interoperability types.<br> """<br> return sorted(cls.registry.get_supported_types())<br>

Back to top