odant-work 1.0.22 → 1.0.24
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 +10 -9
- package/MODELS/$ai/$folder/$class/$provider/handlers/pages/form/trainer/$handler/trainer.js +215 -1
- package/package.json +1 -1
- package/sources/data/progress.md +8 -0
- package/sources/modules/trainer/downloader.js +1637 -0
- package/sources/modules/trainer/halogen.js +42 -27
- package/sources/modules/trainer/huggingface.js +260 -142
- package/sources/modules/trainer/index.js +78 -0
|
@@ -35,6 +35,7 @@ import https from 'node:https';
|
|
|
35
35
|
import crypto from 'node:crypto';
|
|
36
36
|
import { spawn } from 'node:child_process';
|
|
37
37
|
import { startHuggingFaceDownload, listHuggingFaceDownloads, registerLocalModelNode } from './huggingface.js';
|
|
38
|
+
import { loadTrainerNetworkSettings, createNetworkFetch, downloadFileMultipart } from './downloader.js';
|
|
38
39
|
|
|
39
40
|
export const HALOGEN_DEFAULT_PORT = Number(process.env.HALOGEN_API_PORT) || 8731;
|
|
40
41
|
export const HALOGEN_DEFAULT_BASE_URL = process.env.HALOGEN_BASE_URL || `http://127.0.0.1:${HALOGEN_DEFAULT_PORT}/v1/chat/completions`;
|
|
@@ -852,43 +853,57 @@ export async function prepareWindowsBuboRuntime({
|
|
|
852
853
|
// Шаг 1: Если `bubo.exe` ещё не установлен, скачиваем официальный релиз `bubo-v0.1.2-windows-x64-gfx1151.zip`
|
|
853
854
|
if (!envInfo.buboInstalled || step === 'download-bubo') {
|
|
854
855
|
const zipPath = path.join(runtimeRoot, BUBO_WINDOWS_RELEASE.zipFileName);
|
|
855
|
-
|
|
856
|
+
const netCfg = loadTrainerNetworkSettings(rootDir);
|
|
857
|
+
const effProxy = fetchImpl === globalThis.fetch ? netCfg.proxyUrl : '';
|
|
858
|
+
const netFetch = createNetworkFetch({ proxyUrl: effProxy, fetchImpl });
|
|
859
|
+
|
|
860
|
+
appendLog(`Скачивание ${BUBO_WINDOWS_RELEASE.zipFileName} (${(BUBO_WINDOWS_RELEASE.sizeBytes / (1024 * 1024)).toFixed(1)} МБ, ${netCfg.threads} потоков)…`);
|
|
856
861
|
_windowsPrepareState.progress = 15;
|
|
857
862
|
|
|
858
|
-
const
|
|
859
|
-
|
|
860
|
-
|
|
863
|
+
const dlRes = await downloadFileMultipart({
|
|
864
|
+
url: BUBO_WINDOWS_RELEASE.downloadUrl,
|
|
865
|
+
stagedFile: zipPath,
|
|
866
|
+
expectedSize: BUBO_WINDOWS_RELEASE.sizeBytes,
|
|
867
|
+
threads: netCfg.threads,
|
|
868
|
+
fetchImpl: netFetch,
|
|
869
|
+
onProgress: ({ downloadedBytes, totalBytes }) => {
|
|
870
|
+
const denom = totalBytes || BUBO_WINDOWS_RELEASE.sizeBytes;
|
|
871
|
+
if (denom > 0)
|
|
872
|
+
_windowsPrepareState.progress = Math.min(55, 15 + Math.round((downloadedBytes / denom) * 40));
|
|
873
|
+
},
|
|
874
|
+
});
|
|
861
875
|
|
|
862
|
-
const
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
876
|
+
const statZip = await fsp.stat(zipPath);
|
|
877
|
+
if (statZip.size === BUBO_WINDOWS_RELEASE.sizeBytes) {
|
|
878
|
+
const hash = crypto.createHash('sha256');
|
|
879
|
+
await new Promise((resolve, reject) => {
|
|
880
|
+
const rs = fs.createReadStream(zipPath);
|
|
881
|
+
rs.on('data', c => hash.update(c));
|
|
882
|
+
rs.once('end', resolve);
|
|
883
|
+
rs.once('error', reject);
|
|
884
|
+
});
|
|
885
|
+
const digest = hash.digest('hex');
|
|
886
|
+
if (digest !== BUBO_WINDOWS_RELEASE.sha256) {
|
|
887
|
+
await fsp.rm(zipPath, { force: true }).catch(() => {});
|
|
888
|
+
throw new Error(`Контрольная сумма SHA-256 архива Bubo не совпала: ожидалась ${BUBO_WINDOWS_RELEASE.sha256}, получена ${digest}`);
|
|
872
889
|
}
|
|
873
890
|
}
|
|
874
|
-
else if (typeof res.arrayBuffer === 'function') {
|
|
875
|
-
const buf = Buffer.from(await res.arrayBuffer());
|
|
876
|
-
hash.update(buf);
|
|
877
|
-
chunks.push(buf);
|
|
878
|
-
}
|
|
879
891
|
|
|
880
|
-
const fullZip = Buffer.concat(chunks);
|
|
881
|
-
const digest = hash.digest('hex');
|
|
882
|
-
if (fullZip.length === BUBO_WINDOWS_RELEASE.sizeBytes && digest !== BUBO_WINDOWS_RELEASE.sha256) {
|
|
883
|
-
throw new Error(`Контрольная сумма SHA-256 архива Bubo не совпала: ожидалась ${BUBO_WINDOWS_RELEASE.sha256}, получена ${digest}`);
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
await fsp.writeFile(zipPath, fullZip);
|
|
887
892
|
await fsp.mkdir(buboDir, { recursive: true });
|
|
888
893
|
appendLog('Распаковка архива Halowin Bubo…');
|
|
889
894
|
_windowsPrepareState.progress = 60;
|
|
890
895
|
|
|
891
|
-
|
|
896
|
+
let isPkZip = false;
|
|
897
|
+
try {
|
|
898
|
+
const fh = await fsp.open(zipPath, 'r');
|
|
899
|
+
const magic = Buffer.alloc(2);
|
|
900
|
+
await fh.read(magic, 0, 2, 0);
|
|
901
|
+
await fh.close();
|
|
902
|
+
isPkZip = magic.toString('ascii') === 'PK';
|
|
903
|
+
}
|
|
904
|
+
catch { /* ignore */ }
|
|
905
|
+
|
|
906
|
+
if (os.platform() === 'win32' && isPkZip) {
|
|
892
907
|
await new Promise((resolve, reject) => {
|
|
893
908
|
const ps = spawnImpl('powershell', [
|
|
894
909
|
'-NoProfile',
|