aixplain.enums.function
__author__
Copyright 2023 The aiXplain SDK authors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Author: aiXplain team Date: March 20th 2023 Description: Function Enum
FunctionMetadata Objects
@dataclass
class FunctionMetadata()
Metadata container for function information.
This class holds metadata about a function including its identifier, name, description, parameters, outputs, and additional metadata.
Attributes:
id
str - ID of the function.name
str - Name of the function.description
Optional[str] - Description of what the function does.params
List[Dict[str, Any]] - List of parameter specifications.output
List[Dict[str, Any]] - List of output specifications.metadata
Dict[str, Any] - Additional metadata about the function.
to_dict
def to_dict() -> dict
Convert the function metadata to a dictionary.
Returns:
dict
- Dictionary representation of the function metadata.
from_dict
@classmethod
def from_dict(cls, data: dict) -> "FunctionMetadata"
Create a FunctionMetadata instance from a dictionary.
Arguments:
data
dict - Dictionary containing function metadata.
Returns:
FunctionMetadata
- New instance created from the dictionary data.
load_functions
def load_functions() -> Tuple[Enum, Dict]
Load function definitions from the backend or cache.
This function attempts to load function definitions from the cache first. If the cache is invalid or doesn't exist, it fetches the data from the backend API.
Returns:
Tuple[Function, Dict]: A tuple containing:
- Function: Dynamically created Function enum class
- Dict: Dictionary mapping function IDs to their input/output specifications
Raises:
Exception
- If functions cannot be loaded due to invalid API key or other errors.
FunctionParameters Objects
class FunctionParameters(BaseParameters)
Class to store and manage function parameters
__init__
def __init__(input_params: Dict)
Initialize FunctionParameters with input parameters
Arguments:
input_params
Dict - Dictionary of input parameters