odant-work 1.0.15 → 1.0.17
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.
- package/#system/package-manifest.json +57 -49
- package/$server/$folder/handlers/methods/create/$handler/class.js +83 -2
- package/$server/$folder/handlers/pages/form/$handler/form.js +2 -1
- package/$server/$folder/lib/icon/icon.js +14 -0
- package/$server/$folder/lib/node/node.js +51 -1
- package/$server/$folder/lib/tree/tree.js +5 -1
- package/.secretsignore +4 -0
- package/MODELS/$ai/$folder/$class/$ai/class.js +58 -3
- package/MODELS/$ai/$folder/$class/$ai/handlers/pages/form/trainer/$handler/class.js +6 -4
- package/MODELS/$ai/$folder/$class/$ai/handlers/pages/form/trainer/$handler/trainer.js +344 -3
- package/MODELS/$ai/$folder/$class/$provider/class.js +1 -1
- package/MODELS/$ai/$folder/$class/$provider/handlers/pages/form/provider/$handler/class.js +13 -0
- package/MODELS/$ai/$folder/$class/$provider/handlers/pages/form/provider/$handler/provider.js +479 -0
- package/MODELS/$ai/$folder/$class/$provider/handlers/pages/form/trainer/$handler/class.js +3 -3
- package/MODELS/$ai/$folder/$class/$provider/handlers/pages/form/trainer/$handler/trainer.js +530 -920
- package/MODELS/GigaChat/$provider/$folder/$class/$ai/class.js +10 -20
- package/MODELS/GigaChat/$provider/class.js +10 -7
- package/MODELS/GigaChat/GigaChat 2 Lite/$ai/class.js +15 -0
- package/MODELS/GigaChat/GigaChat 2 Max/$ai/class.js +16 -0
- package/MODELS/GigaChat/GigaChat 2 Pro/$ai/class.js +15 -0
- package/MODELS/GigaChat/GigaChat Embeddings/$ai/class.js +13 -0
- package/MODELS/Local/$provider/$folder/$class/$ai/class.js +3 -3
- package/MODELS/Local/$provider/class.js +7 -3
- package/MODELS/MTS-AI/$provider/$folder/$class/$ai/class.js +8 -0
- package/MODELS/MTS-AI/$provider/class.js +8 -0
- package/MODELS/MTS-AI/Cotype Lite/$ai/class.js +15 -0
- package/MODELS/MTS-AI/Cotype Pro 2/$ai/class.js +15 -0
- package/MODELS/MTS-AI/Cotype Vision/$ai/class.js +14 -0
- package/MODELS/T-Bank/$provider/$folder/$class/$ai/class.js +8 -0
- package/MODELS/T-Bank/$provider/class.js +8 -0
- package/MODELS/T-Bank/T-Lite 2.0/$ai/class.js +15 -0
- package/MODELS/T-Bank/T-Pro 2.0/$ai/class.js +16 -0
- package/MODELS/T-Bank/T-VoiceKit ASR/$ai/class.js +13 -0
- package/MODELS/T-Bank/T-VoiceKit TTS/$ai/class.js +13 -0
- package/MODELS/Yandex/$provider/$folder/$class/$ai/class.js +9 -0
- package/MODELS/Yandex/$provider/class.js +9 -0
- package/MODELS/Yandex/Alice AI (YandexGPT 5 Pro)/$ai/class.js +15 -0
- package/MODELS/Yandex/Yandex Embeddings/$ai/class.js +13 -0
- package/MODELS/Yandex/Yandex SpeechKit ASR/$ai/class.js +13 -0
- package/MODELS/Yandex/Yandex SpeechKit TTS/$ai/class.js +13 -0
- package/MODELS/Yandex/YandexART/$ai/class.js +13 -0
- package/MODELS/Yandex/YandexGPT 5 Lite/$ai/class.js +15 -0
- package/MODELS/Yandex/YandexGPT Reasoning/$ai/class.js +22 -0
- package/oda/tools/icons/lib/svg/ai.svg +20 -0
- package/package.json +1 -1
- package/scripts/check-ignored-code.mjs +3 -0
- package/scripts/check-secrets.mjs +1 -1
- package/sources/data/progress.md +24 -0
- package/sources/host/watch.js +13 -2
- package/sources/modules/agent/index.js +23 -2
- package/sources/modules/trainer/halogen.js +128 -29
- package/sources/modules/trainer/huggingface.js +11 -5
- package/sources/modules/trainer/index.js +176 -3
- package/sources/modules/trainer/local-engine.js +67 -1
- package/sources/modules/trainer/providers.js +1213 -0
- package/sources/modules/trainer/runner.js +47 -1
- package/sources/server/class.js +55 -3
- package/MODELS/GigaChat/GigaChat Light/$ai/class.js +0 -15
- package/MODELS/GigaChat/GigaChat Pro/$ai/class.js +0 -15
- package/MODELS/Halogen/$provider/$folder/$class/$ai/class.js +0 -11
- package/MODELS/Halogen/$provider/class.js +0 -16
- package/MODELS/Halogen/$provider/readme.md +0 -28
- package/MODELS/Halogen/Decider-NPU/$ai/class.js +0 -22
- package/MODELS/Halogen/Flux2-Klein-NPU/$ai/class.js +0 -21
- package/MODELS/Halogen/Qwen3-ASR-NPU/$ai/class.js +0 -21
- package/MODELS/Halogen/Qwen3-Embedding-NPU/$ai/class.js +0 -22
- package/MODELS/Halogen/Qwen3-Reranker-NPU/$ai/class.js +0 -21
- package/MODELS/Halogen/Qwen3-TTS-NPU/$ai/class.js +0 -26
- package/MODELS/Halogen/Qwen3.5-2B-NPU/$ai/class.js +0 -23
- package/MODELS/Halogen/Qwen3.8-Flash-Next/$ai/class.js +0 -31
- package/MODELS/Local/Flux-Image/$ai/class.js +0 -20
- package/MODELS/Local/Qwen3-0.6B/$ai/class.js +0 -26
- package/MODELS/Local/Qwen3-14B/$ai/class.js +0 -27
- package/MODELS/Local/Qwen3-30B-A3B/$ai/class.js +0 -30
- package/MODELS/Local/Qwen3-Embedding/$ai/class.js +0 -21
- package/MODELS/Local/Qwen3-Voice/$ai/class.js +0 -26
- package/MODELS/odant/$provider/$folder/$class/$ai/class.js +0 -11
- package/MODELS/odant/$provider/class.js +0 -75
- package/MODELS/odant/$provider/readme.md +0 -21
- package/MODELS/odant/Qwen3-ASR/$ai/class.js +0 -15
- package/MODELS/odant/Qwen3-TTS/$ai/class.js +0 -22
- package/MODELS/odant/Qwen3.8 27b/$ai/class.js +0 -11
- package/MODELS/odant/Z-Image-Turbo/$ai/class.js +0 -8
- package/MODELS/odant/Z-Image-Turbo/$ai/readme.md +0 -24
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* подмешивает точные факты из живой БД `work.db`), обеспечивая мгновенный отклик без внешних серверов.
|
|
8
8
|
*/
|
|
9
9
|
import fs from 'node:fs';
|
|
10
|
+
import os from 'node:os';
|
|
10
11
|
import path from 'node:path';
|
|
11
12
|
import crypto from 'node:crypto';
|
|
12
13
|
import { spawn } from 'node:child_process';
|
|
@@ -14,7 +15,7 @@ import { dataStore } from '../../data/api.js';
|
|
|
14
15
|
import { classesOfType } from '../../data/classes.js';
|
|
15
16
|
import { classSchema } from '../../data/schema.js';
|
|
16
17
|
import { trialBalance } from '../../data/reports.js';
|
|
17
|
-
import { recordHalogenSessionHandle } from './halogen.js';
|
|
18
|
+
import { recordHalogenSessionHandle, stopHalogenBackend } from './halogen.js';
|
|
18
19
|
|
|
19
20
|
const money = v => Number(v || 0).toLocaleString('ru-RU', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
20
21
|
|
|
@@ -23,6 +24,70 @@ let _workerProc = null;
|
|
|
23
24
|
let _workerReady = false;
|
|
24
25
|
const _pendingRequests = new Map();
|
|
25
26
|
|
|
27
|
+
export const LOCAL_IDLE_TIMEOUT_MS = Number(process.env.WORK_LOCAL_AI_IDLE_MS) || (30 * 60 * 1000);
|
|
28
|
+
let _lastActivityAt = 0;
|
|
29
|
+
let _idleTimer = null;
|
|
30
|
+
|
|
31
|
+
function isHaloHighMemHost(totalRamGb) {
|
|
32
|
+
const ram = Number(totalRamGb) || (os.totalmem() / (1024 ** 3));
|
|
33
|
+
return ram >= 120;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function touchLocalEngineActivity(totalRamGb) {
|
|
37
|
+
_lastActivityAt = Date.now();
|
|
38
|
+
if (_idleTimer) {
|
|
39
|
+
clearTimeout(_idleTimer);
|
|
40
|
+
_idleTimer = null;
|
|
41
|
+
}
|
|
42
|
+
if (!isHaloHighMemHost(totalRamGb)) {
|
|
43
|
+
_idleTimer = setTimeout(() => {
|
|
44
|
+
_idleTimer = null;
|
|
45
|
+
if (_pendingRequests.size === 0) {
|
|
46
|
+
releaseLocalEngineMemory();
|
|
47
|
+
}
|
|
48
|
+
}, LOCAL_IDLE_TIMEOUT_MS);
|
|
49
|
+
_idleTimer.unref?.();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function getLocalEngineStatus({ totalRamGb, halogenOnline = false } = {}) {
|
|
54
|
+
const highMem = isHaloHighMemHost(totalRamGb);
|
|
55
|
+
const workerAlive = Boolean(_workerProc && !_workerProc.killed);
|
|
56
|
+
const running = workerAlive || Boolean(halogenOnline);
|
|
57
|
+
const idleTimeoutMin = Math.round(LOCAL_IDLE_TIMEOUT_MS / 60000);
|
|
58
|
+
return {
|
|
59
|
+
running,
|
|
60
|
+
workerAlive,
|
|
61
|
+
halogenOnline: Boolean(halogenOnline),
|
|
62
|
+
mode: highMem ? 'always-on' : 'on-demand',
|
|
63
|
+
modeLabel: highMem
|
|
64
|
+
? (running ? 'В памяти постоянно (Halo 128–192 ГБ)' : 'Готов к запуску (Halo 128–192 ГБ)')
|
|
65
|
+
: (running ? `В памяти (автовыгрузка через ${idleTimeoutMin} мин простоя)` : `Автозапуск по запросу (выгрузка через ${idleTimeoutMin} мин)`),
|
|
66
|
+
idleTimeoutMin: highMem ? 0 : idleTimeoutMin,
|
|
67
|
+
lastActivityAt: _lastActivityAt,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function releaseLocalEngineMemory() {
|
|
72
|
+
if (_idleTimer) {
|
|
73
|
+
clearTimeout(_idleTimer);
|
|
74
|
+
_idleTimer = null;
|
|
75
|
+
}
|
|
76
|
+
closeInferWorker();
|
|
77
|
+
_tokenizerCache.clear();
|
|
78
|
+
let haloStopped = false;
|
|
79
|
+
try {
|
|
80
|
+
const res = stopHalogenBackend();
|
|
81
|
+
haloStopped = Boolean(res?.stopped);
|
|
82
|
+
}
|
|
83
|
+
catch { /* ignore */ }
|
|
84
|
+
return {
|
|
85
|
+
ok: true,
|
|
86
|
+
released: true,
|
|
87
|
+
haloStopped,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
26
91
|
function resolveWeightsDir(ai, rootDir = process.cwd()) {
|
|
27
92
|
const modelId = String(ai?.id || ai?.label || ai?.model || 'Local-Model').split('/').pop();
|
|
28
93
|
const weightsRel = ai?.weightsDir || ai?.DATA?.weightsDir || `MODELS/Local/${modelId}/#weights`;
|
|
@@ -216,6 +281,7 @@ export function closeInferWorker() {
|
|
|
216
281
|
* Потоковая генерация ответа локальной модели (`streamChat` для `/MODELS/Local/*`).
|
|
217
282
|
*/
|
|
218
283
|
export async function* localStreamChat(ai, body = {}, options = {}) {
|
|
284
|
+
touchLocalEngineActivity();
|
|
219
285
|
const weightsDir = resolveWeightsDir(ai);
|
|
220
286
|
const messages = Array.isArray(body?.messages) ? body.messages : [];
|
|
221
287
|
const turns = extractConversationTurns(messages);
|