SuperAPI AI Directory

tcm-meridian-inference

Agents & models

View repository

Updated 10-15 11:24

About this skill

TCM Meridian Inference Skill

TCM meridian inference engine — input left/right measurement values for 6 meridians (liver/spleen/kidney/stomach/gallbladder/bladder), output: health score, meridian status, combination diagnoses, store explanation copy, conditioning recommendations.

Trigger words

meridian inference, TCM inference, meridian analysis, meridian diagnosis, tcm inference

Feature overview

  • Input: left/right temperature measurement values for 6 meridians (foot collection)
  • Output:
    • healthScore — Overall health score (0-100)
    • meridians — Status of each meridian (stable / left_low / right_low / cross), score, symptom tags
    • combinations — Cross-meridian combination diagnoses (e.g. "elevated transaminases", "cervical spine risk alert")
    • summary — Overall summary
    • storefront — Store explanation copy (focus title, customer explanation, talking points guidance, retest reminder)
    • advice — Conditioning recommendation list
    • riskTags — Risk tags
  • Engine: pure rule-based inference (Python stdlib-only), no external dependencies required
  • Meridian list: liver (Liver), spleen (Spleen), kidney (Kidney), stomach (Stomach), gallbladder (Gallbladder), bladder (Bladder)

Directory structure

tcm-meridian-inference/
├── SKILL.md              # 本文件
├── scripts/
│   ├── infer.py          # 推理引擎核心
│   ├── tcm_api.py        # HTTP API 服务
│   └── start_api.sh      # 一键启动脚本
└── rules/
    ├── thresholds.json       # 温度阈值与评分参数
    ├── meridian_rules.json   # 单经络规则(18条)
    └── combination_rules.json # 组合判症规则(6条)

HTTP API interface definition

The TCM inference engine runs as an independent HTTP service (default port 18790), and all features are called via HTTP.

Start service

cd ~/clawd/skills/tcm-meridian-inference
bash scripts/start_api.sh          # 默认 18790
bash scripts/start_api.sh 8080     # 指定端口
TCM_API_PORT=9090 bash scripts/start_api.sh  # 环境变量

Interface list

Method Path Description
POST /api/inference/meridian-diagnosis Full inference (score + status + combination diagnosis + store copy + recommendations)
POST /test Test with built-in sample data
GET /healthz Health check
GET / Service information

Request body (POST /api/inference/meridian-diagnosis)

{
  "subject": {"id": "test-001", "name": "测试用户"},
  "measurements": {
    "liver":       {"left": 35.0, "right": 36.1},
    "spleen":      {"left": 35.1, "right": 35.9},
    "kidney":      {"left": 35.0, "right": 35.8},
    "stomach":     {"left": 35.1, "right": 36.0},
    "gallbladder": {"left": 35.0, "right": 35.9},
    "bladder":     {"left": 35.2, "right": 35.9}
  }
}

Field descriptions:

  • subject: optional, subject identifier
  • measurements: required, left/right values for the 6 meridians
    • Each meridian must include left and right(floating-point numbers, unit: °C)
    • Optional trendDelta field (default = right - left)

Response body

{
  "engine": {"mode": "rule-based-mvp", "version": "0.2.0"},
  "subject": {"id": "test-001", "name": "测试用户"},
  "healthScore": 84.0,
  "scores": {"liver": 84.0, "spleen": 100.0, "kidney": 100.0, "stomach": 100.0, "gallbladder": 100.0, "bladder": 100.0},
  "meridians": {
    "liver": {
      "status": "left_low",
      "score": 84.0,
      "symptoms": ["代谢差", "气虚", ...],
      "tags": ["left_low"]
    },
    ...
  },
  "sixDimensionScores": [...],
  "riskTags": ["left_low"],
  "combinations": [],
  "summary": "肝左低:代谢侧偏弱",
  "reportSummary": "...",
  "advice": ["关注代谢与睡眠节律", ...],
  "storefront": {
    "focusHeadline": "左侧偏低",
    "clientExplanation": "...",
    "talkTrack": ["...", "...", "..."],
    "retestPrompt": "建议间隔 20-30 分钟复测一次,连续 2-3 次趋势更可靠。"
  },
  "trace": {...}
}

Response field descriptions

Field Type Description
healthScore float Overall score (0-100), average of the 6 meridians
scores object Score for each meridian
meridians object Status details for each meridian (status / score / symptoms / tags)
combinations array Matched combination diagnosis rules
summary string Short machine-readable summary
storefront object Copy for store explanation
advice array[string] Conditioning recommendations
riskTags array[string] Deduplicated risk tags
trace object Full inference trace (for debugging)

Meridian status enum

Status Meaning
stable Normal range
left_low Left side low
right_low Right side low
cross Significant left-right difference

Combination diagnoses (combinations)

Combination name Trigger condition Tag
Elevated transaminases Liver left low + Gallbladder left low transaminase, liver_combo
Cervical spine risk alert Kidney and Bladder low on opposite sides cervical
Lumbar spine risk alert Kidney and bladder low on the same side lumbar
Attention to cardiac blood supply ≥4 meridians low on the right heart_supply
Attention to head blood supply ≥4 meridians low on the left head_supply
Cervical spine worsening indication Kidney + bladder oppositely low and spleen low on the left cervical_plus

CLI single inference

No need to start an HTTP service; use the inference engine directly:

cd ~/clawd/skills/tcm-meridian-inference
python3 scripts/infer.py path/to/case.json --pretty
python3 scripts/infer.py path/to/case.json --out result.json

How OpenClaw calls it

Method A: Agent calls the TCM API via the exec tool

The OpenClaw agent can directly execute curl through exec to call the TCM API:

# 确保 API 正在运行
curl -s http://localhost:18790/healthz

# 完整推理
curl -s -X POST http://localhost:18790/api/inference/meridian-diagnosis \
  -H "Content-Type: application/json" \
  -d '{
    "subject": {"id": "user-001", "name": "张三"},
    "measurements": {
      "liver": {"left": 34.5, "right": 34.3},
      "spleen": {"left": 34.8, "right": 34.6},
      "kidney": {"left": 33.5, "right": 34.2},
      "stomach": {"left": 34.0, "right": 34.5},
      "gallbladder": {"left": 34.2, "right": 34.0},
      "bladder": {"left": 33.8, "right": 34.8}
    }
  }'

Method B: CLI command-line trigger

Send a message to the OpenClaw agent from any script to request inference:

openclaw agent --agent main --deliver --message "请帮我推理经络数据: liver左35右36, spleen左35.1右35.9, kidney左35右35.8, stomach左35.1右36, gallbladder左35右35.9, bladder左35.2右35.9"

Method C: Cron scheduled inference + result push

Configure a scheduled inference task via OpenClaw cron and push the results to an external webhook:

{
  "schedule": "0 9 * * *",
  "task": "调用 TCM API 推理经络数据并将结果 POST 到外部 URL",
  "delivery": {
    "mode": "webhook",
    "to": "https://your-app.com/api/tcm-callback"
  }
}

Method D: Reverse integration (external system calls TCM)

The external system directly calls the TCM API:

curl -X POST http://<HOST_IP>:18790/api/inference/meridian-diagnosis \
  -H "Content-Type: application/json" \
  -d @request.json

Applicable to: store systems, mini-program backends, IoT device gateways, etc.

Usage examples

# 1. 启动 API
cd ~/clawd/skills/tcm-meridian-inference
bash scripts/start_api.sh

# 2. 健康检查
curl http://localhost:18790/healthz

# 3. 用示例数据测试
curl -X POST http://localhost:18790/test

# 4. 完整推理
curl -s -X POST http://localhost:18790/api/inference/meridian-diagnosis \
  -H "Content-Type: application/json" \
  -d '{"measurements":{"liver":{"left":34.5,"right":34.3},"spleen":{"left":34.8,"right":34.6},"kidney":{"left":33.5,"right":34.2},"stomach":{"left":34.0,"right":34.5},"gallbladder":{"left":34.2,"right":34.0},"bladder":{"left":33.8,"right":34.8}}}' | python3 -m json.tool

# 5. CLI 单次推理(无需 API)
python3 scripts/infer.py /path/to/case.json --pretty

Integration with AI inference

When the TCM rule inference results need to be handed to AI for further analysis:

  1. First call the TCM API to obtain structured inference results (healthScore, meridian status, combined syndrome differentiation, etc.)
  2. Use the results as part of the promptsent to the OpenClaw agent
  3. The Agent uses AI capabilitiesfor natural language interpretation, personalized recommendations, and user-friendly report generation

Example workflow:

用户提交经络数据 → TCM API 规则推理 → 结构化 JSON → Agent AI 解读 → 用户友好报告

The rule engine excels at precise threshold judgments and combinatorial logic; AI excels at natural language understanding and personalized expression. The combination of the two works best.

Technical notes

  • Python stdlib-only: zero external dependencies, runs on Python 3.6+
  • Rule base hot reload: after modifying the JSON files under rules/ , restart the API for the changes to take effect
  • Default port: 18790 (can be changed via the environment variable TCM_API_PORT or a startup parameter)
  • Original project path:~/clawd/projects/tcm-meridian-inference-mvp/(do not modify directly)

Rule tuning

The rule files are located in the rules/ directory:

  • thresholds.json — temperature thresholds (lowMin=35.3, normalMin=35.6, etc.) and scoring parameters (deduction value for each item)
  • meridian_rules.json — single-meridian rules (3 states per meridian × 6 meridians = 18 rules)
  • combination_rules.json — cross-meridian combined syndrome differentiation rules (6 rules)

After modifying the rules, restart the API for the changes to take effect; no code changes are required.