gsas-query 0.2.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.
@@ -0,0 +1,29 @@
1
+ # ── LLM Backend ──────────────────────────────────────────────────────────────
2
+ # "ollama" — fully local, free, no data leaves the network (RECOMMENDED)
3
+ # "anthropic" — Anthropic Claude API (requires ANTHROPIC_API_KEY below)
4
+ LLM_BACKEND=ollama
5
+
6
+ # ── Ollama settings (used when LLM_BACKEND=ollama) ───────────────────────────
7
+ # Install Ollama: https://ollama.com
8
+ # Pull a model: ollama pull llama3
9
+ # Recommended models (balance of quality and speed):
10
+ # llama3 — 8B params, good quality, ~8 GB RAM
11
+ # llama3:70b — 70B params, excellent quality, ~48 GB RAM / GPU
12
+ # mistral — fast, ~5 GB RAM
13
+ # phi3 — lightweight, ~4 GB RAM
14
+ OLLAMA_URL=http://localhost:11434
15
+ OLLAMA_MODEL=llama3
16
+
17
+ # ── Anthropic API (only needed if LLM_BACKEND=anthropic) ─────────────────────
18
+ # ANTHROPIC_API_KEY=sk-ant-...
19
+ # ANTHROPIC_MODEL=claude-sonnet-4-6
20
+
21
+ # ── Server settings ───────────────────────────────────────────────────────────
22
+ # Comma-separated origins allowed for CORS. Use "*" to allow all.
23
+ ALLOWED_ORIGINS=*
24
+
25
+ # Requests per minute per IP (0 to disable)
26
+ RATE_LIMIT_RPM=30
27
+
28
+ # Secret key required for POST /ingest (leave blank to disable auth on that route)
29
+ ADMIN_KEY=
@@ -0,0 +1,72 @@
1
+ name: Build ChromaDB index
2
+
3
+ on:
4
+ push:
5
+ branches: ["main"]
6
+ paths:
7
+ - "gsas_query/sources.py"
8
+ - "gsas_query/ingest.py"
9
+ - ".github/workflows/ingest.yml"
10
+ workflow_dispatch:
11
+ inputs:
12
+ include_pdfs:
13
+ description: "Include PDF ingestion (slower, needs more RAM)"
14
+ type: boolean
15
+ default: false
16
+
17
+ jobs:
18
+ ingest:
19
+ runs-on: ubuntu-latest
20
+ timeout-minutes: 45
21
+ permissions:
22
+ contents: read
23
+
24
+ steps:
25
+ - uses: actions/checkout@v4
26
+
27
+ - uses: actions/setup-python@v5
28
+ with:
29
+ python-version: "3.12"
30
+
31
+ - name: Cache pip
32
+ uses: actions/cache@v4
33
+ with:
34
+ path: ~/.cache/pip
35
+ key: pip-ingest-${{ hashFiles('pyproject.toml') }}
36
+
37
+ # CPU-only torch is ~400 MB; the default CUDA wheel is ~2.5 GB and
38
+ # causes OOM (exit 143) on GitHub-hosted runners.
39
+ - name: Install CPU-only PyTorch
40
+ run: pip install torch --index-url https://download.pytorch.org/whl/cpu
41
+
42
+ - name: Install dependencies
43
+ run: pip install chromadb sentence-transformers beautifulsoup4 requests pypdf lxml
44
+
45
+ - name: Install gsas_query package
46
+ run: pip install -e .
47
+
48
+ - name: Build ChromaDB index (HTML only by default)
49
+ env:
50
+ TOKENIZERS_PARALLELISM: "false"
51
+ OMP_NUM_THREADS: "1"
52
+ GSAS_QUERY_DATA_DIR: ${{ github.workspace }}/ci_data
53
+ run: python ingest.py --html-only
54
+
55
+ - name: Show index stats
56
+ env:
57
+ GSAS_QUERY_DATA_DIR: ${{ github.workspace }}/ci_data
58
+ run: |
59
+ python -c "
60
+ import chromadb, os
61
+ path = os.path.join(os.environ['GSAS_QUERY_DATA_DIR'], 'chroma_db')
62
+ c = chromadb.PersistentClient(path=path)
63
+ col = c.get_collection('gsasii_docs')
64
+ print(f'Chunks in index: {col.count()}')
65
+ "
66
+
67
+ - name: Upload chroma_db artifact
68
+ uses: actions/upload-artifact@v4
69
+ with:
70
+ name: chroma_db
71
+ path: ci_data/chroma_db/
72
+ retention-days: 90
@@ -0,0 +1,29 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ build-and-publish:
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: read # required for actions/checkout
13
+ id-token: write # required for OIDC trusted publishing
14
+
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - uses: actions/setup-python@v5
19
+ with:
20
+ python-version: "3.11"
21
+
22
+ - name: Install build
23
+ run: pip install build
24
+
25
+ - name: Build package
26
+ run: python -m build
27
+
28
+ - name: Publish to PyPI
29
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,23 @@
1
+ # Environment
2
+ .env
3
+ *.env.local
4
+
5
+ # Vector store (rebuild with ingest.py — do not commit)
6
+ chroma_db/
7
+
8
+ # Python
9
+ __pycache__/
10
+ *.py[cod]
11
+ *.pyo
12
+ .venv/
13
+ venv/
14
+ env/
15
+ *.egg-info/
16
+ dist/
17
+ build/
18
+
19
+ # macOS
20
+ .DS_Store
21
+
22
+ # Downloaded PDFs (re-fetched during ingestion)
23
+ *.pdf
@@ -0,0 +1,283 @@
1
+ Metadata-Version: 2.4
2
+ Name: gsas-query
3
+ Version: 0.2.0
4
+ Summary: GSAS-II Documentation Assistant — semantic search and AI answers over GSAS-II tutorials and help pages
5
+ Project-URL: Repository, https://github.com/pawantr/Query-GSAS
6
+ Author: Pawan Tripathi
7
+ License: MIT
8
+ Keywords: crystallography,documentation,gsas,rag,xrd
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Scientific/Engineering :: Chemistry
14
+ Requires-Python: >=3.10
15
+ Requires-Dist: beautifulsoup4>=4.12.0
16
+ Requires-Dist: chromadb>=0.5.0
17
+ Requires-Dist: fastapi>=0.110.0
18
+ Requires-Dist: httpx>=0.27.0
19
+ Requires-Dist: lxml>=5.0.0
20
+ Requires-Dist: pydantic>=2.0.0
21
+ Requires-Dist: pypdf>=4.0.0
22
+ Requires-Dist: python-dotenv>=1.0.0
23
+ Requires-Dist: requests>=2.31.0
24
+ Requires-Dist: sentence-transformers>=3.0.0
25
+ Requires-Dist: uvicorn[standard]>=0.29.0
26
+ Provides-Extra: anthropic
27
+ Requires-Dist: anthropic>=0.25.0; extra == 'anthropic'
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest>=8.0; extra == 'dev'
30
+ Provides-Extra: gui
31
+ Requires-Dist: wxpython>=4.2.0; extra == 'gui'
32
+ Description-Content-Type: text/markdown
33
+
34
+ # gsas-query — GSAS-II Documentation Assistant
35
+
36
+ Semantic search + AI answers over the full GSAS-II documentation set:
37
+ **129 HTML pages** (home, help, and all 62 tutorials) plus the
38
+ **Programmer's Guide** and **Powder Crystallography** book PDFs.
39
+
40
+ Answers include **inline citations** — every `[N]` in the response is a
41
+ clickable link to the exact documentation section that supported that sentence.
42
+
43
+ All embedding and retrieval runs on your machine — no data is sent externally
44
+ unless you explicitly choose the Anthropic API backend.
45
+
46
+ ---
47
+
48
+ ## Installation
49
+
50
+ ### pip
51
+
52
+ ```bash
53
+ pip install gsas-query
54
+ ```
55
+
56
+ Or install directly from source:
57
+
58
+ ```bash
59
+ pip install git+https://github.com/pawantr/Query-GSAS.git
60
+ ```
61
+
62
+ ### conda
63
+
64
+ ```bash
65
+ conda install -c conda-forge gsas-query
66
+ ```
67
+
68
+ ### Into an existing GSAS-II environment
69
+
70
+ ```bash
71
+ # Activate the GSAS-II conda environment first, then:
72
+ pip install gsas-query
73
+ ```
74
+
75
+ ### Development / editable install
76
+
77
+ ```bash
78
+ git clone https://github.com/pawantr/Query-GSAS.git
79
+ cd Query-GSAS
80
+ pip install -e ".[dev]"
81
+ ```
82
+
83
+ ---
84
+
85
+ ## Ollama — free local LLM (recommended)
86
+
87
+ ```bash
88
+ brew install ollama # macOS; see https://ollama.com for other platforms
89
+ ollama serve & # start the local server
90
+ ollama pull llama3 # ~5 GB one-time download
91
+ ```
92
+
93
+ Other model options: `llama3:70b` (better quality, ~40 GB), `mistral` (faster, ~4 GB).
94
+
95
+ ---
96
+
97
+ ## First-time setup — index the documentation
98
+
99
+ Run once, or again when the docs are updated. Fetches ~130 web pages and 2 PDFs,
100
+ embeds everything locally. Takes ~10–20 minutes.
101
+
102
+ The index is stored in `~/.gsas_query/chroma_db` (override with `GSAS_QUERY_DATA_DIR`).
103
+
104
+ ```bash
105
+ gsas-query --setup # all sources (HTML + PDFs)
106
+ gsas-query --setup --html-only # skip PDFs, faster (~5 min)
107
+ gsas-query --setup --reset # drop index and rebuild from scratch
108
+ ```
109
+
110
+ ---
111
+
112
+ ## Usage
113
+
114
+ ### Command-line — single question
115
+
116
+ ```bash
117
+ gsas-query "How do I set up a sequential refinement?"
118
+ gsas-query "What parameters control the background in Rietveld?"
119
+ gsas-query "How do I export a CIF for publication?"
120
+ ```
121
+
122
+ ### Command-line — interactive REPL
123
+
124
+ Multi-turn conversation that remembers previous questions in the session.
125
+
126
+ ```bash
127
+ gsas-query
128
+ ```
129
+
130
+ ```
131
+ GSAS-II Documentation Assistant
132
+ ════════════════════════════════════════════════════════════════════════════════
133
+
134
+ Knowledge base: 3,847 indexed chunks.
135
+ LLM backend: ollama
136
+ Type your question and press Enter. 'clear' resets history, 'quit' exits.
137
+
138
+ ────────────────────────────────────────────────────────────────────────────────
139
+ You: How do I constrain lattice parameters?
140
+ Thinking…
141
+ Assistant: To constrain lattice parameters in GSAS-II, open the Constraints
142
+ tab in the Phase panel [1]…
143
+
144
+ Sources:
145
+ [94%] Help: Phase General › Constraints
146
+ https://advancedphotonsource.github.io/GSAS-II-tutorials/help/phasegeneral.html
147
+ ```
148
+
149
+ Commands inside the REPL: `clear` (reset history), `quit` / `exit` (exit).
150
+
151
+ ### Desktop GUI
152
+
153
+ Opens a standalone floating dialog — stays open while you work in GSAS-II.
154
+
155
+ ```bash
156
+ gsas-query --gui
157
+ ```
158
+
159
+ ### Embed in GSAS-II Help menu
160
+
161
+ Add one call to the GSAS-II menu handler (e.g. in `GSASIIctrl.py`):
162
+
163
+ ```python
164
+ def OnDocAssistant(self, event):
165
+ try:
166
+ from gsas_query.gui import show_assistant
167
+ show_assistant(self) # self = GSAS-II main frame
168
+ except ImportError:
169
+ wx.MessageBox(
170
+ "GSAS-II Assistant not installed.\n"
171
+ "Run: pip install gsas-query",
172
+ "Not available"
173
+ )
174
+ ```
175
+
176
+ `show_assistant()` is idempotent — calling it a second time raises the existing
177
+ window rather than opening a duplicate.
178
+
179
+ ### Web UI
180
+
181
+ ```bash
182
+ gsas-query-web # serves on 0.0.0.0:8000
183
+ HOST=127.0.0.1 PORT=8765 gsas-query-web
184
+ ```
185
+
186
+ Then open `http://localhost:8000` in a browser. The web UI shows inline citations
187
+ as clickable superscript links and source chips below each answer.
188
+
189
+ ---
190
+
191
+ ## CLI flags reference
192
+
193
+ | Flag | Description |
194
+ |---|---|
195
+ | `--setup` | Index all documentation sources |
196
+ | `--setup --reset` | Drop the existing index and rebuild |
197
+ | `--setup --html-only` | Index HTML only, skip PDFs |
198
+ | `--gui` | Open the wxPython desktop assistant |
199
+ | `--backend ollama\|anthropic\|retrieval` | Override `LLM_BACKEND` env var |
200
+ | `--model <name>` | Override Ollama or Anthropic model |
201
+ | `--stats` | Show chunk count, backend, and DB path |
202
+
203
+ ---
204
+
205
+ ## LLM backend configuration
206
+
207
+ Set `LLM_BACKEND` in a `.env` file or the environment:
208
+
209
+ | Backend | Config | Notes |
210
+ |---|---|---|
211
+ | `ollama` (default) | `OLLAMA_MODEL=llama3` | Free, fully local — no data leaves the network |
212
+ | `anthropic` | `ANTHROPIC_API_KEY=sk-ant-…` | Better answers; queries sent to Anthropic |
213
+ | `retrieval` | — | No LLM — returns raw matched chunks; useful offline or for testing |
214
+
215
+ ```bash
216
+ gsas-query --backend retrieval "What is Le Bail extraction?"
217
+ gsas-query --backend ollama --model mistral "How do I index peaks?"
218
+ ```
219
+
220
+ ---
221
+
222
+ ## Inline citations
223
+
224
+ When using Ollama or Anthropic backends, answers contain `[N]` markers inline.
225
+ In the **web UI** these render as clickable superscript links opening the exact
226
+ source section. In the **CLI**, source URLs are listed below the answer with
227
+ relevance scores.
228
+
229
+ ---
230
+
231
+ ## Doc sources
232
+
233
+ | Category | Count |
234
+ |---|---|
235
+ | Home / installation pages | 22 |
236
+ | Help pages (all sections) | 42 |
237
+ | Tutorials | 62 |
238
+ | Programmer's Guide (PDF, readthedocs) | 1 |
239
+ | Powder Crystallography book (PDF, auto-fetches latest release) | 1 |
240
+ | **Total** | **128 sources** |
241
+
242
+ All HTML sources are fetched from
243
+ `https://advancedphotonsource.github.io/GSAS-II-tutorials/`.
244
+ The book PDF is fetched from the latest GitHub release of
245
+ [briantoby/PowderCrystallography](https://github.com/briantoby/PowderCrystallography/releases).
246
+
247
+ ---
248
+
249
+ ## Re-indexing when docs update
250
+
251
+ ```bash
252
+ gsas-query --setup --reset
253
+ ```
254
+
255
+ Or trigger via the web API (requires `ADMIN_KEY` set in `.env`):
256
+
257
+ ```bash
258
+ curl -X POST http://localhost:8000/ingest -H "X-Admin-Key: your-key"
259
+ ```
260
+
261
+ ---
262
+
263
+ ## Security and deployment notes
264
+
265
+ - All embeddings and vector search run locally (sentence-transformers, ChromaDB).
266
+ - Ollama runs entirely on-premises — no queries leave the network.
267
+ - The `anthropic` backend sends question text and retrieved doc chunks to Anthropic.
268
+ Do not use it in air-gapped or data-sensitive environments.
269
+ - The web server applies per-IP rate limiting (default 30 req/min, configurable
270
+ via `RATE_LIMIT_RPM` in `.env`).
271
+ - The `/ingest` endpoint is protected by `X-Admin-Key`; leave `ADMIN_KEY` blank
272
+ to disable remote re-indexing.
273
+
274
+ ---
275
+
276
+ ## User data directory
277
+
278
+ The ChromaDB index is stored at `~/.gsas_query/chroma_db` by default.
279
+ Override with the `GSAS_QUERY_DATA_DIR` environment variable:
280
+
281
+ ```bash
282
+ GSAS_QUERY_DATA_DIR=/data/gsas_query gsas-query --setup
283
+ ```
@@ -0,0 +1,250 @@
1
+ # gsas-query — GSAS-II Documentation Assistant
2
+
3
+ Semantic search + AI answers over the full GSAS-II documentation set:
4
+ **129 HTML pages** (home, help, and all 62 tutorials) plus the
5
+ **Programmer's Guide** and **Powder Crystallography** book PDFs.
6
+
7
+ Answers include **inline citations** — every `[N]` in the response is a
8
+ clickable link to the exact documentation section that supported that sentence.
9
+
10
+ All embedding and retrieval runs on your machine — no data is sent externally
11
+ unless you explicitly choose the Anthropic API backend.
12
+
13
+ ---
14
+
15
+ ## Installation
16
+
17
+ ### pip
18
+
19
+ ```bash
20
+ pip install gsas-query
21
+ ```
22
+
23
+ Or install directly from source:
24
+
25
+ ```bash
26
+ pip install git+https://github.com/pawantr/Query-GSAS.git
27
+ ```
28
+
29
+ ### conda
30
+
31
+ ```bash
32
+ conda install -c conda-forge gsas-query
33
+ ```
34
+
35
+ ### Into an existing GSAS-II environment
36
+
37
+ ```bash
38
+ # Activate the GSAS-II conda environment first, then:
39
+ pip install gsas-query
40
+ ```
41
+
42
+ ### Development / editable install
43
+
44
+ ```bash
45
+ git clone https://github.com/pawantr/Query-GSAS.git
46
+ cd Query-GSAS
47
+ pip install -e ".[dev]"
48
+ ```
49
+
50
+ ---
51
+
52
+ ## Ollama — free local LLM (recommended)
53
+
54
+ ```bash
55
+ brew install ollama # macOS; see https://ollama.com for other platforms
56
+ ollama serve & # start the local server
57
+ ollama pull llama3 # ~5 GB one-time download
58
+ ```
59
+
60
+ Other model options: `llama3:70b` (better quality, ~40 GB), `mistral` (faster, ~4 GB).
61
+
62
+ ---
63
+
64
+ ## First-time setup — index the documentation
65
+
66
+ Run once, or again when the docs are updated. Fetches ~130 web pages and 2 PDFs,
67
+ embeds everything locally. Takes ~10–20 minutes.
68
+
69
+ The index is stored in `~/.gsas_query/chroma_db` (override with `GSAS_QUERY_DATA_DIR`).
70
+
71
+ ```bash
72
+ gsas-query --setup # all sources (HTML + PDFs)
73
+ gsas-query --setup --html-only # skip PDFs, faster (~5 min)
74
+ gsas-query --setup --reset # drop index and rebuild from scratch
75
+ ```
76
+
77
+ ---
78
+
79
+ ## Usage
80
+
81
+ ### Command-line — single question
82
+
83
+ ```bash
84
+ gsas-query "How do I set up a sequential refinement?"
85
+ gsas-query "What parameters control the background in Rietveld?"
86
+ gsas-query "How do I export a CIF for publication?"
87
+ ```
88
+
89
+ ### Command-line — interactive REPL
90
+
91
+ Multi-turn conversation that remembers previous questions in the session.
92
+
93
+ ```bash
94
+ gsas-query
95
+ ```
96
+
97
+ ```
98
+ GSAS-II Documentation Assistant
99
+ ════════════════════════════════════════════════════════════════════════════════
100
+
101
+ Knowledge base: 3,847 indexed chunks.
102
+ LLM backend: ollama
103
+ Type your question and press Enter. 'clear' resets history, 'quit' exits.
104
+
105
+ ────────────────────────────────────────────────────────────────────────────────
106
+ You: How do I constrain lattice parameters?
107
+ Thinking…
108
+ Assistant: To constrain lattice parameters in GSAS-II, open the Constraints
109
+ tab in the Phase panel [1]…
110
+
111
+ Sources:
112
+ [94%] Help: Phase General › Constraints
113
+ https://advancedphotonsource.github.io/GSAS-II-tutorials/help/phasegeneral.html
114
+ ```
115
+
116
+ Commands inside the REPL: `clear` (reset history), `quit` / `exit` (exit).
117
+
118
+ ### Desktop GUI
119
+
120
+ Opens a standalone floating dialog — stays open while you work in GSAS-II.
121
+
122
+ ```bash
123
+ gsas-query --gui
124
+ ```
125
+
126
+ ### Embed in GSAS-II Help menu
127
+
128
+ Add one call to the GSAS-II menu handler (e.g. in `GSASIIctrl.py`):
129
+
130
+ ```python
131
+ def OnDocAssistant(self, event):
132
+ try:
133
+ from gsas_query.gui import show_assistant
134
+ show_assistant(self) # self = GSAS-II main frame
135
+ except ImportError:
136
+ wx.MessageBox(
137
+ "GSAS-II Assistant not installed.\n"
138
+ "Run: pip install gsas-query",
139
+ "Not available"
140
+ )
141
+ ```
142
+
143
+ `show_assistant()` is idempotent — calling it a second time raises the existing
144
+ window rather than opening a duplicate.
145
+
146
+ ### Web UI
147
+
148
+ ```bash
149
+ gsas-query-web # serves on 0.0.0.0:8000
150
+ HOST=127.0.0.1 PORT=8765 gsas-query-web
151
+ ```
152
+
153
+ Then open `http://localhost:8000` in a browser. The web UI shows inline citations
154
+ as clickable superscript links and source chips below each answer.
155
+
156
+ ---
157
+
158
+ ## CLI flags reference
159
+
160
+ | Flag | Description |
161
+ |---|---|
162
+ | `--setup` | Index all documentation sources |
163
+ | `--setup --reset` | Drop the existing index and rebuild |
164
+ | `--setup --html-only` | Index HTML only, skip PDFs |
165
+ | `--gui` | Open the wxPython desktop assistant |
166
+ | `--backend ollama\|anthropic\|retrieval` | Override `LLM_BACKEND` env var |
167
+ | `--model <name>` | Override Ollama or Anthropic model |
168
+ | `--stats` | Show chunk count, backend, and DB path |
169
+
170
+ ---
171
+
172
+ ## LLM backend configuration
173
+
174
+ Set `LLM_BACKEND` in a `.env` file or the environment:
175
+
176
+ | Backend | Config | Notes |
177
+ |---|---|---|
178
+ | `ollama` (default) | `OLLAMA_MODEL=llama3` | Free, fully local — no data leaves the network |
179
+ | `anthropic` | `ANTHROPIC_API_KEY=sk-ant-…` | Better answers; queries sent to Anthropic |
180
+ | `retrieval` | — | No LLM — returns raw matched chunks; useful offline or for testing |
181
+
182
+ ```bash
183
+ gsas-query --backend retrieval "What is Le Bail extraction?"
184
+ gsas-query --backend ollama --model mistral "How do I index peaks?"
185
+ ```
186
+
187
+ ---
188
+
189
+ ## Inline citations
190
+
191
+ When using Ollama or Anthropic backends, answers contain `[N]` markers inline.
192
+ In the **web UI** these render as clickable superscript links opening the exact
193
+ source section. In the **CLI**, source URLs are listed below the answer with
194
+ relevance scores.
195
+
196
+ ---
197
+
198
+ ## Doc sources
199
+
200
+ | Category | Count |
201
+ |---|---|
202
+ | Home / installation pages | 22 |
203
+ | Help pages (all sections) | 42 |
204
+ | Tutorials | 62 |
205
+ | Programmer's Guide (PDF, readthedocs) | 1 |
206
+ | Powder Crystallography book (PDF, auto-fetches latest release) | 1 |
207
+ | **Total** | **128 sources** |
208
+
209
+ All HTML sources are fetched from
210
+ `https://advancedphotonsource.github.io/GSAS-II-tutorials/`.
211
+ The book PDF is fetched from the latest GitHub release of
212
+ [briantoby/PowderCrystallography](https://github.com/briantoby/PowderCrystallography/releases).
213
+
214
+ ---
215
+
216
+ ## Re-indexing when docs update
217
+
218
+ ```bash
219
+ gsas-query --setup --reset
220
+ ```
221
+
222
+ Or trigger via the web API (requires `ADMIN_KEY` set in `.env`):
223
+
224
+ ```bash
225
+ curl -X POST http://localhost:8000/ingest -H "X-Admin-Key: your-key"
226
+ ```
227
+
228
+ ---
229
+
230
+ ## Security and deployment notes
231
+
232
+ - All embeddings and vector search run locally (sentence-transformers, ChromaDB).
233
+ - Ollama runs entirely on-premises — no queries leave the network.
234
+ - The `anthropic` backend sends question text and retrieved doc chunks to Anthropic.
235
+ Do not use it in air-gapped or data-sensitive environments.
236
+ - The web server applies per-IP rate limiting (default 30 req/min, configurable
237
+ via `RATE_LIMIT_RPM` in `.env`).
238
+ - The `/ingest` endpoint is protected by `X-Admin-Key`; leave `ADMIN_KEY` blank
239
+ to disable remote re-indexing.
240
+
241
+ ---
242
+
243
+ ## User data directory
244
+
245
+ The ChromaDB index is stored at `~/.gsas_query/chroma_db` by default.
246
+ Override with the `GSAS_QUERY_DATA_DIR` environment variable:
247
+
248
+ ```bash
249
+ GSAS_QUERY_DATA_DIR=/data/gsas_query gsas-query --setup
250
+ ```
@@ -0,0 +1,4 @@
1
+ # Backwards-compatible stub — the app object is now in gsas_query.app.
2
+ # Start the server with: gsas-query-web
3
+ # or: uvicorn gsas_query.app:app
4
+ from gsas_query.app import app # noqa: F401
@@ -0,0 +1,6 @@
1
+ # Backwards-compatible stub — delegates to the gsas_query package.
2
+ # Run `gsas-query` instead if installed via pip.
3
+ from gsas_query.cli import main
4
+
5
+ if __name__ == "__main__":
6
+ main()