gla-api 1.0.0__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 +0 -0
- gla_api/__main__.pyc +0 -0
- gla_api/_answer.pyc +0 -0
- gla_api/_paths.pyc +0 -0
- gla_api/_runtime/v2/CodeMind.pyc +0 -0
- gla_api/_runtime/v2/codemind_brain_dual.pyc +0 -0
- gla_api/_runtime/v2/linguistic_safety.pyc +0 -0
- gla_api/_runtime/v3/CodeMind.pyc +0 -0
- gla_api/_runtime/v3/codemind_brain_dual.pyc +0 -0
- gla_api/_runtime/v3/linguistic_safety.pyc +0 -0
- gla_api/api.pyc +0 -0
- gla_api/cli.pyc +0 -0
- gla_api/client.pyc +0 -0
- gla_api/engine.pyc +0 -0
- gla_api/pool.pyc +0 -0
- gla_api/server.pyc +0 -0
- gla_api/store.pyc +0 -0
- gla_api-1.0.0.dist-info/METADATA +473 -0
- gla_api-1.0.0.dist-info/RECORD +22 -0
- gla_api-1.0.0.dist-info/WHEEL +4 -0
- gla_api-1.0.0.dist-info/entry_points.txt +2 -0
- gla_api-1.0.0.dist-info/top_level.txt +1 -0
gla_api/__init__.pyc
ADDED
|
Binary file
|
gla_api/__main__.pyc
ADDED
|
Binary file
|
gla_api/_answer.pyc
ADDED
|
Binary file
|
gla_api/_paths.pyc
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
gla_api/api.pyc
ADDED
|
Binary file
|
gla_api/cli.pyc
ADDED
|
Binary file
|
gla_api/client.pyc
ADDED
|
Binary file
|
gla_api/engine.pyc
ADDED
|
Binary file
|
gla_api/pool.pyc
ADDED
|
Binary file
|
gla_api/server.pyc
ADDED
|
Binary file
|
gla_api/store.pyc
ADDED
|
Binary file
|
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: gla-api
|
|
3
|
+
Version: 1.0.0
|
|
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
|
+
Author: ATEC (Advancement Through Engineering & Creation)
|
|
6
|
+
Maintainer: ATEC (Advancement Through Engineering & Creation)
|
|
7
|
+
Home-page: https://pypi.org/project/gla-api/
|
|
8
|
+
Project-URL: Homepage, https://pypi.org/project/gla-api/
|
|
9
|
+
Project-URL: Documentation, https://github.com/FWKTechnologies/CodeMind-Code-Intelligence
|
|
10
|
+
Project-URL: License, https://github.com/FWKTechnologies/CodeMind-Code-Intelligence/blob/main/LICENSE
|
|
11
|
+
Keywords: GLA,Graph-Language Assistant,ATEC,code,AI,LLM,API,OpenAI-compatible,server
|
|
12
|
+
Requires-Python: >=3.11,<3.14
|
|
13
|
+
License: Proprietary
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
19
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
20
|
+
Classifier: Environment :: GPU :: NVIDIA CUDA
|
|
21
|
+
Classifier: License :: Other/Proprietary License
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
23
|
+
Requires-Dist: torch>=2.4
|
|
24
|
+
Requires-Dist: safetensors>=0.4.5
|
|
25
|
+
Requires-Dist: psutil>=5.9
|
|
26
|
+
Requires-Dist: tree-sitter-language-pack>=1.0,<2
|
|
27
|
+
Requires-Dist: pypdf>=4.0
|
|
28
|
+
Requires-Dist: fastapi>=0.115,<1
|
|
29
|
+
Requires-Dist: uvicorn[standard]>=0.30
|
|
30
|
+
Requires-Dist: pydantic>=2.7,<3
|
|
31
|
+
Provides-Extra: server
|
|
32
|
+
Requires-Dist: redis>=5.0 ; extra == "server"
|
|
33
|
+
Requires-Dist: psycopg[binary]>=3.2 ; extra == "server"
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# gla-api
|
|
37
|
+
|
|
38
|
+
**The official library for GLA models — Graph-Language Assistant, by ATEC (Advancement Through Engineering & Creation).**
|
|
39
|
+
|
|
40
|
+
`gla-api` runs a trained GLA model on your own computer or server and manages everything around it: an
|
|
41
|
+
OpenAI-compatible API server for your websites and apps, API keys with limits, a background service you can start and
|
|
42
|
+
stop, a chat in the terminal, speed tests, backups and a full system check. Windows and Linux, one or many NVIDIA GPUs.
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install gla-api
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Library page: **https://pypi.org/project/gla-api/**
|
|
49
|
+
|
|
50
|
+
| | |
|
|
51
|
+
|---|---|
|
|
52
|
+
| Runs | **GLA 2.0** and **GLA 3.0** (the version is detected from the model folder) |
|
|
53
|
+
| Operating systems | Windows 10/11 (64-bit), Linux (x86-64) |
|
|
54
|
+
| Python | 3.11, 3.12 or 3.13 |
|
|
55
|
+
| GPU | NVIDIA, any number (a CPU works for testing) |
|
|
56
|
+
| Precision | FP32, BF16, FP16, FP8, FP4 — tested on your GPU, with automatic fallback |
|
|
57
|
+
| License | Proprietary (ATEC). Not open source — see [License](#license) |
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Contents
|
|
62
|
+
|
|
63
|
+
1. [Install](#1-install)
|
|
64
|
+
2. [Start in one minute](#2-start-in-one-minute)
|
|
65
|
+
3. [Every command](#3-every-command)
|
|
66
|
+
4. [Run the API server](#4-run-the-api-server)
|
|
67
|
+
5. [API keys](#5-api-keys)
|
|
68
|
+
6. [Settings](#6-settings)
|
|
69
|
+
7. [Use it from Python](#7-use-it-from-python)
|
|
70
|
+
8. [Call the server from any language](#8-call-the-server-from-any-language)
|
|
71
|
+
9. [GPUs and precision](#9-gpus-and-precision)
|
|
72
|
+
10. [Security](#10-security)
|
|
73
|
+
11. [Troubleshooting](#11-troubleshooting)
|
|
74
|
+
12. [Coming from codemindai-api](#12-coming-from-codemindai-api)
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## 1. Install
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
pip install gla-api
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
That one command installs the model runtime **and** the API server. Check it:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
gla-api --version
|
|
88
|
+
gla-api doctor --quick
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**NVIDIA GPU on Windows:** `pip` installs the CPU build of PyTorch by default. For your GPU, install the CUDA build
|
|
92
|
+
first (once), then the library:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
pip install torch --index-url https://download.pytorch.org/whl/cu128
|
|
96
|
+
pip install gla-api
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Update later with `pip install --upgrade gla-api` (`gla-api check-update` tells you when there is a new
|
|
100
|
+
version).
|
|
101
|
+
|
|
102
|
+
> **`pip` not found on Windows?** Use `py -m pip install gla-api` and `py -m gla_api <command>` — they
|
|
103
|
+
> work the same everywhere. To get the short commands, reinstall Python with **"Add python.exe to PATH"** ticked.
|
|
104
|
+
|
|
105
|
+
**Several servers sharing one database (optional):** `pip install "gla-api[server]"` adds Redis and PostgreSQL
|
|
106
|
+
support. A single server needs nothing extra.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## 2. Start in one minute
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
mkdir my-gla && cd my-gla
|
|
114
|
+
gla-api setup --owner my-website
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
`setup` does everything a new folder needs, in one step:
|
|
118
|
+
|
|
119
|
+
1. creates `.env` with a secret **admin token** and the model folder **`Model_GLA/`**;
|
|
120
|
+
2. checks the model folder;
|
|
121
|
+
3. creates your first **API key** and prints it (once — copy it).
|
|
122
|
+
|
|
123
|
+
Then copy the exported GLA model's files into `Model_GLA/` and:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
gla-api start # API server in the background: http://127.0.0.1:8000/v1
|
|
127
|
+
gla-api status # running? model loaded? how busy?
|
|
128
|
+
gla-api chat "Write a Python function that reverses a string"
|
|
129
|
+
gla-api stop
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
A model folder holds only data — weights (`safetensors`), configuration, tokenizer and documents. No code is ever run
|
|
133
|
+
from it. A folder named `Model_CodeMind/` is found too.
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## 3. Every command
|
|
138
|
+
|
|
139
|
+
Every command has its own help: `gla-api <command> --help`. All of them also work as
|
|
140
|
+
`py -m gla_api <command>` (or `python -m gla_api <command>`).
|
|
141
|
+
|
|
142
|
+
### Set up and check
|
|
143
|
+
|
|
144
|
+
| command | what it does |
|
|
145
|
+
|---|---|
|
|
146
|
+
| `gla-api setup [--owner NAME] [--start]` | everything for a new folder: `.env`, `Model_GLA/`, first API key, next steps |
|
|
147
|
+
| `gla-api init` | only `.env` (admin token) and `Model_GLA/` |
|
|
148
|
+
| `gla-api doctor [--quick]` | full check: Python packages, PyTorch, every GPU, FP8 self-test, model files (SHA-256), disks, key database → **READY** or the exact problem |
|
|
149
|
+
| `gla-api info` | model version, size, runtime, PyTorch, GPUs (does not load the model) |
|
|
150
|
+
| `gla-api verify` | checks every model file against its SHA-256 |
|
|
151
|
+
| `gla-api prefetch` | downloads the code-parser grammars once (run before taking a machine offline) |
|
|
152
|
+
|
|
153
|
+
### Run the server
|
|
154
|
+
|
|
155
|
+
| command | what it does |
|
|
156
|
+
|---|---|
|
|
157
|
+
| `gla-api start [options]` | starts the API server **in the background** (keeps running after you close the window) |
|
|
158
|
+
| `gla-api stop [--timeout 60] [--force]` | stops it — answers that are running finish first |
|
|
159
|
+
| `gla-api restart [options]` | stop + start (same options as before unless you give new ones) |
|
|
160
|
+
| `gla-api status [--json]` | running or not, model ready or loading, uptime, workers, queue, served, errors |
|
|
161
|
+
| `gla-api logs [-n 50] [-f]` | the background server's log (`-f` keeps following it) |
|
|
162
|
+
| `gla-api serve [options]` | runs the server **in this window** (Ctrl+C stops it); `--supervise` restarts it after a crash |
|
|
163
|
+
|
|
164
|
+
`start`, `restart` and `serve` take the same options: `--host`, `--port`, `--gpus`, `--precision`, `--workers-per-gpu`,
|
|
165
|
+
`--max-queue`, `--max-output-tokens`, `--default-rpm`, `--hooks`, `--ssl-certfile`/`--ssl-keyfile` and more
|
|
166
|
+
(`gla-api serve --help`). `start --wait-ready` waits until the model is loaded.
|
|
167
|
+
|
|
168
|
+
### Use the model
|
|
169
|
+
|
|
170
|
+
| command | what it does |
|
|
171
|
+
|---|---|
|
|
172
|
+
| `gla-api chat "question"` | one answer |
|
|
173
|
+
| `gla-api chat` | a conversation in the terminal (`/mode code`, `/lang rust`, `/clear`, `/exit`) |
|
|
174
|
+
| `gla-api chat --code --language rust "..."` | a code answer in a chosen language |
|
|
175
|
+
| `gla-api chat --url http://HOST:8000 --key gla_live_...` | ask a running server (streams the answer) |
|
|
176
|
+
| `gla-api chat --json "..."` | the full answer as JSON (confidence, reason, questions, ...) |
|
|
177
|
+
| `gla-api bench [-n 5] [--url ...]` | answer speed: seconds per answer, tokens per second |
|
|
178
|
+
|
|
179
|
+
### API keys and data
|
|
180
|
+
|
|
181
|
+
| command | what it does |
|
|
182
|
+
|---|---|
|
|
183
|
+
| `gla-api key create --owner NAME [limits]` | a new key, printed once |
|
|
184
|
+
| `gla-api key list [--owner NAME] [--all]` | every key (never the secrets) |
|
|
185
|
+
| `gla-api key show ID` | one key's settings |
|
|
186
|
+
| `gla-api key update ID [limits]` | change limits, name, allowed IPs/websites, expiry |
|
|
187
|
+
| `gla-api key rotate ID [--grace 3600]` | a new secret with the same settings (the old one can keep working for a while) |
|
|
188
|
+
| `gla-api key revoke ID` | disable a key at once |
|
|
189
|
+
| `gla-api key usage ID` / `--owner NAME` | requests and tokens per day |
|
|
190
|
+
| `gla-api audit` | recent admin actions (created, updated, rotated, revoked ...) |
|
|
191
|
+
| `gla-api gen-token` | a strong random token |
|
|
192
|
+
| `gla-api backup [--out DIR]` | a safe copy of the key database, its secret and `.env` (also while the server runs) |
|
|
193
|
+
|
|
194
|
+
### Settings and updates
|
|
195
|
+
|
|
196
|
+
| command | what it does |
|
|
197
|
+
|---|---|
|
|
198
|
+
| `gla-api config show` | every setting of this folder (secrets masked) and the main values in use |
|
|
199
|
+
| `gla-api config set NAME VALUE` | save one, e.g. `config set port 9000` |
|
|
200
|
+
| `gla-api config unset NAME` | remove one |
|
|
201
|
+
| `gla-api config path` | where the `.env` file is |
|
|
202
|
+
| `gla-api check-update` | is a newer `gla-api` on PyPI? |
|
|
203
|
+
|
|
204
|
+
`--dir FOLDER` before any command works in that folder instead of the current one:
|
|
205
|
+
`gla-api --dir D:\gla status`.
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## 4. Run the API server
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
gla-api start # this computer only: http://127.0.0.1:8000/v1
|
|
213
|
+
gla-api start --host 0.0.0.0 # reachable from other computers in your network
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
The server uses **every GPU** of the machine, loads as many copies of the model per GPU as fit, adds copies under load
|
|
217
|
+
and releases them when idle, and spreads the requests over all of them. It is **OpenAI-compatible**:
|
|
218
|
+
|
|
219
|
+
| endpoint | for |
|
|
220
|
+
|---|---|
|
|
221
|
+
| `POST /v1/chat/completions` | answers (with `"stream": true` the answer arrives piece by piece) |
|
|
222
|
+
| `POST /v1/completions` | plain text completion |
|
|
223
|
+
| `POST /v1/code/validate` | checks code: valid, score, issues |
|
|
224
|
+
| `POST /v1/ground` | exact math and physics with units |
|
|
225
|
+
| `GET /v1/models`, `/v1/me`, `/v1/usage` | the model, this key's limits, this key's usage |
|
|
226
|
+
| `GET /health`, `/ready` | is the process up / is the model loaded |
|
|
227
|
+
| `/admin/keys ...`, `/admin/stats`, `/admin/workers`, `/admin/audit`, `POST /admin/model/reload` | management with the admin token (reload = new model without stopping) |
|
|
228
|
+
| `GET /metrics` | Prometheus metrics |
|
|
229
|
+
|
|
230
|
+
Interactive API docs: `gla-api config set docs 1`, `gla-api restart`, then open
|
|
231
|
+
`http://127.0.0.1:8000/docs` (off by default, so a public server does not show them). The model folder also contains
|
|
232
|
+
`API_REFERENCE.md`.
|
|
233
|
+
|
|
234
|
+
**Extra options per request** go in a `gla` object: `{"gla": {"mode": "code", "language": "rust"}}` (`mode`: `auto`,
|
|
235
|
+
`text` or `code`). Answers carry the same object back with `confidence`, `uncertain`, `reason` and `questions`.
|
|
236
|
+
|
|
237
|
+
**Your own code around every answer:** `gla-api start --hooks my_hooks.py`, where `my_hooks.py` defines
|
|
238
|
+
`before_request(ctx)` (change or refuse a request) and/or `after_response(ctx, result)` (change the answer).
|
|
239
|
+
|
|
240
|
+
**Always on (Linux):** run `gla-api serve --supervise` from a systemd service. **Windows:** a Task Scheduler
|
|
241
|
+
task "At log on" running `gla-api start`.
|
|
242
|
+
|
|
243
|
+
**Public internet:** put HTTPS in front (a reverse proxy such as Caddy or nginx, or `--ssl-certfile`/`--ssl-keyfile`)
|
|
244
|
+
and keep `trusted_proxies` set to the proxy's address.
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## 5. API keys
|
|
249
|
+
|
|
250
|
+
Apps and websites call the server with an API key: `Authorization: Bearer gla_live_...`.
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
gla-api key create --owner my-website --rpm 120 --daily-tokens 2000000 --allowed-origins https://example.com
|
|
254
|
+
gla-api key list
|
|
255
|
+
gla-api key update KEY_ID --rpm 0 # 0 = unlimited
|
|
256
|
+
gla-api key rotate KEY_ID --grace 3600 # new secret; the old one works one more hour
|
|
257
|
+
gla-api key usage --owner my-website
|
|
258
|
+
gla-api key revoke KEY_ID
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Limits per key — each can be `0` for unlimited: requests per minute (`--rpm`), tokens per day (`--daily-tokens`),
|
|
262
|
+
parallel requests (`--concurrency`), tokens per answer (`--max-tokens`), priority 0–9 (`--priority`), allowed IP
|
|
263
|
+
addresses (`--allowed-ips`), allowed websites (`--allowed-origins`), expiry (`--expires-days`), scopes (`--scopes`) and
|
|
264
|
+
test keys (`--env test`).
|
|
265
|
+
|
|
266
|
+
Keys are stored only as HMAC-SHA256 hashes: even a stolen database contains no usable keys. Keys made by earlier
|
|
267
|
+
versions (`cm_...`) keep working.
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## 6. Settings
|
|
272
|
+
|
|
273
|
+
Settings live in the `.env` file of the folder you run the server from (made by `setup`/`init`). Change them with
|
|
274
|
+
`gla-api config set NAME VALUE` (then `gla-api restart`), or set the same names as environment
|
|
275
|
+
variables with the `GLA_` prefix (`GLA_PORT=9000`). The earlier prefix `CODEMIND_` still works.
|
|
276
|
+
|
|
277
|
+
| name | default | meaning |
|
|
278
|
+
|---|---|---|
|
|
279
|
+
| `model` | `./Model_GLA` | model folder |
|
|
280
|
+
| `host` | `127.0.0.1` | `0.0.0.0` = reachable from the network |
|
|
281
|
+
| `port` | `8000` | |
|
|
282
|
+
| `gpus` | `auto` | `auto`, `0,1`, or `cpu` |
|
|
283
|
+
| `precision` | `auto` | `auto`, `fp32`, `bf16`, `fp16`, `fp8`, `fp4` |
|
|
284
|
+
| `admin_token` | made by `init` | controls `/admin` and keys — keep it secret |
|
|
285
|
+
| `default_rpm` | `60` | requests per minute for new keys (`0` = unlimited) |
|
|
286
|
+
| `default_concurrency` | `16` | parallel requests per key |
|
|
287
|
+
| `max_output_tokens` | `8192` | per answer (`0` = unlimited) |
|
|
288
|
+
| `max_queue` | `1024` | waiting requests before "busy" (`0` = unlimited) |
|
|
289
|
+
| `request_timeout` | `300` | seconds per request |
|
|
290
|
+
| `cors_origins` | — | websites allowed to call from a browser |
|
|
291
|
+
| `trusted_proxies` | `127.0.0.1` | your HTTPS proxy's address |
|
|
292
|
+
| `data_dir` | `./gla_api_data` | keys, usage, audit log, server log, backups |
|
|
293
|
+
| `database_url` / `redis_url` | SQLite / none | PostgreSQL and Redis for several servers |
|
|
294
|
+
| `hooks` | — | your `before_request` / `after_response` module |
|
|
295
|
+
| `log_level` | `INFO` | |
|
|
296
|
+
|
|
297
|
+
`gla-api config show` lists what is set and what is in use.
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## 7. Use it from Python
|
|
302
|
+
|
|
303
|
+
### The model in your own program
|
|
304
|
+
|
|
305
|
+
```python
|
|
306
|
+
import gla_api
|
|
307
|
+
|
|
308
|
+
model = gla_api.load("./Model_GLA") # first GPU (CPU if none); FP8 where it pays off
|
|
309
|
+
|
|
310
|
+
print(model.chat("What is the difference between a process and a thread?"))
|
|
311
|
+
|
|
312
|
+
ans = model.code("A thread-safe LRU cache", language="python")
|
|
313
|
+
print(ans.text, ans.confidence, ans.uncertain)
|
|
314
|
+
|
|
315
|
+
for piece in model.stream("Explain this regex: ^\\d{3}-\\d{4}$"):
|
|
316
|
+
print(piece, end="", flush=True)
|
|
317
|
+
|
|
318
|
+
print(model.validate("SELECT * FROM users WHERE id = ' + user_id", language="sql")["issues"])
|
|
319
|
+
print(model.ground("speed of a 2 kg object after falling 10 m"))
|
|
320
|
+
|
|
321
|
+
big = gla_api.load("./Model_GLA", precision="fp8", devices="all") # one copy on every GPU
|
|
322
|
+
answers = big.chat_many([f"Explain error code E{i}" for i in range(100)]) # spread over all of them
|
|
323
|
+
big.close()
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
`load(path, precision="auto", device="auto", devices=None, split=False, fp8="auto", safety=True, verify=False,
|
|
327
|
+
warmup=True, threads=0, before=None, after=None)`
|
|
328
|
+
|
|
329
|
+
`chat(prompt | messages=[...], system="", mode="auto"|"text"|"code", language=None, temperature=0.8, max_tokens=0)`
|
|
330
|
+
returns an **`Answer`**: `text`, `mode`, `uncertain`, `confidence`, `reason`, `questions`, `language`,
|
|
331
|
+
`language_supported`, `score`, `raw`. `str(answer)` is the text.
|
|
332
|
+
|
|
333
|
+
Also: `code()`, `stream()`, `chat_many()`, `validate()`, `ground()`, `count_tokens()`, `add_hook()`, `info`, `close()`;
|
|
334
|
+
`with gla_api.load(...) as model:` closes it for you.
|
|
335
|
+
|
|
336
|
+
### A running server (no GPU or model files on this machine)
|
|
337
|
+
|
|
338
|
+
```python
|
|
339
|
+
import gla_api
|
|
340
|
+
|
|
341
|
+
gla = gla_api.Client("http://127.0.0.1:8000", api_key="gla_live_...") # or GLA_URL / GLA_API_KEY
|
|
342
|
+
print(gla.chat("Explain what a mutex is"))
|
|
343
|
+
print(gla.code("Binary search", language="rust").text)
|
|
344
|
+
for piece in gla.stream("Write a haiku about graphs"):
|
|
345
|
+
print(piece, end="", flush=True)
|
|
346
|
+
print(gla.ready(), gla.models(), gla.me(), gla.usage(days=7))
|
|
347
|
+
|
|
348
|
+
admin = gla_api.Client("http://127.0.0.1:8000", admin_token="...") # or GLA_ADMIN_TOKEN
|
|
349
|
+
new = admin.create_key("my-website", rpm=120)
|
|
350
|
+
print(new["key"]) # shown only here
|
|
351
|
+
admin.rotate_key(new["id"], grace_seconds=3600)
|
|
352
|
+
print(admin.stats())
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
The client needs nothing but Python — use it on your web server while the model runs on a GPU machine. Errors raise
|
|
356
|
+
`gla_api.APIError` with `status`, `code` and `message`.
|
|
357
|
+
|
|
358
|
+
---
|
|
359
|
+
|
|
360
|
+
## 8. Call the server from any language
|
|
361
|
+
|
|
362
|
+
Any OpenAI SDK works — point it at your server:
|
|
363
|
+
|
|
364
|
+
```python
|
|
365
|
+
from openai import OpenAI
|
|
366
|
+
client = OpenAI(base_url="http://127.0.0.1:8000/v1", api_key="gla_live_...")
|
|
367
|
+
r = client.chat.completions.create(model="gla-3.0", messages=[{"role": "user", "content": "Hello"}])
|
|
368
|
+
print(r.choices[0].message.content)
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
```javascript
|
|
372
|
+
const r = await fetch("http://127.0.0.1:8000/v1/chat/completions", {
|
|
373
|
+
method: "POST",
|
|
374
|
+
headers: { "Authorization": "Bearer gla_live_...", "Content-Type": "application/json" },
|
|
375
|
+
body: JSON.stringify({ messages: [{ role: "user", content: "Hello" }], gla: { mode: "auto" } }),
|
|
376
|
+
});
|
|
377
|
+
console.log((await r.json()).choices[0].message.content);
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
curl http://127.0.0.1:8000/v1/chat/completions -H "Authorization: Bearer gla_live_..." \
|
|
382
|
+
-H "Content-Type: application/json" -d '{"messages":[{"role":"user","content":"Hello"}]}'
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
The model ID is `gla-<version>` (see `GET /v1/models`); any ID is accepted.
|
|
386
|
+
|
|
387
|
+
---
|
|
388
|
+
|
|
389
|
+
## 9. GPUs and precision
|
|
390
|
+
|
|
391
|
+
| `precision` | weights | use it for |
|
|
392
|
+
|---|---|---|
|
|
393
|
+
| `fp32` | 4 bytes | exact reference |
|
|
394
|
+
| `bf16` | 2 bytes | the same quality, half the memory (RTX 30xx and newer) |
|
|
395
|
+
| `fp16` | 2 bytes | older GPUs without BF16 |
|
|
396
|
+
| `fp8` | 1 byte | FP8 tensor cores on RTX 40xx/50xx, Hopper, Blackwell (elsewhere FP8 storage, BF16 compute) |
|
|
397
|
+
| `fp4` | ~5 bits | the smallest |
|
|
398
|
+
| `auto` | | FP8 when the GPU passes a numeric self-test, else BF16; FP32 on CPU |
|
|
399
|
+
|
|
400
|
+
Every choice is tested on the real GPU and falls back safely instead of failing. Rough GPU memory for the weights:
|
|
401
|
+
GLA 2.0 (≈6.1 B parameters) ≈ 12 GB in BF16, 6 GB in FP8, 4 GB in FP4; GLA 3.0 (≈17.9 B) ≈ 36 GB, 18 GB, 11 GB.
|
|
402
|
+
A GLA 3.0 model can also be split over two GPUs: `load(path, devices="all", split=True)`.
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
## 10. Security
|
|
407
|
+
|
|
408
|
+
- **Model folders are data only** (`safetensors`, no pickle): loading a model never runs code from it. Every load
|
|
409
|
+
checks the files; `gla-api verify` checks each SHA-256.
|
|
410
|
+
- **This machine only by default:** the server listens on 127.0.0.1 unless you pass `--host 0.0.0.0`.
|
|
411
|
+
- **API keys** are stored as HMAC-SHA256 hashes; per-key limits, IP and website allow-lists, expiry, rotation with a
|
|
412
|
+
grace period and an audit log of every admin action.
|
|
413
|
+
- **The admin token** controls `/admin`; keep `.env` private (`gla-api backup` copies it — keep backups private
|
|
414
|
+
too).
|
|
415
|
+
- Request size limits, content screening of requests and answers, and secret redaction in answers.
|
|
416
|
+
- **No internet needed to answer.** Only the code-parser grammars are downloaded once (`gla-api prefetch`).
|
|
417
|
+
- For the public internet: HTTPS in front, `--host 0.0.0.0` only behind it.
|
|
418
|
+
|
|
419
|
+
---
|
|
420
|
+
|
|
421
|
+
## 11. Troubleshooting
|
|
422
|
+
|
|
423
|
+
| you see | do this |
|
|
424
|
+
|---|---|
|
|
425
|
+
| `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" |
|
|
426
|
+
| `doctor`: `no trained model found` | normal before you have a model: copy the exported model files into `Model_GLA/` |
|
|
427
|
+
| `doctor`: `GPUs - 0 found` | install the CUDA build of PyTorch ([Install](#1-install)) and a current NVIDIA driver |
|
|
428
|
+
| `FP8 self-test - selected 'dequant'` | normal on GPUs without FP8 tensor cores — FP8 storage with BF16 compute is used |
|
|
429
|
+
| `status`: `model: loading` | the model is still loading — wait, or `gla-api start --wait-ready` |
|
|
430
|
+
| `cannot reach http://...` | the server is not running: `gla-api start`, then `gla-api logs` |
|
|
431
|
+
| out of GPU memory | `--precision fp8` or `fp4`, fewer `--workers-per-gpu`, or `split=True` for GLA 3.0 |
|
|
432
|
+
| `model folder is incomplete` | copy the whole folder again; `gla-api verify` names the bad file |
|
|
433
|
+
| `this process already runs the v2 runtime` | GLA 2.x and 3.x models need separate processes |
|
|
434
|
+
|
|
435
|
+
---
|
|
436
|
+
|
|
437
|
+
## 12. Coming from codemindai-api
|
|
438
|
+
|
|
439
|
+
`gla-api` 1.0.0 is the new name of the library previously published as `codemindai-api`, the model's earlier name
|
|
440
|
+
being CodeMind. Moving over takes two commands:
|
|
441
|
+
|
|
442
|
+
```bash
|
|
443
|
+
pip uninstall codemindai-api
|
|
444
|
+
pip install gla-api
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
Then use `gla-api` where you used `codemindai-api`, and `import gla_api` where you used `import codemindai_api`.
|
|
448
|
+
Nothing else has to change:
|
|
449
|
+
|
|
450
|
+
- **Folders, keys and settings carry over.** `codemindai_api_data/` (and the older `codemindai_data/`) is moved to
|
|
451
|
+
`gla_api_data/` the first time it is needed, with every API key, usage record and the audit log; the cache folder
|
|
452
|
+
moves the same way.
|
|
453
|
+
- **Old names still work:** model folder `Model_CodeMind/`, API keys `cm_live_...`, settings `CODEMIND_...` and the
|
|
454
|
+
request option `codemind` are all accepted next to `Model_GLA/`, `gla_live_...`, `GLA_...` and `gla`.
|
|
455
|
+
|
|
456
|
+
New in this release: one install command with the API server included; `setup`, `start` / `stop` / `restart` /
|
|
457
|
+
`status` / `logs`, `key create | list | show | update | rotate | revoke | usage`, `audit`, `config`, `backup`,
|
|
458
|
+
`bench`, `check-update` and `--dir`; `chat` without a question opens a conversation and `--url` asks a running
|
|
459
|
+
server; `gla_api.Client` for using a server from Python; graceful stop on Windows and Linux and log rotation.
|
|
460
|
+
|
|
461
|
+
---
|
|
462
|
+
|
|
463
|
+
## License
|
|
464
|
+
|
|
465
|
+
GLA models and `gla-api` are **proprietary** software of **ATEC (Advancement Through Engineering & Creation)**.
|
|
466
|
+
They are licensed, not sold, and are **not open source**. Each GLA model version comes with its own license, which
|
|
467
|
+
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
|
|
468
|
+
API services, but you may never sell the model, and you must always credit ATEC:
|
|
469
|
+
|
|
470
|
+
> **Built with GLA <version> by ATEC**
|
|
471
|
+
|
|
472
|
+
The library is licensed only to run GLA models and may not be decompiled or reverse-engineered. Licenses and technical
|
|
473
|
+
documentation: https://github.com/FWKTechnologies/CodeMind-Code-Intelligence
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
gla_api/__init__.pyc,sha256=K8eI6MKuJcnNCyOBIoVI2HTnj4MCm-DN6UMrd_T7VU8,1018
|
|
2
|
+
gla_api/__main__.pyc,sha256=tLU3IQ7Qoh1ms3UTZwDvTxeX09N38vzC4LX--8urmZs,215
|
|
3
|
+
gla_api/_answer.pyc,sha256=BdjATNG3KOLzG9bw6Wv5d0Jk40QOpZMjL1qmqXuRPMw,3447
|
|
4
|
+
gla_api/_paths.pyc,sha256=zYZbKRbfUTiXB6aUR-W1x9B-qJ9wwPkDPQ-OTNEKAVE,6185
|
|
5
|
+
gla_api/_runtime/v2/CodeMind.pyc,sha256=_vTawFzfq3cb5uA_ceseSpT3YCqLS_6_hhzPSfCuKBE,1441466
|
|
6
|
+
gla_api/_runtime/v2/codemind_brain_dual.pyc,sha256=I6bzlXrswh9-9ZzSOxWW_ZvK3EH3Y5FqB5SJcvyVmsQ,89162
|
|
7
|
+
gla_api/_runtime/v2/linguistic_safety.pyc,sha256=vi9eK4c45hDYXPE3fa9gxfBDbwaE13WBy4Uk2eBXks0,67157
|
|
8
|
+
gla_api/_runtime/v3/CodeMind.pyc,sha256=FKRSVLDgDD6PgrBP5yKCe875pJ3OCX4wgPX61Dx2E9w,1451632
|
|
9
|
+
gla_api/_runtime/v3/codemind_brain_dual.pyc,sha256=bNAwqMv1o4svUdaYqFWGTIq1y9DSSV6wAD-Oi2DYypo,94616
|
|
10
|
+
gla_api/_runtime/v3/linguistic_safety.pyc,sha256=DNwvcnCiWzm2iix16D-k4LCr0n0DpzcfeF0-dAnRYUM,68236
|
|
11
|
+
gla_api/api.pyc,sha256=O5eUBYaOBK-vm3EHDIWQHOwoCbNIdUnn48b15RjnhRM,29217
|
|
12
|
+
gla_api/cli.pyc,sha256=bRUUlxFmNTNbKsBfSgOz1xqmz-WSqr0fny6n37rN8sQ,72748
|
|
13
|
+
gla_api/client.pyc,sha256=1q4g7zd61iuG4n2qSsSr3zMtmr-FAeIguxSkMn7yLR8,16895
|
|
14
|
+
gla_api/engine.pyc,sha256=D4bphaao4Ojy8D0AfLi_OepfL38QfyQFGKuJCc4bB1U,71556
|
|
15
|
+
gla_api/pool.pyc,sha256=Kp4YtcD7_9eS3kMfBbBez0gHtwxcwsxQQ4BbQlt8x0A,51291
|
|
16
|
+
gla_api/server.pyc,sha256=410MrySXn1YlQKnWYjojZqQL5YiJL1xDwVQQ7laYcs8,123038
|
|
17
|
+
gla_api/store.pyc,sha256=w768AtdiN4UDWA6WGW5eV365sgEZ42125VpexKebjKY,57218
|
|
18
|
+
gla_api-1.0.0.dist-info/METADATA,sha256=sUtahyraCc3Kv7T-1YzLogmJW15ldCYz7vq2223Uaq8,21467
|
|
19
|
+
gla_api-1.0.0.dist-info/WHEEL,sha256=CC0jpaOav8vea1YBDBB9lH5Ywf5ye9HcawI_KiEitTo,86
|
|
20
|
+
gla_api-1.0.0.dist-info/entry_points.txt,sha256=aeHJRkFYS6A48JlONqIlKTRIk9oIXStsGa467ssy0Fk,45
|
|
21
|
+
gla_api-1.0.0.dist-info/top_level.txt,sha256=kyHlFVdlSBr-1ddC_3um7Qw9Rp8tMkYXVkDz8k8VGLE,8
|
|
22
|
+
gla_api-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
gla_api
|