| | |
- gen_ai_hub.orchestration.models.base.JSONSerializable(abc.ABC)
-
- ChatCompletionTool
-
- FunctionTool
class FunctionTool(ChatCompletionTool) |
| |
FunctionTool(name: str, parameters: dict, strict: bool = False, description: Optional[str] = None, function: Optional[Callable] = None)
Represents a function tool for OpenAI-like function calling. |
| |
- Method resolution order:
- FunctionTool
- ChatCompletionTool
- gen_ai_hub.orchestration.models.base.JSONSerializable
- abc.ABC
- builtins.object
Methods defined here:
- __init__(self, name: str, parameters: dict, strict: bool = False, description: Optional[str] = None, function: Optional[Callable] = None)
- Initializes a FunctionTool instance.
:param name: The name of the function.
:type name: str
:param parameters: The parameters schema for the function.
:type parameters: dict
:param strict: Whether to enforce strict parameter checking, defaults to False
:type strict: bool, optional
:param description: The description of the function, defaults to None
:type description: Optional[str], optional
:param function: The actual callable function, defaults to None
:type function: Optional[Callable], optional
- async aexecute(self, **kwargs: Any) -> Any
- Asynchronously execute the function with the provided arguments.
:raises ValueError: If the function is not set or if unexpected arguments are provided in strict mode.
:return: The result of the function execution.
:rtype: Any
- execute(self, **kwargs: Any) -> Any
- Execute the function with the provided arguments.
:raises ValueError: If the function is not set or if unexpected arguments are provided in strict mode.
:return: The result of the function execution.
:rtype: Any
- to_dict(self) -> Dict[str, Any]
- Converts the FunctionTool instance to a dictionary representation.
:return: A dictionary representation of the FunctionTool instance.
:rtype: Dict[str, Any]
Static methods defined here:
- from_function(func: Callable, *, description: Optional[str] = None, strict: bool = False) -> 'FunctionTool'
- Create a FunctionTool from a Python function.
:param func: The Python function to convert.
:type func: Callable
:param description: The description of the function, defaults to None
:type description: Optional[str], optional
:param strict: Whether to enforce strict parameter checking, defaults to False
:type strict: bool, optional
:raises TypeError: If any parameter is missing a type hint.
:return: A FunctionTool instance.
:rtype: FunctionTool
Data and other attributes defined here:
- __abstractmethods__ = frozenset()
- __annotations__ = {}
Data descriptors inherited from gen_ai_hub.orchestration.models.base.JSONSerializable:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |