Importing Tools
Use the orchestrate tools import
command to import the tools you create in your active environment.
The type of the tool that you import can be controlled by the tool kind argument (-k
or --kind
). There are two types of tools which can be imported: Python tools and OpenAPI tools.
Importing Python tools
Python tools can be imported in two different ways: as a single Python tool file and as a multi Python tool files.
Importing a single Python tool file
This importing type can be used when all the Python code that your tool needs are housed in a single .py
file. Typically, a single file import can be initiated through omitting the package root CLI argument (--package-root
or -r
). Setting the value of said CLI argument to an empty string or white space will also have the same effect.
Let’s assume that the single file tool is placed in the following folder structure, relative to the root of an assumed working directory.
The following are the contents of orchestrate_tools/py/single_file_tool/source/sample_tool.py
.
Then, the following is the command that you have to run to import this tool.
Note:
- The system will only accept strings composed of alphanumeric characters and underscores (
_
) in thename
attribute of the@tool
decorator insample_tool.py
. - The system will only accept tool file names composed of alphanumeric characters and underscores (
_
).
Importing a multi Python tool files
In case that the tool you want to import into watsonx Orchestrate is more complex and spans several files and folders, the system allows you to provide a package root folder which houses all the files and folders your tool requires during import.
Let’s assume that the multifile tool has the following folder structure, relative to the root of an assumed working directory.
The following are the contents of orchestrate_tools/py/multi_file_tool/source/tool_entry_point.py
.
Then, the following example command shows you how to import a multifile tool.
Notes:
- The system will only accept strings composed of alphanumeric characters and underscores (
_
) in thename
attribute of the@tool
decorator intool_entry_point.py
. - The system will only accept tool file names composed of alphanumeric characters and underscores (
_
). - The package root folder and the tool file path CLI arguments MUST share a common base path.
- The path of the tool file folder relative to the package root folder, must be composed of folder names which are only composed of alphanumeric characters and underscores (
_
). - Any whitespace like characters which prefix or suffix provided package root path will be stripped by the system.
- A package root folder path that resolves to an empty string will make the system assume that no package root was specified. Then, the system falls back to single Python file tool import.
Importing OpenAPI tools
This requires a yaml (.yaml/.yml) or json (.json) file passed through the --file
of -f
flag. This yaml or json should be a valid OpenAPI spec for the API you want to generate tools from.