codemindai-api 1.0.1__cp313-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.
Binary file
Binary file
Binary file
Binary file
Binary file
codemindai_api/api.pyc ADDED
Binary file
codemindai_api/cli.pyc ADDED
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,189 @@
1
+ Metadata-Version: 2.1
2
+ Name: codemindai-api
3
+ Version: 1.0.1
4
+ Summary: Run trained CodeMind code-intelligence models - from Python or as an OpenAI-compatible API server
5
+ Author: FWKTechnologies
6
+ Maintainer: FWKTechnologies
7
+ Home-page: https://github.com/FWKTechnologies/CodeMind-Code-Intelligence
8
+ Project-URL: Homepage, https://github.com/FWKTechnologies/CodeMind-Code-Intelligence
9
+ Project-URL: License, https://github.com/FWKTechnologies/CodeMind-Code-Intelligence/blob/main/LICENSE
10
+ Requires-Python: >=3.11,<3.14
11
+ License: Proprietary
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Operating System :: Microsoft :: Windows
17
+ Classifier: Operating System :: POSIX :: Linux
18
+ Classifier: Environment :: GPU :: NVIDIA CUDA
19
+ Classifier: License :: Other/Proprietary License
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Requires-Dist: torch>=2.4
22
+ Requires-Dist: safetensors>=0.4.5
23
+ Requires-Dist: psutil>=5.9
24
+ Requires-Dist: tree-sitter-language-pack>=1.0,<2
25
+ Requires-Dist: pypdf>=4.0
26
+ Provides-Extra: server
27
+ Requires-Dist: fastapi>=0.115,<1 ; extra == "server"
28
+ Requires-Dist: uvicorn[standard]>=0.30 ; extra == "server"
29
+ Requires-Dist: pydantic>=2.7,<3 ; extra == "server"
30
+ Requires-Dist: redis>=5.0 ; extra == "server"
31
+ Requires-Dist: psycopg[binary]>=3.2 ; extra == "server"
32
+ Description-Content-Type: text/markdown
33
+
34
+ # codemindai-api
35
+
36
+ Run trained **CodeMind** code-intelligence models on your own machine - from Python, or as an OpenAI-compatible API
37
+ server for websites and apps. Windows and Linux, one or many NVIDIA GPUs.
38
+
39
+ A CodeMind model folder (`Model_CodeMind/`) contains only data: weights (`safetensors`), configuration, tokenizers
40
+ and documents. `codemindai-api` is what runs it.
41
+
42
+ ## Requirements
43
+
44
+ | | |
45
+ |---|---|
46
+ | OS | Windows 10/11 (64-bit) or Linux (x86-64) |
47
+ | Python | 3.11, 3.12 or 3.13 |
48
+ | PyTorch | 2.4+ with CUDA (install it first - see below) |
49
+ | GPU | NVIDIA, any number; memory per precision is in each model's README |
50
+
51
+ ## Install
52
+
53
+ ```bash
54
+ python -m venv .venv
55
+ # Linux: source .venv/bin/activate
56
+ # Windows: .venv\Scripts\activate
57
+
58
+ # 1. PyTorch with CUDA (choose your system at https://pytorch.org/get-started/locally/), e.g.
59
+ pip install torch --index-url https://download.pytorch.org/whl/cu128
60
+
61
+ # 2. codemindai-api - add [server] for the HTTP API server
62
+ pip install "codemindai-api[server]"
63
+
64
+ codemindai-api info --model ./Model_CodeMind # model, runtime, PyTorch, GPUs
65
+ ```
66
+
67
+ ## Use it from Python
68
+
69
+ ```python
70
+ import codemindai_api
71
+
72
+ model = codemindai_api.load("./Model_CodeMind") # first GPU (CPU if none); FP8 where supported
73
+
74
+ print(model.chat("What is the difference between a process and a thread?"))
75
+
76
+ ans = model.code("A thread-safe LRU cache", language="python")
77
+ print(ans.text, ans.confidence)
78
+
79
+ print(model.validate("SELECT * FROM users WHERE id = ' + user_id", language="sql")["issues"])
80
+
81
+ with codemindai_api.load("./Model_CodeMind", precision="bf16", device="cuda:1") as m2: # one chosen GPU
82
+ for piece in m2.stream("Explain this regex: ^\\d{3}-\\d{4}$"):
83
+ print(piece, end="")
84
+
85
+ big = codemindai_api.load("./Model_CodeMind", precision="fp8", devices="all") # one copy on EVERY GPU
86
+ answers = big.chat_many([f"Explain error code E{i}" for i in range(100)]) # spread over all of them
87
+ ```
88
+
89
+ `load(path, precision="auto"|"fp32"|"bf16"|"fp16"|"fp8"|"fp4", device="auto"|"cuda:N"|"cpu", devices="all"|[...],
90
+ split=False, fp8="auto", safety=True, before=None, after=None, verify=False, threads=0, warmup=True)`
91
+
92
+ `Model.chat(prompt | messages=[...], system="", mode="auto"|"text"|"code", language=None, temperature=0.8, top_p=0.92,
93
+ max_tokens=0)` → `Answer(text, mode, uncertain, confidence, reason, questions, language, language_supported, score, raw)`
94
+
95
+ Also `code()`, `chat_many()`, `stream()`, `validate()`, `ground()` (exact math/physics with units), `count_tokens()`,
96
+ `add_hook()`, `info`, `runtime`, `close()`.
97
+
98
+ ### Precision
99
+
100
+ | `precision` | weights | use it for |
101
+ |---|---|---|
102
+ | `fp32` | 4 bytes | exact reference |
103
+ | `bf16` | 2 bytes | same quality, half the memory (Ampere and newer) |
104
+ | `fp16` | 2 bytes | GPUs without BF16 (Turing, Volta) |
105
+ | `fp8` | 1 byte | FP8 tensor cores on RTX 40xx / Ada, Hopper, Blackwell (elsewhere FP8 storage, BF16 compute) |
106
+ | `fp4` | ~5 bits | the smallest: 4-bit E2M1 values, one scale per 16 |
107
+ | `auto` | | FP8 when the GPU passes a numeric self-test, else BF16; FP32 on CPU |
108
+
109
+ Every choice is checked on the real GPU and falls back safely (FP4 → BF16, FP8 → BF16) instead of failing.
110
+
111
+ ### Your own code around every answer
112
+
113
+ ```python
114
+ def before(ctx): # system, prompt, mode, language, temperature, top_p, max_tokens
115
+ if "password" in ctx["prompt"].lower():
116
+ raise ValueError("not on this service") # refuses the request
117
+ return ctx
118
+
119
+ model = codemindai_api.load("./Model_CodeMind", before=before, after=lambda ctx, a: a.text.strip())
120
+ ```
121
+
122
+ The server takes the same idea from a file: `codemindai-api serve --hooks my_hooks.py` with `before_request(ctx)` and
123
+ `after_response(ctx, result)`.
124
+
125
+ ## Run the API server
126
+
127
+ ```bash
128
+ mkdir my-server && cd my-server
129
+ codemindai-api init # .env with an admin token + Model_CodeMind/
130
+ # put the model files into Model_CodeMind/
131
+ codemindai-api serve --supervise --host 0.0.0.0 # every GPU, auto-restart (default host 127.0.0.1 = local only)
132
+ codemindai-api create-key --owner my-app
133
+ ```
134
+
135
+ OpenAI-compatible: `POST /v1/chat/completions` (streaming), `/v1/completions`, `/v1/code/validate`, `/v1/ground`,
136
+ `/v1/models`, `/v1/me`, `/v1/usage`, `/health`, `/ready`, plus `/admin/*` (keys, limits, usage, audit, workers,
137
+ zero-downtime model reload) and `/metrics`. Any OpenAI SDK works:
138
+
139
+ ```python
140
+ from openai import OpenAI
141
+ client = OpenAI(base_url="http://localhost:8000/v1", api_key="YOUR_KEY")
142
+ print(client.chat.completions.create(model="codemind-3.0",
143
+ messages=[{"role": "user", "content": "Hello"}]).choices[0].message.content)
144
+ ```
145
+
146
+ The full reference ships with every model: `Model_CodeMind/API_REFERENCE.md`.
147
+
148
+ ## Hardware use
149
+
150
+ - **Any number of GPUs:** the server starts model workers on every GPU (`--gpus auto|0,1,2,...`), sizes how many copies
151
+ fit per GPU from real memory use (`--workers-per-gpu`), scales up under load and down when idle, and spreads requests
152
+ over all of them. In Python: `devices="all"` + `chat_many()`.
153
+ - **Precision:** `--precision` / `precision=` FP32, BF16, FP16, FP8, FP4 - self-tested on each GPU, with fallback.
154
+ - **One big 3.x model over GPU pairs:** `codemindai_api.load(path, devices="all", split=True)`.
155
+ - **Limits are yours:** queue, connections, output length, requests/minute, parallel requests per key - each can be
156
+ set, or `0` for unlimited (`codemindai-api serve --help`).
157
+ - **CPU:** works without a GPU (slow - for testing).
158
+
159
+ ## Security
160
+
161
+ - Model folders are data only (`safetensors`, no pickle): loading a model never runs code from it.
162
+ - Every load checks the model files; `codemindai-api verify` checks each file's SHA-256 against `manifest.json`.
163
+ - No internet needed to answer. The code parser downloads each language grammar once and caches it - run
164
+ `codemindai-api prefetch` once before taking a machine offline (`serve` does it at start).
165
+ - Server: API keys stored only as HMAC-SHA256 hashes; admin token for `/admin`; per-key rate, token, concurrency,
166
+ IP and website limits; request size limits; content screening of requests and answers; secret redaction; audit log.
167
+ - The server listens on this machine only (127.0.0.1) unless you pass `--host 0.0.0.0`.
168
+ - Keep `.env` private; use HTTPS in front of a public server.
169
+
170
+ ## Commands
171
+
172
+ | command | does |
173
+ |---|---|
174
+ | `codemindai-api init` | prepare the current folder for serving |
175
+ | `codemindai-api serve` | run the API server |
176
+ | `codemindai-api chat "..."` | one answer from the command line |
177
+ | `codemindai-api info` / `verify` / `doctor` / `prefetch` | inspect, check files, full system check, download grammars |
178
+ | `codemindai-api create-key` / `list-keys` / `revoke-key` / `gen-token` | API keys and tokens |
179
+
180
+ ## Troubleshooting
181
+
182
+ | message | fix |
183
+ |---|---|
184
+ | `PyTorch sees no CUDA GPU` | install the CUDA build of PyTorch (step 1), update the NVIDIA driver |
185
+ | `this process already runs the v2 runtime` | 2.x and 3.x models need separate processes |
186
+ | `model folder is incomplete` | copy the whole model folder again; `codemindai-api verify` names the bad file |
187
+ | out of GPU memory | `fp8="auto"` (default), a smaller `--workers-per-gpu`, or `devices=[...]` for 3.x |
188
+
189
+ License: proprietary - see the terms that came with the model.
@@ -0,0 +1,20 @@
1
+ codemindai_api/__init__.pyc,sha256=-WaAcqmCaK5JHNvc7LfKwiej2sxZbwNRW_O2wI7nBgE,672
2
+ codemindai_api/__main__.pyc,sha256=7x6yFPWmc_Z1lQ5cNPAQszcBeo0gUUHK_B2bnanhKOU,224
3
+ codemindai_api/_paths.pyc,sha256=8f6rvTLvgo7SbThxAZKpaCRdTaHC7bm62X51ZzJpIEo,3536
4
+ codemindai_api/_runtime/v2/CodeMind.pyc,sha256=Oq4zyQAFXNVYzZMExusHWWM2Pz1xd7-xmtzI4_8cHl4,1448665
5
+ codemindai_api/_runtime/v2/codemind_brain_dual.pyc,sha256=ZMM5AXshxjk9ev7pbey9zvGkkQkjI0rNA19ThnRPZyQ,88924
6
+ codemindai_api/_runtime/v2/linguistic_safety.pyc,sha256=DgOW2HZnI39qj8qrggXzOCcOH9Q3uerqA5_2dkEzmzs,68420
7
+ codemindai_api/_runtime/v3/CodeMind.pyc,sha256=lIo50W--WuwqNpiAVmJL1_f6jo9MF4gtyVq0DxinLPs,1462091
8
+ codemindai_api/_runtime/v3/codemind_brain_dual.pyc,sha256=TmRsYzOPQvWQgmt6K_kyX9MwvT0fVM_hp6vyWNv_1cc,94337
9
+ codemindai_api/_runtime/v3/linguistic_safety.pyc,sha256=p1UfkINEaIZ-kvJ4WDFs1YhnXAPjfr4VGjWqpiwSZds,69504
10
+ codemindai_api/api.pyc,sha256=WM-Nky1VS2Z10pAWy6osYA-KnX5gicmfi6spW6nIRUc,32263
11
+ codemindai_api/cli.pyc,sha256=1CsDj804D_AQm7p5UyhDkLgntaMQPTLZ8CnCJmQXfXM,19816
12
+ codemindai_api/engine.pyc,sha256=kKAocBMYHIoulIZgTaK7QZtDcnQ2KQqeDf2fILm1LYk,72967
13
+ codemindai_api/pool.pyc,sha256=wPiuq5A8_KzNTyZhcsdMRM0rK9BjAn_Bh0av8dtABuA,52835
14
+ codemindai_api/server.pyc,sha256=MwrEHNi0MhJdjGTIV2vdy65hYZNnJ3D1jZEqE11z_-Q,116473
15
+ codemindai_api/store.pyc,sha256=AR4S5n_xWPZU8tYJhS277B4CSAF1tqXdCWBxxCzGTpg,58260
16
+ codemindai_api-1.0.1.dist-info/METADATA,sha256=Vm75BVnIl_ZwwMxE6CEW6JRGCD8xSxziIwQRRLCirMc,8719
17
+ codemindai_api-1.0.1.dist-info/WHEEL,sha256=z11AgxUlkxNJaKutJ-qddoF_F5IpnLT_P57QJW2YQQM,93
18
+ codemindai_api-1.0.1.dist-info/entry_points.txt,sha256=ZRXP1LQNSmJ7_MsOaBXdlE9srPUsaKbLK-RiXp6puFY,59
19
+ codemindai_api-1.0.1.dist-info/top_level.txt,sha256=XENHKjE7GGmBG6MCyL4Odbjb8ZM-3No9qO31iqW9yjI,15
20
+ codemindai_api-1.0.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: codemindai-api-build
3
+ Root-Is-Purelib: true
4
+ Tag: cp313-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ codemindai-api = codemindai_api.cli:main
@@ -0,0 +1 @@
1
+ codemindai_api