gla-api 1.2.5__cp312-none-any.whl

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.

Potentially problematic release.


This version of gla-api might be problematic. Click here for more details.

gla_api/__init__.pyc ADDED
Binary file
gla_api/__main__.pyc ADDED
Binary file
@@ -0,0 +1,12 @@
1
+ {
2
+ "v2": {
3
+ "GLA.pyc": "ab9e97e4f9b790dc73759fe58d8f2eaeb10beb22ca000ab78d9a434d90f15d40",
4
+ "gla_brain_dual.pyc": "0e4b5cee96ed725d1cd922c6c2a8791ccd4c1480564720f77f2e39b547d9098c",
5
+ "linguistic_safety.pyc": "69ec621edc161eae5412ee627f6c87418cdeedcfbcef981d252fd719989ac40b"
6
+ },
7
+ "v3": {
8
+ "GLA.pyc": "c68aa5dd41a40d5d7e20f09aae3eca5a7f3ac2df929805bb2cd8059a375361c9",
9
+ "gla_brain_dual.pyc": "ba8727f1c9aaa3e09bdc736baa177c49954801e0b28a4ed9d3746d2abf5fde74",
10
+ "linguistic_safety.pyc": "d9c99c0fac9d06cb3fcc582a16a45782b248373539a24b5a6e51b999fb4a55bb"
11
+ }
12
+ }
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
gla_api/_version.pyc ADDED
Binary file
gla_api/answer.pyc ADDED
Binary file
gla_api/cli.pyc ADDED
Binary file
gla_api/client.pyc ADDED
Binary file
gla_api/doctor.pyc ADDED
Binary file
gla_api/envfile.pyc ADDED
Binary file
gla_api/model.pyc ADDED
Binary file
gla_api/paths.pyc ADDED
Binary file
gla_api/py.typed ADDED
File without changes
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
gla_api/safety.pyc ADDED
Binary file
Binary file
gla_api/server/app.pyc ADDED
Binary file
Binary file
Binary file
Binary file
gla_api/server/run.pyc ADDED
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,574 @@
1
+ Metadata-Version: 2.1
2
+ Name: gla-api
3
+ Version: 1.2.5
4
+ Summary: The official library for GLA (Graph-Language Assistant) models by ATEC - run, serve and manage them from Python or as an OpenAI-compatible API server
5
+ Requires-Python: >=3.11,<3.15
6
+ License: Proprietary
7
+ Author: ATEC (Advancement Through Engineering & Creation)
8
+ Maintainer: ATEC (Advancement Through Engineering & Creation)
9
+ Keywords: GLA,Graph-Language Assistant,ATEC,code,AI,LLM,API,OpenAI-compatible,server
10
+ Project-URL: Homepage, https://pypi.org/project/gla-api/
11
+ Project-URL: Documentation, https://github.com/ATECTechnologies/Graph-Language-Assistant
12
+ Project-URL: License, https://github.com/ATECTechnologies/Graph-Language-Assistant/blob/main/LICENSE
13
+ Classifier: Operating System :: Microsoft :: Windows
14
+ Classifier: Operating System :: POSIX :: Linux
15
+ Classifier: Environment :: GPU :: NVIDIA CUDA
16
+ Classifier: License :: Other/Proprietary License
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Programming Language :: Python :: Free Threading :: 2 - Beta
22
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
23
+ Requires-Dist: torch>=2.5
24
+ Requires-Dist: numpy>=1.26
25
+ Requires-Dist: safetensors>=0.4.5
26
+ Requires-Dist: psutil>=5.9
27
+ Requires-Dist: tree-sitter>=0.23
28
+ Requires-Dist: tree-sitter-language-pack>=1.24,<2; python_version < '3.14'
29
+ Requires-Dist: pypdf>=4.0
30
+ Requires-Dist: starlette>=0.40,<2
31
+ Requires-Dist: uvicorn[standard]>=0.30
32
+ Requires-Dist: pydantic>=2.7,<3
33
+ Provides-Extra: server
34
+ Requires-Dist: redis>=5.0; extra == "server"
35
+ Requires-Dist: psycopg[binary]>=3.2; extra == "server"
36
+ Provides-Extra: grammars
37
+ Requires-Dist: tree-sitter-language-pack>=1.24,<2; extra == "grammars"
38
+ Provides-Extra: dev
39
+ Requires-Dist: pytest>=8; extra == "dev"
40
+ Description-Content-Type: text/markdown
41
+
42
+ # gla-api
43
+
44
+ **The official library for GLA models — Graph-Language Assistant, by ATEC (Advancement Through Engineering & Creation).**
45
+
46
+ `gla-api` runs a trained GLA model on your own computer or server and manages everything around it: an
47
+ OpenAI-compatible API server for your websites and apps, API keys with limits, a background service you can start and
48
+ stop, a chat in the terminal, speed tests, backups and a full system check. Windows and Linux, one or many NVIDIA GPUs.
49
+
50
+ ```bash
51
+ pip install gla-api
52
+ ```
53
+
54
+ Library page: **https://pypi.org/project/gla-api/**
55
+
56
+ | | |
57
+ |---|---|
58
+ | Version | **1.2.5** |
59
+ | Runs | **GLA 2.0** and **GLA 3.0** (the version is detected from the model folder) — the GLA 3.0 release needs 1.2.1 or newer |
60
+ | Code | compiled to native code (Windows `.pyd`, Linux `.so`) |
61
+ | Operating systems | Windows 10/11 (64-bit), Linux (x86-64) |
62
+ | Python | 3.11, 3.12, 3.13 or 3.14 (also the free-threaded 3.14t) |
63
+ | GPU | NVIDIA, any number; a 3.x model can be split over 2 or 3 GPUs per copy (a CPU works for testing) |
64
+ | Precision | FP32, BF16, FP16, FP8, FP4 — tested on your GPU, with automatic fallback |
65
+ | License | Proprietary (ATEC). Not open source — see [License](#license) |
66
+
67
+ ---
68
+
69
+ ## Contents
70
+
71
+ 1. [Install](#1-install)
72
+ 2. [Start in one minute](#2-start-in-one-minute)
73
+ 3. [Every command](#3-every-command)
74
+ 4. [Run the API server](#4-run-the-api-server)
75
+ 5. [API keys](#5-api-keys)
76
+ 6. [Settings](#6-settings)
77
+ 7. [Use it from Python](#7-use-it-from-python)
78
+ 8. [Call the server from any language](#8-call-the-server-from-any-language)
79
+ 9. [GPUs, splitting and precision](#9-gpus-splitting-and-precision)
80
+ 10. [Security](#10-security)
81
+ 11. [Troubleshooting](#11-troubleshooting)
82
+ 12. [What is new in 1.2.5 / upgrading](#12-what-is-new-in-125--upgrading)
83
+
84
+ ---
85
+
86
+ ## 1. Install
87
+
88
+ ```bash
89
+ pip install gla-api
90
+ ```
91
+
92
+ That one command installs the model runtime **and** the API server. Check it:
93
+
94
+ ```bash
95
+ gla-api --version
96
+ gla-api doctor --quick
97
+ ```
98
+
99
+ **NVIDIA GPU on Windows:** `pip` installs the CPU build of PyTorch by default. For your GPU, install the CUDA build
100
+ first (once), then the library:
101
+
102
+ ```bash
103
+ pip install torch --index-url https://download.pytorch.org/whl/cu128
104
+ pip install gla-api
105
+ ```
106
+
107
+ Update later with `pip install --upgrade gla-api` (`gla-api check-update` tells you when there is a new version).
108
+
109
+ > **`pip` not found on Windows?** Use `py -m pip install gla-api` and `py -m gla_api <command>` — they
110
+ > work the same everywhere. To get the short commands, reinstall Python with **"Add python.exe to PATH"** ticked.
111
+
112
+ **Several servers sharing one database (optional):** `pip install "gla-api[server]"` adds Redis and PostgreSQL
113
+ support. A single server needs nothing extra.
114
+
115
+ ---
116
+
117
+ ## 2. Start in one minute
118
+
119
+ ```bash
120
+ mkdir my-gla && cd my-gla
121
+ gla-api setup --owner my-website
122
+ ```
123
+
124
+ `setup` does everything a new folder needs, in one step:
125
+
126
+ 1. creates `.env` with a secret **admin token** and the model folder **`Model_GLA/`**;
127
+ 2. checks the model folder;
128
+ 3. creates your first **API key** and prints it (once — copy it).
129
+
130
+ Then copy the exported GLA model's files into `Model_GLA/` and:
131
+
132
+ ```bash
133
+ gla-api start # API server in the background: http://127.0.0.1:8000/v1
134
+ gla-api status # running? model loaded? how busy?
135
+ gla-api chat "Write a Python function that reverses a string"
136
+ gla-api stop
137
+ ```
138
+
139
+ A model folder holds only data — weights (`safetensors`), configuration, tokenizer and documents. No code is ever run
140
+ from it. A folder named `Model_CodeMind/` is found too.
141
+
142
+ ---
143
+
144
+ ## 3. Every command
145
+
146
+ Every command has its own help: `gla-api <command> --help`. All of them also work as
147
+ `py -m gla_api <command>` (or `python -m gla_api <command>`).
148
+
149
+ ### Set up and check
150
+
151
+ | command | what it does |
152
+ |---|---|
153
+ | `gla-api setup [--owner NAME] [--start]` | everything for a new folder: `.env`, `Model_GLA/`, first API key, next steps |
154
+ | `gla-api init` | only `.env` (admin token) and `Model_GLA/` |
155
+ | `gla-api doctor [--quick]` | full check: Python packages, PyTorch, every GPU, FP8 self-test, model files (SHA-256), tokenizer, disks, key database → **READY** or the exact problem |
156
+ | `gla-api info` | model version, size, runtime, PyTorch, GPUs (does not load the model) |
157
+ | `gla-api verify` | checks every model file against its SHA-256 |
158
+ | `gla-api prefetch` | downloads the code-parser grammars once (run before taking a machine offline) |
159
+
160
+ ### Run the server
161
+
162
+ | command | what it does |
163
+ |---|---|
164
+ | `gla-api start [options]` | starts the API server **in the background** (keeps running after you close the window) |
165
+ | `gla-api stop [--timeout 60] [--force]` | stops it — answers that are running finish first |
166
+ | `gla-api restart [options]` | stop + start (same options as before unless you give new ones) |
167
+ | `gla-api status [--json]` | running or not, model ready or loading, uptime, workers, queue, served, errors |
168
+ | `gla-api logs [-n 50] [-f]` | the background server's log (`-f` keeps following it) |
169
+ | `gla-api serve [options]` | runs the server **in this window** (Ctrl+C stops it); `--supervise` restarts it after a crash |
170
+
171
+ `start`, `restart` and `serve` take the same options: `--host`, `--port`, `--gpus`, `--split`, `--precision`, `--fp8`,
172
+ `--workers-per-gpu`, `--min-workers-per-gpu`, `--max-queue`, `--max-connections`, `--max-output-tokens`,
173
+ `--default-rpm`, `--default-concurrency`, `--request-timeout`, `--hooks`, `--ssl-certfile`/`--ssl-keyfile`, `--docs`
174
+ (`gla-api serve --help`). `start --wait-ready` waits until the model is loaded.
175
+
176
+ ### Use the model
177
+
178
+ | command | what it does |
179
+ |---|---|
180
+ | `gla-api chat "question"` | one answer |
181
+ | `gla-api chat` | a conversation in the terminal (`/mode code`, `/lang rust`, `/clear`, `/exit`) |
182
+ | `gla-api chat --code --language rust "..."` | a code answer in a chosen language |
183
+ | `gla-api chat --url http://HOST:8000 --key gla_live_...` | ask a running server (streams the answer) |
184
+ | `gla-api chat --json "..."` | the full answer as JSON (confidence, reason, questions, ...) |
185
+ | `gla-api bench [-n 5] [--url ...]` | answer speed: seconds per answer, tokens per second |
186
+
187
+ ### API keys and data
188
+
189
+ | command | what it does |
190
+ |---|---|
191
+ | `gla-api key create --owner NAME [limits]` | a new key, printed once |
192
+ | `gla-api key list [--owner NAME] [--all] [--json]` | every key (never the secrets) |
193
+ | `gla-api key show ID` | one key's settings |
194
+ | `gla-api key update ID [limits]` | change limits, name, allowed IPs/websites, expiry (`--expires-days 0` = never) |
195
+ | `gla-api key rotate ID [--grace 3600]` | a new secret with the same settings (the old one can keep working for a while) |
196
+ | `gla-api key revoke ID` | disable a key at once |
197
+ | `gla-api key usage ID` / `--owner NAME` | requests and tokens per day |
198
+ | `gla-api audit` | recent admin actions (created, updated, rotated, revoked ...) |
199
+ | `gla-api gen-token` | a strong random token |
200
+ | `gla-api backup [--out DIR]` | a safe copy of the key database, its secret and `.env` (also while the server runs) |
201
+
202
+ ### Settings and updates
203
+
204
+ | command | what it does |
205
+ |---|---|
206
+ | `gla-api config show` | every setting of this folder (secrets masked) and the main values in use |
207
+ | `gla-api config set NAME VALUE` | save one, e.g. `config set port 9000` |
208
+ | `gla-api config unset NAME` | remove one |
209
+ | `gla-api config path` | where the `.env` file is |
210
+ | `gla-api check-update` | is a newer `gla-api` on PyPI? |
211
+ | `gla-api service show \| install \| remove` | keep the server running: a systemd service (Linux) or a task at log-on (Windows) |
212
+
213
+ `--dir FOLDER` before any command works in that folder instead of the current one: `gla-api --dir D:\gla status`.
214
+
215
+ ---
216
+
217
+ ## 4. Run the API server
218
+
219
+ ```bash
220
+ gla-api start # this computer only: http://127.0.0.1:8000/v1
221
+ gla-api start --host 0.0.0.0 # reachable from other computers in your network
222
+ gla-api start --split 3 # GLA 3.x: each copy of the model spread over 3 GPUs
223
+ ```
224
+
225
+ The server uses **every GPU** of the machine, loads as many copies of the model per GPU as fit, adds copies under load
226
+ and releases them when idle, and spreads the requests over all of them. A crashed or frozen copy is restarted on its
227
+ own; a GPU that cannot run the chosen precision steps down safely (fp4 → fp8, fp8 kernels → bf16). It is
228
+ **OpenAI-compatible**:
229
+
230
+ | endpoint | for |
231
+ |---|---|
232
+ | `POST /v1/chat/completions` | answers (with `"stream": true` the answer arrives piece by piece) |
233
+ | `POST /v1/completions` | plain text completion |
234
+ | `POST /v1/code/validate` | checks code: valid, score, issues |
235
+ | `POST /v1/ground` | exact math and physics with units |
236
+ | `GET /v1/models`, `/v1/me`, `/v1/usage` | the model, this key's limits, this key's usage |
237
+ | `GET /health`, `/ready` | is the process up / is the model loaded |
238
+ | `/admin/keys ...`, `/admin/stats`, `/admin/workers`, `/admin/audit`, `POST /admin/model/reload` | management with the admin token (reload = new model without stopping) |
239
+ | `GET /metrics` | Prometheus metrics |
240
+
241
+ API description: `gla-api config set docs 1`, `gla-api restart`, then open `http://127.0.0.1:8000/docs` (or
242
+ `/openapi.json`). Off by default, so a public server does not show them. The model folder also contains
243
+ `API_REFERENCE.md`.
244
+
245
+ **Extra options per request** go in a `gla` object: `{"gla": {"mode": "code", "language": "rust"}}` (`mode`: `auto`,
246
+ `text` or `code`). Answers carry the same object back with `confidence`, `uncertain`, `reason` and `questions`.
247
+
248
+ **Streaming behind a proxy.** While the model writes, a streaming answer sends a keep-alive line every 15 seconds
249
+ (`stream_keepalive`), so proxies such as Cloudflare or nginx do not close a long answer.
250
+
251
+ **Safe retries.** Send `Idempotency-Key: <unique id>`: a retry with the same key and body returns the first answer
252
+ instead of generating again (kept 24 h). `gla_api.Client` does this for you.
253
+
254
+ **Your own code around every answer:** `gla-api start --hooks my_hooks.py`, where `my_hooks.py` defines
255
+ `before_request(ctx)` (change or refuse a request) and/or `after_response(ctx, result)` (change the answer). Both may
256
+ be `async def`.
257
+
258
+ **Always on:** `gla-api service install` — on Linux it writes a systemd service (`serve --supervise`, restarted after
259
+ a crash and at boot), on Windows a task that starts the server when you log on. `gla-api service show` prints it first.
260
+
261
+ **Public internet:** put HTTPS in front (a reverse proxy such as Cloudflare, Caddy or nginx, or
262
+ `--ssl-certfile`/`--ssl-keyfile`) and keep `trusted_proxies` set to the proxy's address.
263
+
264
+ ---
265
+
266
+ ## 5. API keys
267
+
268
+ Apps and websites call the server with an API key: `Authorization: Bearer gla_live_...`.
269
+
270
+ ```bash
271
+ gla-api key create --owner my-website --rpm 120 --daily-tokens 2000000 --allowed-origins https://example.com
272
+ gla-api key list
273
+ gla-api key update KEY_ID --rpm 0 # 0 = unlimited
274
+ gla-api key rotate KEY_ID --grace 3600 # new secret; the old one works one more hour
275
+ gla-api key usage --owner my-website
276
+ gla-api key revoke KEY_ID
277
+ ```
278
+
279
+ Limits per key — each can be `0` for unlimited: requests per minute (`--rpm`), tokens per day (`--daily-tokens`),
280
+ parallel requests (`--concurrency`), tokens per answer (`--max-tokens`), priority 0–9 (`--priority`), allowed IP
281
+ addresses (`--allowed-ips`), allowed websites (`--allowed-origins`), expiry (`--expires-days`), scopes (`--scopes`:
282
+ `chat`, `code`, `validate`, `ground`, `usage`) and test keys (`--env test`).
283
+
284
+ Keys are stored only as HMAC-SHA256 hashes: even a stolen database contains no usable keys. Keys made by earlier
285
+ versions (`cm_...`) keep working. A key that appears in an answer is redacted.
286
+
287
+ ---
288
+
289
+ ## 6. Settings
290
+
291
+ Settings live in the `.env` file of the folder you run the server from (made by `setup`/`init`). Change them with
292
+ `gla-api config set NAME VALUE` (then `gla-api restart`), or set the same names as environment variables with the
293
+ `GLA_` prefix (`GLA_PORT=9000`). The earlier prefix `CODEMIND_` still works.
294
+
295
+ | name | default | meaning |
296
+ |---|---|---|
297
+ | `model` | `./Model_GLA` | model folder |
298
+ | `host` | `127.0.0.1` | `0.0.0.0` = reachable from the network |
299
+ | `port` | `8000` | |
300
+ | `gpus` | `auto` | `auto`, `0,1`, or `cpu` |
301
+ | `split` | `off` | GLA 3.x: `2` or `3` GPUs per copy, `auto` = 3 when the GPUs divide into threes, else 2 |
302
+ | `precision` | `auto` | `auto`, `fp32`, `bf16`, `fp16`, `fp8`, `fp4` |
303
+ | `fp8` | `auto` | FP8 kernel: `rowwise`, `tensor`, `dequant`, `off` |
304
+ | `max_workers_per_gpu` / `min_workers_per_gpu` | `3` / `1` | model copies per GPU (fitted to memory and load) |
305
+ | `admin_token` | made by `init` | controls `/admin` and keys — keep it secret |
306
+ | `admin_ips` | `local` | where `/admin` may be called from: `local` (this computer and private networks), a list of IPs / networks, or `*` (anywhere — the token is still needed) |
307
+ | `ip_rpm` | `0` | requests per minute per client address on `/v1` (`0` = off; behind a proxy set `trusted_proxies`) |
308
+ | `verify_model` | `first` | model files' SHA-256 before the server loads them: `first` (once, remembered until a file changes), `always`, `size` (sizes only) |
309
+ | `default_rpm` | `60` | requests per minute for new keys (`0` = unlimited) |
310
+ | `default_concurrency` | `16` | parallel requests per key |
311
+ | `max_output_tokens` | `8192` | per answer (`0` = unlimited) |
312
+ | `max_queue` | `1024` | waiting requests before "busy" (`0` = unlimited) |
313
+ | `max_connections` | `8192` | open connections (`0` = unlimited) |
314
+ | `request_timeout` | `300` | seconds per request |
315
+ | `stream_keepalive` | `15` | seconds between keep-alive lines of a streaming answer |
316
+ | `cache_ttl` | `600` | seconds a deterministic answer (temperature 0) is reused |
317
+ | `cors_origins` | — | websites allowed to call from a browser |
318
+ | `trusted_proxies` | `127.0.0.1` | your HTTPS proxy's address |
319
+ | `data_dir` | `./gla_api_data` | keys, usage, audit log, server log, backups |
320
+ | `database_url` / `redis_url` | SQLite / none | PostgreSQL and Redis for several servers (`GLA_KEY_PEPPER` must then be the same on all) |
321
+ | `hooks` | — | your `before_request` / `after_response` module |
322
+ | `safety` / `redact_output` | `1` / `1` | content screening / secret redaction |
323
+ | `docs` | `0` | `/docs` and `/openapi.json` |
324
+ | `log_level` / `log_json` | `INFO` / `0` | |
325
+
326
+ `gla-api config show` lists what is set and what is in use. A JSON file with the same names can be given with
327
+ `gla-api --config settings.json serve`.
328
+
329
+ ---
330
+
331
+ ## 7. Use it from Python
332
+
333
+ ### The model in your own program
334
+
335
+ ```python
336
+ import gla_api
337
+
338
+ model = gla_api.load("./Model_GLA") # first GPU (CPU if none); FP8 where it pays off
339
+
340
+ print(model.chat("What is the difference between a process and a thread?"))
341
+
342
+ ans = model.code("A thread-safe LRU cache", language="python")
343
+ print(ans.text, ans.confidence, ans.uncertain)
344
+
345
+ for piece in model.stream("Explain this regex: ^\\d{3}-\\d{4}$"):
346
+ print(piece, end="", flush=True)
347
+
348
+ print(model.validate("SELECT * FROM users WHERE id = ' + user_id", language="sql")["issues"])
349
+ print(model.ground("speed of a 2 kg object after falling 10 m"))
350
+
351
+ big = gla_api.load("./Model_GLA", precision="fp8", devices="all") # one copy on every GPU
352
+ answers = big.chat_many([f"Explain error code E{i}" for i in range(100)]) # spread over all of them
353
+ big.close()
354
+
355
+ huge = gla_api.load("./Model_GLA", devices="all", split=3) # GLA 3.x: each copy over 3 GPUs (split=2: over 2)
356
+ ```
357
+
358
+ `load(path, precision="auto", device="auto", devices=None, split=False, fp8="auto", safety=True, verify=False,
359
+ warmup=True, threads=0, web_search=False, before=None, after=None)` — `gla_api.load("echo")` gives a tiny test model
360
+ (no GPU, no files) for trying out your code.
361
+
362
+ `chat(prompt | messages=[...], system="", mode="auto"|"text"|"code", language=None, temperature=0.8, top_p=0.92,
363
+ max_tokens=0, stop=None)` returns an **`Answer`**: `text`, `mode`, `uncertain`, `confidence`, `reason`, `questions`,
364
+ `sources`, `language`, `language_supported`, `score`, `finish_reason`, `usage`, `raw`. `str(answer)` is the text.
365
+
366
+ Also: `code()`, `stream()`, `chat_many()`, `achat()` / `acode()` (asyncio), `validate()`, `ground()`, `count_tokens()`,
367
+ `add_hook()`, `info`, `devices`, `runtime`, `close()`; `with gla_api.load(...) as model:` closes it for you.
368
+
369
+ ### A running server (no GPU or model files on this machine)
370
+
371
+ ```python
372
+ import gla_api
373
+
374
+ gla = gla_api.Client("http://127.0.0.1:8000", api_key="gla_live_...") # or GLA_URL / GLA_API_KEY
375
+ print(gla.chat("Explain what a mutex is"))
376
+ print(gla.code("Binary search", language="rust").text)
377
+ for piece in gla.stream("Write a haiku about graphs"):
378
+ print(piece, end="", flush=True)
379
+ print(gla.ready(), gla.models(), gla.me(), gla.usage(days=7))
380
+
381
+ admin = gla_api.Client("http://127.0.0.1:8000", admin_token="...") # or GLA_ADMIN_TOKEN
382
+ new = admin.create_key("my-website", rpm=120)
383
+ print(new["key"]) # shown only here
384
+ admin.rotate_key(new["id"], grace_seconds=3600)
385
+ print(admin.stats())
386
+ ```
387
+
388
+ ```python
389
+ async with gla_api.AsyncClient("http://127.0.0.1:8000", api_key="gla_live_...") as gla: # asyncio programs
390
+ print(await gla.chat("Hello"))
391
+ async for piece in gla.stream("Tell me about graphs"):
392
+ print(piece, end="")
393
+ ```
394
+
395
+ The client needs nothing but Python — use it on your web server while the model runs on a GPU machine. A busy or
396
+ rate-limited answer (503 / 429) is retried after the server's `Retry-After` (`retries=2`), always with an
397
+ `Idempotency-Key`, so a retry never produces a second answer. Errors raise `gla_api.APIError` with `status`, `code`,
398
+ `message`, `retry_after` and `request_id`.
399
+
400
+ ---
401
+
402
+ ## 8. Call the server from any language
403
+
404
+ Any OpenAI SDK works — point it at your server:
405
+
406
+ ```python
407
+ from openai import OpenAI
408
+ client = OpenAI(base_url="http://127.0.0.1:8000/v1", api_key="gla_live_...")
409
+ r = client.chat.completions.create(model="gla-3.0", messages=[{"role": "user", "content": "Hello"}])
410
+ print(r.choices[0].message.content)
411
+ ```
412
+
413
+ ```javascript
414
+ const r = await fetch("http://127.0.0.1:8000/v1/chat/completions", {
415
+ method: "POST",
416
+ headers: { "Authorization": "Bearer gla_live_...", "Content-Type": "application/json" },
417
+ body: JSON.stringify({ messages: [{ role: "user", content: "Hello" }], gla: { mode: "auto" } }),
418
+ });
419
+ console.log((await r.json()).choices[0].message.content);
420
+ ```
421
+
422
+ ```bash
423
+ curl http://127.0.0.1:8000/v1/chat/completions -H "Authorization: Bearer gla_live_..." \
424
+ -H "Content-Type: application/json" -d '{"messages":[{"role":"user","content":"Hello"}]}'
425
+ ```
426
+
427
+ The model ID is `gla-<version>` (see `GET /v1/models`); any ID is accepted.
428
+
429
+ ---
430
+
431
+ ## 9. GPUs, splitting and precision
432
+
433
+ | `precision` | weights | use it for |
434
+ |---|---|---|
435
+ | `fp32` | 4 bytes | exact reference |
436
+ | `bf16` | 2 bytes | the same quality, half the memory (RTX 30xx and newer) |
437
+ | `fp16` | 2 bytes | older GPUs without BF16 |
438
+ | `fp8` | 1 byte | FP8 tensor cores on RTX 40xx/50xx, Hopper, Blackwell (elsewhere FP8 storage, BF16 compute) |
439
+ | `fp4` | ~5 bits | the smallest |
440
+ | `auto` | | FP8 when the GPU passes a numeric self-test, else BF16; FP32 on CPU |
441
+
442
+ Every choice is tested on the real GPU and falls back safely instead of failing. The router, the writer's output layer
443
+ and small layers stay at the compute precision. Approximate memory for one copy of GLA 3.0 (≈ 21.2 B parameters):
444
+ ≈ 45 GB in BF16, ≈ 24 GB in FP8, ≈ 14 GB in FP4; GLA 2.0 (≈ 6.1 B): ≈ 12 GB, 6 GB, 4 GB.
445
+
446
+ **Splitting (GLA 3.x).** When one GPU is too small for a whole copy, spread each copy over several GPUs:
447
+
448
+ | | GPU 1 | GPU 2 | GPU 3 |
449
+ |---|---|---|---|
450
+ | `split=3` | encoder + Brain A + router | Brain B + Brain C | writer |
451
+ | `split=2` | encoder + Brain A + Brain B | Brain C + writer | |
452
+
453
+ `gla_api.load(path, devices="all", split=3)` in Python; `gla-api start --split 3` (or `config set split 3`) for the
454
+ server, which then runs one copy per group of GPUs (6 GPUs → 2 copies). `split=True` / `auto` picks 3 when the GPUs
455
+ divide into threes, else 2.
456
+
457
+ ---
458
+
459
+ ## 10. Security
460
+
461
+ - **Model folders are data only** (`safetensors`, no pickle): loading a model never runs code from it. The server
462
+ checks every file's SHA-256 before its first load (`verify_model`); `gla-api verify` checks them by hand.
463
+ - **Native code.** The library and the model runtime are compiled to native machine code, carry no source,
464
+ comments or docstrings, and refuse to run when an installed runtime file was changed (reinstall to repair).
465
+ - **This machine only by default:** the server listens on 127.0.0.1 unless you pass `--host 0.0.0.0`.
466
+ - **API keys** are stored as HMAC-SHA256 hashes; per-key limits, IP and website allow-lists, expiry, rotation with a
467
+ grace period and an audit log of every admin action; repeated wrong keys lock the address out for a while (logged
468
+ as `auth.lockout`). Keys never appear in full in logs or answers.
469
+ - **The admin token** controls `/admin`, which by default answers only this computer and private networks
470
+ (`admin_ips`); keep `.env` private (`gla-api backup` copies it — keep backups private too).
471
+ - **`gla-api doctor`** also reports risky settings: plain HTTP on a public address, a short admin token, an open admin
472
+ API, screening switched off, readable secret files.
473
+ - Request size limits (checked before a body is read), content screening of requests and answers, and redaction of
474
+ secrets (including API keys) in answers.
475
+ - **No internet needed to answer.** Only the code-parser grammars are downloaded once (`gla-api prefetch`).
476
+ - For the public internet: HTTPS in front, `--host 0.0.0.0` only behind it.
477
+
478
+ ---
479
+
480
+ ## 11. Troubleshooting
481
+
482
+ | you see | do this |
483
+ |---|---|
484
+ | `pip` / `gla-api` is not recognized (Windows) | use `py -m pip ...` and `py -m gla_api ...`, or reinstall Python with "Add python.exe to PATH" |
485
+ | `doctor`: `no trained model found` | normal before you have a model: copy the exported model files into `Model_GLA/` |
486
+ | `doctor`: `GPUs - 0 found` | install the CUDA build of PyTorch ([Install](#1-install)) and a current NVIDIA driver |
487
+ | `FP8 self-test - selected 'dequant'` | normal on GPUs without FP8 tensor cores — FP8 storage with BF16 compute is used |
488
+ | `status`: `model: loading` | the model is still loading — wait, or `gla-api start --wait-ready` |
489
+ | `cannot reach http://...` | the server is not running: `gla-api start`, then `gla-api logs` |
490
+ | out of GPU memory | `--precision fp8` or `fp4`, fewer `--workers-per-gpu`, or `--split 2` / `3` for GLA 3.x |
491
+ | `split needs a 3.x model` | GLA 2.0 runs on one GPU per copy — drop `split` |
492
+ | `model folder is incomplete` | copy the whole folder again; `gla-api verify` names the bad file |
493
+ | `this process already runs the v2 runtime` | GLA 2.x and 3.x models need separate processes |
494
+ | a long streaming answer is cut by a proxy | lower `stream_keepalive` (e.g. 10) or raise the proxy's read timeout |
495
+ | `Admin API not allowed from this address` | call it from the server itself or your private network, or set `admin_ips` |
496
+ | `model files failed the check` | a file is damaged or incomplete: copy the model folder again, then `gla-api restart` |
497
+ | `the model runtime of this installation was changed` | `pip install --force-reinstall gla-api` |
498
+
499
+ ---
500
+
501
+ ## 12. What is new in 1.2.5 / upgrading
502
+
503
+ ```bash
504
+ pip install --upgrade "gla-api>=1.2.5"
505
+ ```
506
+
507
+ Folders, keys, settings and code written for 1.0.x and 1.2.x keep working unchanged.
508
+
509
+ New in 1.2.5:
510
+
511
+ - **Faster answers (GLA 3.0):** the answer is written with a preallocated memory of the text so far and each new
512
+ word is one recorded GPU program (CUDA graph) instead of hundreds of separate launches - about 10x more words per
513
+ second on the same GPU, with the same sampling (temperature, top-p, top-k, repetition penalty) and the same answers
514
+ for the same random draws' distribution.
515
+ - **Faster understanding (GLA 3.0):** the graph layers compute every node type and relation in one pass; the batch
516
+ goes to the GPU in one transfer.
517
+ - **Better code graphs:** data flow of assignments and C / C++ parameters fixed; the parser is safe with many threads.
518
+ - **Python 3.14** and the free-threaded **3.14t** (GIL off). On 3.14 install the grammars with
519
+ `pip install "gla-api[grammars]"`; 3.11-3.13 get them automatically.
520
+ - **Updated GLA 2.0 and GLA 3.0 runtimes** (the current model code); WinCore is no longer used.
521
+
522
+ New in 1.2.3:
523
+
524
+ - **Updated GLA 2.0 and GLA 3.0 runtimes** (the current model code): checkpoints are found in `Model-GLA` /
525
+ `Models/Model-GLA` (the folder GLA training now writes to) as well as `Model_GLA`; GLA 3.0 answers carry a
526
+ readability check (`raw["gibberish"]`, 0-1) and an unreadable answer comes back as "not sure" with
527
+ `reason="unreadable"` instead of mixed-up tokens; fixes for checkpoints saved after a second training round.
528
+ - Use 1.2.3 for every GLA 2.0 / 3.0 model trained with the current code; 1.2.2 is withdrawn.
529
+
530
+ New in 1.2.2:
531
+
532
+ - **Native code** for Windows and Linux; the model runtime ships without comments or docstrings and is checked
533
+ against its SHA-256 before it runs.
534
+ - The server checks the model files' SHA-256 before the first load (`verify_model`); `gla_api.load(...,
535
+ verify="first")` does the same in Python.
536
+ - `/admin` answers only this computer and private networks by default (`admin_ips`); `ip_rpm` limits requests per
537
+ client address; lock-outs after wrong keys are written to the audit log; keys are shortened in every log line;
538
+ stricter response headers.
539
+ - `gla-api service install` keeps the server running (systemd / Windows log-on task); `gla-api doctor` checks the
540
+ security settings.
541
+
542
+ New in 1.2.1:
543
+
544
+ - **Runs the GLA 3.0 release** (connected graphs, global attention, 24 / 18 / 34-layer brains, 40-layer writer).
545
+ - **Split copies** of 3.x models over 2 or 3 GPUs — in `gla_api.load(..., split=3)` and in the server (`--split`).
546
+ - **Lighter server**: Starlette + uvicorn directly (FastAPI is no longer installed); `/docs` and `/openapi.json` still
547
+ available with `docs=1`.
548
+ - **Streaming keep-alive** for long answers behind proxies; streams start at once and stop the work when the client
549
+ leaves.
550
+ - **`AsyncClient`**, `Model.achat()` / `acode()`, `Client.complete()`, `wait_ready()`, `get_key()`, `audit()`,
551
+ `owner_usage()`; automatic, idempotent retries in the client.
552
+ - **Answers** carry `sources`, `finish_reason` and `usage`; `stop` sequences in Python too; `validate(language="auto")`
553
+ detects the language.
554
+ - **Hooks** may be `async def`; API keys in answers are redacted; better worker supervision (precision step-down per
555
+ GPU, one-at-a-time rolling reload, faster recovery).
556
+ - `GLA_RUNTIME_DIR`: run the model code from another folder (for model developers).
557
+
558
+ Coming from `codemindai-api`: `pip uninstall codemindai-api`, `pip install gla-api`, then use `gla-api` where you used
559
+ `codemindai-api` and `import gla_api` where you used `import codemindai_api`. Folders (`codemindai_api_data/`), keys
560
+ (`cm_live_...`), settings (`CODEMIND_...`) and the request option `codemind` are all accepted.
561
+
562
+ ---
563
+
564
+ ## License
565
+
566
+ GLA models and `gla-api` are **proprietary** software of **ATEC (Advancement Through Engineering & Creation)**.
567
+ They are licensed, not sold, and are **not open source**. Each GLA model version comes with its own license, which
568
+ governs how you may use it; in short, you may use GLA 2.0 and 3.0 commercially to power your own websites, apps and
569
+ API services, but you may never sell the model, and you must always credit ATEC:
570
+
571
+ > **Built with GLA &lt;version&gt; by ATEC**
572
+
573
+ The library is licensed only to run GLA models and may not be decompiled or reverse-engineered. Licenses and technical
574
+ documentation: https://github.com/ATECTechnologies/Graph-Language-Assistant
@@ -0,0 +1,42 @@
1
+ gla_api/__init__.pyc,sha256=2XE-eBSES8zGfx_bW6Myi-lCXQKuLzVO2u5JLZRuELw,1359
2
+ gla_api/__main__.pyc,sha256=NLX2DAYj8oRnNjwYPtIqBZysypUhhuBE9jCXBSWhcX8,245
3
+ gla_api/_models/runtime.sha256.json,sha256=c3i8-E9mh3cZAtDRvKjZuIl-y5K3yqAKy-paarOz9ew,562
4
+ gla_api/_models/v2/GLA.pyc,sha256=q56X5Pm3kNxzdZ_ljY8urrEL6yLKAAq3jZpDTZDxXUA,1207895
5
+ gla_api/_models/v2/gla_brain_dual.pyc,sha256=Dktc7pbtcl0c2SLGwqh5HM1MFIBWRyD3fy45tUfZCYw,60753
6
+ gla_api/_models/v2/linguistic_safety.pyc,sha256=aexiHtwWHq5UEu5if2yHQYze7c-875gdJS_XGZiaxAs,57054
7
+ gla_api/_models/v3/GLA.pyc,sha256=xoql3UGkDV1-IPCarj7KWn86wt-SmAW7LNgFmjdTYck,1321960
8
+ gla_api/_models/v3/gla_brain_dual.pyc,sha256=uocn8cmqo-Cb3HNrqhd8SZVIAeCyik7Z03RtKr9f3nQ,65703
9
+ gla_api/_models/v3/linguistic_safety.pyc,sha256=2cmcD6ydBss_zFgqFqRXgrJINzU5oktablG5mftKVbs,62801
10
+ gla_api/_version.pyc,sha256=yjGd-Xwonf6vxT0ZwRkT9KVT1cVUqdNXPNNoWcfU6es,251
11
+ gla_api/answer.pyc,sha256=aKfQXLrDw3lolyMrfGwjInPc5_Iu1wj7ZddNvDYA2Uw,5918
12
+ gla_api/cli.pyc,sha256=ABfJH75qcIGtVoIyiL1J5SNJvCmo5OPP0HLgGc46eko,80481
13
+ gla_api/client.pyc,sha256=t2GReCb3h4MrWtNnleHHLiroUxvBHimkkze38Mtw8Lk,26057
14
+ gla_api/doctor.pyc,sha256=Zdwi6wRZUc75N5pUEIbPMcMzu8tAnDxzGVTurCyUDBc,12763
15
+ gla_api/envfile.pyc,sha256=wNMiTHCQaFdynOPXM_0Z7N4fxqwERjH6V8KeqXf1m74,7726
16
+ gla_api/model.pyc,sha256=Hnzv_tIEgj7MphMOlfbVSbruCgpMz80epdxJE9tKKDM,22943
17
+ gla_api/paths.pyc,sha256=FHtQAa2Zji2KDY9rIdWZQJUz_O_MfTpeXfuw4mg4SY8,7832
18
+ gla_api/runtime/__init__.pyc,sha256=a7U9_QlRBszImQRLAo-MhOnFoKhsBViNWHGMMFJM3Xo,833
19
+ gla_api/runtime/devices.pyc,sha256=SOi88uxr0AUTfXjtB4BCCUWMpono3T3DGWNr97zHztg,8072
20
+ gla_api/runtime/loader.pyc,sha256=wyIQq1k6Ydsts4x4fh9Er6WzHb2vlwhpjuJb0J4QpW4,10080
21
+ gla_api/runtime/locate.pyc,sha256=-yDcFMAFeDPHgwmziGq--X5FkfYt9D-YHgBipwb7BbQ,17977
22
+ gla_api/runtime/ops.pyc,sha256=Ys4kVU3_7SVSmeHJqIzoXn3ZMiGXe-N9AP11rBQSZZY,18624
23
+ gla_api/runtime/precision.pyc,sha256=cnxsLfwRjKy3aw02hmeriEOGdAGpd72OziAESEJnv8o,31342
24
+ gla_api/runtime/prepare.pyc,sha256=bnhEZEikAt5xjjP0h8sJMID3Wd63YzAiSIG6RPQl1J0,6927
25
+ gla_api/runtime/worker.pyc,sha256=jgEjiWn2wO5YYn2Yr2fFH048emO7ERctRWnWdMwipNU,14475
26
+ gla_api/safety.pyc,sha256=ZJvUH1eueArBjxpmeTCHUD3SfgOf75o1B9xcYCrp_oA,4008
27
+ gla_api/server/__init__.pyc,sha256=TJXxDfaLWcOw732fsoEamcfDbPbS5gRCkLGkDlrLJ5E,852
28
+ gla_api/server/app.pyc,sha256=gEaQ9Ddk5nMWnSdsJGi2BIkhropA_b7qopSX32uWvJs,75260
29
+ gla_api/server/hooks.pyc,sha256=hyD3vf79ZdxohHTd4NXCuzPLnN8W2M2UmDOz61g7JwY,5032
30
+ gla_api/server/metrics.pyc,sha256=2xaC0l31xPeGXUA0ybg7JMHaNwJ80zHSyXH8fSfkC6o,6695
31
+ gla_api/server/pool.pyc,sha256=RGDF6VRoNzo0GC1mPYnZTa42k9WKDpjNZvPvdwZus8s,55676
32
+ gla_api/server/run.pyc,sha256=lfJOL3p1CvHiRpE7QT74UO8Xa09boSkW80lcL8tsdGM,4092
33
+ gla_api/server/schemas.pyc,sha256=j8j6e7Qi1PAj9pnV9wDsXGw75XEe-1_qEoxaSxcsd1A,7123
34
+ gla_api/server/settings.pyc,sha256=D6Ce-vQiahdSxqe2DT2o3Th8-x_pP_ySEbluM5I9L6g,16020
35
+ gla_api/server/state.pyc,sha256=zAhXGMtTs2GCB-GhF8HeAF3bijxTgBGXt_XJKV6O3Eo,14110
36
+ gla_api/server/store.pyc,sha256=E4mLaahpusZChRFUkb_FY2MrFUJ5JkejYsblrYy1j1I,39419
37
+ gla_api/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
+ gla_api-1.2.5.dist-info/METADATA,sha256=b0tLK4uuu8wwOa-aJo51iKFCk5ezwf9ETsXqxxWNaPM,29513
39
+ gla_api-1.2.5.dist-info/WHEEL,sha256=D6BNkmK7I_wIg39ysjMg2Bvyp5FGKGxhZNENtfIG6o4,102
40
+ gla_api-1.2.5.dist-info/entry_points.txt,sha256=aeHJRkFYS6A48JlONqIlKTRIk9oIXStsGa467ssy0Fk,45
41
+ gla_api-1.2.5.dist-info/top_level.txt,sha256=kyHlFVdlSBr-1ddC_3um7Qw9Rp8tMkYXVkDz8k8VGLE,8
42
+ gla_api-1.2.5.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: gla-api tools/build_wheels.py
3
+ Root-Is-Purelib: true
4
+ Tag: cp312-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ gla-api = gla_api.cli:main
@@ -0,0 +1 @@
1
+ gla_api