aixplain.modules.agent.tool.pipeline_tool
__author__
Copyright 2024 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: Lucas Pavanelli and Thiago Castro Ferreira Date: May 16th 2024 Description: Agentification Class
PipelineTool Objects
class PipelineTool(Tool)
A tool that wraps aiXplain pipelines to execute complex workflows based on user commands.
This class provides an interface for using aiXplain pipelines as tools, allowing them to be integrated into agent workflows. It handles pipeline validation, status management, and execution.
Attributes:
description
Text - A description of what the pipeline tool does.pipeline
Union[Text, Pipeline] - The pipeline to execute, either as a Pipeline instance or a pipeline ID string.status
AssetStatus - The current status of the pipeline tool.name
Text - The name of the tool, defaults to pipeline name if not provided.
__init__
def __init__(description: Text,
pipeline: Union[Text, Pipeline],
name: Optional[Text] = None,
**additional_info) -> None
Initialize a new PipelineTool instance.
Arguments:
description
Text - A description of what the pipeline tool does.pipeline
Union[Text, Pipeline] - The pipeline to execute, either as a Pipeline instance or a pipeline ID string.name
Optional[Text], optional - The name of the tool. If not provided, will use the pipeline's name. Defaults to None.**additional_info
- Additional keyword arguments for tool configuration.
Raises:
Exception
- If the specified pipeline doesn't exist or is inaccessible.
to_dict
def to_dict()
Convert the tool instance to a dictionary representation.
Returns:
dict
- A dictionary containing the tool's configuration with keys:- assetId: The pipeline ID
- name: The tool's name
- description: The tool's description
- type: Always "pipeline"
- status: The tool's status
__repr__
def __repr__() -> Text
Return a string representation of the tool.
Returns:
Text
- A string in the format "PipelineTool(name=<name>, pipeline=<pipeline>)".
validate
def validate()
Validate the pipeline tool's configuration.
This method performs several checks:
- Verifies the pipeline exists and is accessible
- Sets the tool name to the pipeline name if not provided
- Updates the tool status to match the pipeline status
Raises:
Exception
- If the pipeline doesn't exist or is inaccessible.
deploy
def deploy()
Deploy the pipeline tool.
This is a placeholder method as pipeline tools are managed through the aiXplain platform and don't require explicit deployment.