Tiangong KB Textbook Search
Use this skill for Tiangong textbook-source retrieval. It is intentionally
single-source: always search textbook, never all, course, or edu.
Prerequisites
- The wrapper defaults to
npx @tiangong-ai/cli@0.0.19; users do not need a
preinstalled CLI. Set TIANGONG_AI_CLI or TIANGONG_AI_CLI_BIN only to
override the CLI entrypoint.
- Set the authentication environment variables expected by
tiangong-ai.
- When
request_file / input_file is provided, the wrapper loads .env from
that file's directory by default. env_file can point to a different dotenv
file. Loaded dotenv values only fill unset environment variables; explicit
JSON fields such as api_key, textbook_api_key, and api_base_url are
passed as CLI flags and take precedence.
- Optionally set
TIANGONG_AI_API_BASE_URL; the CLI accepts a Supabase project
root, /functions/v1, or /rest/v1 and derives Functions URLs.
Search
For normal searches, pass a query:
./scripts/textbook_search.sh '{
"query": "activated sludge process principles",
"top_k": 5
}'
The script calls:
npx @tiangong-ai/cli@0.0.19 education search --query <query> --sources textbook --json
For exact edge-function payloads, provide request_file or input_file:
./scripts/textbook_search.sh '{
"request_file": "./textbook-request.json",
"dry_run": true
}'
Raw Payload Filters
Wrapper JSON can include inline raw textbook_search fields; the wrapper will
forward them through the CLI --input path. The same payload can also be put in
request_file / input_file:
{
"query": "如何减排二氧化碳?",
"filter": {
"isbn_number": ["9787030641274"]
},
"datefilter": {
"publication_date": { "gte": 1262304000 }
},
"topK": 5,
"extK": 1
}
filter: metadata term filters, shaped as { "field": ["value"] }.
datefilter: numeric range filters, shaped as
{ "field": { "gte"?: number, "lte"?: number } }, for indexed numeric/date
metadata fields.
topK, extK: raw edge-function names for result count and adjacent chunk
expansion.
getMeta is not supported by textbook_search.
Input Fields
query or input: convenience query text.
request_file or input_file: JSON body forwarded unchanged.
env_file: optional dotenv file. Without it, request_file /
input_file causes the wrapper to load .env from that file's directory.
filter, datefilter, topK, extK: optional inline raw payload fields
for textbook search.
sources: optional compatibility field; only textbook or default is
accepted.
dry_run: true to return the exact request plan with masked credentials.
api_base_url, api_key, textbook_api_key.
textbook_url, region, timeout.
top_k, ext_k: only used in query mode.
1---2name: tiangong-kb-textbook-search3description: Search Tiangong knowledge-base textbook sources through the Tiangong AI CLI. Use for textbook-style explanations and reference material only. This skill searches only the textbook source, not course or edu.4---5
6# Tiangong KB Textbook Search
7
8Use this skill for Tiangong textbook-source retrieval. It is intentionally
9single-source: always search `textbook`, never `all`, `course`, or `edu`.
10
11## Prerequisites
12
13- The wrapper defaults to `npx @tiangong-ai/cli@0.0.19`; users do not need a
14 preinstalled CLI. Set `TIANGONG_AI_CLI` or `TIANGONG_AI_CLI_BIN` only to
15 override the CLI entrypoint.
16- Set the authentication environment variables expected by `tiangong-ai`.
17- When `request_file` / `input_file` is provided, the wrapper loads `.env` from
18 that file's directory by default. `env_file` can point to a different dotenv
19 file. Loaded dotenv values only fill unset environment variables; explicit
20 JSON fields such as `api_key`, `textbook_api_key`, and `api_base_url` are
21 passed as CLI flags and take precedence.
22- Optionally set `TIANGONG_AI_API_BASE_URL`; the CLI accepts a Supabase project
23 root, `/functions/v1`, or `/rest/v1` and derives Functions URLs.
24
25## Search
26
27For normal searches, pass a query:
28
29```bash
30./scripts/textbook_search.sh '{
31 "query": "activated sludge process principles",
32 "top_k": 5
33}'
34```
35
36The script calls:
37
38```bash
39npx @tiangong-ai/cli@0.0.19 education search --query <query> --sources textbook --json
40```
41
42For exact edge-function payloads, provide `request_file` or `input_file`:
43
44```bash
45./scripts/textbook_search.sh '{
46 "request_file": "./textbook-request.json",
47 "dry_run": true
48}'
49```
50
51## Raw Payload Filters
52
53Wrapper JSON can include inline raw `textbook_search` fields; the wrapper will
54forward them through the CLI `--input` path. The same payload can also be put in
55`request_file` / `input_file`:
56
57```json
58{
59 "query": "如何减排二氧化碳?",
60 "filter": {
61 "isbn_number": ["9787030641274"]
62 },
63 "datefilter": {
64 "publication_date": { "gte": 1262304000 }
65 },
66 "topK": 5,
67 "extK": 1
68}
69```
70
71- `filter`: metadata term filters, shaped as `{ "field": ["value"] }`.
72- `datefilter`: numeric range filters, shaped as
73 `{ "field": { "gte"?: number, "lte"?: number } }`, for indexed numeric/date
74 metadata fields.
75- `topK`, `extK`: raw edge-function names for result count and adjacent chunk
76 expansion.
77- `getMeta` is not supported by `textbook_search`.
78
79## Input Fields
80
81- `query` or `input`: convenience query text.
82- `request_file` or `input_file`: JSON body forwarded unchanged.
83- `env_file`: optional dotenv file. Without it, `request_file` /
84 `input_file` causes the wrapper to load `.env` from that file's directory.
85- `filter`, `datefilter`, `topK`, `extK`: optional inline raw payload fields
86 for textbook search.
87- `sources`: optional compatibility field; only `textbook` or `default` is
88 accepted.
89- `dry_run`: true to return the exact request plan with masked credentials.
90- `api_base_url`, `api_key`, `textbook_api_key`.
91- `textbook_url`, `region`, `timeout`.
92- `top_k`, `ext_k`: only used in query mode.