codemindai-api 1.0.0__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.

Potentially problematic release.


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

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