odant-work 1.0.52 → 1.0.54
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 +14 -14
- package/MODELS/$ai/$folder/$class/$ai/class.js +31 -0
- package/MODELS/$ai/$folder/$class/$ai/handlers/pages/form/trainer/$handler/trainer.js +78 -7
- package/MODELS/$ai/$folder/$class/$provider/handlers/pages/form/trainer/$handler/trainer.js +11 -7
- package/package.json +1 -1
- package/sources/data/progress.md +8 -0
- package/sources/modules/agent/voice.js +3 -0
- package/sources/modules/trainer/huggingface.js +32 -4
- package/sources/modules/trainer/index.js +107 -4
- package/sources/modules/trainer/local-engine.js +113 -19
- package/sources/modules/trainer/paths.js +20 -13
- package/sources/modules/trainer/worker/local_infer_worker.py +337 -5
|
@@ -384,6 +384,10 @@ function inferTestModality(ai) {
|
|
|
384
384
|
return 'tts';
|
|
385
385
|
if (caps.includes('stt') || caps.includes('asr') || mod === 'stt' || mod === 'asr')
|
|
386
386
|
return 'stt';
|
|
387
|
+
if (caps.includes('music') || mod === 'music' || /musicgen|audioldm/i.test(String(ai?.id || ai?.model || '')))
|
|
388
|
+
return 'music';
|
|
389
|
+
if (caps.includes('video') || caps.includes('text-to-video') || mod === 'video')
|
|
390
|
+
return 'video';
|
|
387
391
|
if (caps.includes('image') || caps.includes('text-to-image') || mod === 'image')
|
|
388
392
|
return 'image';
|
|
389
393
|
if (caps.includes('rerank') || mod === 'rerank' || /rerank/i.test(String(ai?.id || ai?.model || '')))
|
|
@@ -498,6 +502,59 @@ async function runSingleModelSmokeTest(ai, p = {}) {
|
|
|
498
502
|
summary: `Картинка ${pic?.mime || 'image/png'} за ${(durationMs / 1000).toFixed(1)} с`,
|
|
499
503
|
};
|
|
500
504
|
}
|
|
505
|
+
if (modality === 'video') {
|
|
506
|
+
const prompt = String(p.prompt || 'Камера плавно облетает современный светлый офис с панорамными окнами, кинематографичный свет').trim();
|
|
507
|
+
const vid = await ai.generateVideo({
|
|
508
|
+
prompt,
|
|
509
|
+
size: p.size,
|
|
510
|
+
numFrames: p.numFrames ? Number(p.numFrames) : undefined,
|
|
511
|
+
fps: p.fps ? Number(p.fps) : undefined,
|
|
512
|
+
steps: p.steps ? Number(p.steps) : undefined,
|
|
513
|
+
});
|
|
514
|
+
const totalMs = Math.max(1, Date.now() - t0);
|
|
515
|
+
const loadMs = Number(vid?.loadMs) || 0;
|
|
516
|
+
const durationMs = Number(vid?.genMs || vid?.durationMs) || Math.max(1, totalMs - loadMs);
|
|
517
|
+
return {
|
|
518
|
+
ok: true,
|
|
519
|
+
modality,
|
|
520
|
+
device: vid?.device || '',
|
|
521
|
+
loadMs,
|
|
522
|
+
durationMs,
|
|
523
|
+
totalMs,
|
|
524
|
+
mime: vid?.mime || 'video/mp4',
|
|
525
|
+
base64: vid?.base64 || '',
|
|
526
|
+
frames: vid?.frames || 0,
|
|
527
|
+
fps: vid?.fps || 16,
|
|
528
|
+
summary: `Видео ${vid?.frames || 17} кадр. (${vid?.mime || 'video/mp4'}) за ${(durationMs / 1000).toFixed(1)} с`,
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
if (modality === 'music') {
|
|
532
|
+
const prompt = String(p.prompt || 'Спокойная современная корпоративная фоновая мелодия, мягкое пианино и лёгкий ритм').trim();
|
|
533
|
+
const rawCaps = Array.isArray(ai?.capabilities) ? ai.capabilities : (Array.isArray(ai?.DATA?.capabilities) ? ai.DATA.capabilities : []);
|
|
534
|
+
const patchedAi = rawCaps.map(c => String(c).toLowerCase()).includes('music')
|
|
535
|
+
? ai
|
|
536
|
+
: Object.assign(Object.create(Object.getPrototypeOf(ai)), ai, { capabilities: ['music'] });
|
|
537
|
+
const mus = await patchedAi.generateMusic({
|
|
538
|
+
prompt,
|
|
539
|
+
durationSec: p.durationSec ? Number(p.durationSec) : (p.duration ? Number(p.duration) : undefined),
|
|
540
|
+
seed: p.seed,
|
|
541
|
+
});
|
|
542
|
+
const totalMs = Math.max(1, Date.now() - t0);
|
|
543
|
+
const loadMs = Number(mus?.loadMs) || 0;
|
|
544
|
+
const durationMs = Number(mus?.genMs || mus?.durationMs) || Math.max(1, totalMs - loadMs);
|
|
545
|
+
return {
|
|
546
|
+
ok: true,
|
|
547
|
+
modality,
|
|
548
|
+
device: mus?.device || '',
|
|
549
|
+
loadMs,
|
|
550
|
+
durationMs,
|
|
551
|
+
totalMs,
|
|
552
|
+
mime: mus?.mime || 'audio/wav',
|
|
553
|
+
audioBase64: mus?.audioBase64 || '',
|
|
554
|
+
sampleRate: mus?.sampleRate || 32000,
|
|
555
|
+
summary: `Аудио WAV (${Math.round((mus?.audioBase64?.length || 0) * 0.75 / 1024)} КБ) за ${(durationMs / 1000).toFixed(1)} с`,
|
|
556
|
+
};
|
|
557
|
+
}
|
|
501
558
|
if (modality === 'embed') {
|
|
502
559
|
const input = Array.isArray(p.input) && p.input.length
|
|
503
560
|
? p.input
|
|
@@ -798,6 +855,42 @@ export const TRAINER_METHODS = Object.freeze({
|
|
|
798
855
|
const resolvedProtocol = d.protocol || (isLocal ? 'local' : 'openai');
|
|
799
856
|
const rawBaseUrl = (d.baseUrl && d.baseUrl !== 'null') ? String(d.baseUrl) : '';
|
|
800
857
|
const cleanBaseUrl = resolvedProtocol === 'local' ? '' : rawBaseUrl;
|
|
858
|
+
|
|
859
|
+
// Автоисправление устаревших метаданных для известных не-LLM моделей
|
|
860
|
+
// (например, если ранняя версия зарегистрировала musicgen-medium с `['chat', 'stream']`).
|
|
861
|
+
let effModality = d.modality || 'llm';
|
|
862
|
+
let effCaps = Array.isArray(d.capabilities) ? d.capabilities : (d.$public?.capabilities || ['chat', 'stream']);
|
|
863
|
+
if (isLocal) {
|
|
864
|
+
const lookupKey = String(d.hfRepo || d.model || this?.id || '').trim();
|
|
865
|
+
const curated = CURATED_HF_MODELS.find(m =>
|
|
866
|
+
m.id.toLowerCase() === lookupKey.toLowerCase()
|
|
867
|
+
|| String(m.folderName || '').toLowerCase() === String(this?.id || '').toLowerCase()
|
|
868
|
+
|| m.id.split('/').pop().toLowerCase() === String(this?.id || '').toLowerCase()
|
|
869
|
+
);
|
|
870
|
+
const inferred = curated || (lookupKey ? inferModalityAndCapabilities({ id: lookupKey }) : null);
|
|
871
|
+
const capsLow = effCaps.map(c => String(c).toLowerCase());
|
|
872
|
+
const looksLikeDefaultChat = capsLow.length === 0 || capsLow.every(c => c === 'chat' || c === 'stream' || c === 'functions');
|
|
873
|
+
if (inferred && inferred.modality && inferred.modality !== 'llm' && looksLikeDefaultChat && !(inferred.capabilities || []).includes('chat')) {
|
|
874
|
+
effModality = inferred.modality;
|
|
875
|
+
effCaps = [...inferred.capabilities];
|
|
876
|
+
try {
|
|
877
|
+
const clsPath = path.join(process.cwd(), 'MODELS', 'Local', this?.id || '', '$ai', 'class.js');
|
|
878
|
+
if (fs.existsSync(clsPath)) {
|
|
879
|
+
const rawCls = fs.readFileSync(clsPath, 'utf-8');
|
|
880
|
+
const mJson = rawCls.match(/export\s+default\s+(\{[\s\S]*\})\s*;?\s*$/);
|
|
881
|
+
if (mJson) {
|
|
882
|
+
const parsed = JSON.parse(mJson[1]);
|
|
883
|
+
parsed.modality = effModality;
|
|
884
|
+
parsed.capabilities = effCaps;
|
|
885
|
+
fs.writeFileSync(clsPath, `/**\n * Локальная модель ИИ: ${parsed.label || this?.id} (${effModality})\n * Репозиторий Hugging Face: ${parsed.hfRepo || 'локальный'}\n */\nexport default ${JSON.stringify(parsed, null, 4)};\n`, 'utf-8');
|
|
886
|
+
this?.reset?.();
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
catch { /* ignore */ }
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
|
|
801
894
|
const engineSetup = (resolvedProtocol === 'halogen' || weightInfo?.hasGguf)
|
|
802
895
|
? await describeEngineSetup().catch(() => null)
|
|
803
896
|
: null;
|
|
@@ -827,10 +920,10 @@ export const TRAINER_METHODS = Object.freeze({
|
|
|
827
920
|
protocol: resolvedProtocol,
|
|
828
921
|
model: d.model || this?.id || '',
|
|
829
922
|
baseUrl: cleanBaseUrl,
|
|
830
|
-
modality:
|
|
923
|
+
modality: effModality,
|
|
831
924
|
maxTokens: Number(d.maxTokens || d.$public?.maxTokens) || 32768,
|
|
832
925
|
maxOutput: Number(d.maxOutput || d.$public?.maxOutput) || 8192,
|
|
833
|
-
capabilities:
|
|
926
|
+
capabilities: effCaps,
|
|
834
927
|
efforts: Array.isArray(d.efforts) ? d.efforts : [],
|
|
835
928
|
weightsDir: resolvedWeightsRel,
|
|
836
929
|
primaryFile: resolvedPrimaryFile,
|
|
@@ -1197,15 +1290,25 @@ export const TRAINER_METHODS = Object.freeze({
|
|
|
1197
1290
|
trainer_hf_download: {
|
|
1198
1291
|
level: 'admin',
|
|
1199
1292
|
fn: async function (p = {}) {
|
|
1200
|
-
const
|
|
1293
|
+
const repoId = String(p.repoId ?? p.id ?? '').trim();
|
|
1294
|
+
const curated = CURATED_HF_MODELS.find(m => m.id.toLowerCase() === repoId.toLowerCase()) || null;
|
|
1295
|
+
let files = typeof p.files === 'string' && p.files.trim().startsWith('[')
|
|
1201
1296
|
? JSON.parse(p.files)
|
|
1202
1297
|
: Array.isArray(p.files) ? p.files : null;
|
|
1298
|
+
if (!files && Array.isArray(curated?.files) && curated.files.length)
|
|
1299
|
+
files = curated.files;
|
|
1203
1300
|
const job = await startHuggingFaceDownload({
|
|
1204
|
-
repoId
|
|
1301
|
+
repoId,
|
|
1205
1302
|
files,
|
|
1206
1303
|
quant: p.quant || 'Q8_0',
|
|
1207
1304
|
revision: p.revision || 'main',
|
|
1208
1305
|
token: p.token || '',
|
|
1306
|
+
targetNodeName: p.targetNodeName || curated?.folderName || '',
|
|
1307
|
+
nodeMeta: curated ? {
|
|
1308
|
+
label: curated.modelName,
|
|
1309
|
+
modality: curated.modality,
|
|
1310
|
+
capabilities: curated.capabilities,
|
|
1311
|
+
} : null,
|
|
1209
1312
|
registerInWork: p.registerInWork !== false && p.registerInWork !== 'false',
|
|
1210
1313
|
waitForCompletion: p.wait === true || p.wait === 'true',
|
|
1211
1314
|
});
|
|
@@ -340,18 +340,31 @@ function hasTorchWeightsSync(weightsDir) {
|
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
-
function
|
|
344
|
-
if (!
|
|
345
|
-
return
|
|
346
|
-
|
|
347
|
-
const
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
343
|
+
function scanOnnxFilesSync(dirPath, depth = 0, out = []) {
|
|
344
|
+
if (!dirPath || depth > 6 || !fs.existsSync(dirPath))
|
|
345
|
+
return out;
|
|
346
|
+
try {
|
|
347
|
+
for (const ent of fs.readdirSync(dirPath, { withFileTypes: true })) {
|
|
348
|
+
if (ent.name.startsWith('.') || ent.name === '__pycache__')
|
|
349
|
+
continue;
|
|
350
|
+
const full = path.join(dirPath, ent.name);
|
|
351
|
+
if (ent.isFile() && ent.name.toLowerCase().endsWith('.onnx') && !ent.name.endsWith('.part'))
|
|
352
|
+
out.push(full);
|
|
353
|
+
else if (ent.isDirectory())
|
|
354
|
+
scanOnnxFilesSync(full, depth + 1, out);
|
|
351
355
|
}
|
|
352
|
-
catch { /* ignore */ }
|
|
353
356
|
}
|
|
354
|
-
|
|
357
|
+
catch { /* ignore */ }
|
|
358
|
+
return out;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
function hasOnnxModelSync(weightsDir) {
|
|
362
|
+
return scanOnnxFilesSync(weightsDir).length > 0;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
function isPiperOnnxDirSync(weightsDir) {
|
|
366
|
+
const onnxFiles = scanOnnxFilesSync(weightsDir);
|
|
367
|
+
return onnxFiles.some(f => fs.existsSync(`${f}.json`));
|
|
355
368
|
}
|
|
356
369
|
|
|
357
370
|
export function packagesForModality(modality = 'llm', weightsDir = '') {
|
|
@@ -367,8 +380,14 @@ export function packagesForModality(modality = 'llm', weightsDir = '') {
|
|
|
367
380
|
}
|
|
368
381
|
if (mod === 'embed' || mod === 'embedding' || mod === 'rerank')
|
|
369
382
|
return ['torch', 'transformers', 'safetensors', 'accelerate'];
|
|
383
|
+
if (mod === 'video' || mod === 'text-to-video')
|
|
384
|
+
return ['torch', 'diffusers', 'accelerate', 'pillow', 'transformers', 'safetensors', 'imageio', 'imageio-ffmpeg'];
|
|
370
385
|
if (mod === 'image' || mod === 'text-to-image')
|
|
371
386
|
return ['torch', 'diffusers', 'accelerate', 'pillow', 'transformers', 'safetensors'];
|
|
387
|
+
if ((mod === 'tts' || mod === 'voice') && isPiperOnnxDirSync(weightsDir))
|
|
388
|
+
return ['piper-tts', 'onnxruntime'];
|
|
389
|
+
if (mod === 'music' || mod === 'text-to-audio')
|
|
390
|
+
return ['torch', 'transformers', 'accelerate', 'safetensors', 'soundfile'];
|
|
372
391
|
if (mod === 'tts' || mod === 'voice')
|
|
373
392
|
return ['torch', 'qwen-tts', 'soundfile', 'transformers', 'accelerate', 'safetensors'];
|
|
374
393
|
if (mod === 'stt' || mod === 'asr' || mod === 'audio')
|
|
@@ -750,8 +769,19 @@ export async function* localStreamChat(ai, body = {}, options = {}) {
|
|
|
750
769
|
throw new Error('Загрузка весов модели ещё не завершена (проверьте вкладку «Модели» в /MODELS/Local).');
|
|
751
770
|
}
|
|
752
771
|
|
|
753
|
-
|
|
754
|
-
|
|
772
|
+
const aiCaps = (Array.isArray(ai?.capabilities || ai?.DATA?.capabilities)
|
|
773
|
+
? (ai?.capabilities || ai?.DATA?.capabilities)
|
|
774
|
+
: []).map(c => String(c).toLowerCase());
|
|
775
|
+
const aiMod = String(ai?.modality || ai?.DATA?.modality || '').toLowerCase();
|
|
776
|
+
const nonChatCap = aiCaps.find(c => ['music', 'tts', 'stt', 'asr', 'image', 'video', 'embeddings', 'rerank'].includes(c));
|
|
777
|
+
if (wInsp.hasReadyWeights) {
|
|
778
|
+
if ((nonChatCap && !aiCaps.includes('chat')) || ['image', 'video', 'embed', 'rerank', 'tts', 'stt', 'music'].includes(aiMod)) {
|
|
779
|
+
throw new Error(`Эта модель (${nonChatCap || aiMod}) не предназначена для текстового чата — используйте соответствующий режим в её карточке.`);
|
|
780
|
+
}
|
|
781
|
+
if (!wInsp.hasSafetensors) {
|
|
782
|
+
throw new Error(`Веса модели уже скачаны (формат: ${wInsp.weightFormat || 'other'}), но для локального текстового чата требуются .safetensors + tokenizer.json.`);
|
|
783
|
+
}
|
|
784
|
+
throw new Error('Веса модели (.safetensors) скачаны, но в $ai/#weights отсутствует config.json или tokenizer.json.');
|
|
755
785
|
}
|
|
756
786
|
|
|
757
787
|
throw new Error('Файлы весов модели ещё не скачаны в $ai/#weights (откройте /MODELS/Local для установки).');
|
|
@@ -855,7 +885,8 @@ async function runWorkerOp(payload, timeoutMs = 120000) {
|
|
|
855
885
|
// На машинах Strix Halo (gfx1151) автоматически апгрейдим CPU-only torch до GPU ROCm 7.13 (Radeon 8060S/8065S),
|
|
856
886
|
// чтобы Qwen3-TTS 1.7B, Qwen3-ASR 1.7B, Z-Image-Turbo 6B и локальные LLM работали на iGPU в 5–10 раз быстрее.
|
|
857
887
|
const op = String(payload?.op || 'llm');
|
|
858
|
-
const usesOnnxFastPath = (op === 'embed' || op === 'rerank') && hasOnnxModelSync(payload?.weightsDir || '')
|
|
888
|
+
const usesOnnxFastPath = ((op === 'embed' || op === 'rerank') && hasOnnxModelSync(payload?.weightsDir || ''))
|
|
889
|
+
|| (op === 'tts' && isPiperOnnxDirSync(payload?.weightsDir || ''));
|
|
859
890
|
if (
|
|
860
891
|
op !== 'check_deps'
|
|
861
892
|
&& !usesOnnxFastPath
|
|
@@ -896,7 +927,7 @@ function assertLocalWeightsReady(ai) {
|
|
|
896
927
|
const wInsp = inspectWeightsDirectorySync(weightsDir);
|
|
897
928
|
if (wInsp.incompatibleOnPlatform)
|
|
898
929
|
throw new Error(wInsp.incompatibleReason);
|
|
899
|
-
if (!wInsp.exists || (!wInsp.hasSafetensors && !wInsp.hasConfig && !hasOnnxModelSync(weightsDir)))
|
|
930
|
+
if (!wInsp.exists || (!wInsp.hasReadyWeights && !wInsp.hasSafetensors && !wInsp.hasConfig && !hasOnnxModelSync(weightsDir)))
|
|
900
931
|
throw new Error('Файлы весов модели ещё не скачаны в $ai/#weights.');
|
|
901
932
|
return weightsDir;
|
|
902
933
|
}
|
|
@@ -944,7 +975,7 @@ export async function localGenerateImage(ai, params = {}) {
|
|
|
944
975
|
const prompt = String(params.prompt || params.post || '').trim();
|
|
945
976
|
if (!prompt)
|
|
946
977
|
throw new Error('generateImage: пустой prompt');
|
|
947
|
-
const isTurbo = /z-image|turbo/i.test(weightsDir) || /z-image|turbo/i.test(String(ai?.model || ai?.id || ''));
|
|
978
|
+
const isTurbo = /z-image|turbo|schnell/i.test(weightsDir) || /z-image|turbo|schnell/i.test(String(ai?.model || ai?.id || ''));
|
|
948
979
|
const defaultSteps = isTurbo ? 4 : 8;
|
|
949
980
|
const res = await runWorkerOp({
|
|
950
981
|
op: 'image',
|
|
@@ -965,6 +996,60 @@ export async function localGenerateImage(ai, params = {}) {
|
|
|
965
996
|
};
|
|
966
997
|
}
|
|
967
998
|
|
|
999
|
+
export async function localGenerateVideo(ai, params = {}) {
|
|
1000
|
+
const weightsDir = assertLocalWeightsReady(ai);
|
|
1001
|
+
const prompt = String(params.prompt || params.post || '').trim();
|
|
1002
|
+
if (!prompt)
|
|
1003
|
+
throw new Error('generateVideo: пустой prompt');
|
|
1004
|
+
const isLtx = /ltx/i.test(weightsDir) || /ltx/i.test(String(ai?.model || ai?.id || ''));
|
|
1005
|
+
const res = await runWorkerOp({
|
|
1006
|
+
op: 'video',
|
|
1007
|
+
weightsDir,
|
|
1008
|
+
prompt,
|
|
1009
|
+
size: String(params.size || (isLtx ? '512x320' : '480x320')),
|
|
1010
|
+
numFrames: Math.max(9, Math.min(121, Number(params.numFrames || params.frames) || 17)),
|
|
1011
|
+
fps: Math.max(8, Math.min(30, Number(params.fps) || 16)),
|
|
1012
|
+
steps: Math.max(4, Math.min(50, Number(params.steps) || (isLtx ? 12 : 18))),
|
|
1013
|
+
seed: params.seed != null ? Number(params.seed) : 42,
|
|
1014
|
+
}, 600000);
|
|
1015
|
+
return {
|
|
1016
|
+
mime: res.mime || 'video/mp4',
|
|
1017
|
+
base64: res.base64,
|
|
1018
|
+
frames: Number(res.frames) || 0,
|
|
1019
|
+
fps: Number(res.fps) || 16,
|
|
1020
|
+
model: String(ai?.model || ai?.id || 'local-video'),
|
|
1021
|
+
device: res.device || '',
|
|
1022
|
+
loadMs: Number(res.loadMs) || 0,
|
|
1023
|
+
genMs: Number(res.genMs || res.durationMs) || 0,
|
|
1024
|
+
durationMs: Number(res.genMs || res.durationMs) || 0,
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
export async function localGenerateMusic(ai, params = {}) {
|
|
1029
|
+
const weightsDir = assertLocalWeightsReady(ai);
|
|
1030
|
+
const prompt = String(params.prompt || params.post || '').trim();
|
|
1031
|
+
if (!prompt)
|
|
1032
|
+
throw new Error('generateMusic: пустой prompt');
|
|
1033
|
+
const durationSec = Math.max(2, Math.min(30, Number(params.durationSec || params.duration) || 8));
|
|
1034
|
+
const res = await runWorkerOp({
|
|
1035
|
+
op: 'music',
|
|
1036
|
+
weightsDir,
|
|
1037
|
+
prompt,
|
|
1038
|
+
durationSec,
|
|
1039
|
+
...(params.seed != null ? { seed: Number(params.seed) } : {}),
|
|
1040
|
+
}, 360000);
|
|
1041
|
+
return {
|
|
1042
|
+
mime: res.mime || 'audio/wav',
|
|
1043
|
+
audioBase64: res.audioBase64,
|
|
1044
|
+
sampleRate: Number(res.sampleRate) || 32000,
|
|
1045
|
+
model: String(ai?.model || ai?.id || 'local-music'),
|
|
1046
|
+
device: res.device || '',
|
|
1047
|
+
loadMs: Number(res.loadMs) || 0,
|
|
1048
|
+
genMs: Number(res.genMs || res.durationMs) || 0,
|
|
1049
|
+
durationMs: Number(res.genMs || res.durationMs) || 0,
|
|
1050
|
+
};
|
|
1051
|
+
}
|
|
1052
|
+
|
|
968
1053
|
export async function localSpeak(ai, params = {}) {
|
|
969
1054
|
const weightsDir = assertLocalWeightsReady(ai);
|
|
970
1055
|
const text = String(params.text ?? params.post ?? '').trim().slice(0, 1500);
|
|
@@ -1069,6 +1154,9 @@ const ALLOWED_PYTHON_DEPS = new Set([
|
|
|
1069
1154
|
'soundfile',
|
|
1070
1155
|
'qwen-tts',
|
|
1071
1156
|
'qwen-asr',
|
|
1157
|
+
'piper-tts',
|
|
1158
|
+
'imageio',
|
|
1159
|
+
'imageio-ffmpeg',
|
|
1072
1160
|
'sentencepiece',
|
|
1073
1161
|
'safetensors',
|
|
1074
1162
|
'onnxruntime',
|
|
@@ -1298,15 +1386,17 @@ export function collectPackagesForAllInstalledModelsSync(rootDir = process.cwd()
|
|
|
1298
1386
|
if (!fs.existsSync(weightsDir))
|
|
1299
1387
|
continue;
|
|
1300
1388
|
const wInsp = inspectWeightsDirectorySync(weightsDir);
|
|
1301
|
-
if (!wInsp.
|
|
1389
|
+
if (!wInsp.hasReadyWeights)
|
|
1302
1390
|
continue;
|
|
1303
1391
|
let mod = '';
|
|
1304
1392
|
const classFile = path.join(aiDir, 'class.js');
|
|
1305
1393
|
if (fs.existsSync(classFile)) {
|
|
1306
1394
|
try {
|
|
1307
1395
|
const raw = fs.readFileSync(classFile, 'utf-8');
|
|
1308
|
-
if (/"
|
|
1396
|
+
if (/"music"/i.test(raw)) mod = 'music';
|
|
1397
|
+
else if (/"tts"/i.test(raw)) mod = 'tts';
|
|
1309
1398
|
else if (/"(stt|asr)"/i.test(raw)) mod = 'stt';
|
|
1399
|
+
else if (/"video"/i.test(raw)) mod = 'video';
|
|
1310
1400
|
else if (/"(image|text-to-image)"/i.test(raw)) mod = 'image';
|
|
1311
1401
|
else if (/"rerank"/i.test(raw)) mod = 'rerank';
|
|
1312
1402
|
else if (/"(embeddings|embed)"/i.test(raw)) mod = 'embed';
|
|
@@ -1315,8 +1405,10 @@ export function collectPackagesForAllInstalledModelsSync(rootDir = process.cwd()
|
|
|
1315
1405
|
}
|
|
1316
1406
|
if (!mod) {
|
|
1317
1407
|
const low = ent.name.toLowerCase();
|
|
1318
|
-
if (low.includes('
|
|
1408
|
+
if (low.includes('musicgen') || low.includes('audioldm')) mod = 'music';
|
|
1409
|
+
else if (low.includes('tts') || low.includes('piper')) mod = 'tts';
|
|
1319
1410
|
else if (low.includes('asr') || low.includes('whisper')) mod = 'stt';
|
|
1411
|
+
else if (low.includes('video') || low.includes('wan') || low.includes('ltx')) mod = 'video';
|
|
1320
1412
|
else if (low.includes('image') || low.includes('flux') || low.includes('sd')) mod = 'image';
|
|
1321
1413
|
else if (low.includes('rerank')) mod = 'rerank';
|
|
1322
1414
|
else if (low.includes('bge') || low.includes('embed')) mod = 'embed';
|
|
@@ -1364,7 +1456,7 @@ export async function installLocalPythonDeps(packages = [], { rootDir = process.
|
|
|
1364
1456
|
if (!clean.length)
|
|
1365
1457
|
clean = ['torch', 'transformers', 'accelerate', 'safetensors'];
|
|
1366
1458
|
|
|
1367
|
-
const usesOnnxOnly = clean.some(p => p.startsWith('onnxruntime')) && !clean.includes('torch') && !upgradeRocmGfx1151;
|
|
1459
|
+
const usesOnnxOnly = (clean.some(p => p.startsWith('onnxruntime')) || clean.includes('piper-tts')) && !clean.includes('torch') && !upgradeRocmGfx1151;
|
|
1368
1460
|
if (!usesOnnxOnly && !clean.includes('torch') && clean.some(p => p !== 'safetensors' && p !== 'numpy'))
|
|
1369
1461
|
clean.unshift('torch');
|
|
1370
1462
|
|
|
@@ -1541,6 +1633,8 @@ export const localEngine = Object.freeze({
|
|
|
1541
1633
|
embed: localEmbed,
|
|
1542
1634
|
rerank: localRerank,
|
|
1543
1635
|
generateImage: localGenerateImage,
|
|
1636
|
+
generateVideo: localGenerateVideo,
|
|
1637
|
+
generateMusic: localGenerateMusic,
|
|
1544
1638
|
speak: localSpeak,
|
|
1545
1639
|
transcribe: localTranscribe,
|
|
1546
1640
|
decide: localDecide,
|
|
@@ -26,22 +26,29 @@ const WEIGHT_SCANNED_SUBDIRS = [...WEIGHT_SIDECAR_SUBDIRS, ...WEIGHT_COMPONENT_S
|
|
|
26
26
|
|
|
27
27
|
function collectWeightDirRawEntriesSync(dirPath) {
|
|
28
28
|
const out = [];
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
const walk = (absDir, relPrefix, depth) => {
|
|
30
|
+
if (depth > 6)
|
|
31
|
+
return;
|
|
32
|
+
let entries = [];
|
|
33
|
+
try {
|
|
34
|
+
entries = fs.readdirSync(absDir, { withFileTypes: true });
|
|
33
35
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
catch {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
for (const ent of entries) {
|
|
40
|
+
if (ent.name.startsWith('.') || ent.name === '__pycache__')
|
|
41
|
+
continue;
|
|
42
|
+
const rel = relPrefix ? `${relPrefix}/${ent.name}` : ent.name;
|
|
43
|
+
if (ent.isFile()) {
|
|
44
|
+
out.push(rel);
|
|
45
|
+
}
|
|
46
|
+
else if (ent.isDirectory()) {
|
|
47
|
+
walk(path.join(absDir, ent.name), rel, depth + 1);
|
|
41
48
|
}
|
|
42
|
-
catch { /* ignore */ }
|
|
43
49
|
}
|
|
44
|
-
}
|
|
50
|
+
};
|
|
51
|
+
walk(dirPath, '', 0);
|
|
45
52
|
return out;
|
|
46
53
|
}
|
|
47
54
|
|