odant-work 1.0.37 → 1.0.38
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 +27 -27
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/file.js +18 -2
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/docs.js +15 -0
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/feed.js +7 -3
- package/$server/$folder/handlers/pages/form/$handler/form.js +1 -1
- package/$server/$folder/lib/consultant/consultant.js +18 -45
- package/MODELS/$ai/$folder/$class/$ai/class.js +135 -10
- package/MODELS/$ai/$folder/$class/$ai/handlers/pages/form/trainer/$handler/trainer.js +183 -10
- package/MODELS/$ai/$folder/$class/$ai/methods/chat/$method/class.js +19 -0
- package/MODELS/$ai/$folder/$class/$provider/handlers/pages/form/trainer/$handler/trainer.js +91 -0
- package/package.json +1 -1
- package/sources/data/progress.md +8 -0
- package/sources/modules/agent/index.js +47 -3
- package/sources/modules/agent/loop.js +6 -0
- package/sources/modules/agent/session.js +2 -2
- package/sources/modules/agent/voice.js +29 -1
- package/sources/modules/rag/config.js +75 -75
- package/sources/modules/rag/embedder.js +118 -81
- package/sources/modules/rag/search.js +31 -5
- package/sources/modules/rag/store.js +3 -1
- package/sources/modules/trainer/index.js +210 -0
- package/sources/modules/trainer/local-engine.js +244 -1
- package/sources/modules/trainer/worker/local_infer_worker.py +319 -1
- package/sources/server/class.js +6 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"packageName": "odant-work",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"createdAt":
|
|
5
|
-
"updatedAt":
|
|
3
|
+
"version": "1.0.38",
|
|
4
|
+
"createdAt": 1794916599757,
|
|
5
|
+
"updatedAt": 1794916660148,
|
|
6
6
|
"files": {
|
|
7
7
|
"run.mjs": "f8918c612e8641e9beee06221be6680aa6fd21f25468451f2ac857fd51772266",
|
|
8
|
-
"package.json": "
|
|
9
|
-
"package-lock.json": "
|
|
8
|
+
"package.json": "229d14f02982a9e01b05064b1d1cfa848067e677838a1c4dd66c9492803a2a60",
|
|
9
|
+
"package-lock.json": "91dba270b04959e1dcf069e8551724b71ef2ad73e7df2c42bcd18e84d40d2437",
|
|
10
10
|
"sources/client/class.js": "c3fb8f143fc83aaa2df1ddeddd412d2d4dfe88656578095babe2df34fb3b3922",
|
|
11
11
|
"sources/client/field.js": "ffdd50fa8b6ec515cc42da5fca96658ff2b20e274601a1f926e0031372467a19",
|
|
12
12
|
"sources/client/file.js": "667101d75fa30840370d5be232e518aaac7c1fd52ca05a12da560eef6c0848b0",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"sources/data/objects.js": "23f51d5b00cd766fe27879b874738bc9bd9056bd6e27285fb7a52926c0dbc6a8",
|
|
27
27
|
"sources/data/posting.js": "6595bb9ec632539ae7629504db327d25a491e61c1cdc598bb43d08ea0d45548d",
|
|
28
28
|
"sources/data/print.js": "704f0f2fc80c6466a4196e4650d763150cf9b592eab14ea67ece85d51100107c",
|
|
29
|
-
"sources/data/progress.md": "
|
|
29
|
+
"sources/data/progress.md": "ad0a77f9398a45d46b22a8f05085952e617649f7d04d0169e9acb3004c046902",
|
|
30
30
|
"sources/data/readme.md": "593fa2ae07aa91bc26d7542275da6953a9cd419240a9a49e00cb62fb9d5d8e36",
|
|
31
31
|
"sources/data/reports.js": "0330f404860fe2589a7d46a2f0fe690ca23249bd841a062a26718742d4fd11d6",
|
|
32
32
|
"sources/data/schema.js": "1c994f9adb76c156dc86601dd6b1046376b66549b041e1a58aa1727b5476bdbe",
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
"sources/modules/agent/eval.js": "91f907554630ad53c30d5c1d760bb646bb4dbd10ec854a69453d002368ce25cc",
|
|
66
66
|
"sources/modules/agent/extensions.js": "a2549960cbfece9698c730506b05e2db9bd5b12434fc29156cb391dc566ec643",
|
|
67
67
|
"sources/modules/agent/hooks.js": "b74e9d8f4b491b6d16d979891de69941955e50852289f55589c82997405c9048",
|
|
68
|
-
"sources/modules/agent/index.js": "
|
|
68
|
+
"sources/modules/agent/index.js": "eeb1f34f9ca36e13749389ea544f23e385891d355f6050206bff3f6bd106ceeb",
|
|
69
69
|
"sources/modules/agent/log.js": "03ae1979e2b00459178deda49847c30ed75937fc4f3eea9b778ca6c0f8c4ded0",
|
|
70
|
-
"sources/modules/agent/loop.js": "
|
|
70
|
+
"sources/modules/agent/loop.js": "8d0c1293092fbf9c6d91be5c9b172b8d7350195c45bba1f38bca986c6095a23b",
|
|
71
71
|
"sources/modules/agent/mcp-pool.js": "aa4e75e2fcfe07883f9b721b33cee642fbbe11b8f416f8cd6a81f9c1ab39edde",
|
|
72
72
|
"sources/modules/agent/permissions.js": "c173d451b3fdd5e1722aaccc4648ae985016962a8f97799a32fc8f96f6cf35b4",
|
|
73
73
|
"sources/modules/agent/plugins.js": "9aed13c2d7bbf66dcd165f23b3969874561aea470dc16dac1435d183696cfda5",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"sources/modules/agent/recovery.js": "7a61dfdb2aef10b5049aee85d579379fdf98af3524f8509428ebc5a613bad92d",
|
|
76
76
|
"sources/modules/agent/resources.js": "2a52a31b2a96e17c713a6e311cbf0fe31a6debf8cd596e8e8067c722e6299eb2",
|
|
77
77
|
"sources/modules/agent/scheduler.js": "26cc6fffb9f570d501dbef5261b274323fe8e8165d1598097ff8f77d32cdd9cf",
|
|
78
|
-
"sources/modules/agent/session.js": "
|
|
78
|
+
"sources/modules/agent/session.js": "cbd44b41c5e9acde4854edaa4e240d775b5d848b378a0f2a5414cba0e81f289e",
|
|
79
79
|
"sources/modules/agent/system.js": "6eb8be4b1626d83c64e059531bb63433a5c592b80c4b20facb657ccf26767025",
|
|
80
80
|
"sources/modules/agent/taint.js": "bf6aee5cc7e8b15ac365525fa74645d4a92da5ce1bdbcdba012e80767b5c7063",
|
|
81
81
|
"sources/modules/agent/tools/branch.js": "1ac9ccafcf292801575e8205ec7b63ab7dd6d53b03ad2a67cc3571092b716bcf",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"sources/modules/agent/types.d.ts": "9d47168bb9fefb1d7c5506afb263c6a6f2e3609602ee78e50c98c02bc052831f",
|
|
112
112
|
"sources/modules/agent/undo.js": "e46f3f1172c6d6e4055332bada74c546c0b0a0e585f1c96eac9b40e4d35b8544",
|
|
113
113
|
"sources/modules/agent/util.js": "9bca6569c16cdfed0134dfec0c99347b3e999692afdc35719886f6083fed87c5",
|
|
114
|
-
"sources/modules/agent/voice.js": "
|
|
114
|
+
"sources/modules/agent/voice.js": "498f4b1cad8b3b211eb3dee7b362f95cfd3e5ac2c6d69edd517f219b5f582a1d",
|
|
115
115
|
"sources/modules/ai-schema.js": "84ecc7a872dec42e521f9e05366f053e36ae19b185f35c552b945157f95c66f4",
|
|
116
116
|
"sources/modules/bridge/chrome.js": "3bbba8c1726ef8341918bf94d9542093d47e57ec5364f600e863fe2500342e37",
|
|
117
117
|
"sources/modules/bridge/hub.js": "4398d503ad2581fad763ec2f56a6893cd00ecc6f0c0af42523f77de43c4e5f45",
|
|
@@ -153,16 +153,16 @@
|
|
|
153
153
|
"sources/modules/notify/telegram.js": "233c811a143b0f0b32f20620a3c59c2f49693eb02d11977114a1be5c2e597833",
|
|
154
154
|
"sources/modules/office/index.js": "acb67f1b53bd5b1ec7d3a97af352680db038d650915fb0367bcb8a131d8e6c31",
|
|
155
155
|
"sources/modules/rag/chunker.js": "52cd62d3b02ec3148397a4052ce9614d0b61ee8f42b8facf27ff3bb99b4875b7",
|
|
156
|
-
"sources/modules/rag/config.js": "
|
|
156
|
+
"sources/modules/rag/config.js": "f707aba44fad238699c9647972367d121e928fd8bfe87c594d8e5b5a401d8dc8",
|
|
157
157
|
"sources/modules/rag/embed-worker.js": "1fa44ca68f2ab9e3c092979baa327ae4f93cf48865ae2d2a231edfed0eb0d538",
|
|
158
|
-
"sources/modules/rag/embedder.js": "
|
|
158
|
+
"sources/modules/rag/embedder.js": "bb2485673f2144f3afdb4d6228e2a0eddbc51ad6316861ffd502180d016efc72",
|
|
159
159
|
"sources/modules/rag/extract.js": "52e7c9a7e481b26bae58bf18d70ee892d5be962cd5c867f1fa42635ea689931b",
|
|
160
160
|
"sources/modules/rag/index.js": "cc2722a881566e2ad2a61b2269fad39ecc7e4abda256aa9b59d1ff47b239c135",
|
|
161
161
|
"sources/modules/rag/indexer.js": "4fb0e6e55a257cc7a3726665ac710229a093522eadf022441b5ec04f62a44312",
|
|
162
162
|
"sources/modules/rag/readme.md": "d246e30e7d3ceb5971156f6e0ba94cb38b6ac75374252a818d56bce8fbfab629",
|
|
163
163
|
"sources/modules/rag/scope.js": "89c9f6236bda2b82b2f0851a1e12f782ba3c0ef5fcd95414cd1771ba6d21016a",
|
|
164
|
-
"sources/modules/rag/search.js": "
|
|
165
|
-
"sources/modules/rag/store.js": "
|
|
164
|
+
"sources/modules/rag/search.js": "cebd185425703a017264d31b8af30970f6620f8e97de0874669c0622c2948fa1",
|
|
165
|
+
"sources/modules/rag/store.js": "f2c263089fd3ee942cf757b0256e5661070db1f587f3e5ab1abc1ffc2409f477",
|
|
166
166
|
"sources/modules/readme.md": "fa34cb09ed4a548c964fc0217f0db5ef673a2d0e0ae4f9aefd9ca057a654f316",
|
|
167
167
|
"sources/modules/sandbox/config.js": "815c93f8d605dbca10e405b840e7e95d260ea256e9549cc0c979b4e5d6afed35",
|
|
168
168
|
"sources/modules/sandbox/driver.js": "1183f3f586d24421c0f18304cb40b198ffc2d1db5986e8e3fb0169bcd319fcd0",
|
|
@@ -178,14 +178,14 @@
|
|
|
178
178
|
"sources/modules/trainer/downloader.js": "d9e96cb07e7bf64386558be8c2265c482af35a513f42954250add6d5fc87bdc4",
|
|
179
179
|
"sources/modules/trainer/halogen.js": "eddc61b4acf5494703d599e4dc5811ce27aa34d60abe24fddadc1755d460c9fe",
|
|
180
180
|
"sources/modules/trainer/huggingface.js": "91878bb2975981e02dd21d2a587d7c345ef65cd2d7032c5769a63c9dba21f982",
|
|
181
|
-
"sources/modules/trainer/index.js": "
|
|
182
|
-
"sources/modules/trainer/local-engine.js": "
|
|
181
|
+
"sources/modules/trainer/index.js": "e82c094d4054c2e8cc2b191f41b053dfb9d528a36dea4911a80cfc6dac19e1e3",
|
|
182
|
+
"sources/modules/trainer/local-engine.js": "7f2254f8d1d67fb11b2812b1173eda513df5cc116d93f7eb1968e00f0cbd93ff",
|
|
183
183
|
"sources/modules/trainer/paths.js": "86d12a1f3a79127c2284a5e0eaf4f523fbf0f3aa8e13b92d8889ebf4fa5400f4",
|
|
184
184
|
"sources/modules/trainer/providers.js": "56ffd2de03449ecaa13751a7e82c615cf5f84e6f02bb0b34c4432c3d85db28da",
|
|
185
185
|
"sources/modules/trainer/runner.js": "328843672fe0c1bd7e8c35c2e25285c31a9f749e04814e64c32e8cae74086024",
|
|
186
186
|
"sources/modules/trainer/tar-stream.js": "52f1739579a01818b53d04a93fd05a91c49a0716019f309a6fca951ba112794f",
|
|
187
187
|
"sources/modules/trainer/transfer.js": "2c603d538e0f85e1794e2f304081fac136f0ff72f85d8b00c2141c7402b3a1fb",
|
|
188
|
-
"sources/modules/trainer/worker/local_infer_worker.py": "
|
|
188
|
+
"sources/modules/trainer/worker/local_infer_worker.py": "9444b6320fb0fddac7afeecbed7e72278ca8435b1652f2b87c6fadf4249125a1",
|
|
189
189
|
"sources/modules/trainer/worker/unsloth_train.py": "7774d94ffa6f60eed20c57a8dfdc12621d5d9f74d594c605dff32ff70e321e33",
|
|
190
190
|
"sources/modules/user-profile/user-profile.js": "5c8fd002809848b204aee83a44161375e8144bffcc048fde748f4f778162bbef",
|
|
191
191
|
"sources/modules/user-profile/user-token.js": "3797685232684e9e80261a2e63f70cbff4ef1bcc3ded6f755800804e9848d7d9",
|
|
@@ -208,7 +208,7 @@
|
|
|
208
208
|
"sources/server/class/script.js": "146ef61b5a55201c34f80de4bbfcb116922f03348773548c041bdba0e53aba64",
|
|
209
209
|
"sources/server/class/search.js": "c3d50a82769d65cfabdc0b83c73c289cec212ac5feb685aec4b1489b206546dd",
|
|
210
210
|
"sources/server/class/security.js": "b4ba6e328988221d02fc1dc516f41932a7f55370c48d0ac6d410a6650a9272d5",
|
|
211
|
-
"sources/server/class.js": "
|
|
211
|
+
"sources/server/class.js": "fd22f6b2619d4a28c17df7e3ff7b9df6341c2bd6fefb96d09364636ca954e454",
|
|
212
212
|
"sources/server/external-source.js": "a576a42d380dc2f4688f5c7b0bcb4ca5e0870c55cd8900b34e9ba4d71eb6eb38",
|
|
213
213
|
"sources/server/file.js": "4ff9c5ff372824a937d4d6782851b0c8ead0c830eb94176e5802bc90fc4ed4a1",
|
|
214
214
|
"sources/server/folder.js": "c92a9872e214942a3b89ece192691295ec4c9576b5806b8050a62cb12ec1f970",
|
|
@@ -735,11 +735,11 @@
|
|
|
735
735
|
"$server/$folder/$file/$office/methods/save/$handler/class.js": "88c7f2c6779ec77cba043558956a9892dd4e1802f12e8554dbd21e1afff03f4a",
|
|
736
736
|
"$server/$folder/$file/$task/class.js": "904f2a18d813d8176867b068d23e0f202a9187af52ba7dc8361e61cdc105fe7c",
|
|
737
737
|
"$server/$folder/$file/$task/handlers/pages/form/file/$handler/class.js": "67034be6dc54c7116f9f7e4ac83e0bf62de02ca7af7498f3b0e19fee50bf0875",
|
|
738
|
-
"$server/$folder/$file/$task/handlers/pages/form/file/$handler/file.js": "
|
|
738
|
+
"$server/$folder/$file/$task/handlers/pages/form/file/$handler/file.js": "0cee95b7a369d55f4a9fe7e963e28d9132606115335f91b1cd61bf4f48347eb6",
|
|
739
739
|
"$server/$folder/$file/$task/handlers/pages/form/file/$handler/readme.md": "c9ef3c69af48b7f2437c06b45e9fc7d08da1676663514cc963a9860abf89c3d3",
|
|
740
740
|
"$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/dock.js": "28f4ceebb28a87a5b3c287103a9c06d5728f04afc1b97f599211cb1d242a0a1c",
|
|
741
|
-
"$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/docs.js": "
|
|
742
|
-
"$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/feed.js": "
|
|
741
|
+
"$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/docs.js": "85dbc8d304b79dd917213b93d837f7882e5453dcdffa0c3f3176a0034da4cf72",
|
|
742
|
+
"$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/feed.js": "b2196db89f073054b4d7cedf3e9777923211689a64101a9a9fbd00263b38bb06",
|
|
743
743
|
"$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/panel.js": "8a158cf43e87a6a70b4e0631a98a48fbd0aa977dd541cfb8308ad6d59ea431c9",
|
|
744
744
|
"$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/segments.js": "165030064982dc162586f368a8b0531afc297c401debf665def4e73ea6a8e32b",
|
|
745
745
|
"$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/util.js": "db0dca0c9d447034461dd94a408c9efff37999816a7df9acb505ceb4fdb703c0",
|
|
@@ -768,12 +768,12 @@
|
|
|
768
768
|
"$server/$folder/handlers/methods/help/$handler/class.js": "ff54bf976cbdc846d7c1b46ff12b111e99a3f4831240a4e420b73c98c0355a5c",
|
|
769
769
|
"$server/$folder/handlers/methods/info/$handler/class.js": "8752efb28abdcfad4e8ce56cfebcd8bb09ec0735cba7b84156d248bfcb0f9db0",
|
|
770
770
|
"$server/$folder/handlers/pages/form/$handler/class.js": "3902d3e1a8742afa2625410f97c68a3afac2559bd3d8f37044338edf7386d4df",
|
|
771
|
-
"$server/$folder/handlers/pages/form/$handler/form.js": "
|
|
771
|
+
"$server/$folder/handlers/pages/form/$handler/form.js": "344fab4b777b158c4a7d2e3ad22f23b731adb8f998d8e026dc8818f35ddce9ea",
|
|
772
772
|
"$server/$folder/handlers/readme.md": "1167594c32f46323d229098a72e80a9865005c347373fdacef5af69838a0f8eb",
|
|
773
773
|
"$server/$folder/lib/calendar-form/calendar-form.js": "3035cab0a489c891d7dd7ed52ae5c475068b97361a1f7c855d500a0823614d1c",
|
|
774
774
|
"$server/$folder/lib/chat-item/chat-item.js": "6af09b84e5ef31c7e22007ba763bccf874d642afeff359414400ec36d4d5c560",
|
|
775
775
|
"$server/$folder/lib/class-picker/class-picker.js": "b166f0852b38bf91e2576931c62d2d54f27ce259e2e9f8f998e81cb17c6f153b",
|
|
776
|
-
"$server/$folder/lib/consultant/consultant.js": "
|
|
776
|
+
"$server/$folder/lib/consultant/consultant.js": "eff426dfd290e693a3e6ca80b14c6dad27fdca04390084768cf8f9dc8d58254d",
|
|
777
777
|
"$server/$folder/lib/dialogs/confirm/confirm.js": "dea87a6fc521df05c79aa469bfb060bbb5056105758ef708fd058c6cb2c0d109",
|
|
778
778
|
"$server/$folder/lib/dialogs/input/input.js": "59f57a2514059d76529aa6fd062a6e0ac833f1d8b7a71dda7b8dcc07658df746",
|
|
779
779
|
"$server/$folder/lib/dialogs/popover/popover.js": "f845067f0db0f1851dcea596772aeb45d9916b37dd7de44a753033e5f14ede79",
|
|
@@ -974,15 +974,15 @@
|
|
|
974
974
|
"MODULES/Register/STRUCTS/Банковский счёт/$struct/class.js": "166ffafd1c7d1609b174ae7766e77842e6294c6902baabe787225a2eeb026cce",
|
|
975
975
|
"MODULES/Register/STRUCTS/Единица измерения/$struct/class.js": "dd0982281ed782d23afd80d5985b79aa65c6acbe58dc080f943840ea798000b0",
|
|
976
976
|
"MODULES/Register/STRUCTS/Паспорт/$struct/class.js": "4a50808e4db7741b0384a775177545d71686a680ccda7ef0ec68bf81f9c988b5",
|
|
977
|
-
"MODELS/$ai/$folder/$class/$ai/class.js": "
|
|
977
|
+
"MODELS/$ai/$folder/$class/$ai/class.js": "633d6226576af4ea9731a79fb3d1018a57b50e8e3c4e90464532ae30e39de5de",
|
|
978
978
|
"MODELS/$ai/$folder/$class/$ai/handlers/pages/form/trainer/$handler/class.js": "fe5ba834156495c28a34acd4b70a6b6b3bdfccb67ec7bf99e92a292afbb66d19",
|
|
979
|
-
"MODELS/$ai/$folder/$class/$ai/handlers/pages/form/trainer/$handler/trainer.js": "
|
|
980
|
-
"MODELS/$ai/$folder/$class/$ai/methods/chat/$method/class.js": "
|
|
979
|
+
"MODELS/$ai/$folder/$class/$ai/handlers/pages/form/trainer/$handler/trainer.js": "b3a7d14f263d7bf59d54bee7e84f45d03ecc0b0fadb34c43c8deda22921feb94",
|
|
980
|
+
"MODELS/$ai/$folder/$class/$ai/methods/chat/$method/class.js": "02fbb40d8ce93fbf568a6a8036c199e2af815be3d63d81f815aeb1da999db717",
|
|
981
981
|
"MODELS/$ai/$folder/$class/$provider/class.js": "069073501b93a95bb9d77e59ce71e53c7a8bcab2564c391b551f68a2453ac486",
|
|
982
982
|
"MODELS/$ai/$folder/$class/$provider/handlers/pages/form/provider/$handler/class.js": "8d327820cefd696d351ac4fa7998994039e4d57ef7a9f8ae297209e4dd1b0a9e",
|
|
983
983
|
"MODELS/$ai/$folder/$class/$provider/handlers/pages/form/provider/$handler/provider.js": "b9ddf0040a9cd12e0dacd2dd3a61a1f0e62686cc664d02ef446326bc3991f4ce",
|
|
984
984
|
"MODELS/$ai/$folder/$class/$provider/handlers/pages/form/trainer/$handler/class.js": "06b279a1c053deb37dd7401c84df7f9370309b8dfbd35b368ab1bab4f635cb3f",
|
|
985
|
-
"MODELS/$ai/$folder/$class/$provider/handlers/pages/form/trainer/$handler/trainer.js": "
|
|
985
|
+
"MODELS/$ai/$folder/$class/$provider/handlers/pages/form/trainer/$handler/trainer.js": "c32bdea5c6e961fdb5c6be0c4a46fdac03d0c0cd14132e3f073096dbd31fc169",
|
|
986
986
|
"MODELS/$ai/$folder/$class/$provider/readme.md": "d6ceef2010231ab121510c3d3f35630dd7009a069c7723f6673a0e264799b227",
|
|
987
987
|
"MODELS/$ai/class.js": "54e1bbbde88f8b1f272ff7f5cad87243407591748a44719b7ec90ae2b4962de7",
|
|
988
988
|
"MODELS/$ai/readme.md": "90d70305a2c85312282cf67cc468a0f0b417495cb3d5b3d2ca60c6f44b81cb77",
|
|
@@ -423,11 +423,27 @@ export default {
|
|
|
423
423
|
return Array.isArray(t) && t.length && t.some(x => x.status !== 'completed');
|
|
424
424
|
},
|
|
425
425
|
_onDelta(d) {
|
|
426
|
-
if (!d?.item
|
|
426
|
+
if (!d?.item)
|
|
427
427
|
return;
|
|
428
428
|
const cur = this.streams[d.item] || {};
|
|
429
|
+
if (d.field === 'tool') {
|
|
430
|
+
this.streams = {
|
|
431
|
+
...this.streams,
|
|
432
|
+
[d.item]: { ...cur, tool: { name: d.name || '', target: d.target || '', chars: Number(d.chars) || 0 } },
|
|
433
|
+
};
|
|
434
|
+
this._lastDelta = Date.now();
|
|
435
|
+
if (this.status !== 'running')
|
|
436
|
+
this.status = 'running';
|
|
437
|
+
this._stick();
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
if (!d.token)
|
|
441
|
+
return;
|
|
429
442
|
const field = d.field === 'reasoning' ? 'reasoning' : 'content';
|
|
430
|
-
|
|
443
|
+
const next = { ...cur, [field]: (cur[field] || '') + d.token };
|
|
444
|
+
if (next.tool)
|
|
445
|
+
delete next.tool;
|
|
446
|
+
this.streams = { ...this.streams, [d.item]: next };
|
|
431
447
|
this._lastDelta = Date.now();
|
|
432
448
|
if (this.status !== 'running')
|
|
433
449
|
this.status = 'running';
|
|
@@ -227,6 +227,19 @@ export function stableDocs(prev, list) {
|
|
|
227
227
|
return { docs: same ? prev : out, changed: !same };
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
+
/**
|
|
231
|
+
* Формат строки активности во время генерации аргументов tool_call (напр. запись кода в файл).
|
|
232
|
+
*/
|
|
233
|
+
export function formatToolStreamActivity(t) {
|
|
234
|
+
if (!t?.name)
|
|
235
|
+
return 'Готовлю вызов инструмента…';
|
|
236
|
+
const label = toolMeta(t.name)?.label || t.name;
|
|
237
|
+
const target = String(t.target || '').trim();
|
|
238
|
+
const chars = Number(t.chars) || 0;
|
|
239
|
+
const size = chars >= 1024 ? ` (${(chars / 1024).toFixed(1)} КБ)` : (chars > 0 ? ` (${chars} симв.)` : '');
|
|
240
|
+
return `${label}${target ? ': ' + target : ''}${size}…`;
|
|
241
|
+
}
|
|
242
|
+
|
|
230
243
|
/**
|
|
231
244
|
* Чем занят агент: текст строки состояния. null — виден текст с кареткой или задача не running.
|
|
232
245
|
*/
|
|
@@ -235,6 +248,8 @@ export function activityOf({ status, items, streams, nowMs, lastDeltaMs } = {})
|
|
|
235
248
|
return null;
|
|
236
249
|
const last = Array.isArray(items) ? items[items.length - 1] : null;
|
|
237
250
|
const s = last && streams ? streams[last.id] : null;
|
|
251
|
+
if (s?.tool && !last?.durationMs)
|
|
252
|
+
return { kind: 'tool_stream', text: formatToolStreamActivity(s.tool) };
|
|
238
253
|
if (String(s?.content || '').trim())
|
|
239
254
|
return null;
|
|
240
255
|
const tool = last?.tools?.find(t => t?.status === 'running' || t?.status === 'pending');
|
|
@@ -222,14 +222,18 @@ ODA({ is: 'microchat-assistant',
|
|
|
222
222
|
get reasoning() { return liveText(this.data?.reasoning, this.stream?.reasoning); },
|
|
223
223
|
/** Стрим — как есть (ссылки дорисуются по завершении), готовый ответ — с WORK-ссылками. */
|
|
224
224
|
get md() { return this.streamingText ? this.text : linkifyWork(this.text, this.artifacts || new Map()); },
|
|
225
|
-
get streamingText() { return !!this.stream?.content && !this.data?.durationMs; },
|
|
226
|
-
get thinkingNow() { return !!this.stream?.reasoning && !this.stream?.content && !this.data?.durationMs; },
|
|
225
|
+
get streamingText() { return !!this.stream?.content && !this.stream?.tool && !this.data?.durationMs; },
|
|
226
|
+
get thinkingNow() { return !!this.stream?.reasoning && !this.stream?.content && !this.stream?.tool && !this.data?.durationMs; },
|
|
227
227
|
get reasoningOpen() { return this.showReasoning || this.thinkingNow; },
|
|
228
228
|
get info() {
|
|
229
229
|
const u = this.data?.usage;
|
|
230
|
+
const tps = Number(u?.tokPerSec ?? u?.timings?.predicted_per_second) || 0;
|
|
231
|
+
const ttft = Number(u?.ttftMs) || 0;
|
|
230
232
|
return [
|
|
231
233
|
modelShort(this.data?.model),
|
|
232
234
|
fmtDuration(this.data?.durationMs),
|
|
235
|
+
tps > 0 ? `${tps.toFixed(1)} tok/s` : '',
|
|
236
|
+
ttft > 0 ? `TTFT ${fmtDuration(ttft)}` : '',
|
|
233
237
|
u?.total ? fmtTokens(u.prompt) + ' → ' + fmtTokens(u.completion) + ' ток.' : '',
|
|
234
238
|
].filter(Boolean).join(' · ');
|
|
235
239
|
},
|
|
@@ -344,7 +348,7 @@ ODA({ is: 'microchat-tool',
|
|
|
344
348
|
.ask .q { font-weight: 600; line-height: 1.4; white-space: pre-wrap; }
|
|
345
349
|
.ask .why { @apply --muted; font-size: x-small; }
|
|
346
350
|
.btns { @apply --horizontal; flex-wrap: wrap; gap: 8px; }
|
|
347
|
-
.btns oda-button { border-radius: var(--radius-s); padding:
|
|
351
|
+
.btns oda-button { border-radius: var(--radius-s); padding: 4px 12px; box-sizing: border-box; }
|
|
348
352
|
.ghost { border: 1px solid var(--subtle-border); background: var(--content-background); }
|
|
349
353
|
.danger { color: var(--error-color); fill: var(--error-color); }
|
|
350
354
|
.opt[selected] { outline: 2px solid var(--accent-color); }
|
|
@@ -201,7 +201,7 @@ ODA({is: 'work-form',
|
|
|
201
201
|
<div :flex="ODA.states?.mobileMode"></div>
|
|
202
202
|
<item-node-explorer no-flex :$item="rootItem"></item-node-explorer>
|
|
203
203
|
<div flex></div>
|
|
204
|
-
<oda-button id="consultantBtn" shadow icon="
|
|
204
|
+
<oda-button id="consultantBtn" shadow icon="bootstrap:robot" @tap="askConsultant" title="Спросить ИИ-консультанта по текущей форме" :icon-size info-invert style="border-radius: 50%; margin-right: 8px; flex-shrink: 0;"></oda-button>
|
|
205
205
|
<oda-button shadow icon="communication:call" @tap="call" title="Call..." :icon-size success style="border-radius: 50%;margin-right:32px;"></oda-button>
|
|
206
206
|
<slot name="top-panel"></slot>
|
|
207
207
|
<div class="view-selector" no-flex horizontal style="justify-content: space-between; overflow: hidden;">
|
|
@@ -298,43 +298,6 @@ ODA({
|
|
|
298
298
|
width: 16px;
|
|
299
299
|
height: 16px;
|
|
300
300
|
}
|
|
301
|
-
.ctx-bar {
|
|
302
|
-
@apply --horizontal;
|
|
303
|
-
align-items: center;
|
|
304
|
-
gap: 6px;
|
|
305
|
-
padding: 5px 10px;
|
|
306
|
-
border-bottom: 1px solid var(--subtle-border);
|
|
307
|
-
background: var(--subtle-background);
|
|
308
|
-
font-size: 12px;
|
|
309
|
-
min-width: 0;
|
|
310
|
-
}
|
|
311
|
-
.ctx-label {
|
|
312
|
-
@apply --flex;
|
|
313
|
-
overflow: hidden;
|
|
314
|
-
text-overflow: ellipsis;
|
|
315
|
-
white-space: nowrap;
|
|
316
|
-
color: var(--muted-color);
|
|
317
|
-
}
|
|
318
|
-
.ctx-label b {
|
|
319
|
-
color: var(--content-color);
|
|
320
|
-
font-weight: 600;
|
|
321
|
-
}
|
|
322
|
-
.ctx-ask-btn {
|
|
323
|
-
@apply --no-flex;
|
|
324
|
-
padding: 2px 8px;
|
|
325
|
-
border-radius: 12px;
|
|
326
|
-
font-size: 11px;
|
|
327
|
-
font-weight: 600;
|
|
328
|
-
border: 1px solid var(--accent-color);
|
|
329
|
-
background: var(--accent-soft);
|
|
330
|
-
color: var(--accent-color);
|
|
331
|
-
cursor: pointer;
|
|
332
|
-
white-space: nowrap;
|
|
333
|
-
}
|
|
334
|
-
.ctx-ask-btn:hover {
|
|
335
|
-
background: var(--accent-color);
|
|
336
|
-
color: var(--accent-back);
|
|
337
|
-
}
|
|
338
301
|
.history-panel {
|
|
339
302
|
@apply --vertical;
|
|
340
303
|
gap: 4px;
|
|
@@ -556,12 +519,6 @@ ODA({
|
|
|
556
519
|
<oda-button no-flex icon="carbon:add" :icon-size="18" title="Новый вопрос (новая задача)" @tap="startNewChat"></oda-button>
|
|
557
520
|
</div>
|
|
558
521
|
|
|
559
|
-
<div class="ctx-bar" no-flex ~if="activeFormSummary">
|
|
560
|
-
<oda-icon no-flex icon="icons:dashboard" :icon-size="14"></oda-icon>
|
|
561
|
-
<span class="ctx-label" :title="activeFormSummary.path">Форма: <b>{{activeFormSummary.label}}{{activeFormSummary.focusSubject ? ' · ' + activeFormSummary.focusSubject : ''}}</b></span>
|
|
562
|
-
<button class="ctx-ask-btn" @tap="askCurrentForm" title="Задать Консультанту вопрос по открытой форме">Спросить по форме</button>
|
|
563
|
-
</div>
|
|
564
|
-
|
|
565
522
|
<div class="prompts-panel" no-flex ~if="showPrompts && hasMessages">
|
|
566
523
|
<div class="history-head">
|
|
567
524
|
<span>Типовые сценарии и промпты</span>
|
|
@@ -1225,11 +1182,27 @@ ODA({
|
|
|
1225
1182
|
},
|
|
1226
1183
|
|
|
1227
1184
|
_onDelta(d) {
|
|
1228
|
-
if (!d?.item
|
|
1185
|
+
if (!d?.item)
|
|
1229
1186
|
return;
|
|
1230
1187
|
const cur = this.streams[d.item] || {};
|
|
1188
|
+
if (d.field === 'tool') {
|
|
1189
|
+
this.streams = {
|
|
1190
|
+
...this.streams,
|
|
1191
|
+
[d.item]: { ...cur, tool: { name: d.name || '', target: d.target || '', chars: Number(d.chars) || 0 } },
|
|
1192
|
+
};
|
|
1193
|
+
this._lastDelta = Date.now();
|
|
1194
|
+
if (this.status !== 'running')
|
|
1195
|
+
this.status = 'running';
|
|
1196
|
+
this._stick();
|
|
1197
|
+
return;
|
|
1198
|
+
}
|
|
1199
|
+
if (!d.token)
|
|
1200
|
+
return;
|
|
1231
1201
|
const field = d.field === 'reasoning' ? 'reasoning' : 'content';
|
|
1232
|
-
|
|
1202
|
+
const next = { ...cur, [field]: (cur[field] || '') + d.token };
|
|
1203
|
+
if (next.tool)
|
|
1204
|
+
delete next.tool;
|
|
1205
|
+
this.streams = { ...this.streams, [d.item]: next };
|
|
1233
1206
|
this._lastDelta = Date.now();
|
|
1234
1207
|
if (this.status !== 'running')
|
|
1235
1208
|
this.status = 'running';
|
|
@@ -320,6 +320,11 @@ export default {
|
|
|
320
320
|
|
|
321
321
|
// Вызовы инструментов копятся по index (параллельные tool_calls), отдаются одним событием в конце.
|
|
322
322
|
const calls = [];
|
|
323
|
+
const tStart = Date.now();
|
|
324
|
+
let tFirstToken = 0;
|
|
325
|
+
let lastToolProgressAt = 0;
|
|
326
|
+
let streamedChars = 0;
|
|
327
|
+
let emittedUsage = false;
|
|
323
328
|
const noteCall = (idx, id, name, args) => {
|
|
324
329
|
const e = calls[idx] ??= { id: '', name: '', args: '' };
|
|
325
330
|
if (id)
|
|
@@ -328,6 +333,24 @@ export default {
|
|
|
328
333
|
e.name = name;
|
|
329
334
|
if (args != null)
|
|
330
335
|
e.args = appendFunctionArgs(e.args, args);
|
|
336
|
+
return e;
|
|
337
|
+
};
|
|
338
|
+
const buildSpeedMeta = (completionTokens, timings) => {
|
|
339
|
+
const now = Date.now();
|
|
340
|
+
const ttftMs = tFirstToken ? Math.max(1, tFirstToken - tStart) : Math.max(1, now - tStart);
|
|
341
|
+
const decodeMs = tFirstToken ? Math.max(1, now - tFirstToken) : ttftMs;
|
|
342
|
+
const predPerSec = Number(timings?.predicted_per_second) || 0;
|
|
343
|
+
const promptPerSec = Number(timings?.prompt_per_second) || 0;
|
|
344
|
+
const estTok = completionTokens > 0 ? completionTokens : Math.round(streamedChars / 4);
|
|
345
|
+
const tokPerSec = predPerSec > 0
|
|
346
|
+
? +predPerSec.toFixed(1)
|
|
347
|
+
: (estTok > 0 && decodeMs > 0 ? +((estTok * 1000) / decodeMs).toFixed(1) : 0);
|
|
348
|
+
return {
|
|
349
|
+
ttftMs,
|
|
350
|
+
decodeMs,
|
|
351
|
+
...(tokPerSec > 0 ? { tokPerSec } : {}),
|
|
352
|
+
...(promptPerSec > 0 ? { promptTokPerSec: +promptPerSec.toFixed(1) } : {}),
|
|
353
|
+
};
|
|
331
354
|
};
|
|
332
355
|
// Конец ответа: finish_reason и/или [DONE]; без обоих — поток оборвался (цикл агента повторит ход).
|
|
333
356
|
let finishReason = null;
|
|
@@ -359,16 +382,49 @@ export default {
|
|
|
359
382
|
finishReason = String(json.choices[0].finish_reason);
|
|
360
383
|
const delta = json.choices?.[0]?.delta || json.choices?.[0]?.message || {};
|
|
361
384
|
const reasoning = delta.reasoning ?? delta.reasoning_content;
|
|
362
|
-
if (reasoning)
|
|
385
|
+
if (reasoning) {
|
|
386
|
+
tFirstToken ||= Date.now();
|
|
387
|
+
streamedChars += String(reasoning).length;
|
|
363
388
|
yield { type: 'reasoning', content: String(reasoning) };
|
|
389
|
+
}
|
|
364
390
|
const content = delta.content || delta.text;
|
|
365
|
-
if (content)
|
|
391
|
+
if (content) {
|
|
392
|
+
tFirstToken ||= Date.now();
|
|
393
|
+
streamedChars += String(content).length;
|
|
366
394
|
yield String(content);
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
395
|
+
}
|
|
396
|
+
let activeTool = null;
|
|
397
|
+
if (Array.isArray(delta.tool_calls)) {
|
|
398
|
+
tFirstToken ||= Date.now();
|
|
399
|
+
for (const tc of delta.tool_calls) {
|
|
400
|
+
const entry = noteCall(tc.index ?? 0, tc.id, tc.function?.name, tc.function?.arguments);
|
|
401
|
+
if (tc.function?.arguments)
|
|
402
|
+
streamedChars += String(tc.function.arguments).length;
|
|
403
|
+
if (entry?.name)
|
|
404
|
+
activeTool = { index: tc.index ?? 0, entry, freshName: Boolean(tc.function?.name) };
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
if (delta.function_call) {
|
|
408
|
+
tFirstToken ||= Date.now();
|
|
409
|
+
const entry = noteCall(0, null, delta.function_call.name, delta.function_call.arguments);
|
|
410
|
+
if (delta.function_call.arguments)
|
|
411
|
+
streamedChars += String(delta.function_call.arguments).length;
|
|
412
|
+
if (entry?.name)
|
|
413
|
+
activeTool = { index: 0, entry, freshName: Boolean(delta.function_call.name) };
|
|
414
|
+
}
|
|
415
|
+
if (activeTool) {
|
|
416
|
+
const now = Date.now();
|
|
417
|
+
if (activeTool.freshName || now - lastToolProgressAt >= 200) {
|
|
418
|
+
lastToolProgressAt = now;
|
|
419
|
+
yield {
|
|
420
|
+
type: 'tool_progress',
|
|
421
|
+
index: activeTool.index,
|
|
422
|
+
name: activeTool.entry.name,
|
|
423
|
+
target: extractToolTarget(activeTool.entry.args),
|
|
424
|
+
chars: activeTool.entry.args.length,
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
}
|
|
372
428
|
if (json.usage) {
|
|
373
429
|
const u = json.usage;
|
|
374
430
|
const timings = json.timings || lastTimings || null;
|
|
@@ -382,12 +438,14 @@ export default {
|
|
|
382
438
|
promptTokens = (Number(u.input_tokens) || 0) + cached + cacheWrite;
|
|
383
439
|
const completionTokens = Number(u.completion_tokens ?? u.completionTokens ?? u.output_tokens ?? 0) || 0;
|
|
384
440
|
const totalTokens = Number(u.total_tokens ?? u.totalTokens ?? (promptTokens + completionTokens)) || 0;
|
|
441
|
+
emittedUsage = true;
|
|
385
442
|
yield {
|
|
386
443
|
type: 'usage',
|
|
387
444
|
prompt_tokens: promptTokens,
|
|
388
445
|
completion_tokens: completionTokens,
|
|
389
446
|
total_tokens: totalTokens,
|
|
390
447
|
cached_tokens: cached,
|
|
448
|
+
...buildSpeedMeta(completionTokens, timings),
|
|
391
449
|
...(u.completion_tokens_details ? { completion_tokens_details: u.completion_tokens_details } : {}),
|
|
392
450
|
...(timings ? { timings } : {}),
|
|
393
451
|
...(halogenFromHeader ? { halogen_from: halogenFromHeader } : {}),
|
|
@@ -413,6 +471,21 @@ export default {
|
|
|
413
471
|
if (String(buf || '').trim())
|
|
414
472
|
yield* parseLine(buf.trim());
|
|
415
473
|
|
|
474
|
+
if (!emittedUsage && (lastTimings || tFirstToken || streamedChars > 0)) {
|
|
475
|
+
const predCount = Number(lastTimings?.predicted_n) || Math.round(streamedChars / 4);
|
|
476
|
+
const promptCount = Number(lastTimings?.prompt_n) || 0;
|
|
477
|
+
yield {
|
|
478
|
+
type: 'usage',
|
|
479
|
+
prompt_tokens: promptCount,
|
|
480
|
+
completion_tokens: predCount,
|
|
481
|
+
total_tokens: promptCount + predCount,
|
|
482
|
+
cached_tokens: Number(lastTimings?.cache_n) || 0,
|
|
483
|
+
...buildSpeedMeta(predCount, lastTimings),
|
|
484
|
+
...(lastTimings ? { timings: lastTimings } : {}),
|
|
485
|
+
...(halogenFromHeader ? { halogen_from: halogenFromHeader } : {}),
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
|
|
416
489
|
// reasoning не подменяем content: silent-меню иначе получает абзац «think»
|
|
417
490
|
const done = calls.filter(c => c && c.name);
|
|
418
491
|
if (done.length)
|
|
@@ -438,6 +511,8 @@ export default {
|
|
|
438
511
|
const ai = params.$ai || this;
|
|
439
512
|
if (!hasCap(ai, 'image'))
|
|
440
513
|
throw new Error('generateImage: у модели нет capabilities image');
|
|
514
|
+
if (isLocalDirectModel(ai) && typeof WORK?.localEngine?.generateImage === 'function')
|
|
515
|
+
return WORK.localEngine.generateImage(ai, params);
|
|
441
516
|
const prompt = String(params.prompt || params.post || '').trim();
|
|
442
517
|
if (!prompt)
|
|
443
518
|
throw new Error('generateImage: пустой prompt');
|
|
@@ -501,6 +576,8 @@ export default {
|
|
|
501
576
|
const ai = params.$ai || this;
|
|
502
577
|
if (!hasCap(ai, 'tts'))
|
|
503
578
|
throw new Error('speak: у модели нет capabilities tts');
|
|
579
|
+
if (isLocalDirectModel(ai) && typeof WORK?.localEngine?.speak === 'function')
|
|
580
|
+
return WORK.localEngine.speak(ai, params);
|
|
504
581
|
const text = String(params.text ?? params.post ?? '').trim().slice(0, 1500);
|
|
505
582
|
if (!text)
|
|
506
583
|
throw new Error('speak: пустой текст');
|
|
@@ -583,6 +660,8 @@ export default {
|
|
|
583
660
|
const ai = params.$ai || this;
|
|
584
661
|
if (!hasCap(ai, 'stt'))
|
|
585
662
|
throw new Error('transcribe: у модели нет capabilities stt');
|
|
663
|
+
if (isLocalDirectModel(ai) && typeof WORK?.localEngine?.transcribe === 'function')
|
|
664
|
+
return WORK.localEngine.transcribe(ai, params);
|
|
586
665
|
const audio = Buffer.isBuffer(params.audio) ? params.audio : null;
|
|
587
666
|
if (!audio?.length)
|
|
588
667
|
throw new Error('transcribe: нет аудио');
|
|
@@ -627,6 +706,8 @@ export default {
|
|
|
627
706
|
*/
|
|
628
707
|
async embed(params = {}) {
|
|
629
708
|
const ai = params.$ai || this;
|
|
709
|
+
if (isLocalDirectModel(ai) && typeof WORK?.localEngine?.embed === 'function')
|
|
710
|
+
return WORK.localEngine.embed(ai, params);
|
|
630
711
|
const tag = String(params.model || ai.model || 'qwen3-embedding-0.6b').trim();
|
|
631
712
|
const input = params.input ?? params.text ?? params.post ?? '';
|
|
632
713
|
const origin = speechOrigin(params, ai, 'embed');
|
|
@@ -660,6 +741,8 @@ export default {
|
|
|
660
741
|
*/
|
|
661
742
|
async rerank(params = {}) {
|
|
662
743
|
const ai = params.$ai || this;
|
|
744
|
+
if (isLocalDirectModel(ai) && typeof WORK?.localEngine?.rerank === 'function')
|
|
745
|
+
return WORK.localEngine.rerank(ai, params);
|
|
663
746
|
const tag = String(params.model || ai.model || 'qwen3-reranker-0.6b').trim();
|
|
664
747
|
const query = String(params.query || '').trim();
|
|
665
748
|
const documents = Array.isArray(params.documents) ? params.documents : [];
|
|
@@ -695,6 +778,8 @@ export default {
|
|
|
695
778
|
*/
|
|
696
779
|
async decide(params = {}) {
|
|
697
780
|
const ai = params.$ai || this;
|
|
781
|
+
if (isLocalDirectModel(ai) && typeof WORK?.localEngine?.decide === 'function')
|
|
782
|
+
return WORK.localEngine.decide(ai, params);
|
|
698
783
|
const tag = String(params.model || ai.model || 'decider-0.8b').trim();
|
|
699
784
|
const origin = speechOrigin(params, ai, 'decide');
|
|
700
785
|
const headers = await getAuthHeaders(ai);
|
|
@@ -728,6 +813,13 @@ function isHalogenModel(ai) {
|
|
|
728
813
|
|| (p.startsWith('/MODELS/Local/') && b.includes(':8731'));
|
|
729
814
|
}
|
|
730
815
|
|
|
816
|
+
function isLocalDirectModel(ai) {
|
|
817
|
+
const p = String(ai?.path || ai?.short || '');
|
|
818
|
+
const b = String(ai?.baseUrl || ai?.DATA?.baseUrl || '').trim();
|
|
819
|
+
return ai?.protocol === 'local'
|
|
820
|
+
|| (p.startsWith('/MODELS/Local/') && !b && ai?.protocol !== 'halogen');
|
|
821
|
+
}
|
|
822
|
+
|
|
731
823
|
function speechOrigin(params, ai, who) {
|
|
732
824
|
const base = String(ai.baseUrl || ai.DATA?.baseUrl || '').trim();
|
|
733
825
|
if (!base)
|
|
@@ -1392,6 +1484,9 @@ const ANTHROPIC_STOP = { end_turn: 'stop', stop_sequence: 'stop', tool_use: 'too
|
|
|
1392
1484
|
export function createAnthropicParser(model = '') {
|
|
1393
1485
|
const blocks = [];
|
|
1394
1486
|
const usage = { input: 0, cacheRead: 0, cacheWrite: 0, output: 0 };
|
|
1487
|
+
const tStart = Date.now();
|
|
1488
|
+
let tFirstToken = 0;
|
|
1489
|
+
let lastToolProgressAt = 0;
|
|
1395
1490
|
let stop = null;
|
|
1396
1491
|
let done = false;
|
|
1397
1492
|
const takeUsage = u => {
|
|
@@ -1412,18 +1507,35 @@ export function createAnthropicParser(model = '') {
|
|
|
1412
1507
|
case 'content_block_start': {
|
|
1413
1508
|
const cb = ev.content_block || {};
|
|
1414
1509
|
blocks[ev.index] = { type: cb.type, id: cb.id, name: cb.name, args: '', thinking: cb.thinking || '', signature: cb.signature || '', data: cb.data };
|
|
1415
|
-
if (cb.type === 'text' && cb.text)
|
|
1510
|
+
if (cb.type === 'text' && cb.text) {
|
|
1511
|
+
tFirstToken ||= Date.now();
|
|
1416
1512
|
out.push(String(cb.text));
|
|
1513
|
+
}
|
|
1514
|
+
else if (cb.type === 'tool_use' && cb.name) {
|
|
1515
|
+
tFirstToken ||= Date.now();
|
|
1516
|
+
lastToolProgressAt = Date.now();
|
|
1517
|
+
out.push({ type: 'tool_progress', index: ev.index, name: cb.name, target: '', chars: 0 });
|
|
1518
|
+
}
|
|
1417
1519
|
break;
|
|
1418
1520
|
}
|
|
1419
1521
|
case 'content_block_delta': {
|
|
1420
1522
|
const d = ev.delta || {};
|
|
1421
1523
|
const b = blocks[ev.index] ??= { type: d.type === 'input_json_delta' ? 'tool_use' : 'text', args: '', thinking: '', signature: '' };
|
|
1422
|
-
if (d.type === 'text_delta' && d.text)
|
|
1524
|
+
if (d.type === 'text_delta' && d.text) {
|
|
1525
|
+
tFirstToken ||= Date.now();
|
|
1423
1526
|
out.push(String(d.text));
|
|
1424
|
-
|
|
1527
|
+
}
|
|
1528
|
+
else if (d.type === 'input_json_delta') {
|
|
1529
|
+
tFirstToken ||= Date.now();
|
|
1425
1530
|
b.args += d.partial_json || '';
|
|
1531
|
+
const now = Date.now();
|
|
1532
|
+
if (b.name && now - lastToolProgressAt >= 200) {
|
|
1533
|
+
lastToolProgressAt = now;
|
|
1534
|
+
out.push({ type: 'tool_progress', index: ev.index, name: b.name, target: extractToolTarget(b.args), chars: b.args.length });
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1426
1537
|
else if (d.type === 'thinking_delta' && d.thinking) {
|
|
1538
|
+
tFirstToken ||= Date.now();
|
|
1427
1539
|
b.thinking += d.thinking;
|
|
1428
1540
|
out.push({ type: 'reasoning', content: String(d.thinking) });
|
|
1429
1541
|
}
|
|
@@ -1455,9 +1567,14 @@ export function createAnthropicParser(model = '') {
|
|
|
1455
1567
|
if (calls.length)
|
|
1456
1568
|
out.push({ type: 'tool_calls', calls });
|
|
1457
1569
|
const prompt = usage.input + usage.cacheRead + usage.cacheWrite;
|
|
1570
|
+
const now = Date.now();
|
|
1571
|
+
const ttftMs = tFirstToken ? Math.max(1, tFirstToken - tStart) : Math.max(1, now - tStart);
|
|
1572
|
+
const decodeMs = tFirstToken ? Math.max(1, now - tFirstToken) : ttftMs;
|
|
1573
|
+
const tokPerSec = usage.output > 0 && decodeMs > 0 ? +((usage.output * 1000) / decodeMs).toFixed(1) : 0;
|
|
1458
1574
|
out.push({
|
|
1459
1575
|
type: 'usage', prompt_tokens: prompt, completion_tokens: usage.output, total_tokens: prompt + usage.output,
|
|
1460
1576
|
cached_tokens: usage.cacheRead, cache_creation_tokens: usage.cacheWrite,
|
|
1577
|
+
ttftMs, decodeMs, ...(tokPerSec > 0 ? { tokPerSec } : {}),
|
|
1461
1578
|
});
|
|
1462
1579
|
out.push({ type: 'finish', reason: stop ? (ANTHROPIC_STOP[stop] || stop) : null, done });
|
|
1463
1580
|
return out;
|
|
@@ -1465,6 +1582,14 @@ export function createAnthropicParser(model = '') {
|
|
|
1465
1582
|
};
|
|
1466
1583
|
}
|
|
1467
1584
|
|
|
1585
|
+
function extractToolTarget(rawArgs) {
|
|
1586
|
+
const s = String(rawArgs || '');
|
|
1587
|
+
const m = /"(?:path|filePath|file|target|command|cmd|query|url|name)"\s*:\s*"((?:[^"\\]|\\.)*)/i.exec(s);
|
|
1588
|
+
if (!m)
|
|
1589
|
+
return '';
|
|
1590
|
+
return m[1].replace(/\\"/g, '"').replace(/\\\\/g, '\\').slice(0, 80);
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1468
1593
|
/** SSE-поток Messages API (res — ответ HTTP) → события адаптера. Строки `event:` не нужны: тип есть в каждом data. */
|
|
1469
1594
|
async function* anthropicStream(res, model) {
|
|
1470
1595
|
const parser = createAnthropicParser(model);
|