gen_ai_hub.orchestration.models.tools
index
/home/jenkins/agent/workspace/ation_generative-ai-hub-sdk_main/gen_ai_hub/orchestration/models/tools.py

 
Modules
       
inspect
typing

 
Classes
       
gen_ai_hub.orchestration.models.base.JSONSerializable(abc.ABC)
ChatCompletionTool
FunctionTool

 
class ChatCompletionTool(gen_ai_hub.orchestration.models.base.JSONSerializable)
    ChatCompletionTool(type_: str)
 
Base class for all chat completion tools.
 
 
Method resolution order:
ChatCompletionTool
gen_ai_hub.orchestration.models.base.JSONSerializable
abc.ABC
builtins.object

Methods defined here:
__init__(self, type_: str)
Initializes a ChatCompletionTool instance.
 
:param type_: The type of the tool.
:type type_: str
to_dict(self) -> Dict[str, Any]
Converts the ChatCompletionTool instance to a dictionary representation.
 
:return: A dictionary representation of the ChatCompletionTool instance.
:rtype: Dict[str, Any]

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)

 
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)

 
Functions
       
function_tool(func: Optional[Callable] = None, *, description: Optional[str] = None, strict: bool = False) -> Union[Callable[[Callable], gen_ai_hub.orchestration.models.tools.FunctionTool], gen_ai_hub.orchestration.models.tools.FunctionTool]
Create a decorator that converts a function into a FunctionTool.
 
Usage:
    
@function_tool
 
def my_func(...): ...
 
@function_tool()
 
def my_func(...): ...
 
:param func: The function to convert, defaults to None
:type func: Optional[Callable], optional
: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
:return: A FunctionTool instance or a decorator function.
:rtype: Callable[[Callable], FunctionTool] | FunctionTool
python_type_to_json_type(py_type)
Converts a Python type to a JSON Schema type.
 
:param py_type: The Python type to convert.
:type py_type: type
:return: A dictionary representing the JSON Schema type.
:rtype: Dict[str, Any]

 
Data
        Any = typing.Any
Callable = typing.Callable
Dict = typing.Dict
Optional = typing.Optional