Deploy Algorithms with AI
TDgpt publishes AI skills in tools/tdgpt/skills/ of the source repository. After an AI tool reads a skill's SKILL.md, it can carry out the whole procedure, including dependency checks, file deployment, service restart, and registration verification, instead of you running each step by hand.
The Linux package installs this directory as <install_dir>/skills/, /usr/local/taos/taosanode/skills/ by default, and refreshes it on upgrade; working from source uses tools/tdgpt/skills/ in the repository. The Windows package does not include it, because the deploy script relies on POSIX tools and can only manage Linux targets through the remote mode.
This section describes the supported algorithm types, prerequisites, and usage.
Supported Algorithm Types
User algorithms are deployed to the Anode's custom_algo_dir, <data_dir>/custom by default, which is /var/lib/taos/taosanode/custom for a native Linux installation. Each type has its own subdirectory and is discovered and called through a different endpoint.
| Type | Directory | Registration contract | Discovery endpoint | Call endpoint |
|---|---|---|---|---|
ad anomaly detection | custom/ad/ | Subclass AbstractAnomalyDetectionService; execute() returns a list of flags | GET /list | POST /anomaly-detect |
fc forecast | custom/fc/ | Subclass AbstractForecastService; execute() returns a result dict | GET /list | POST /forecast |
classification | custom/classification/ | Subclass AbstractClassificationService; execute() returns labels | GET /list | POST /classification |
regression | custom/regression/ | Subclass AbstractRegressionService; execute() returns predicted values | GET /list | POST /regression |
batch envelope | custom/batch/ | Class named _X implementing build(ts, values, windows, params) | GET /api/v1/analysis/batch/algos | POST /api/v1/analysis/batch |
Imputation, correlation, clustering, and series diagnosis have no user extension directory and cannot be extended this way. Dynamically loaded model files and user models that run in their own virtual environment also follow separate paths and are out of scope here.
Two Integration Paths
The AI tool first decides whether your code already follows the TDgpt class hierarchy, and then either deploys it directly or generates an Adapter.
| Your code | What happens |
|---|---|
Already subclasses the base classes above, or implements batch build() | Preflight and deploy directly |
Plain function, plain class (such as predict or forecast), CLI script, or third-party model object | An Adapter is generated: a new entry file subclasses the TDgpt base class and calls your code inside |
| Multi-file package, model weights, or configuration files | An Adapter plus these files, deployed next to the entry |
Code that does not follow the TDgpt hierarchy is the common case, and the model does not have to be rewritten: the generated Adapter performs the adaptation.
Prerequisites
- The host running the AI tool is Linux or macOS. The deploy script relies on POSIX tools (
sh,chmod,sha256sum,base64). A Windows host cannot use the local or local Docker mode; it can only manage a Linux target through the remote mode. - The target Anode is reachable in one of three ways: a native install on the same host, a Docker container, or a Linux host over SSH.
- The Anode main virtual environment is detected automatically, or supplied explicitly with a flag.
- Docker deployments must use a persistent bind mount or named volume for
custom_algo_dir, otherwise the algorithms are lost when the container is recreated.
Procedure
- Collect the deployment information: the Anode URL (port 6035 by default), the public algorithm name, the algorithm type, the script path, and the deployment form (local, Docker, or remote).
- Let the AI tool load the skill: point it at
tools/tdgpt/skills/tdgpt-custom-algorithm/SKILL.md, or open that skill directory. - Preflight with
--checkto confirm the detected algorithm type, the target paths, and whether dependencies are present. Missing packages are installed only after confirmation. - Deploy: the script copies the entry file, plus any file given with
--asset, into the target directory. Docker mode needs a container name, and remote mode needs an SSH target. - Restart the Anode: the script does not restart the service by default and only prints the command. Pass a restart mode to restart automatically.
- Verify: check that the algorithm appears in the discovery endpoint of its type, then call the corresponding endpoint once.
Example command:
python3 scripts/deploy_custom_algorithm.py \
--tdgpt-url http://192.168.1.20:6035 \
--model-name my_ad \
--algorithm-type ad \
--script ./my_ad.py \
--deploy-mode remote --ssh root@192.168.1.20 \
--check
Common Options
| Option | Description |
|---|---|
--tdgpt-url | Anode URL, for example http://127.0.0.1:6035 |
--model-name | Public algorithm name; it must match the name attribute of the class in the script |
--script | Path to the algorithm script |
--algorithm-type | ad, fc, classification, regression, or batch; detected from the script by default |
--deploy-mode | local, docker, or remote; detected by default |
--container | Container name for Docker deployments |
--ssh | SSH target for remote deployments, for example root@192.168.1.20 |
--venv-python | Python path of the target Anode main virtual environment |
--custom-dir | Override custom_algo_dir on the target |
--config | Anode configuration file path on the target |
--restart | How to restart after deployment; defaults to none, which only prints the command |
--service | systemd service name used for the restart |
--install-missing | Install missing packages; requires --yes |
--check | Preflight only, no deployment |
--dry-run | Resolve and validate only, write nothing |
--verify-only | Rerun only the registration and call checks |
--asset | Extra file or directory deployed next to the entry; repeatable |
--allow-ephemeral | Allow writing into an unmounted container path, whose content is lost when the container is recreated |
Notes
- There is no hot reload: the Anode must be restarted before a deployed algorithm takes effect.
- Built-in algorithms ship with TDgpt and cannot be overridden by placing files under
custom/. - Models that need their own virtual environment or process isolation use their own integration paths.
- When packages are missing, the AI tool lists them first and installs only after you confirm.