odant-work 1.0.59 → 1.0.61
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/certs/russian_trusted_root_ca.pem +32 -32
- package/#system/mail.json.example +9 -9
- package/#system/package-manifest.json +14 -14
- package/#system/settings.json.example +3 -3
- package/$server/$folder/$class/$device/class.js +2 -2
- package/$server/$folder/$class/$domain/class.js +4 -4
- package/$server/$folder/$class/$domain/readme.md +5 -5
- package/$server/$folder/$class/$handler/$task/class.js +2 -2
- package/$server/$folder/$class/$handler/$trigger/class.js +3 -3
- package/$server/$folder/$class/$handler/class.js +9 -9
- package/$server/$folder/$class/$handler/handlers/pages/editor/$handler/class.js +5 -5
- package/$server/$folder/$class/$handler/readme.md +23 -23
- package/$server/$folder/$class/$service/$class/$service/class.js +3 -3
- package/$server/$folder/$class/$structure/$base/class.js +9 -9
- package/$server/$folder/$class/$structure/$user/class.js +2 -2
- package/$server/$folder/$class/$structure/handlers/pages/explorer/$handler/class.js +4 -4
- package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/readme.md +40 -40
- package/$server/$folder/$class/$structure/handlers/pages/site/$handler/readme.md +34 -34
- package/$server/$folder/$class/ai/config.js +19 -19
- package/$server/$folder/$class/ai/prompt/$method/class.js +41 -41
- package/$server/$folder/$class/ai/skills/approval-flow.md +14 -14
- package/$server/$folder/$class/ai/skills/backup-check.md +13 -13
- package/$server/$folder/$class/ai/skills/computer.md +27 -27
- package/$server/$folder/$class/ai/skills/delegate-task.md +15 -15
- package/$server/$folder/$class/ai/skills/external-signup.md +14 -14
- package/$server/$folder/$class/ai/skills/lan-inventory.md +16 -16
- package/$server/$folder/$class/ai/skills/onboarding.md +15 -15
- package/$server/$folder/$class/ai/skills/orchestration.md +41 -41
- package/$server/$folder/$class/handlers/pages/form/builder/$handler/builder.js +259 -259
- package/$server/$folder/$class/handlers/pages/form/editor/$handler/editor.js +19 -19
- package/$server/$folder/$class/handlers/pages/storage/$handler/storage.js +20 -20
- package/$server/$folder/$file/$audio/handlers/preview/$handler/class.js +3 -3
- package/$server/$folder/$file/$audio/handlers/preview/$handler/preview.js +88 -88
- package/$server/$folder/$file/$call/class.js +10 -10
- package/$server/$folder/$file/$call/handlers/preview/$handler/class.js +4 -4
- package/$server/$folder/$file/$call/triggers/on_save/$trigger/class.js +48 -48
- package/$server/$folder/$file/$data/class.js +16 -16
- package/$server/$folder/$file/$data/handlers/pages/form/editor/$handler/class.js +5 -5
- package/$server/$folder/$file/$data/handlers/pages/form/editor/$handler/editor.js +26 -26
- package/$server/$folder/$file/$devs/$js/class.js +2 -2
- package/$server/$folder/$file/$devs/$json/class.js +2 -2
- package/$server/$folder/$file/$devs/$ts/class.js +2 -2
- package/$server/$folder/$file/$devs/handlers/pages/form/file/$handler/class.js +3 -3
- package/$server/$folder/$file/$devs/handlers/pages/form/file/$handler/file.js +30 -30
- package/$server/$folder/$file/$eml/class.js +17 -17
- package/$server/$folder/$file/$eml/triggers/on_save/$trigger/class.js +97 -97
- package/$server/$folder/$file/$ics/class.js +44 -44
- package/$server/$folder/$file/$ics/handlers/pages/form/file/$handler/class.js +3 -3
- package/$server/$folder/$file/$ics/handlers/pages/form/file/$handler/file.js +10 -10
- package/$server/$folder/$file/$ics/handlers/preview/$handler/class.js +3 -3
- package/$server/$folder/$file/$ics/handlers/preview/$handler/preview.js +67 -67
- package/$server/$folder/$file/$ics/readme.md +21 -21
- package/$server/$folder/$file/$image/$svg/class.js +11 -11
- package/$server/$folder/$file/$image/handlers/preview/$handler/class.js +3 -3
- package/$server/$folder/$file/$image/handlers/preview/$handler/preview.js +33 -33
- package/$server/$folder/$file/$ipynb/handlers/pages/form/file/$handler/class.js +3 -3
- package/$server/$folder/$file/$logs/class.js +39 -39
- package/$server/$folder/$file/$logs/handlers/methods/txt-test/$handler/class.js +4 -4
- package/$server/$folder/$file/$md/handlers/pages/form/file/$handler/class.js +3 -3
- package/$server/$folder/$file/$md/handlers/pages/form/file/$handler/file.js +63 -63
- package/$server/$folder/$file/$office/$outlook/$ics/class.js +227 -227
- package/$server/$folder/$file/$office/$word/$rtf/template.rtf +159 -159
- package/$server/$folder/$file/$task/handlers/preview/$handler/class.js +3 -3
- package/$server/$folder/$file/$task/progress.md +20 -20
- package/$server/$folder/$file/$task/readme.md +32 -32
- package/$server/$folder/$file/$txt/handlers/preview/$handler/class.js +3 -3
- package/$server/$folder/$file/$txt/handlers/preview/$handler/preview.js +41 -41
- package/$server/$folder/$file/$video/handlers/preview/$handler/class.js +4 -4
- package/$server/$folder/$file/$video/handlers/preview/$handler/preview.js +13 -13
- package/$server/$folder/$file/class.js +2 -2
- package/$server/$folder/$file/handlers/methods/download/$handler/class.js +2 -2
- package/$server/$folder/$file/handlers/methods/download/$handler/download.js +4 -4
- package/$server/$folder/$file/handlers/pages/form/$handler/class.js +2 -2
- package/$server/$folder/$file/handlers/pages/form/file/$handler/class.js +3 -3
- package/$server/$folder/$file/handlers/pages/form/file/$handler/file.js +28 -28
- package/$server/$folder/$file/readme.md +31 -31
- package/$server/$folder/class.js +11 -11
- package/$server/$folder/handlers/methods/create/progress.md +15 -15
- package/$server/$folder/handlers/pages/form/$handler/class.js +5 -5
- package/$server/$folder/handlers/readme.md +24 -24
- package/$server/$folder/lib/calendar-form/calendar-form.js +296 -296
- package/$server/$folder/lib/dialogs/confirm/confirm.js +30 -30
- package/$server/$folder/lib/dialogs/input/input.js +57 -57
- package/$server/$folder/lib/email/settings.js +82 -82
- package/$server/$folder/lib/file-viewer/file-viewer.js +8 -8
- package/$server/$folder/lib/icon/user/user.js +6 -6
- package/$server/$folder/lib/item-data-grid/item-data-grid.js +48 -48
- package/$server/$folder/lib/item-form/item-form.js +84 -84
- package/$server/$folder/lib/menu/progress.md +13 -13
- package/$server/$folder/lib/menu/readme.md +29 -29
- package/$server/$folder/lib/node/progress.md +13 -13
- package/$server/$folder/lib/node/readme.md +29 -29
- package/$server/$folder/lib/pack/pack.js +4 -4
- package/$server/$folder/lib/prompt-bar/progress.md +13 -13
- package/$server/$folder/lib/security/admin/admin.js +30 -30
- package/$server/$folder/lib/site-loc/readme.md +16 -16
- package/$server/$folder/lib/site-loc/site-loc.js +80 -80
- package/$server/$folder/lib/tree/progress.md +16 -16
- package/$server/$folder/readme.md +18 -18
- package/$server/readme.md +13 -13
- package/.cursor/rules/work.mdc +8 -8
- package/.github/workflows/ci.yml +39 -39
- package/MODELS/$ai/$folder/$class/$ai/handlers/pages/form/trainer/$handler/trainer.js +28 -0
- package/MODELS/$ai/$folder/$class/$provider/handlers/pages/form/trainer/$handler/trainer.js +5 -1
- package/MODELS/$ai/$folder/$class/$provider/readme.md +16 -16
- package/MODELS/GigaChat/$provider/readme.md +24 -24
- package/MODULES/Register/$module/$folder/$class/$register/class.js +4 -4
- package/MODULES/Register/$module/$folder/$class/$struct/class.js +4 -4
- package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$virtual/class.js +14 -14
- package/MODULES/Register/CATALOGS//320/241/321/203/320/261/321/212/320/265/320/272/321/202/321/213//320/244/320/270/320/267. /320/273/320/270/321/206/320/260/$catalog/class.js" +11 -11
- package/MODULES/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217//320/237/320/276/320/272/321/203/320/277/320/260/321/202/320/265/320/273/321/216/$operation/print//320/241/321/207/321/221/321/202 /320/275/320/260 /320/276/320/277/320/273/320/260/321/202/321/203.html" +40 -40
- package/MODULES/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217//320/237/320/276/320/272/321/203/320/277/320/260/321/202/320/265/320/273/321/216/$operation/print//320/242/320/276/320/262/320/260/321/200/320/275/320/260/321/217 /320/275/320/260/320/272/320/273/320/260/320/264/320/275/320/260/321/217.html" +56 -56
- package/MODULES/Register/REGISTER/$register/$folder/$class/$account/class.js +18 -18
- package/MODULES/Register/REGISTER/$register/$folder/$class/$register/class.js +11 -11
- package/MODULES/Register/REGISTER/68/01/$account/class.js +1 -1
- package/MODULES/Register/REGISTER/68/02/$account/class.js +1 -1
- package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/320/276/320/262/321/213/320/271 /321/200/320/265/320/267/320/265/321/200/320/262/$account/class.js" +1 -1
- package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/321/213//320/222 /320/276/321/202/320/277/321/203/321/201/320/272/320/265/$account/class.js" +1 -1
- package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/321/213//320/240/320/260/320/261/320/276/321/202/320/260/321/216/321/202/$account/class.js +1 -1
- package/MODULES/Register/REGISTER//320/242/320/265/321/205/320/275/320/270/321/207/320/265/321/201/320/272/320/270/320/271/$account/class.js +1 -1
- package/MODULES/Register/STRUCTS/$struct/$folder/$class/$struct/class.js +4 -4
- package/MODULES/Register/STRUCTS/$struct/class.js +4 -4
- package/MODULES/Register/STRUCTS//320/220/320/264/321/200/320/265/321/201/$struct/class.js +11 -11
- package/MODULES/Register/STRUCTS//320/225/320/264/320/270/320/275/320/270/321/206/320/260 /320/270/320/267/320/274/320/265/321/200/320/265/320/275/320/270/321/217/$struct/class.js" +11 -11
- package/MODULES/Register/STRUCTS//320/237/320/260/321/201/320/277/320/276/321/200/321/202/$struct/class.js +11 -11
- package/NODES/$node/$folder/$class/$node/class.js +35 -35
- package/NODES/$node/class.js +5 -5
- package/NODES/$node/handlers/pages/form/network/$handler/class.js +5 -5
- package/NODES/$node/handlers/pages/form/network/$handler/network.js +110 -110
- package/NODES/teewtew/$node/class.js +2 -2
- package/NODES/work.odant.org/$node/class.js +3 -3
- package/ORGANIZATIONS/$domain/$folder/$class/$base/$folder/$class/$structure/$base/class.js +17 -17
- package/ORGANIZATIONS/$domain/$folder/$class/$base/class.js +4 -4
- package/SERVICES/$service/$folder/$storage/$service/class.js +8 -8
- package/SERVICES/2GIS/$service/class.js +32 -0
- package/SERVICES/2GIS/$service/readme.md +57 -0
- package/USERS/$users/class.js +2 -2
- package/eslint.config.js +51 -51
- package/jsconfig.json +37 -37
- package/oda/benchmarks/dbmon/lib/ENV.js +213 -213
- package/oda/benchmarks/dbmon/lib/ga.js +11 -11
- package/oda/benchmarks/dbmon/lib/memory-stats.js +105 -105
- package/oda/benchmarks/dbmon/lib/monitor.js +69 -69
- package/oda/benchmarks/sierpinski/sierpinski.js +149 -149
- package/oda/components/editors/code-editor/code-editor.js +387 -387
- package/oda/components/editors/code-editor/src/ace.js +16 -16
- package/oda/components/editors/code-editor/src/beautify-css.js +1625 -1625
- package/oda/components/editors/code-editor/src/beautify-html.js +3122 -3122
- package/oda/components/editors/code-editor/src/beautify.js +4005 -4005
- package/oda/components/editors/code-editor/src/ext-beautify.js +7 -7
- package/oda/components/editors/code-editor/src/ext-code_lens.js +7 -7
- package/oda/components/editors/code-editor/src/ext-elastic_tabstops_lite.js +7 -7
- package/oda/components/editors/code-editor/src/ext-emmet.js +7 -7
- package/oda/components/editors/code-editor/src/ext-error_marker.js +7 -7
- package/oda/components/editors/code-editor/src/ext-hardwrap.js +7 -7
- package/oda/components/editors/code-editor/src/ext-keybinding_menu.js +7 -7
- package/oda/components/editors/code-editor/src/ext-language_tools.js +7 -7
- package/oda/components/editors/code-editor/src/ext-linking.js +7 -7
- package/oda/components/editors/code-editor/src/ext-modelist.js +7 -7
- package/oda/components/editors/code-editor/src/ext-options.js +7 -7
- package/oda/components/editors/code-editor/src/ext-prompt.js +7 -7
- package/oda/components/editors/code-editor/src/ext-rtl.js +7 -7
- package/oda/components/editors/code-editor/src/ext-searchbox.js +7 -7
- package/oda/components/editors/code-editor/src/ext-settings_menu.js +7 -7
- package/oda/components/editors/code-editor/src/ext-spellcheck.js +7 -7
- package/oda/components/editors/code-editor/src/ext-split.js +7 -7
- package/oda/components/editors/code-editor/src/ext-static_highlight.js +7 -7
- package/oda/components/editors/code-editor/src/ext-statusbar.js +7 -7
- package/oda/components/editors/code-editor/src/ext-textarea.js +7 -7
- package/oda/components/editors/code-editor/src/ext-themelist.js +7 -7
- package/oda/components/editors/code-editor/src/ext-whitespace.js +7 -7
- package/oda/components/editors/code-editor/src/keybinding-emacs.js +7 -7
- package/oda/components/editors/code-editor/src/keybinding-sublime.js +7 -7
- package/oda/components/editors/code-editor/src/keybinding-vim.js +7 -7
- package/oda/components/editors/code-editor/src/keybinding-vscode.js +7 -7
- package/oda/components/editors/code-editor/src/mode-css.js +7 -7
- package/oda/components/editors/code-editor/src/mode-html.js +7 -7
- package/oda/components/editors/code-editor/src/mode-javascript.js +7 -7
- package/oda/components/editors/code-editor/src/mode-json.js +7 -7
- package/oda/components/editors/code-editor/src/mode-markdown.js +7 -7
- package/oda/components/editors/code-editor/src/mode-svg.js +7 -7
- package/oda/components/editors/code-editor/src/mode-text.js +7 -7
- package/oda/components/editors/code-editor/src/mode-xml.js +7 -7
- package/oda/components/editors/code-editor/src/mode-xquery.js +7 -7
- package/oda/components/editors/code-editor/src/snippets/css.js +7 -7
- package/oda/components/editors/code-editor/src/snippets/html.js +7 -7
- package/oda/components/editors/code-editor/src/snippets/javascript.js +7 -7
- package/oda/components/editors/code-editor/src/snippets/json.js +7 -7
- package/oda/components/editors/code-editor/src/snippets/markdown.js +7 -7
- package/oda/components/editors/code-editor/src/snippets/svg.js +7 -7
- package/oda/components/editors/code-editor/src/snippets/text.js +7 -7
- package/oda/components/editors/code-editor/src/snippets/xml.js +7 -7
- package/oda/components/editors/code-editor/src/snippets/xquery.js +7 -7
- package/oda/components/editors/code-editor/src/theme-solarized_dark.js +7 -7
- package/oda/components/editors/code-editor/src/theme-solarized_light.js +7 -7
- package/oda/components/editors/markdown/markdown-editor/lib/font-awesome.min.css +3 -3
- package/oda/components/editors/markdown/markdown-editor/lib/readme.md +332 -332
- package/oda/components/editors/markdown/markdown-editor/markdown-editor.js +78 -78
- package/oda/components/editors/markdown/markdown-viewer/test.md +239 -239
- package/oda/components/editors/markdown/markdown.js +76 -76
- package/oda/components/inputs/block/readme.md +39 -39
- package/oda/components/inputs/checkbox/checkbox.js +92 -92
- package/oda/components/inputs/color/color.js +83 -83
- package/oda/components/inputs/date/date.js +40 -40
- package/oda/components/inputs/input/input.js +219 -219
- package/oda/components/inputs/link/readme.md +42 -42
- package/oda/components/inputs/markdown-input/markdown-input.js +77 -77
- package/oda/components/inputs/numeric/numeric.js +141 -141
- package/oda/components/inputs/table-input/readme.md +39 -39
- package/oda/components/inputs/text/text.js +88 -88
- package/oda/components/inputs/toggle/toggle.js +101 -101
- package/oda/components/layouts/hexagon-layout/hexagon-layout.js +218 -218
- package/oda/components/menus/menu/index_old.html +140 -140
- package/oda/components/menus/menu/menu.js +238 -238
- package/oda/components/structure/controls-map.js +56 -56
- package/oda/components/structure/controls.js +29 -29
- package/oda/components/structure/readme.md +31 -31
- package/oda/components/structure/structure.js +64 -64
- package/oda/components/table/index.html +210 -210
- package/oda/components/table/lib/coerce.js +68 -68
- package/oda/components/table/lib/column.js +568 -568
- package/oda/components/table/readme.md +120 -120
- package/oda/components/table/router.js +86 -86
- package/oda/components/table/settings.js +89 -89
- package/oda/index.html +159 -159
- package/oda/tools/icons/icons-set/icons-set.js +60 -60
- package/oda/tools/icons/lib/svg/_makeSVG.html +41 -41
- package/oda/tools/icons/lib/svg/aws.svg +2679 -2679
- package/oda/tools/icons/lib/svg/info.json +46 -46
- package/oda/tools/jupyter/demo.ipynb +160 -160
- package/oda/tools/jupyter/lib/print_elements.js +73 -73
- package/oda/tools/jupyter/test-2.ipynb +305 -305
- package/oda/tools/jupyter/test.ipynb +603 -603
- package/oda/tools/styles/adoptedStyleSheets.js +333 -333
- package/oda/tools/tester/device-preview/devices.json +9 -9
- package/opencode.json +9 -9
- package/package.json +1 -1
- package/publish.cmd +2 -2
- package/readme.md +164 -164
- package/rules/rules.md +445 -445
- package/scripts/SYNC-README.md +107 -107
- package/scripts/agent-eval.mjs +223 -223
- package/scripts/dump-svn-chat.mjs +9 -9
- package/scripts/extract-chat-day.mjs +21 -21
- package/scripts/rag-bench.mjs +166 -166
- package/scripts/restore-chat.mjs +166 -166
- package/scripts/sync-svn-git.bat +129 -129
- package/scripts/test-merge.mjs +75 -75
- package/scripts/work-desktop-bridge.mjs +101 -101
- package/sources/client/field.js +168 -168
- package/sources/client/index.js +32 -32
- package/sources/client/readme.md +16 -16
- package/sources/core.js +91 -91
- package/sources/data/choices.js +125 -125
- package/sources/data/progress.md +5 -0
- package/sources/host/babel-merge.js +353 -353
- package/sources/host/config.js +48 -48
- package/sources/host/email-utils.js +269 -269
- package/sources/host/http-server.js +8 -0
- package/sources/host/index-db.js +94 -94
- package/sources/host/net-guard.js +228 -228
- package/sources/host/package-install.js +63 -63
- package/sources/host/progress.md +14 -14
- package/sources/host/push.js +86 -86
- package/sources/host/readme.md +41 -41
- package/sources/host/secret-box.js +93 -93
- package/sources/host/server-id.js +26 -26
- package/sources/host/stun.js +33 -33
- package/sources/host/tls-ca.js +60 -60
- package/sources/host/vapid.js +14 -14
- package/sources/index.html +49 -49
- package/sources/manifest.json +49 -49
- package/sources/modules/a2a/server.js +608 -608
- package/sources/modules/agent/connections.js +442 -442
- package/sources/modules/agent/diff.js +69 -69
- package/sources/modules/agent/eval.js +222 -222
- package/sources/modules/agent/hooks.js +131 -131
- package/sources/modules/agent/log.js +43 -43
- package/sources/modules/agent/mcp-pool.js +253 -253
- package/sources/modules/agent/plugins.js +343 -343
- package/sources/modules/agent/recovery.js +89 -89
- package/sources/modules/agent/taint.js +100 -100
- package/sources/modules/agent/tools/branch.js +311 -311
- package/sources/modules/agent/tools/browser.js +254 -254
- package/sources/modules/agent/tools/computer.js +120 -120
- package/sources/modules/agent/tools/connect.js +316 -316
- package/sources/modules/agent/tools/dev/lsp.js +334 -334
- package/sources/modules/agent/tools/dev/patch.js +564 -564
- package/sources/modules/agent/tools/memory.js +153 -153
- package/sources/modules/agent/tools/os-files.js +358 -358
- package/sources/modules/agent/tools/plugins.js +80 -80
- package/sources/modules/agent/tools/sandbox.js +268 -268
- package/sources/modules/agent/types.d.ts +183 -183
- package/sources/modules/agent/undo.js +254 -254
- package/sources/modules/agent/util.js +179 -179
- package/sources/modules/contacts/contacts.js +200 -200
- package/sources/modules/contacts/index.html +546 -546
- package/sources/modules/lan/discovery.js +192 -192
- package/sources/modules/lan/store.js +62 -62
- package/sources/modules/mcp/readme.md +70 -70
- package/sources/modules/mcp/server.js +525 -525
- package/sources/modules/mcp/tokens.js +140 -140
- package/sources/modules/nodes/identity.js +123 -123
- package/sources/modules/nodes/inbound.js +172 -172
- package/sources/modules/nodes/outbound.js +105 -105
- package/sources/modules/nodes/signing.js +71 -71
- package/sources/modules/rag/embed-worker.js +36 -36
- package/sources/modules/rag/readme.md +70 -70
- package/sources/modules/readme.md +21 -21
- package/sources/modules/sandbox/config.js +74 -74
- package/sources/modules/sandbox/driver.js +100 -100
- package/sources/modules/sandbox/images/work-computer/Dockerfile +34 -34
- package/sources/modules/sandbox/images/work-computer/entrypoint.sh +24 -24
- package/sources/modules/sandbox/manager.js +1089 -1089
- package/sources/modules/sandbox/readme.md +63 -63
- package/sources/modules/sandbox/vnc-proxy.js +296 -296
- package/sources/modules/trainer/halogen.js +9 -9
- package/sources/modules/trainer/huggingface.js +3 -18
- package/sources/modules/trainer/index.js +227 -7
- package/sources/modules/trainer/local-engine.js +163 -18
- package/sources/modules/trainer/worker/local_infer_worker.py +378 -158
- package/sources/readme.md +216 -216
- package/sources/server/access/audit.js +138 -138
- package/sources/server/access/refs.js +106 -106
- package/sources/server/assert-class-id.js +23 -23
- package/sources/server/external-source.js +90 -90
- package/sources/server/index.js +12 -12
- package/sources/server/memory-mark.js +34 -34
- package/sources/server/readme.md +110 -110
- package/sources/server/safe-node-name.js +67 -67
- package/sources/server/upload-mark.js +24 -24
- package/sources/server/zip-guard.js +81 -81
- package/sources/tester.html +54 -54
- package/whitepaper.md +568 -568
|
@@ -301,23 +301,28 @@ class LocalCausalLM:
|
|
|
301
301
|
except Exception:
|
|
302
302
|
pass
|
|
303
303
|
self.store.files.clear()
|
|
304
|
-
except Exception:
|
|
304
|
+
except Exception as e:
|
|
305
305
|
if str(self.device).startswith("cuda"):
|
|
306
306
|
try:
|
|
307
|
+
gc.collect()
|
|
307
308
|
torch.cuda.empty_cache()
|
|
308
309
|
except Exception:
|
|
309
310
|
pass
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
311
|
+
try:
|
|
312
|
+
(
|
|
313
|
+
self.embed_tokens,
|
|
314
|
+
self.norm,
|
|
315
|
+
self.lm_head,
|
|
316
|
+
self.compute_dtype,
|
|
317
|
+
self.inv_freq,
|
|
318
|
+
self.layers,
|
|
319
|
+
) = _build_weights(self.device)
|
|
320
|
+
except Exception as e2:
|
|
321
|
+
raise RuntimeError(json.dumps({
|
|
322
|
+
"error": f"Не удалось загрузить LLM на GPU ({self.device}): {e2} (тихий откат на CPU отключён)"
|
|
323
|
+
}))
|
|
319
324
|
else:
|
|
320
|
-
raise
|
|
325
|
+
raise e
|
|
321
326
|
|
|
322
327
|
def _rope_cos_sin(self, positions, dtype):
|
|
323
328
|
freqs = torch.outer(positions.to(torch.float32), self.inv_freq)
|
|
@@ -470,11 +475,9 @@ def _describe_torch_device(device="cpu"):
|
|
|
470
475
|
if HAS_TORCH and dev_str.startswith("cuda") and torch.cuda.is_available():
|
|
471
476
|
try:
|
|
472
477
|
name = str(torch.cuda.get_device_name(0) or "").strip()
|
|
473
|
-
return f"
|
|
478
|
+
return f"iGPU ({name})" if name else "iGPU (ROCm)"
|
|
474
479
|
except Exception:
|
|
475
|
-
return "
|
|
476
|
-
if dev_str == "ort":
|
|
477
|
-
return "ONNX (DirectML/NPU)"
|
|
480
|
+
return "iGPU (ROCm)"
|
|
478
481
|
return "CPU (BF16)" if _cpu_supports_bf16() else "CPU"
|
|
479
482
|
|
|
480
483
|
|
|
@@ -562,7 +565,6 @@ def _missing_pkg_error(exc, required_map):
|
|
|
562
565
|
|
|
563
566
|
|
|
564
567
|
def handle_check_deps():
|
|
565
|
-
ort_pkg = "onnxruntime-directml" if sys.platform == "win32" else "onnxruntime"
|
|
566
568
|
mods = {
|
|
567
569
|
"torch": "torch",
|
|
568
570
|
"transformers": "transformers",
|
|
@@ -574,7 +576,6 @@ def handle_check_deps():
|
|
|
574
576
|
"qwen_asr": "qwen-asr",
|
|
575
577
|
"piper": "piper-tts",
|
|
576
578
|
"imageio": "imageio",
|
|
577
|
-
"onnxruntime": ort_pkg,
|
|
578
579
|
}
|
|
579
580
|
status = {}
|
|
580
581
|
for mod, pkg in mods.items():
|
|
@@ -585,22 +586,19 @@ def handle_check_deps():
|
|
|
585
586
|
status[pkg] = False
|
|
586
587
|
cuda = False
|
|
587
588
|
device_name = "CPU (BF16)" if _cpu_supports_bf16() else "CPU"
|
|
589
|
+
torch_version = ""
|
|
588
590
|
try:
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
provs = set(ort.get_available_providers() or [])
|
|
595
|
-
if "VitisAIExecutionProvider" in provs or "QNNExecutionProvider" in provs:
|
|
596
|
-
device_name = f"NPU (ONNX) + {device_name}"
|
|
597
|
-
elif "DmlExecutionProvider" in provs:
|
|
598
|
-
device_name = f"DirectML + {device_name}"
|
|
591
|
+
if HAS_TORCH and torch is not None:
|
|
592
|
+
torch_version = str(getattr(torch, "__version__", "") or "")
|
|
593
|
+
cuda = bool(torch.cuda.is_available())
|
|
594
|
+
if cuda:
|
|
595
|
+
device_name = f"iGPU {torch.cuda.get_device_name(0)}"
|
|
599
596
|
except Exception:
|
|
600
597
|
pass
|
|
601
598
|
return {
|
|
602
599
|
"packages": status,
|
|
603
600
|
"cuda": cuda,
|
|
601
|
+
"torchVersion": torch_version,
|
|
604
602
|
"deviceName": device_name,
|
|
605
603
|
"python": sys.executable,
|
|
606
604
|
}
|
|
@@ -609,32 +607,44 @@ def handle_check_deps():
|
|
|
609
607
|
def _load_embed_model(weights_dir, cache):
|
|
610
608
|
key = ("embed", weights_dir)
|
|
611
609
|
if key in cache:
|
|
612
|
-
|
|
610
|
+
cached = cache[key]
|
|
611
|
+
if len(cached) >= 4 and str(cached[3]) == "cpu" and HAS_TORCH and torch.cuda.is_available():
|
|
612
|
+
cache.pop(key, None)
|
|
613
|
+
else:
|
|
614
|
+
return cached
|
|
613
615
|
try:
|
|
614
616
|
from transformers import AutoTokenizer, AutoModel
|
|
615
617
|
except Exception as e:
|
|
616
618
|
raise RuntimeError(json.dumps(_missing_pkg_error(e, {"transformers": "transformers"})))
|
|
617
619
|
tok = AutoTokenizer.from_pretrained(weights_dir, local_files_only=True)
|
|
618
|
-
onnx_path = _find_onnx_file(weights_dir)
|
|
619
|
-
if onnx_path:
|
|
620
|
-
try:
|
|
621
|
-
sess = _load_ort_session(onnx_path)
|
|
622
|
-
cache[key] = ("onnx", tok, sess, "ort")
|
|
623
|
-
return cache[key]
|
|
624
|
-
except Exception:
|
|
625
|
-
if not _has_torch_weights(weights_dir) or not HAS_TORCH:
|
|
626
|
-
raise
|
|
627
620
|
device, dtype = _best_device_and_dtype()
|
|
628
|
-
|
|
621
|
+
load_dtype = dtype if str(device).startswith("cuda") else torch.float32
|
|
622
|
+
|
|
623
|
+
def _load_on(dev, dt):
|
|
629
624
|
try:
|
|
630
|
-
|
|
625
|
+
m = AutoModel.from_pretrained(weights_dir, local_files_only=True, torch_dtype=dt, attn_implementation="sdpa")
|
|
631
626
|
except Exception:
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
627
|
+
m = AutoModel.from_pretrained(weights_dir, local_files_only=True, torch_dtype=dt)
|
|
628
|
+
m.to(dev).eval()
|
|
629
|
+
return m
|
|
630
|
+
|
|
631
|
+
try:
|
|
632
|
+
mdl = _load_on(device, load_dtype)
|
|
633
|
+
except Exception as e:
|
|
634
|
+
if str(device).startswith("cuda") and HAS_TORCH:
|
|
635
|
+
try:
|
|
636
|
+
gc.collect()
|
|
637
|
+
torch.cuda.empty_cache()
|
|
638
|
+
except Exception:
|
|
639
|
+
pass
|
|
640
|
+
try:
|
|
641
|
+
mdl = _load_on(device, load_dtype)
|
|
642
|
+
except Exception as e2:
|
|
643
|
+
raise RuntimeError(json.dumps({
|
|
644
|
+
"error": f"Не удалось загрузить модель эмбеддингов на GPU ({device}): {e2} (тихий откат на CPU отключён)"
|
|
645
|
+
}))
|
|
646
|
+
else:
|
|
647
|
+
raise e
|
|
638
648
|
cache[key] = ("torch", tok, mdl, device)
|
|
639
649
|
return cache[key]
|
|
640
650
|
|
|
@@ -688,32 +698,44 @@ def handle_embed(req, cache):
|
|
|
688
698
|
def _load_rerank_model(weights_dir, cache):
|
|
689
699
|
key = ("rerank", weights_dir)
|
|
690
700
|
if key in cache:
|
|
691
|
-
|
|
701
|
+
cached = cache[key]
|
|
702
|
+
if len(cached) >= 4 and str(cached[3]) == "cpu" and HAS_TORCH and torch.cuda.is_available():
|
|
703
|
+
cache.pop(key, None)
|
|
704
|
+
else:
|
|
705
|
+
return cached
|
|
692
706
|
try:
|
|
693
707
|
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
|
694
708
|
except Exception as e:
|
|
695
709
|
raise RuntimeError(json.dumps(_missing_pkg_error(e, {"transformers": "transformers"})))
|
|
696
710
|
tok = AutoTokenizer.from_pretrained(weights_dir, local_files_only=True)
|
|
697
|
-
onnx_path = _find_onnx_file(weights_dir)
|
|
698
|
-
if onnx_path:
|
|
699
|
-
try:
|
|
700
|
-
sess = _load_ort_session(onnx_path)
|
|
701
|
-
cache[key] = ("onnx", tok, sess, "ort")
|
|
702
|
-
return cache[key]
|
|
703
|
-
except Exception:
|
|
704
|
-
if not _has_torch_weights(weights_dir) or not HAS_TORCH:
|
|
705
|
-
raise
|
|
706
711
|
device, dtype = _best_device_and_dtype()
|
|
707
|
-
|
|
712
|
+
load_dtype = dtype if str(device).startswith("cuda") else torch.float32
|
|
713
|
+
|
|
714
|
+
def _load_on(dev, dt):
|
|
708
715
|
try:
|
|
709
|
-
|
|
716
|
+
m = AutoModelForSequenceClassification.from_pretrained(weights_dir, local_files_only=True, torch_dtype=dt, attn_implementation="sdpa")
|
|
710
717
|
except Exception:
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
718
|
+
m = AutoModelForSequenceClassification.from_pretrained(weights_dir, local_files_only=True, torch_dtype=dt)
|
|
719
|
+
m.to(dev).eval()
|
|
720
|
+
return m
|
|
721
|
+
|
|
722
|
+
try:
|
|
723
|
+
mdl = _load_on(device, load_dtype)
|
|
724
|
+
except Exception as e:
|
|
725
|
+
if str(device).startswith("cuda") and HAS_TORCH:
|
|
726
|
+
try:
|
|
727
|
+
gc.collect()
|
|
728
|
+
torch.cuda.empty_cache()
|
|
729
|
+
except Exception:
|
|
730
|
+
pass
|
|
731
|
+
try:
|
|
732
|
+
mdl = _load_on(device, load_dtype)
|
|
733
|
+
except Exception as e2:
|
|
734
|
+
raise RuntimeError(json.dumps({
|
|
735
|
+
"error": f"Не удалось загрузить модель реранкинга на GPU ({device}): {e2} (тихий откат на CPU отключён)"
|
|
736
|
+
}))
|
|
737
|
+
else:
|
|
738
|
+
raise e
|
|
717
739
|
cache[key] = ("torch", tok, mdl, device)
|
|
718
740
|
return cache[key]
|
|
719
741
|
|
|
@@ -763,7 +785,11 @@ def handle_rerank(req, cache):
|
|
|
763
785
|
def _load_image_pipeline(weights_dir, cache):
|
|
764
786
|
key = ("image", weights_dir)
|
|
765
787
|
if key in cache:
|
|
766
|
-
|
|
788
|
+
cached = cache[key]
|
|
789
|
+
if len(cached) >= 2 and str(cached[1]) == "cpu" and HAS_TORCH and torch.cuda.is_available():
|
|
790
|
+
cache.pop(key, None)
|
|
791
|
+
else:
|
|
792
|
+
return cached
|
|
767
793
|
if not os.path.isfile(os.path.join(weights_dir, "model_index.json")):
|
|
768
794
|
raise RuntimeError(json.dumps({
|
|
769
795
|
"error": (
|
|
@@ -794,14 +820,26 @@ def _load_image_pipeline(weights_dir, cache):
|
|
|
794
820
|
pipe = diffusers.AutoPipelineForText2Image.from_pretrained(weights_dir, local_files_only=True, torch_dtype=dtype)
|
|
795
821
|
try:
|
|
796
822
|
pipe.to(device)
|
|
797
|
-
except Exception:
|
|
823
|
+
except Exception as e:
|
|
798
824
|
if str(device).startswith("cuda") and HAS_TORCH:
|
|
799
825
|
try:
|
|
826
|
+
gc.collect()
|
|
800
827
|
torch.cuda.empty_cache()
|
|
801
828
|
except Exception:
|
|
802
829
|
pass
|
|
803
|
-
|
|
804
|
-
|
|
830
|
+
try:
|
|
831
|
+
pipe.to(device)
|
|
832
|
+
except Exception as e2:
|
|
833
|
+
raise RuntimeError(json.dumps({
|
|
834
|
+
"error": f"Недостаточно GPU-памяти (ROCm) или сбой драйвера при загрузке генератора изображений на {device}: {e2} (тихий откат на CPU отключён)"
|
|
835
|
+
}))
|
|
836
|
+
else:
|
|
837
|
+
raise e
|
|
838
|
+
try:
|
|
839
|
+
if hasattr(pipe, "enable_vae_slicing"):
|
|
840
|
+
pipe.enable_vae_slicing()
|
|
841
|
+
except Exception:
|
|
842
|
+
pass
|
|
805
843
|
cache[key] = (pipe, device)
|
|
806
844
|
return cache[key]
|
|
807
845
|
|
|
@@ -837,16 +875,19 @@ def handle_image(req, cache):
|
|
|
837
875
|
except Exception as e:
|
|
838
876
|
if str(device).startswith("cuda") and _is_recoverable_gpu_error(e):
|
|
839
877
|
try:
|
|
878
|
+
gc.collect()
|
|
840
879
|
torch.cuda.empty_cache()
|
|
841
880
|
except Exception:
|
|
842
881
|
pass
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
882
|
+
try:
|
|
883
|
+
kwargs["generator"] = torch.Generator(device=device).manual_seed(seed)
|
|
884
|
+
with torch.inference_mode():
|
|
885
|
+
out = pipe(**kwargs)
|
|
886
|
+
img = out.images[0]
|
|
887
|
+
except Exception as e2:
|
|
888
|
+
raise RuntimeError(json.dumps({
|
|
889
|
+
"error": f"Ошибка GPU ({device}) при генерации изображения: {e2} (тихий откат на CPU отключён)"
|
|
890
|
+
}))
|
|
850
891
|
else:
|
|
851
892
|
raise
|
|
852
893
|
buf = io.BytesIO()
|
|
@@ -1441,31 +1482,29 @@ def _move_qwen_tts_vocoder_to_cpu(mdl):
|
|
|
1441
1482
|
def _load_qwen_tts_model(weights_dir):
|
|
1442
1483
|
from qwen_tts import Qwen3TTSModel
|
|
1443
1484
|
device, dtype = _best_device_and_dtype()
|
|
1444
|
-
candidates = [(device, dtype)]
|
|
1445
|
-
if str(device).startswith("cuda"):
|
|
1446
|
-
cpu_dtype = torch.bfloat16 if _cpu_supports_bf16() else torch.float32
|
|
1447
|
-
candidates.append(("cpu", cpu_dtype))
|
|
1448
1485
|
last_err = None
|
|
1449
|
-
|
|
1486
|
+
attempts = 2 if str(device).startswith("cuda") else 1
|
|
1487
|
+
for _ in range(attempts):
|
|
1450
1488
|
try:
|
|
1451
1489
|
try:
|
|
1452
1490
|
mdl = Qwen3TTSModel.from_pretrained(
|
|
1453
1491
|
weights_dir,
|
|
1454
|
-
device_map=
|
|
1455
|
-
dtype=
|
|
1492
|
+
device_map=device,
|
|
1493
|
+
dtype=dtype,
|
|
1456
1494
|
attn_implementation="sdpa",
|
|
1457
1495
|
)
|
|
1458
1496
|
except Exception:
|
|
1459
|
-
mdl = Qwen3TTSModel.from_pretrained(weights_dir, device_map=
|
|
1497
|
+
mdl = Qwen3TTSModel.from_pretrained(weights_dir, device_map=device, dtype=dtype)
|
|
1460
1498
|
_install_fast_qwen_tts_code_predictor(mdl)
|
|
1461
|
-
if str(
|
|
1499
|
+
if str(device).startswith("cuda"):
|
|
1462
1500
|
_move_qwen_tts_vocoder_to_cpu(mdl)
|
|
1463
|
-
mdl._work_device =
|
|
1501
|
+
mdl._work_device = device
|
|
1464
1502
|
return mdl
|
|
1465
1503
|
except Exception as e:
|
|
1466
1504
|
last_err = e
|
|
1467
|
-
if str(
|
|
1505
|
+
if str(device).startswith("cuda") and HAS_TORCH:
|
|
1468
1506
|
try:
|
|
1507
|
+
gc.collect()
|
|
1469
1508
|
torch.cuda.empty_cache()
|
|
1470
1509
|
except Exception:
|
|
1471
1510
|
pass
|
|
@@ -1783,7 +1822,7 @@ def _handle_tts_silero(req, cache, pt_path):
|
|
|
1783
1822
|
"ttsKind": "silero",
|
|
1784
1823
|
"voiceUsed": speaker,
|
|
1785
1824
|
"instructUsed": "",
|
|
1786
|
-
"device": "CPU (Silero v5)",
|
|
1825
|
+
"device": "CPU (Zen 5 · Silero v5)",
|
|
1787
1826
|
"loadMs": load_ms,
|
|
1788
1827
|
"genMs": gen_ms,
|
|
1789
1828
|
"durationMs": gen_ms,
|
|
@@ -1992,72 +2031,87 @@ def handle_music(req, cache):
|
|
|
1992
2031
|
}
|
|
1993
2032
|
|
|
1994
2033
|
|
|
1995
|
-
def
|
|
1996
|
-
weights_dir = req["weightsDir"]
|
|
1997
|
-
audio_b64 = req.get("audioBase64", "")
|
|
1998
|
-
language = _asr_language(req.get("language"))
|
|
1999
|
-
raw = base64.b64decode(audio_b64)
|
|
2034
|
+
def _load_stt_model(weights_dir, cache):
|
|
2000
2035
|
key = ("stt", weights_dir)
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2036
|
+
if key in cache:
|
|
2037
|
+
kind_c, mdl_c = cache[key]
|
|
2038
|
+
active_c = getattr(mdl_c, "_work_device", None) or str(getattr(mdl_c, "device", "cpu"))
|
|
2039
|
+
if str(active_c) == "cpu" and HAS_TORCH and torch.cuda.is_available():
|
|
2040
|
+
cache.pop(key, None)
|
|
2041
|
+
else:
|
|
2042
|
+
return cache[key]
|
|
2043
|
+
device, dtype = _best_device_and_dtype()
|
|
2044
|
+
attempts = 2 if str(device).startswith("cuda") else 1
|
|
2045
|
+
errors = []
|
|
2046
|
+
try:
|
|
2047
|
+
from qwen_asr import Qwen3ASRModel
|
|
2048
|
+
for _ in range(attempts):
|
|
2049
|
+
try:
|
|
2013
2050
|
try:
|
|
2051
|
+
loaded = Qwen3ASRModel.from_pretrained(weights_dir, dtype=dtype, device_map=device, attn_implementation="sdpa")
|
|
2052
|
+
except Exception:
|
|
2053
|
+
loaded = Qwen3ASRModel.from_pretrained(weights_dir, dtype=dtype, device_map=device)
|
|
2054
|
+
loaded._work_device = device
|
|
2055
|
+
cache[key] = ("qwen_asr", loaded)
|
|
2056
|
+
break
|
|
2057
|
+
except Exception as e:
|
|
2058
|
+
errors.append(f"qwen-asr ({device}): {e}")
|
|
2059
|
+
if str(device).startswith("cuda") and HAS_TORCH:
|
|
2014
2060
|
try:
|
|
2015
|
-
|
|
2061
|
+
gc.collect()
|
|
2062
|
+
torch.cuda.empty_cache()
|
|
2016
2063
|
except Exception:
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2064
|
+
pass
|
|
2065
|
+
except Exception as e:
|
|
2066
|
+
errors.append(f"qwen-asr (нет пакета): {e}")
|
|
2067
|
+
if key not in cache:
|
|
2068
|
+
try:
|
|
2069
|
+
from transformers import pipeline
|
|
2070
|
+
for _ in range(attempts):
|
|
2071
|
+
try:
|
|
2072
|
+
p_obj = pipeline(
|
|
2073
|
+
"automatic-speech-recognition",
|
|
2074
|
+
model=weights_dir,
|
|
2075
|
+
device=0 if str(device).startswith("cuda") else -1,
|
|
2076
|
+
torch_dtype=dtype,
|
|
2077
|
+
)
|
|
2078
|
+
p_obj._work_device = device
|
|
2079
|
+
cache[key] = ("hf_asr", p_obj)
|
|
2020
2080
|
break
|
|
2021
2081
|
except Exception as e:
|
|
2022
|
-
errors.append(f"
|
|
2023
|
-
if str(
|
|
2082
|
+
errors.append(f"transformers ({device}): {e}")
|
|
2083
|
+
if str(device).startswith("cuda") and HAS_TORCH:
|
|
2024
2084
|
try:
|
|
2085
|
+
gc.collect()
|
|
2025
2086
|
torch.cuda.empty_cache()
|
|
2026
2087
|
except Exception:
|
|
2027
2088
|
pass
|
|
2028
2089
|
except Exception as e:
|
|
2029
|
-
errors.append(f"
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
"soundfile": "soundfile",
|
|
2054
|
-
"transformers": "transformers",
|
|
2055
|
-
})))
|
|
2056
|
-
raise RuntimeError(json.dumps({
|
|
2057
|
-
"error": f"Не удалось загрузить модель распознавания речи из {weights_dir}: {msg}",
|
|
2058
|
-
}))
|
|
2090
|
+
errors.append(f"transformers (нет пакета): {e}")
|
|
2091
|
+
if key not in cache:
|
|
2092
|
+
msg = " | ".join(errors)
|
|
2093
|
+
if "No module named" in msg:
|
|
2094
|
+
raise RuntimeError(json.dumps(_missing_pkg_error(Exception(msg), {
|
|
2095
|
+
"qwen_asr": "qwen-asr",
|
|
2096
|
+
"soundfile": "soundfile",
|
|
2097
|
+
"transformers": "transformers",
|
|
2098
|
+
})))
|
|
2099
|
+
raise RuntimeError(json.dumps({
|
|
2100
|
+
"error": f"Не удалось загрузить модель распознавания речи на {device} из {weights_dir}: {msg}",
|
|
2101
|
+
}))
|
|
2102
|
+
return cache[key]
|
|
2103
|
+
|
|
2104
|
+
|
|
2105
|
+
def handle_stt(req, cache):
|
|
2106
|
+
weights_dir = req["weightsDir"]
|
|
2107
|
+
audio_b64 = req.get("audioBase64", "")
|
|
2108
|
+
language = _asr_language(req.get("language"))
|
|
2109
|
+
raw = base64.b64decode(audio_b64)
|
|
2110
|
+
key = ("stt", weights_dir)
|
|
2111
|
+
was_cached = key in cache
|
|
2112
|
+
t_load0 = time.time()
|
|
2113
|
+
kind, mdl = _load_stt_model(weights_dir, cache)
|
|
2059
2114
|
load_ms = 0 if was_cached else int((time.time() - t_load0) * 1000)
|
|
2060
|
-
kind, mdl = cache[key]
|
|
2061
2115
|
active_dev = getattr(mdl, "_work_device", None) or str(getattr(mdl, "device", "cpu"))
|
|
2062
2116
|
import tempfile
|
|
2063
2117
|
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as tf:
|
|
@@ -2119,20 +2173,180 @@ def _get_free_ram_gb():
|
|
|
2119
2173
|
|
|
2120
2174
|
def _release_cached_item(obj):
|
|
2121
2175
|
try:
|
|
2122
|
-
if
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2176
|
+
if hasattr(obj, "store") and getattr(obj.store, "files", None):
|
|
2177
|
+
for f_h, mm_h in obj.store.files:
|
|
2178
|
+
try:
|
|
2179
|
+
mm_h.close()
|
|
2180
|
+
except Exception:
|
|
2181
|
+
pass
|
|
2182
|
+
try:
|
|
2183
|
+
f_h.close()
|
|
2184
|
+
except Exception:
|
|
2185
|
+
pass
|
|
2186
|
+
obj.store.files.clear()
|
|
2187
|
+
if getattr(obj.store, "tensors", None):
|
|
2188
|
+
obj.store.tensors.clear()
|
|
2132
2189
|
except Exception:
|
|
2133
2190
|
pass
|
|
2134
2191
|
|
|
2135
2192
|
|
|
2193
|
+
def _describe_cached_entry_device(k, obj):
|
|
2194
|
+
try:
|
|
2195
|
+
if isinstance(k, tuple) and len(k) >= 1 and k[0] == "tts_silero":
|
|
2196
|
+
return "CPU (Zen 5 · Silero v5)"
|
|
2197
|
+
if isinstance(k, tuple) and len(k) >= 1 and k[0] == "tts_piper":
|
|
2198
|
+
return "CPU (Piper ONNX)"
|
|
2199
|
+
if isinstance(k, tuple) and len(k) >= 1 and k[0] in ("embed", "rerank") and isinstance(obj, tuple) and len(obj) >= 4:
|
|
2200
|
+
return _describe_torch_device(obj[3])
|
|
2201
|
+
if isinstance(k, tuple) and len(k) >= 1 and k[0] == "image" and isinstance(obj, tuple) and len(obj) >= 2:
|
|
2202
|
+
return _describe_torch_device(obj[1])
|
|
2203
|
+
if isinstance(obj, tuple) and len(obj) >= 2:
|
|
2204
|
+
mdl = obj[1]
|
|
2205
|
+
dev = getattr(mdl, "_work_device", None) or getattr(mdl, "device", "cpu")
|
|
2206
|
+
return _describe_torch_device(dev)
|
|
2207
|
+
dev = getattr(obj, "_work_device", None) or getattr(obj, "device", "cpu")
|
|
2208
|
+
return _describe_torch_device(dev)
|
|
2209
|
+
except Exception:
|
|
2210
|
+
return _describe_torch_device("cpu")
|
|
2211
|
+
|
|
2212
|
+
|
|
2213
|
+
def handle_status(mod_cache, mod_last_used, models, llm_last_used, cache_lock=None):
|
|
2214
|
+
loaded = []
|
|
2215
|
+
def _collect():
|
|
2216
|
+
for k, obj in mod_cache.items():
|
|
2217
|
+
op_name = k[0] if isinstance(k, tuple) and len(k) >= 1 else "mod"
|
|
2218
|
+
w_dir = k[1] if isinstance(k, tuple) and len(k) >= 2 else ""
|
|
2219
|
+
if op_name in ("tts_silero", "tts_piper", "tts_kokoro"):
|
|
2220
|
+
op_name = "tts"
|
|
2221
|
+
w_dir = os.path.dirname(str(w_dir))
|
|
2222
|
+
loaded.append({
|
|
2223
|
+
"op": op_name,
|
|
2224
|
+
"weightsDir": str(w_dir),
|
|
2225
|
+
"device": _describe_cached_entry_device(k, obj),
|
|
2226
|
+
"lastUsed": float(mod_last_used.get(k, 0.0)),
|
|
2227
|
+
})
|
|
2228
|
+
for w_dir, mdl in models.items():
|
|
2229
|
+
loaded.append({
|
|
2230
|
+
"op": "llm",
|
|
2231
|
+
"weightsDir": str(w_dir),
|
|
2232
|
+
"device": _describe_torch_device(getattr(mdl, "device", "cpu")),
|
|
2233
|
+
"lastUsed": float(llm_last_used.get(w_dir, 0.0)),
|
|
2234
|
+
})
|
|
2235
|
+
if cache_lock is not None:
|
|
2236
|
+
with cache_lock:
|
|
2237
|
+
_collect()
|
|
2238
|
+
else:
|
|
2239
|
+
_collect()
|
|
2240
|
+
cuda_ok = bool(HAS_TORCH and torch is not None and torch.cuda.is_available())
|
|
2241
|
+
dev_name = _describe_torch_device("cuda:0" if cuda_ok else "cpu")
|
|
2242
|
+
return {
|
|
2243
|
+
"cuda": cuda_ok,
|
|
2244
|
+
"deviceName": dev_name,
|
|
2245
|
+
"freeRamGb": round(_get_free_ram_gb() or 0.0, 2),
|
|
2246
|
+
"loadedModels": loaded,
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
|
|
2250
|
+
def handle_warmup(req, mod_cache, mod_last_used, models, llm_last_used, cache_lock=None):
|
|
2251
|
+
modality = str(req.get("modality") or "llm").lower()
|
|
2252
|
+
weights_dir = str(req.get("weightsDir") or "")
|
|
2253
|
+
if not weights_dir or not os.path.isdir(weights_dir):
|
|
2254
|
+
return {"ok": False, "skipped": True, "reason": "weightsDir not found"}
|
|
2255
|
+
if modality in ("image", "video", "music"):
|
|
2256
|
+
return {"ok": True, "skipped": True, "reason": "on-demand modality"}
|
|
2257
|
+
|
|
2258
|
+
t0 = time.time()
|
|
2259
|
+
cached = False
|
|
2260
|
+
dev = "cpu"
|
|
2261
|
+
if modality == "llm":
|
|
2262
|
+
def _load_llm():
|
|
2263
|
+
nonlocal cached, dev
|
|
2264
|
+
if weights_dir in models:
|
|
2265
|
+
cached = True
|
|
2266
|
+
dev = _describe_torch_device(getattr(models[weights_dir], "device", "cpu"))
|
|
2267
|
+
else:
|
|
2268
|
+
models[weights_dir] = LocalCausalLM(weights_dir)
|
|
2269
|
+
dev = _describe_torch_device(getattr(models[weights_dir], "device", "cpu"))
|
|
2270
|
+
llm_last_used[weights_dir] = time.time()
|
|
2271
|
+
if cache_lock is not None:
|
|
2272
|
+
with cache_lock:
|
|
2273
|
+
_load_llm()
|
|
2274
|
+
else:
|
|
2275
|
+
_load_llm()
|
|
2276
|
+
elif modality in ("embed", "embedding"):
|
|
2277
|
+
def _load_emb():
|
|
2278
|
+
nonlocal cached, dev
|
|
2279
|
+
cached = ("embed", weights_dir) in mod_cache
|
|
2280
|
+
_, _, _, d = _load_embed_model(weights_dir, mod_cache)
|
|
2281
|
+
mod_last_used[("embed", weights_dir)] = time.time()
|
|
2282
|
+
dev = _describe_torch_device(d)
|
|
2283
|
+
if cache_lock is not None:
|
|
2284
|
+
with cache_lock:
|
|
2285
|
+
_load_emb()
|
|
2286
|
+
else:
|
|
2287
|
+
_load_emb()
|
|
2288
|
+
elif modality == "rerank":
|
|
2289
|
+
def _load_rr():
|
|
2290
|
+
nonlocal cached, dev
|
|
2291
|
+
cached = ("rerank", weights_dir) in mod_cache
|
|
2292
|
+
_, _, _, d = _load_rerank_model(weights_dir, mod_cache)
|
|
2293
|
+
mod_last_used[("rerank", weights_dir)] = time.time()
|
|
2294
|
+
dev = _describe_torch_device(d)
|
|
2295
|
+
if cache_lock is not None:
|
|
2296
|
+
with cache_lock:
|
|
2297
|
+
_load_rr()
|
|
2298
|
+
else:
|
|
2299
|
+
_load_rr()
|
|
2300
|
+
elif modality in ("stt", "asr"):
|
|
2301
|
+
def _load_stt():
|
|
2302
|
+
nonlocal cached, dev
|
|
2303
|
+
cached = ("stt", weights_dir) in mod_cache
|
|
2304
|
+
_, mdl = _load_stt_model(weights_dir, mod_cache)
|
|
2305
|
+
mod_last_used[("stt", weights_dir)] = time.time()
|
|
2306
|
+
active = getattr(mdl, "_work_device", None) or str(getattr(mdl, "device", "cpu"))
|
|
2307
|
+
dev = _describe_torch_device(active)
|
|
2308
|
+
if cache_lock is not None:
|
|
2309
|
+
with cache_lock:
|
|
2310
|
+
_load_stt()
|
|
2311
|
+
else:
|
|
2312
|
+
_load_stt()
|
|
2313
|
+
elif modality in ("tts", "voice"):
|
|
2314
|
+
silero_pt = _find_silero_tts_file(weights_dir)
|
|
2315
|
+
if silero_pt:
|
|
2316
|
+
def _load_silero():
|
|
2317
|
+
nonlocal cached, dev
|
|
2318
|
+
key = ("tts_silero", silero_pt)
|
|
2319
|
+
cached = key in mod_cache
|
|
2320
|
+
if not cached:
|
|
2321
|
+
mdl = torch.package.PackageImporter(silero_pt).load_pickle("tts_models", "model")
|
|
2322
|
+
mdl.to(torch.device("cpu"))
|
|
2323
|
+
mod_cache[key] = mdl
|
|
2324
|
+
mod_last_used[key] = time.time()
|
|
2325
|
+
dev = "CPU (Zen 5 · Silero v5)"
|
|
2326
|
+
if cache_lock is not None:
|
|
2327
|
+
with cache_lock:
|
|
2328
|
+
_load_silero()
|
|
2329
|
+
else:
|
|
2330
|
+
_load_silero()
|
|
2331
|
+
else:
|
|
2332
|
+
def _load_qtts():
|
|
2333
|
+
nonlocal cached, dev
|
|
2334
|
+
key = ("tts", weights_dir)
|
|
2335
|
+
cached = key in mod_cache
|
|
2336
|
+
if not cached:
|
|
2337
|
+
mod_cache[key] = _load_qwen_tts_model(weights_dir)
|
|
2338
|
+
mod_last_used[key] = time.time()
|
|
2339
|
+
active = getattr(mod_cache[key], "_work_device", None) or str(getattr(mod_cache[key], "device", "cpu"))
|
|
2340
|
+
dev = _describe_torch_device(active)
|
|
2341
|
+
if cache_lock is not None:
|
|
2342
|
+
with cache_lock:
|
|
2343
|
+
_load_qtts()
|
|
2344
|
+
else:
|
|
2345
|
+
_load_qtts()
|
|
2346
|
+
load_ms = 0 if cached else int((time.time() - t0) * 1000)
|
|
2347
|
+
return {"ok": True, "cached": cached, "device": dev, "loadMs": load_ms}
|
|
2348
|
+
|
|
2349
|
+
|
|
2136
2350
|
def _evict_memory_if_needed(
|
|
2137
2351
|
mod_cache,
|
|
2138
2352
|
mod_last_used,
|
|
@@ -2143,16 +2357,16 @@ def _evict_memory_if_needed(
|
|
|
2143
2357
|
keep_llm_key=None,
|
|
2144
2358
|
now_ts=None,
|
|
2145
2359
|
):
|
|
2146
|
-
"""Умная очистка
|
|
2360
|
+
"""Умная очистка памяти (192 ГБ Unified Memory):
|
|
2147
2361
|
- Тяжёлую диффузию (`image`, напр. Z-Image-Turbo) выгружаем через `WORK_IMAGE_IDLE_SEC` (10 мин)
|
|
2148
|
-
или при падении свободной RAM ниже `WORK_MIN_FREE_RAM_GB` (
|
|
2149
|
-
-
|
|
2150
|
-
выгружая по LRU только при критической нехватке RAM (`< WORK_CRIT_FREE_RAM_GB`,
|
|
2362
|
+
или при падении свободной RAM ниже `WORK_MIN_FREE_RAM_GB` (24 ГБ).
|
|
2363
|
+
- Горячие модели (embed, rerank, tts, stt, 0.6B/4B) держим постоянно горячими,
|
|
2364
|
+
выгружая по LRU только при критической нехватке RAM (`< WORK_CRIT_FREE_RAM_GB`, 8 ГБ).
|
|
2151
2365
|
"""
|
|
2152
2366
|
now = float(now_ts if now_ts is not None else time.time())
|
|
2153
2367
|
image_idle_sec = float(os.environ.get("WORK_IMAGE_IDLE_SEC", "600"))
|
|
2154
|
-
min_free_gb = float(os.environ.get("WORK_MIN_FREE_RAM_GB", "
|
|
2155
|
-
crit_free_gb = float(os.environ.get("WORK_CRIT_FREE_RAM_GB", "
|
|
2368
|
+
min_free_gb = float(os.environ.get("WORK_MIN_FREE_RAM_GB", "24"))
|
|
2369
|
+
crit_free_gb = float(os.environ.get("WORK_CRIT_FREE_RAM_GB", "8"))
|
|
2156
2370
|
free_gb = _get_free_ram_gb()
|
|
2157
2371
|
evicted = []
|
|
2158
2372
|
|
|
@@ -2250,9 +2464,11 @@ def main():
|
|
|
2250
2464
|
if op == "check_deps":
|
|
2251
2465
|
print(json.dumps({"id": req_id, "event": "result", "data": handle_check_deps()}), flush=True)
|
|
2252
2466
|
continue
|
|
2467
|
+
if op == "status":
|
|
2468
|
+
print(json.dumps({"id": req_id, "event": "result", "data": handle_status(mod_cache, mod_last_used, models, llm_last_used, cache_lock=cache_lock)}), flush=True)
|
|
2469
|
+
continue
|
|
2253
2470
|
is_onnx_fast = (
|
|
2254
|
-
|
|
2255
|
-
or (op == "tts" and _find_piper_onnx_files(str(req.get("weightsDir") or "")))
|
|
2471
|
+
op == "tts" and _find_piper_onnx_files(str(req.get("weightsDir") or ""))
|
|
2256
2472
|
)
|
|
2257
2473
|
if not HAS_TORCH and not is_onnx_fast:
|
|
2258
2474
|
needed = ["torch"]
|
|
@@ -2281,6 +2497,10 @@ def main():
|
|
|
2281
2497
|
"missingDeps": needed,
|
|
2282
2498
|
}), flush=True)
|
|
2283
2499
|
continue
|
|
2500
|
+
if op == "warmup":
|
|
2501
|
+
res = handle_warmup(req, mod_cache, mod_last_used, models, llm_last_used, cache_lock=cache_lock)
|
|
2502
|
+
print(json.dumps({"id": req_id, "event": "result", "data": res}), flush=True)
|
|
2503
|
+
continue
|
|
2284
2504
|
if op in ("embed", "rerank", "image", "video", "music", "tts", "stt"):
|
|
2285
2505
|
t0 = time.time()
|
|
2286
2506
|
mod_key = (op, str(req.get("weightsDir") or ""))
|