aixplain.modules.model.connection
ConnectAction Objects
class ConnectAction()
A class representing an action that can be performed by a connection.
This class defines the structure of a connection action with its name, description, code, and input parameters.
Attributes:
name
Text - The display name of the action.description
Text - A detailed description of what the action does.code
Optional[Text] - The internal code/identifier for the action.inputs
Optional[Dict] - The input parameters required by the action.
__init__
def __init__(name: Text,
description: Text,
code: Optional[Text] = None,
inputs: Optional[Dict] = None)
Initialize a new ConnectAction instance.
Arguments:
name
Text - The display name of the action.description
Text - A detailed description of what the action does.code
Optional[Text], optional - The internal code/identifier for the action. Defaults to None.inputs
Optional[Dict], optional - The input parameters required by the action. Defaults to None.
__repr__
def __repr__()
Return a string representation of the ConnectAction instance.
Returns:
str
- A string in the format "Action(code=<code>, name=<name>)".
ConnectionTool Objects
class ConnectionTool(Model)
__init__
def __init__(id: Text,
name: Text,
description: Text = "",
api_key: Optional[Text] = None,
supplier: Union[Dict, Text, Supplier, int] = "aiXplain",
version: Optional[Text] = None,
function: Optional[Function] = None,
is_subscribed: bool = False,
cost: Optional[Dict] = None,
function_type: Optional[FunctionType] = FunctionType.CONNECTION,
**additional_info) -> None
Initialize a new ConnectionTool instance.
Arguments:
id
Text - ID of the Connectionname
Text - Name of the Connectiondescription
Text, optional - Description of the Connection. Defaults to "".api_key
Text, optional - API key of the Connection. Defaults to None.supplier
Union[Dict, Text, Supplier, int], optional - Supplier of the Connection. Defaults to "aiXplain".version
Text, optional - Version of the Connection. Defaults to "1.0".function
Function, optional - Function of the Connection. Defaults to None.is_subscribed
bool, optional - Is the user subscribed. Defaults to False.cost
Dict, optional - Cost of the Connection. Defaults to None.function_type
FunctionType, optional - Type of the Connection. Defaults to FunctionType.CONNECTION.name
0 - Any additional Connection info to be saved
get_action_inputs
def get_action_inputs(action: Union[ConnectAction, Text])
Retrieve the input parameters required for a specific action.
Arguments:
action
Union[ConnectAction, Text] - The action to get inputs for, either as a ConnectAction object or as a string code.
Returns:
Dict
- A dictionary containing the input parameters for the action.
Raises:
Exception
- If the inputs cannot be retrieved from the server.
run
def run(action: Union[ConnectAction, Text], inputs: Dict)
Execute a specific action with the provided inputs.
Arguments:
action
Union[ConnectAction, Text] - The action to execute, either as a ConnectAction object or as a string code.inputs
Dict - The input parameters for the action.
Returns:
Response
- The response from the server after executing the action.
get_parameters
def get_parameters() -> List[Dict]
Get the parameters for all actions in the current action scope.
Returns:
List[Dict]
- A list of dictionaries containing the parameters for each action in the action scope. Each dictionary contains the action's code, name, description, and input parameters.
Raises:
AssertionError
- If the action scope is not set or is empty.
__repr__
def __repr__()
Return a string representation of the ConnectionTool instance.
Returns:
str
- A string in the format "ConnectionTool(id=<id>, name=<name>)".