aixplain.modules.model.connection
Copyright 2025 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: Ahmet Gündüz Date: September 10th 2025 Description: Connection Tool Class.
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:
nameText - The display name of the action.descriptionText - A detailed description of what the action does.codeOptional[Text] - The internal code/identifier for the action.inputsOptional[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:
nameText - The display name of the action.descriptionText - A detailed description of what the action does.codeOptional[Text], optional - The internal code/identifier for the action. Defaults to None.inputsOptional[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)
A class representing a connection tool.
This class defines the structure of a connection tool with its actions and action scope.
Attributes:
actionsList[ConnectAction] - A list of available actions for this connection.action_scopeOptional[List[ConnectAction]] - The scope of actions for this connection.
__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:
idText - ID of the ConnectionnameText - Name of the ConnectiondescriptionText, optional - Description of the Connection. Defaults to "".api_keyText, optional - API key of the Connection. Defaults to None.supplierUnion[Dict, Text, Supplier, int], optional - Supplier of the Connection. Defaults to "aiXplain".versionText, optional - Version of the Connection. Defaults to "1.0".functionFunction, optional - Function of the Connection. Defaults to None.is_subscribedbool, optional - Is the user subscribed. Defaults to False.costDict, optional - Cost of the Connection. Defaults to None.function_typeFunctionType, optional - Type of the Connection. Defaults to FunctionType.CONNECTION.name0 - 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:
actionUnion[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:
actionUnion[ConnectAction, Text] - The action to execute, either as a ConnectAction object or as a string code.inputsDict - 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>)".