tcm-cli 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tcm_cli-0.1.0/.github/workflows/python-package.yml +40 -0
- tcm_cli-0.1.0/LICENSE +21 -0
- tcm_cli-0.1.0/PKG-INFO +342 -0
- tcm_cli-0.1.0/README.md +261 -0
- tcm_cli-0.1.0/docs/assets/favicon.svg +4 -0
- tcm_cli-0.1.0/docs/assets/og.svg +14 -0
- tcm_cli-0.1.0/docs/index.html +209 -0
- tcm_cli-0.1.0/docs/script.js +14 -0
- tcm_cli-0.1.0/docs/styles.css +61 -0
- tcm_cli-0.1.0/install.sh +82 -0
- tcm_cli-0.1.0/pyproject.toml +106 -0
- tcm_cli-0.1.0/src/tcm/__init__.py +3 -0
- tcm_cli-0.1.0/src/tcm/agent/__init__.py +1 -0
- tcm_cli-0.1.0/src/tcm/agent/config.py +229 -0
- tcm_cli-0.1.0/src/tcm/agent/doctor.py +92 -0
- tcm_cli-0.1.0/src/tcm/agent/executor.py +122 -0
- tcm_cli-0.1.0/src/tcm/agent/planner.py +90 -0
- tcm_cli-0.1.0/src/tcm/agent/session.py +129 -0
- tcm_cli-0.1.0/src/tcm/agent/synthesizer.py +130 -0
- tcm_cli-0.1.0/src/tcm/cli.py +527 -0
- tcm_cli-0.1.0/src/tcm/data/__init__.py +1 -0
- tcm_cli-0.1.0/src/tcm/data/downloader.py +312 -0
- tcm_cli-0.1.0/src/tcm/models/__init__.py +1 -0
- tcm_cli-0.1.0/src/tcm/models/llm.py +411 -0
- tcm_cli-0.1.0/src/tcm/tools/__init__.py +161 -0
- tcm_cli-0.1.0/src/tcm/tools/code.py +55 -0
- tcm_cli-0.1.0/src/tcm/tools/compounds.py +113 -0
- tcm_cli-0.1.0/src/tcm/tools/data_api.py +128 -0
- tcm_cli-0.1.0/src/tcm/tools/formulas.py +191 -0
- tcm_cli-0.1.0/src/tcm/tools/herbs.py +282 -0
- tcm_cli-0.1.0/src/tcm/tools/interactions.py +146 -0
- tcm_cli-0.1.0/src/tcm/tools/literature.py +105 -0
- tcm_cli-0.1.0/src/tcm/tools/meridians.py +73 -0
- tcm_cli-0.1.0/src/tcm/tools/modern.py +113 -0
- tcm_cli-0.1.0/src/tcm/tools/pharmacology.py +301 -0
- tcm_cli-0.1.0/src/tcm/tools/safety.py +92 -0
- tcm_cli-0.1.0/src/tcm/tools/syndromes.py +164 -0
- tcm_cli-0.1.0/src/tcm/ui/__init__.py +1 -0
- tcm_cli-0.1.0/src/tcm/ui/suggestions.py +16 -0
- tcm_cli-0.1.0/src/tcm/ui/terminal.py +319 -0
- tcm_cli-0.1.0/tests/__init__.py +1 -0
- tcm_cli-0.1.0/tests/test_config.py +80 -0
- tcm_cli-0.1.0/tests/test_models.py +115 -0
- tcm_cli-0.1.0/tests/test_tools.py +163 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
|
|
3
|
+
|
|
4
|
+
name: Python package
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [ "main" ]
|
|
9
|
+
pull_request:
|
|
10
|
+
branches: [ "main" ]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
strategy:
|
|
17
|
+
fail-fast: false
|
|
18
|
+
matrix:
|
|
19
|
+
python-version: ["3.9", "3.10", "3.11"]
|
|
20
|
+
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v4
|
|
23
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
24
|
+
uses: actions/setup-python@v3
|
|
25
|
+
with:
|
|
26
|
+
python-version: ${{ matrix.python-version }}
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: |
|
|
29
|
+
python -m pip install --upgrade pip
|
|
30
|
+
python -m pip install flake8 pytest
|
|
31
|
+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
|
32
|
+
- name: Lint with flake8
|
|
33
|
+
run: |
|
|
34
|
+
# stop the build if there are Python syntax errors or undefined names
|
|
35
|
+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
|
36
|
+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
|
37
|
+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
|
38
|
+
- name: Test with pytest
|
|
39
|
+
run: |
|
|
40
|
+
pytest
|
tcm_cli-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 TCM-CLI Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
tcm_cli-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tcm-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: An autonomous agent for Traditional Chinese Medicine research and discovery
|
|
5
|
+
Project-URL: Homepage, https://github.com/tigerneil/tcm-cli
|
|
6
|
+
Project-URL: Repository, https://github.com/tigerneil/tcm-cli
|
|
7
|
+
Project-URL: Documentation, https://github.com/tigerneil/tcm-cli#readme
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/tigerneil/tcm-cli/issues
|
|
9
|
+
Author: TCM-CLI Contributors
|
|
10
|
+
License: MIT License
|
|
11
|
+
|
|
12
|
+
Copyright (c) 2026 TCM-CLI Contributors
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
SOFTWARE.
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Keywords: ai-agent,bioinformatics,cli,herbs,llm,network-pharmacology,pharmacology,research,tcm,traditional-chinese-medicine
|
|
33
|
+
Classifier: Development Status :: 3 - Alpha
|
|
34
|
+
Classifier: Environment :: Console
|
|
35
|
+
Classifier: Intended Audience :: Education
|
|
36
|
+
Classifier: Intended Audience :: Healthcare Industry
|
|
37
|
+
Classifier: Intended Audience :: Science/Research
|
|
38
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
39
|
+
Classifier: Operating System :: OS Independent
|
|
40
|
+
Classifier: Programming Language :: Python :: 3
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
43
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
44
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
45
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
46
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
47
|
+
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
|
|
48
|
+
Requires-Python: >=3.10
|
|
49
|
+
Requires-Dist: anthropic>=0.40
|
|
50
|
+
Requires-Dist: httpx>=0.27
|
|
51
|
+
Requires-Dist: markdown>=3.5
|
|
52
|
+
Requires-Dist: numpy>=1.24
|
|
53
|
+
Requires-Dist: openai>=1.0
|
|
54
|
+
Requires-Dist: pandas>=2.0
|
|
55
|
+
Requires-Dist: prompt-toolkit>=3.0
|
|
56
|
+
Requires-Dist: python-dotenv>=1.0
|
|
57
|
+
Requires-Dist: rich>=13.0
|
|
58
|
+
Requires-Dist: typer>=0.12
|
|
59
|
+
Provides-Extra: all
|
|
60
|
+
Requires-Dist: rdkit>=2023.03; extra == 'all'
|
|
61
|
+
Requires-Dist: scikit-learn>=1.3; extra == 'all'
|
|
62
|
+
Requires-Dist: scipy>=1.10; extra == 'all'
|
|
63
|
+
Requires-Dist: seaborn>=0.13; extra == 'all'
|
|
64
|
+
Requires-Dist: torch>=2.0; extra == 'all'
|
|
65
|
+
Requires-Dist: transformers>=4.40; extra == 'all'
|
|
66
|
+
Provides-Extra: analysis
|
|
67
|
+
Requires-Dist: scikit-learn>=1.3; extra == 'analysis'
|
|
68
|
+
Requires-Dist: scipy>=1.10; extra == 'analysis'
|
|
69
|
+
Requires-Dist: seaborn>=0.13; extra == 'analysis'
|
|
70
|
+
Provides-Extra: chemistry
|
|
71
|
+
Requires-Dist: rdkit>=2023.03; extra == 'chemistry'
|
|
72
|
+
Provides-Extra: dev
|
|
73
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
74
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
75
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
76
|
+
Requires-Dist: ruff>=0.5; extra == 'dev'
|
|
77
|
+
Provides-Extra: ml
|
|
78
|
+
Requires-Dist: torch>=2.0; extra == 'ml'
|
|
79
|
+
Requires-Dist: transformers>=4.40; extra == 'ml'
|
|
80
|
+
Description-Content-Type: text/markdown
|
|
81
|
+
|
|
82
|
+
# tcm-cli
|
|
83
|
+
|
|
84
|
+
An autonomous agent for Traditional Chinese Medicine research and discovery.
|
|
85
|
+
|
|
86
|
+
Ask questions in natural language. tcm-cli plans the analysis, selects the right tools, executes them, validates results, and returns data-backed conclusions.
|
|
87
|
+
|
|
88
|
+
## Why tcm?
|
|
89
|
+
|
|
90
|
+
- **30+ TCM research tools** — Herb lookup, formula analysis, syndrome differentiation, network pharmacology, safety checks, literature search, and more.
|
|
91
|
+
- **Multi-model reasoning** — Powered by leading LLMs (OpenAI GPT-4o, o3, and more). Automatically plans multi-step research workflows, calls tools, and synthesizes findings.
|
|
92
|
+
- **Bilingual** — Supports both Chinese (中文) and English terminology throughout.
|
|
93
|
+
- **10+ database APIs** — PubMed, TCMSP, UniProt, STRING, KEGG, ClinicalTrials.gov, Open Targets — no setup required.
|
|
94
|
+
- **Research UX** — Interactive terminal with slash commands, session export, and clipboard support.
|
|
95
|
+
- **Open source** — MIT licensed.
|
|
96
|
+
|
|
97
|
+
## Requirements
|
|
98
|
+
|
|
99
|
+
- Python 3.10+
|
|
100
|
+
- An LLM API key (OpenAI or compatible)
|
|
101
|
+
|
|
102
|
+
## Installation
|
|
103
|
+
|
|
104
|
+
### Quick install (script)
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
curl -fsSL https://raw.githubusercontent.com/tigerneil/tcm-cli/main/install.sh | bash
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
The script detects `pipx`, `uv`, or falls back to `pip --user`, then runs `tcm setup`.
|
|
111
|
+
|
|
112
|
+
### With pipx (recommended)
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
pipx install tcm-cli
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### With pip
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Core install
|
|
122
|
+
pip install tcm-cli
|
|
123
|
+
|
|
124
|
+
# With chemistry support (RDKit)
|
|
125
|
+
pip install "tcm-cli[chemistry]"
|
|
126
|
+
|
|
127
|
+
# With ML support (PyTorch + Transformers)
|
|
128
|
+
pip install "tcm-cli[ml]"
|
|
129
|
+
|
|
130
|
+
# With analysis stack (scikit-learn, seaborn, scipy)
|
|
131
|
+
pip install "tcm-cli[analysis]"
|
|
132
|
+
|
|
133
|
+
# Everything
|
|
134
|
+
pip install "tcm-cli[all]"
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Authentication
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
# Interactive setup wizard (recommended)
|
|
141
|
+
tcm setup
|
|
142
|
+
|
|
143
|
+
# Or export directly
|
|
144
|
+
export OPENAI_API_KEY="sk-..."
|
|
145
|
+
|
|
146
|
+
# Non-interactive (CI/scripting)
|
|
147
|
+
tcm setup --api-key YOUR_API_KEY
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
API keys are stored at `~/.tcm/config.json`. Check key status with:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
tcm keys
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Getting Started
|
|
157
|
+
|
|
158
|
+
### Basic usage
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# Start interactive session
|
|
162
|
+
tcm
|
|
163
|
+
|
|
164
|
+
# Single query
|
|
165
|
+
tcm "What herbs are used for Spleen Qi deficiency?"
|
|
166
|
+
|
|
167
|
+
# Use a specific model
|
|
168
|
+
tcm --model gpt-4o "Analyze 四君子汤"
|
|
169
|
+
|
|
170
|
+
# Validate setup
|
|
171
|
+
tcm doctor
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Interactive commands
|
|
175
|
+
|
|
176
|
+
Inside `tcm` interactive mode:
|
|
177
|
+
|
|
178
|
+
- `/help` — command reference + examples
|
|
179
|
+
- `/tools` — list all tools with status
|
|
180
|
+
- `/model` — switch LLM model/provider
|
|
181
|
+
- `/usage` — token and cost tracking
|
|
182
|
+
- `/copy` — copy last answer to clipboard
|
|
183
|
+
- `/export` — export session transcript
|
|
184
|
+
- `/clear` — clear screen
|
|
185
|
+
- `/exit` — exit
|
|
186
|
+
|
|
187
|
+
### Quick examples
|
|
188
|
+
|
|
189
|
+
**Herb lookup**
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
$ tcm "Tell me about 黄芪 (Astragalus) — properties, compounds, and clinical evidence"
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Formula analysis**
|
|
196
|
+
|
|
197
|
+
```
|
|
198
|
+
$ tcm "Analyze the composition of 四君子汤 using the 君臣佐使 framework"
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
**Syndrome differentiation**
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
$ tcm "Patient has fatigue, loose stools, poor appetite, pale tongue. What TCM syndrome?"
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
**Network pharmacology**
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
$ tcm "Build a network pharmacology analysis for 补中益气汤 against diabetes targets"
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**Safety check**
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
$ tcm "Check interactions between 人参, 藜芦, and Warfarin"
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Key Features
|
|
220
|
+
|
|
221
|
+
### 30+ Domain Tools
|
|
222
|
+
|
|
223
|
+
| Category | Examples |
|
|
224
|
+
| --- | --- |
|
|
225
|
+
| **Herbs** | Lookup, property classification, meridian search, compound listing |
|
|
226
|
+
| **Formulas** | Classical formula search, 君臣佐使 analysis, modifications |
|
|
227
|
+
| **Syndromes** | Pattern differentiation, symptom-to-syndrome mapping, treatment plans |
|
|
228
|
+
| **Compounds** | Active compound search, ADMET prediction, target identification |
|
|
229
|
+
| **Pharmacology** | Network pharmacology, pathway enrichment, herb-target networks |
|
|
230
|
+
| **Interactions** | 十八反/十九畏 checks, herb-drug interactions, formula safety |
|
|
231
|
+
| **Literature** | PubMed search, systematic review finder, CNKI integration |
|
|
232
|
+
| **Meridians** | Channel lookup, Five Element associations, meridian-herb mapping |
|
|
233
|
+
| **Safety** | Toxicity profiling, pregnancy safety, dosage validation |
|
|
234
|
+
| **Modern** | Clinical trial search, ICD-10 mapping, evidence summaries |
|
|
235
|
+
| **Data APIs** | TCMSP, UniProt, STRING, KEGG, ClinicalTrials.gov, Open Targets |
|
|
236
|
+
| **Code** | Python sandbox for custom analysis (experimental) |
|
|
237
|
+
|
|
238
|
+
List all tools and their status:
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
tcm tool list
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Supported Models
|
|
245
|
+
|
|
246
|
+
| Provider | Model | Context | Notes |
|
|
247
|
+
| --- | --- | --- | --- |
|
|
248
|
+
| OpenAI | `gpt-4o` | 128k | Default — best balance |
|
|
249
|
+
| OpenAI | `gpt-4o-mini` | 128k | Fast and affordable |
|
|
250
|
+
| OpenAI | `o3-mini` | 200k | Reasoning model |
|
|
251
|
+
| OpenAI | `gpt-4.1` | 1M | Latest flagship with 1M context |
|
|
252
|
+
| OpenAI | `gpt-4.1-mini` | 1M | Balanced speed and intelligence |
|
|
253
|
+
| OpenAI | `gpt-4.1-nano` | 1M | Fastest, most cost-effective |
|
|
254
|
+
|
|
255
|
+
Switch models:
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
tcm model list # Show all models with pricing
|
|
259
|
+
tcm model set gpt-4o # Switch to GPT-4o
|
|
260
|
+
tcm model show # Show current model
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Local Datasets
|
|
264
|
+
|
|
265
|
+
Without local data, tcm works via database APIs and built-in knowledge. To boost accuracy and offline support, install local datasets:
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
tcm data pull herbs # Install bundled herb monograph data (instant)
|
|
269
|
+
tcm data pull formulas # Install bundled classical formula data (instant)
|
|
270
|
+
tcm data pull tcmsp # TCMSP — herbs, compounds, targets (~50 MB)
|
|
271
|
+
tcm data pull tcmid # TCMID — herb-compound-disease (~30 MB)
|
|
272
|
+
tcm data pull batman # BATMAN-TCM bioinformatics data (~100 MB)
|
|
273
|
+
tcm data pull symmap # SymMap symptom-mapping database (~20 MB)
|
|
274
|
+
tcm data status # Show all dataset statuses
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
**Install modes:**
|
|
278
|
+
- `herbs` and `formulas` install instantly from bundled package data.
|
|
279
|
+
- Datasets with a direct download URL are fetched automatically with a progress bar and extracted.
|
|
280
|
+
- Datasets that require registration (tcmsp, tcmid, batman, symmap) print step-by-step instructions. After downloading manually, register the file:
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
tcm data import tcmsp ~/Downloads/tcmsp.zip
|
|
284
|
+
tcm data import tcmsp ~/Downloads/tcmsp-extracted/ # or a directory
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Use `--force` to re-download or reinstall any dataset:
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
tcm data pull herbs --force
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
## Configuration
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
tcm config show # Show all settings
|
|
297
|
+
tcm config set key value # Set a value
|
|
298
|
+
tcm config get key # Get a single value
|
|
299
|
+
tcm config validate # Check for issues
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
Config is stored at `~/.tcm/config.json`.
|
|
303
|
+
|
|
304
|
+
### Common config keys
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
tcm config set llm.provider openai # openai or compatible
|
|
308
|
+
tcm config set llm.model gpt-4o
|
|
309
|
+
tcm config set ui.language zh # en (default) or zh
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### Agent profiles
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
tcm config set agent.profile research # Default — balanced, allows hypotheses
|
|
316
|
+
tcm config set agent.profile clinical # Strict evidence only, no hypotheses
|
|
317
|
+
tcm config set agent.profile education # Relaxed, creative responses
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
## Troubleshooting
|
|
321
|
+
|
|
322
|
+
| Symptom | Fix |
|
|
323
|
+
| --- | --- |
|
|
324
|
+
| `tcm` fails at startup | `tcm doctor` |
|
|
325
|
+
| Authentication error | `tcm setup` or `tcm keys` |
|
|
326
|
+
| Missing API key | `export OPENAI_API_KEY=...` or `tcm config set llm.openai_api_key ...` |
|
|
327
|
+
| Missing dependency | `pip install "tcm-cli[all]"` |
|
|
328
|
+
| Tool module failed | `tcm tool list` — check for load errors |
|
|
329
|
+
|
|
330
|
+
## Contributing
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
git clone https://github.com/tigerneil/tcm-cli.git
|
|
334
|
+
cd tcm-cli
|
|
335
|
+
pip install -e ".[dev]"
|
|
336
|
+
tcm setup
|
|
337
|
+
pytest tests/
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
## License
|
|
341
|
+
|
|
342
|
+
MIT
|
tcm_cli-0.1.0/README.md
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# tcm-cli
|
|
2
|
+
|
|
3
|
+
An autonomous agent for Traditional Chinese Medicine research and discovery.
|
|
4
|
+
|
|
5
|
+
Ask questions in natural language. tcm-cli plans the analysis, selects the right tools, executes them, validates results, and returns data-backed conclusions.
|
|
6
|
+
|
|
7
|
+
## Why tcm?
|
|
8
|
+
|
|
9
|
+
- **30+ TCM research tools** — Herb lookup, formula analysis, syndrome differentiation, network pharmacology, safety checks, literature search, and more.
|
|
10
|
+
- **Multi-model reasoning** — Powered by leading LLMs (OpenAI GPT-4o, o3, and more). Automatically plans multi-step research workflows, calls tools, and synthesizes findings.
|
|
11
|
+
- **Bilingual** — Supports both Chinese (中文) and English terminology throughout.
|
|
12
|
+
- **10+ database APIs** — PubMed, TCMSP, UniProt, STRING, KEGG, ClinicalTrials.gov, Open Targets — no setup required.
|
|
13
|
+
- **Research UX** — Interactive terminal with slash commands, session export, and clipboard support.
|
|
14
|
+
- **Open source** — MIT licensed.
|
|
15
|
+
|
|
16
|
+
## Requirements
|
|
17
|
+
|
|
18
|
+
- Python 3.10+
|
|
19
|
+
- An LLM API key (OpenAI or compatible)
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
### Quick install (script)
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
curl -fsSL https://raw.githubusercontent.com/tigerneil/tcm-cli/main/install.sh | bash
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The script detects `pipx`, `uv`, or falls back to `pip --user`, then runs `tcm setup`.
|
|
30
|
+
|
|
31
|
+
### With pipx (recommended)
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pipx install tcm-cli
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### With pip
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# Core install
|
|
41
|
+
pip install tcm-cli
|
|
42
|
+
|
|
43
|
+
# With chemistry support (RDKit)
|
|
44
|
+
pip install "tcm-cli[chemistry]"
|
|
45
|
+
|
|
46
|
+
# With ML support (PyTorch + Transformers)
|
|
47
|
+
pip install "tcm-cli[ml]"
|
|
48
|
+
|
|
49
|
+
# With analysis stack (scikit-learn, seaborn, scipy)
|
|
50
|
+
pip install "tcm-cli[analysis]"
|
|
51
|
+
|
|
52
|
+
# Everything
|
|
53
|
+
pip install "tcm-cli[all]"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Authentication
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Interactive setup wizard (recommended)
|
|
60
|
+
tcm setup
|
|
61
|
+
|
|
62
|
+
# Or export directly
|
|
63
|
+
export OPENAI_API_KEY="sk-..."
|
|
64
|
+
|
|
65
|
+
# Non-interactive (CI/scripting)
|
|
66
|
+
tcm setup --api-key YOUR_API_KEY
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
API keys are stored at `~/.tcm/config.json`. Check key status with:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
tcm keys
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Getting Started
|
|
76
|
+
|
|
77
|
+
### Basic usage
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# Start interactive session
|
|
81
|
+
tcm
|
|
82
|
+
|
|
83
|
+
# Single query
|
|
84
|
+
tcm "What herbs are used for Spleen Qi deficiency?"
|
|
85
|
+
|
|
86
|
+
# Use a specific model
|
|
87
|
+
tcm --model gpt-4o "Analyze 四君子汤"
|
|
88
|
+
|
|
89
|
+
# Validate setup
|
|
90
|
+
tcm doctor
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Interactive commands
|
|
94
|
+
|
|
95
|
+
Inside `tcm` interactive mode:
|
|
96
|
+
|
|
97
|
+
- `/help` — command reference + examples
|
|
98
|
+
- `/tools` — list all tools with status
|
|
99
|
+
- `/model` — switch LLM model/provider
|
|
100
|
+
- `/usage` — token and cost tracking
|
|
101
|
+
- `/copy` — copy last answer to clipboard
|
|
102
|
+
- `/export` — export session transcript
|
|
103
|
+
- `/clear` — clear screen
|
|
104
|
+
- `/exit` — exit
|
|
105
|
+
|
|
106
|
+
### Quick examples
|
|
107
|
+
|
|
108
|
+
**Herb lookup**
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
$ tcm "Tell me about 黄芪 (Astragalus) — properties, compounds, and clinical evidence"
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Formula analysis**
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
$ tcm "Analyze the composition of 四君子汤 using the 君臣佐使 framework"
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Syndrome differentiation**
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
$ tcm "Patient has fatigue, loose stools, poor appetite, pale tongue. What TCM syndrome?"
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Network pharmacology**
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
$ tcm "Build a network pharmacology analysis for 补中益气汤 against diabetes targets"
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**Safety check**
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
$ tcm "Check interactions between 人参, 藜芦, and Warfarin"
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Key Features
|
|
139
|
+
|
|
140
|
+
### 30+ Domain Tools
|
|
141
|
+
|
|
142
|
+
| Category | Examples |
|
|
143
|
+
| --- | --- |
|
|
144
|
+
| **Herbs** | Lookup, property classification, meridian search, compound listing |
|
|
145
|
+
| **Formulas** | Classical formula search, 君臣佐使 analysis, modifications |
|
|
146
|
+
| **Syndromes** | Pattern differentiation, symptom-to-syndrome mapping, treatment plans |
|
|
147
|
+
| **Compounds** | Active compound search, ADMET prediction, target identification |
|
|
148
|
+
| **Pharmacology** | Network pharmacology, pathway enrichment, herb-target networks |
|
|
149
|
+
| **Interactions** | 十八反/十九畏 checks, herb-drug interactions, formula safety |
|
|
150
|
+
| **Literature** | PubMed search, systematic review finder, CNKI integration |
|
|
151
|
+
| **Meridians** | Channel lookup, Five Element associations, meridian-herb mapping |
|
|
152
|
+
| **Safety** | Toxicity profiling, pregnancy safety, dosage validation |
|
|
153
|
+
| **Modern** | Clinical trial search, ICD-10 mapping, evidence summaries |
|
|
154
|
+
| **Data APIs** | TCMSP, UniProt, STRING, KEGG, ClinicalTrials.gov, Open Targets |
|
|
155
|
+
| **Code** | Python sandbox for custom analysis (experimental) |
|
|
156
|
+
|
|
157
|
+
List all tools and their status:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
tcm tool list
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Supported Models
|
|
164
|
+
|
|
165
|
+
| Provider | Model | Context | Notes |
|
|
166
|
+
| --- | --- | --- | --- |
|
|
167
|
+
| OpenAI | `gpt-4o` | 128k | Default — best balance |
|
|
168
|
+
| OpenAI | `gpt-4o-mini` | 128k | Fast and affordable |
|
|
169
|
+
| OpenAI | `o3-mini` | 200k | Reasoning model |
|
|
170
|
+
| OpenAI | `gpt-4.1` | 1M | Latest flagship with 1M context |
|
|
171
|
+
| OpenAI | `gpt-4.1-mini` | 1M | Balanced speed and intelligence |
|
|
172
|
+
| OpenAI | `gpt-4.1-nano` | 1M | Fastest, most cost-effective |
|
|
173
|
+
|
|
174
|
+
Switch models:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
tcm model list # Show all models with pricing
|
|
178
|
+
tcm model set gpt-4o # Switch to GPT-4o
|
|
179
|
+
tcm model show # Show current model
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Local Datasets
|
|
183
|
+
|
|
184
|
+
Without local data, tcm works via database APIs and built-in knowledge. To boost accuracy and offline support, install local datasets:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
tcm data pull herbs # Install bundled herb monograph data (instant)
|
|
188
|
+
tcm data pull formulas # Install bundled classical formula data (instant)
|
|
189
|
+
tcm data pull tcmsp # TCMSP — herbs, compounds, targets (~50 MB)
|
|
190
|
+
tcm data pull tcmid # TCMID — herb-compound-disease (~30 MB)
|
|
191
|
+
tcm data pull batman # BATMAN-TCM bioinformatics data (~100 MB)
|
|
192
|
+
tcm data pull symmap # SymMap symptom-mapping database (~20 MB)
|
|
193
|
+
tcm data status # Show all dataset statuses
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**Install modes:**
|
|
197
|
+
- `herbs` and `formulas` install instantly from bundled package data.
|
|
198
|
+
- Datasets with a direct download URL are fetched automatically with a progress bar and extracted.
|
|
199
|
+
- Datasets that require registration (tcmsp, tcmid, batman, symmap) print step-by-step instructions. After downloading manually, register the file:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
tcm data import tcmsp ~/Downloads/tcmsp.zip
|
|
203
|
+
tcm data import tcmsp ~/Downloads/tcmsp-extracted/ # or a directory
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Use `--force` to re-download or reinstall any dataset:
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
tcm data pull herbs --force
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Configuration
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
tcm config show # Show all settings
|
|
216
|
+
tcm config set key value # Set a value
|
|
217
|
+
tcm config get key # Get a single value
|
|
218
|
+
tcm config validate # Check for issues
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Config is stored at `~/.tcm/config.json`.
|
|
222
|
+
|
|
223
|
+
### Common config keys
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
tcm config set llm.provider openai # openai or compatible
|
|
227
|
+
tcm config set llm.model gpt-4o
|
|
228
|
+
tcm config set ui.language zh # en (default) or zh
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Agent profiles
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
tcm config set agent.profile research # Default — balanced, allows hypotheses
|
|
235
|
+
tcm config set agent.profile clinical # Strict evidence only, no hypotheses
|
|
236
|
+
tcm config set agent.profile education # Relaxed, creative responses
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Troubleshooting
|
|
240
|
+
|
|
241
|
+
| Symptom | Fix |
|
|
242
|
+
| --- | --- |
|
|
243
|
+
| `tcm` fails at startup | `tcm doctor` |
|
|
244
|
+
| Authentication error | `tcm setup` or `tcm keys` |
|
|
245
|
+
| Missing API key | `export OPENAI_API_KEY=...` or `tcm config set llm.openai_api_key ...` |
|
|
246
|
+
| Missing dependency | `pip install "tcm-cli[all]"` |
|
|
247
|
+
| Tool module failed | `tcm tool list` — check for load errors |
|
|
248
|
+
|
|
249
|
+
## Contributing
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
git clone https://github.com/tigerneil/tcm-cli.git
|
|
253
|
+
cd tcm-cli
|
|
254
|
+
pip install -e ".[dev]"
|
|
255
|
+
tcm setup
|
|
256
|
+
pytest tests/
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## License
|
|
260
|
+
|
|
261
|
+
MIT
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="630" viewBox="0 0 1200 630">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="g" x1="0" y1="0" x2="1" y2="1">
|
|
4
|
+
<stop offset="0" stop-color="#0b0b0b"/>
|
|
5
|
+
<stop offset="1" stop-color="#15151a"/>
|
|
6
|
+
</linearGradient>
|
|
7
|
+
</defs>
|
|
8
|
+
<rect width="1200" height="630" fill="url(#g)"/>
|
|
9
|
+
<rect x="80" y="120" width="120" height="120" rx="24" fill="#c8a85c"/>
|
|
10
|
+
<path d="M112 168h56M112 208h42M112 248h56" stroke="#0b0b0b" stroke-width="10" stroke-linecap="round"/>
|
|
11
|
+
<text x="240" y="180" font-family="-apple-system,Segoe UI,Roboto,Ubuntu,Arial,sans-serif" font-size="64" fill="#e8eaed" font-weight="700">TCM CLI</text>
|
|
12
|
+
<text x="240" y="240" font-family="-apple-system,Segoe UI,Roboto,Ubuntu,Arial,sans-serif" font-size="34" fill="#cfd3d7">Traditional Chinese Medicine research agent</text>
|
|
13
|
+
<text x="240" y="300" font-family="-apple-system,Segoe UI,Roboto,Ubuntu,Arial,sans-serif" font-size="26" fill="#c6c9ce">Ask in natural language → plan, execute tools, validate, conclude.</text>
|
|
14
|
+
</svg>
|