odant-work 1.0.36 → 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 +31 -31
- 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/$server/$folder/lib/prompt-bar/prompt-bar.js +7 -5
- 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/oda/components/containers/popover/popover.js +225 -212
- package/oda/core/shared.js +1 -1
- package/oda/oda.js +4 -2
- package/package.json +1 -1
- package/sources/data/progress.md +11 -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,212 +1,225 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* oda-popover — оболочка всплывающего окна (top layer, нативный popover):
|
|
3
|
-
* заголовок (TITLE / слот title), содержимое (светлый потомок или message), подвал диалога (OK / CANCEL / BUTTONS).
|
|
4
|
-
* Показ и стек — ODA.showPopover (containers.js). Содержимое закрывает окно через parentElement.close(result) / ok().
|
|
5
|
-
*/
|
|
6
|
-
ODA({
|
|
7
|
-
is: 'oda-popover',
|
|
8
|
-
imports: '/oda/components/button/button.js',
|
|
9
|
-
template: /*html*/`
|
|
10
|
-
<style>
|
|
11
|
-
:host {
|
|
12
|
-
border: none;
|
|
13
|
-
visibility: hidden;
|
|
14
|
-
max-width: 100%;
|
|
15
|
-
transition: opacity var(--duration) ease-in;
|
|
16
|
-
opacity: 1;
|
|
17
|
-
position: absolute;
|
|
18
|
-
margin: {{position ? '0px' : 'auto'}} !important;
|
|
19
|
-
min-width: {{width === undefined ? 'min-content' : width + 'px'}};
|
|
20
|
-
max-height: {{height === undefined ? '100% !important' : height + 'px'}};
|
|
21
|
-
padding: 0;
|
|
22
|
-
overflow: hidden;
|
|
23
|
-
box-shadow: var(--elevation-3);
|
|
24
|
-
@apply --vertical;
|
|
25
|
-
{{left < 0 ? '' : 'left:' + left + 'px;'}}
|
|
26
|
-
{{top < 0 ? '' : 'top:' + top + 'px;'}}
|
|
27
|
-
bottom: 0;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
:
|
|
79
|
-
:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
$
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
if (
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
this.
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
this.
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
1
|
+
/**
|
|
2
|
+
* oda-popover — оболочка всплывающего окна (top layer, нативный popover):
|
|
3
|
+
* заголовок (TITLE / слот title), содержимое (светлый потомок или message), подвал диалога (OK / CANCEL / BUTTONS).
|
|
4
|
+
* Показ и стек — ODA.showPopover (containers.js). Содержимое закрывает окно через parentElement.close(result) / ok().
|
|
5
|
+
*/
|
|
6
|
+
ODA({
|
|
7
|
+
is: 'oda-popover',
|
|
8
|
+
imports: '/oda/components/button/button.js',
|
|
9
|
+
template: /*html*/`
|
|
10
|
+
<style>
|
|
11
|
+
:host {
|
|
12
|
+
border: none;
|
|
13
|
+
visibility: hidden;
|
|
14
|
+
max-width: 100%;
|
|
15
|
+
transition: opacity var(--duration) ease-in;
|
|
16
|
+
opacity: 1;
|
|
17
|
+
position: absolute;
|
|
18
|
+
margin: {{position ? '0px' : 'auto'}} !important;
|
|
19
|
+
min-width: {{width === undefined ? 'min-content' : width + 'px'}};
|
|
20
|
+
max-height: {{height === undefined ? '100% !important' : height + 'px'}};
|
|
21
|
+
padding: 0;
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
box-shadow: var(--elevation-3);
|
|
24
|
+
@apply --vertical;
|
|
25
|
+
{{left < 0 ? '' : 'left:' + left + 'px;'}}
|
|
26
|
+
{{top < 0 ? '' : 'top:' + top + 'px;'}}
|
|
27
|
+
{{position ? 'bottom: auto; right: auto;' : 'bottom: 0; right: 0;'}}
|
|
28
|
+
@apply --content;
|
|
29
|
+
}
|
|
30
|
+
:host([visible]) {
|
|
31
|
+
visibility: visible;
|
|
32
|
+
}
|
|
33
|
+
.title {
|
|
34
|
+
align-items: center;
|
|
35
|
+
gap: var(--space-s);
|
|
36
|
+
padding: var(--space-xs) var(--space-xs) var(--space-xs) var(--space-m);
|
|
37
|
+
}
|
|
38
|
+
.title label {
|
|
39
|
+
font-weight: bold;
|
|
40
|
+
text-overflow: ellipsis;
|
|
41
|
+
white-space: nowrap;
|
|
42
|
+
overflow: hidden;
|
|
43
|
+
}
|
|
44
|
+
.footer {
|
|
45
|
+
align-items: center;
|
|
46
|
+
gap: var(--space-m);
|
|
47
|
+
padding: var(--space-m);
|
|
48
|
+
}
|
|
49
|
+
.btn {
|
|
50
|
+
border-radius: var(--control-radius);
|
|
51
|
+
padding: var(--space-s) var(--space-m);
|
|
52
|
+
box-shadow: var(--elevation-1);
|
|
53
|
+
}
|
|
54
|
+
::slotted(:not([slot])) {
|
|
55
|
+
@apply --flex;
|
|
56
|
+
}
|
|
57
|
+
.message {
|
|
58
|
+
margin: var(--space-l);
|
|
59
|
+
}
|
|
60
|
+
</style>
|
|
61
|
+
<div no-flex ~if="hasTitle" accent-invert horizontal class="title">
|
|
62
|
+
<div vertical flex>
|
|
63
|
+
<slot name="title"></slot>
|
|
64
|
+
<div ~if="TITLE?.label" flex horizontal style="align-items: center; gap: var(--space-s);">
|
|
65
|
+
<oda-icon ~if="TITLE.icon" :icon="TITLE.icon"></oda-icon>
|
|
66
|
+
<label flex>{{TITLE.label}}</label>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
<oda-button ~if="allowClose" no-flex error icon="icons:close" @pointerdown="close()"></oda-button>
|
|
70
|
+
</div>
|
|
71
|
+
<slot>
|
|
72
|
+
<label flex ~if="message" class="message">{{message}}</label>
|
|
73
|
+
</slot>
|
|
74
|
+
<div ~if="popoverType === 'dialog'" horizontal no-flex header class="footer">
|
|
75
|
+
<div flex horizontal style="gap: var(--space-m);">
|
|
76
|
+
<oda-button ~for="BUTTONS" ~is="$for.item.is || 'oda-button'" class="btn" no-flex
|
|
77
|
+
:icon="$for.item.icon" :label="$for.item.label" :title="$for.item.title || ''"
|
|
78
|
+
:disabled="!!$for.item.disabled" :color-mode="$for.item.colorMode"
|
|
79
|
+
:tabindex="$for.index + 2"
|
|
80
|
+
@tap="$for.item.tap ? $for.item.tap($event) : ok($for.index + 1)"></oda-button>
|
|
81
|
+
</div>
|
|
82
|
+
<oda-button ~if="OK" tabindex="0" class="btn bold" :icon="OK.icon" :hide-icon="!OK.icon" :icon-size="OK.iconSize || iconSize"
|
|
83
|
+
:label="OK.label" :color-mode="OK.colorMode" :disabled="!enable" @tap="ok()"></oda-button>
|
|
84
|
+
<oda-button ~if="CANCEL" tabindex="1" class="btn" :icon="CANCEL.icon" :hide-icon="!CANCEL.icon" :icon-size="CANCEL.iconSize || iconSize"
|
|
85
|
+
:label="CANCEL.label" :color-mode="CANCEL.colorMode" @tap="close()"></oda-button>
|
|
86
|
+
</div>
|
|
87
|
+
`,
|
|
88
|
+
message: '',
|
|
89
|
+
BUTTONS: [],
|
|
90
|
+
OK: {
|
|
91
|
+
label: 'OK',
|
|
92
|
+
icon: 'icons:check',
|
|
93
|
+
result: 'ok',
|
|
94
|
+
colorMode: 'info-invert'
|
|
95
|
+
},
|
|
96
|
+
CANCEL: {
|
|
97
|
+
label: 'Отмена',
|
|
98
|
+
icon: 'icons:close',
|
|
99
|
+
colorMode: 'info'
|
|
100
|
+
},
|
|
101
|
+
TITLE: {
|
|
102
|
+
icon: '',
|
|
103
|
+
label: '',
|
|
104
|
+
deep: 0
|
|
105
|
+
},
|
|
106
|
+
allowClose: false,
|
|
107
|
+
/** modal | dialog | dropdown | menu */
|
|
108
|
+
popoverType: '',
|
|
109
|
+
position: undefined,
|
|
110
|
+
/** '' | 'top' | 'bottom' — предпочтительное направление раскрытия относительно якоря */
|
|
111
|
+
placement: '',
|
|
112
|
+
visible: {
|
|
113
|
+
$def: false,
|
|
114
|
+
$attr: true
|
|
115
|
+
},
|
|
116
|
+
iconSize: 24,
|
|
117
|
+
left: -1,
|
|
118
|
+
top: -1,
|
|
119
|
+
width: undefined,
|
|
120
|
+
height: undefined,
|
|
121
|
+
get hasTitle() {
|
|
122
|
+
return !!this.TITLE?.label;
|
|
123
|
+
},
|
|
124
|
+
/** доступность OK: переопределяется наследниками/содержимым */
|
|
125
|
+
get enable() {
|
|
126
|
+
return true;
|
|
127
|
+
},
|
|
128
|
+
$listeners: {
|
|
129
|
+
resize() {
|
|
130
|
+
this.async(() => this._show());
|
|
131
|
+
},
|
|
132
|
+
keydown(e) {
|
|
133
|
+
if (e.defaultPrevented)
|
|
134
|
+
return;
|
|
135
|
+
if (e.key === 'Escape') {
|
|
136
|
+
e.stopPropagation();
|
|
137
|
+
this.close();
|
|
138
|
+
}
|
|
139
|
+
else if (e.key === 'Enter' && this.popoverType === 'dialog' && this.enable && !e.composedPath()[0].matches?.('textarea, button, [contenteditable], [contenteditable] *')) {
|
|
140
|
+
e.preventDefault();
|
|
141
|
+
this.ok();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
set control(n) {
|
|
146
|
+
if (n)
|
|
147
|
+
this.appendChild(n);
|
|
148
|
+
},
|
|
149
|
+
layout(finalize = false) {
|
|
150
|
+
const pos = this.position;
|
|
151
|
+
if (!pos)
|
|
152
|
+
return;
|
|
153
|
+
let left, top, width, height;
|
|
154
|
+
if (pos.tagName) {
|
|
155
|
+
const r = pos.getBoundingClientRect();
|
|
156
|
+
left = r.left;
|
|
157
|
+
width = r.width;
|
|
158
|
+
const below = Math.max(0, window.innerHeight - r.bottom);
|
|
159
|
+
const above = Math.max(0, r.top);
|
|
160
|
+
const maxAvail = Math.max(above, below);
|
|
161
|
+
let openUp;
|
|
162
|
+
if (this.placement === 'top') {
|
|
163
|
+
openUp = above >= 80 || above >= below;
|
|
164
|
+
}
|
|
165
|
+
else if (this.placement === 'bottom') {
|
|
166
|
+
openUp = false;
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
openUp = this.offsetHeight > below && above > below;
|
|
170
|
+
}
|
|
171
|
+
if (openUp) {
|
|
172
|
+
height = above;
|
|
173
|
+
top = Math.max(0, r.top - Math.min(this.offsetHeight, above));
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
top = r.bottom;
|
|
177
|
+
height = (this.placement === 'bottom' || finalize || this.visible || above <= below) ? below : maxAvail;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else if (typeof pos.clientX === 'number') {
|
|
181
|
+
left = pos.clientX;
|
|
182
|
+
top = pos.clientY;
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
left = pos.x ?? pos.left ?? 0;
|
|
186
|
+
top = pos.y ?? pos.top ?? 0;
|
|
187
|
+
}
|
|
188
|
+
left = Math.max(0, Math.min(left, window.innerWidth - this.offsetWidth));
|
|
189
|
+
top = Math.max(0, Math.min(top, window.innerHeight - this.offsetHeight));
|
|
190
|
+
// гейты: layout зовётся из resize-наблюдателя, а каждая запись пропа — это
|
|
191
|
+
// notify + ререндер + новый замер; без гейтов размер гуляет и круг не рвётся
|
|
192
|
+
if (width !== undefined && !Object.is(this.width, width))
|
|
193
|
+
this.width = width;
|
|
194
|
+
if (height !== undefined && !Object.is(this.height, height))
|
|
195
|
+
this.height = height;
|
|
196
|
+
if (!Object.is(this.left, left))
|
|
197
|
+
this.left = left;
|
|
198
|
+
if (!Object.is(this.top, top))
|
|
199
|
+
this.top = top;
|
|
200
|
+
},
|
|
201
|
+
_show() {
|
|
202
|
+
this.layout();
|
|
203
|
+
clearTimeout(this._visibleTimer);
|
|
204
|
+
// раскрытие после стабилизации размеров содержимого (асинхронный рендер потомков)
|
|
205
|
+
this._visibleTimer = setTimeout(() => this._reveal(), 250);
|
|
206
|
+
this._safetyTimer ??= setTimeout(() => this._reveal(), 1500);
|
|
207
|
+
},
|
|
208
|
+
_reveal() {
|
|
209
|
+
if (this.visible)
|
|
210
|
+
return;
|
|
211
|
+
clearTimeout(this._visibleTimer);
|
|
212
|
+
clearTimeout(this._safetyTimer);
|
|
213
|
+
this.layout(true);
|
|
214
|
+
this.visible = true;
|
|
215
|
+
this.style.maxWidth = this.getBoundingClientRect().width + 'px';
|
|
216
|
+
},
|
|
217
|
+
ok(result) {
|
|
218
|
+
this.close(result ?? this.OK?.result ?? 'ok');
|
|
219
|
+
},
|
|
220
|
+
close(result = '') {
|
|
221
|
+
clearTimeout(this._visibleTimer);
|
|
222
|
+
clearTimeout(this._safetyTimer);
|
|
223
|
+
this.fire('close', result);
|
|
224
|
+
}
|
|
225
|
+
});
|
package/oda/core/shared.js
CHANGED
|
@@ -12,7 +12,7 @@ export function componentCounter() {
|
|
|
12
12
|
componentCounter.counter = 0;
|
|
13
13
|
|
|
14
14
|
export function setAttribute(name, value) {
|
|
15
|
-
if (typeof value !== 'object') {
|
|
15
|
+
if (typeof value !== 'object' && typeof value !== 'function') {
|
|
16
16
|
try {
|
|
17
17
|
if (value || value === 0) {
|
|
18
18
|
this.setAttribute(name, value === true ? '' : value);
|
package/oda/oda.js
CHANGED
|
@@ -151,8 +151,10 @@ Node:{
|
|
|
151
151
|
const reentering = Reactor._collectorTarget === target && Reactor._collectorKey === p;
|
|
152
152
|
const owner = pdpOwner(reentering ? target.host : target, p);
|
|
153
153
|
if (!owner) return undefined;
|
|
154
|
-
if (owner[R])
|
|
155
|
-
|
|
154
|
+
if (owner[R]) {
|
|
155
|
+
const value = Reactor.get(owner, p);
|
|
156
|
+
return typeof value === 'function' ? value.bind(owner) : value;
|
|
157
|
+
}
|
|
156
158
|
const value = owner[p];
|
|
157
159
|
return typeof value === 'function' ? value.bind(owner) : value;
|
|
158
160
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "odant-work",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.38",
|
|
4
4
|
"description": "ODANT-WORK — платформа цифровой организации (встроенная система учёта, документооборот, управление процессами и приватный мультимодальный ИИ)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "sources/work.js",
|
package/sources/data/progress.md
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
# Прогресс: sources/data
|
|
2
2
|
|
|
3
3
|
## Последние изменения
|
|
4
|
+
- [~15:00, 17.11] Живой статус генерации, метрики скорости моделей (TTFT / tok/s) и автоподключение всех 8 локальных моделей (`/MODELS/Local`) к подсистемам WORK (`MODELS/$ai/$folder/$class/$ai/{class.js,handlers/pages/form/trainer/$handler/trainer.js,methods/chat/$method/class.js}`, `MODELS/$ai/$folder/$class/$provider/handlers/pages/form/trainer/$handler/trainer.js`, `sources/modules/{agent/{loop,index,session,voice}.js,rag/{config,embedder,search,store}.js,trainer/{index,local-engine}.js,trainer/worker/local_infer_worker.py}`, `sources/server/class.js`, `$server/$folder/handlers/pages/form/$handler/form.js`, `$server/$folder/lib/consultant/consultant.js`, `$server/$folder/$file/$task/handlers/pages/form/file/$handler/{file.js,ui/{docs,feed}.js}`, `tests/{ai-stream,task-docs,accounting-forms}.test.js`, `odant-work@1.0.38`):
|
|
5
|
+
- **Живой статус вместо замершего карета `▍` при генерации кода / `tool_calls`:** в `streamChat` (openai/halogen-протоколы и `anthropicStream`) каждые ~200 мс отдаётся событие `tool_progress` (имя инструмента, цель `path`/`command`/`query`, накопленный объём); цикл агента (`loop.js`) и UI задач (`file.js`, `consultant.js`) показывают статус «Запись: <путь> (N КБ)…» (`activityOf` в `ui/docs.js`), а каретка `▍` в `ui/feed.js` скрывается пока стримится `tool_call`.
|
|
6
|
+
- **Метрики скорости моделей:** `ttftMs` (время до первого токена), `tokPerSec` (из `timings.predicted_per_second` Halogen/llama-server или фактически по времени декодирования), `promptTokPerSec` считаются в `streamChat`, локальном движке (`local-engine.js`) и `$method chat`; отображаются в метастроке ответа ИИ (`ui/feed.js`) и в результатах «Быстрой проверки» карточки модели.
|
|
7
|
+
- **Компактные кнопки подтверждения** («Разрешить / Разрешить всегда / Отклонить») в ленте задачи (`ui/feed.js`): убран `min-height: 36px`, `padding: 4px 12px`.
|
|
8
|
+
- **Убрана верхняя плашка `Форма: … / Спросить по форме`** Консультанта (`consultant.js`); иконка круглой кнопки `#consultantBtn` в шапке `work-form` заменена с `icons:help` на `bootstrap:robot` (как на вкладке «ИИ» проводника).
|
|
9
|
+
- **Авто-маршрутизация активных локальных моделей `/MODELS/Local/*` по подсистемам WORK:** сжатие контекста (`compactLlm`) — `Qwen3-4B` / `Qwen3.5-2B-NPU`; классификация/маршрутизация (`classifierModel`) — `Qwen3-0.6B` / `Decider-NPU`; голос (`voice.js`) при дефолтных настройках — `Qwen3-ASR-1.7B` (STT) и `Qwen3-TTS-12Hz-1.7B-VoiceDesign` (TTS); картинки (`findImageModel`) — `Z-Image-Turbo`; RAG (`rag/*`) — эмбеддинги через `BGE-M3` (с автоматическим пересчётом версии индекса) и второй этап реранкинга через `BGE-Reranker-v2-M3`.
|
|
10
|
+
- **Расширен локальный Python-движок (`local_infer_worker.py`, `local-engine.js`) на 5 не-LLM модальностей** (`.safetensors` через PyTorch/transformers/diffusers): `embed` (mean pooling + нормализация), `rerank` (sequence classification), `image` (diffusers, Z-Image-Turbo / AutoPipeline), `tts` (qwen-tts VoiceDesign) и `stt` (qwen-asr или transformers ASR pipeline) + `decide` на локальном чат-движке; методы `generateImage` / `speak` / `transcribe` / `embed` / `rerank` / `decide` у `$ai` с `protocol: 'local'` направляются через `WORK.localEngine`.
|
|
11
|
+
- **Диагностика Python-зависимостей и модально-адаптивная «Быстрая проверка» (`form/trainer`):** методы `trainer_test_model` (тест одной модели по её модальности: LLM с TTFT/tok/s, TTS с WAV-плеером, STT с проверкой WAV-файла, Image с превью, Embed, Rerank), `trainer_check_all_models` (кнопка «Проверить все модели» в карточке `/MODELS/Local` со сводной таблицей) и `trainer_install_python_deps` (кнопка «Доустановить зависимости» при нехватке пакетов); поиск Python берёт `.venv/Scripts/python.exe` проекта при наличии.
|
|
12
|
+
- [13:35, 17.11] Исправление выбора модели в `work-prompt-bar` и раскрытия выпадающих списков вверх над якорем (`oda/core/shared.js`, `oda/oda.js`, `oda/components/containers/popover/popover.js`, `$server/$folder/lib/prompt-bar/prompt-bar.js`, `tests/ui/{oda-core,voice-ui}.html`, `odant-work@1.0.37`):
|
|
13
|
+
- **Выбор модели кликом по узлу дерева (`oda/core/shared.js`, `oda/oda.js`):** в `setAttribute` исключена сериализация функций (`typeof value !== 'function'`) в наблюдаемые HTML-атрибуты (иначе `$public`-функция `execute` у `item-tree` перезаписывалась строкой через `attributeChangedCallback`), а в `$pdp.get` для `owner[R]` функции из `Reactor.get` привязываются к `owner`.
|
|
14
|
+
- **Позиционирование списка вверх над контролом (`popover.js`, `prompt-bar.js`):** в `selectModel` якорный элемент `#model-pill` сохраняется до `await WORK.get_item('/MODELS')`, в `oda-popover` добавлена поддержка `placement: 'top'` и сброс `bottom: auto; right: auto` при заданном `position`, а выбор модели/режима/получателей/действий `+` из нижней панели ввода открывается вверх над кнопкой.
|
|
4
15
|
- [12:46, 17.11] Передача `post` в поднятые `$method` и POST-тело в тесте модели `form/trainer` (`sources/server/folder.js`, `MODELS/$ai/$folder/$class/$ai/{class.js,handlers/pages/form/trainer/$handler/trainer.js}`, `tests/{exec-item-method,ai-stream}.test.js`, `odant-work@1.0.36`):
|
|
5
16
|
- **Устранена ошибка `400 missing_messages` (`'messages' must be a non-empty array`) при «Быстрой проверке ответа»:** в `trainer.js` (`runTestPrompt`) тело `{ messages }` теперь передаётся 3-м аргументом (`this.$item.fetch('chat', {}, { messages })`) как POST-тело, а в `folder.js` (`_liftMethods`) второй аргумент `post` пробрасывается в `handler.execute(params, post)` вместо отбрасывания.
|
|
6
17
|
- **Защита `streamChat` от пустого `post = {}`:** при пустом `post` берутся `params`, чтобы `options.messages` не терялись.
|
|
@@ -279,16 +279,49 @@ async function findFirstAvailableChatModel() {
|
|
|
279
279
|
}
|
|
280
280
|
return firstAny;
|
|
281
281
|
}
|
|
282
|
+
/** Найти активную локальную модель в /MODELS/Local по capabilities (или id). */
|
|
283
|
+
async function findActiveLocalModel({ caps = [], ids = [], method = '' } = {}) {
|
|
284
|
+
const local = await WORK.get_item('/MODELS/Local').catch(() => null);
|
|
285
|
+
const items = (await local?.items) || [];
|
|
286
|
+
const wantCaps = new Set(caps.map(s => String(s).toLowerCase()));
|
|
287
|
+
const wantIds = new Set(ids.map(s => String(s).toLowerCase()));
|
|
288
|
+
const scored = [];
|
|
289
|
+
for (const m of items) {
|
|
290
|
+
if (!m || Array.isArray(m))
|
|
291
|
+
continue;
|
|
292
|
+
await m.init?.catch?.(() => {});
|
|
293
|
+
if ((m.aiActive ?? m.DATA?.aiActive) === false || m.DATA?.enabled === false)
|
|
294
|
+
continue;
|
|
295
|
+
if (method && typeof m[method] !== 'function')
|
|
296
|
+
continue;
|
|
297
|
+
const mCaps = (Array.isArray(m.capabilities) ? m.capabilities : String(m.capabilities || '').split(/[\s,]+/))
|
|
298
|
+
.map(s => String(s).trim().toLowerCase()).filter(Boolean);
|
|
299
|
+
const idLow = String(m.id || '').toLowerCase();
|
|
300
|
+
const capMatch = wantCaps.size ? [...wantCaps].some(c => mCaps.includes(c)) : false;
|
|
301
|
+
const idMatch = wantIds.size ? wantIds.has(idLow) : false;
|
|
302
|
+
if (!capMatch && !idMatch)
|
|
303
|
+
continue;
|
|
304
|
+
scored.push({ m, prio: idMatch ? 0 : 1 });
|
|
305
|
+
}
|
|
306
|
+
scored.sort((a, b) => a.prio - b.prio);
|
|
307
|
+
return scored[0]?.m || null;
|
|
308
|
+
}
|
|
309
|
+
|
|
282
310
|
async function findImageModel(config) {
|
|
283
311
|
if (config.imageModel) {
|
|
284
312
|
const m = await WORK.get_item(config.imageModel).catch(() => null);
|
|
285
|
-
if (m)
|
|
313
|
+
if (m && (m.aiActive ?? m.DATA?.aiActive) !== false)
|
|
286
314
|
return m;
|
|
287
315
|
}
|
|
316
|
+
const localImg = await findActiveLocalModel({ caps: ['image'], ids: ['Z-Image-Turbo', 'Flux2-Klein-NPU'], method: 'generateImage' });
|
|
317
|
+
if (localImg)
|
|
318
|
+
return localImg;
|
|
288
319
|
const root = await WORK.get_item('/MODELS').catch(() => null);
|
|
289
320
|
for (const provider of (await root?.items) || []) {
|
|
290
321
|
for (const m of (await provider.items) || []) {
|
|
291
322
|
await m.init;
|
|
323
|
+
if ((m.aiActive ?? m.DATA?.aiActive) === false)
|
|
324
|
+
continue;
|
|
292
325
|
const caps = Array.isArray(m.capabilities) ? m.capabilities : String(m.capabilities || '').split(/[\s,]+/);
|
|
293
326
|
if (caps.includes('image') && typeof m.generateImage === 'function')
|
|
294
327
|
return m;
|
|
@@ -401,11 +434,22 @@ export async function createEnv({ place, contextPath, session, host, tz, locatio
|
|
|
401
434
|
},
|
|
402
435
|
/** 9.1: список запасных моделей из ai/config.js слоёв (ближний перекрывает). */
|
|
403
436
|
fallbackModels: () => [].concat(config.fallbackModels || []),
|
|
404
|
-
/** 9.2: дешёвая/быстрая модель для сжатия контекста (compactModel
|
|
437
|
+
/** 9.2: дешёвая/быстрая модель для сжатия контекста (compactModel или активная локальная Qwen3-4B / Qwen3.5-2B). */
|
|
405
438
|
compactLlm: async (fallbackPath) => {
|
|
406
|
-
|
|
439
|
+
if (config.compactModel)
|
|
440
|
+
return env.llmFor(config.compactModel);
|
|
441
|
+
const localCompact = await findActiveLocalModel({
|
|
442
|
+
ids: ['Qwen3-4B', 'Qwen3.5-2B-NPU', 'Qwen3-0.6B'],
|
|
443
|
+
caps: ['chat'],
|
|
444
|
+
method: 'streamChat',
|
|
445
|
+
});
|
|
446
|
+
if (localCompact?.path)
|
|
447
|
+
return env.llmFor(localCompact.path);
|
|
448
|
+
const p = fallbackPath || config.model || DEFAULT_MODEL;
|
|
407
449
|
return env.llmFor(p);
|
|
408
450
|
},
|
|
451
|
+
/** Быстрая локальная модель классификации/маршрутизации (Qwen3-0.6B / Decider-NPU). */
|
|
452
|
+
classifierModel: () => findActiveLocalModel({ ids: ['Qwen3-0.6B', 'Decider-NPU'], caps: ['classify', 'decide'] }),
|
|
409
453
|
imageModel: () => findImageModel(config),
|
|
410
454
|
async extTools() {
|
|
411
455
|
extTools ??= Promise.all([serviceTools(session), mcpTools({ onError: (s, e) => {
|
|
@@ -522,11 +522,17 @@ async function streamTurn({ llm, host, it, messages, schemas, effort, halogenKee
|
|
|
522
522
|
it.reasoning = (it.reasoning || '') + ch.content;
|
|
523
523
|
host.emit?.({ type: 'delta', item: it.id, field: 'reasoning', token: ch.content });
|
|
524
524
|
}
|
|
525
|
+
else if (ch?.type === 'tool_progress') {
|
|
526
|
+
host.emit?.({ type: 'delta', item: it.id, field: 'tool', name: ch.name, target: ch.target || '', chars: ch.chars || 0 });
|
|
527
|
+
}
|
|
525
528
|
else if (ch?.type === 'usage')
|
|
526
529
|
it.usage = {
|
|
527
530
|
prompt: ch.prompt_tokens, completion: ch.completion_tokens, total: ch.total_tokens,
|
|
528
531
|
...(ch.cached_tokens ? { cached: ch.cached_tokens } : {}),
|
|
529
532
|
...(ch.cache_creation_tokens ? { cacheWrite: ch.cache_creation_tokens } : {}),
|
|
533
|
+
...(ch.ttftMs ? { ttftMs: ch.ttftMs } : {}),
|
|
534
|
+
...(ch.tokPerSec ? { tokPerSec: ch.tokPerSec } : {}),
|
|
535
|
+
...(ch.promptTokPerSec ? { promptTokPerSec: ch.promptTokPerSec } : {}),
|
|
530
536
|
...(ch.timings ? { timings: ch.timings } : {}),
|
|
531
537
|
...(ch.halogen_from ? { halogenFrom: ch.halogen_from } : {}),
|
|
532
538
|
};
|
|
@@ -1027,8 +1027,8 @@ export async function compact(file, params = {}) {
|
|
|
1027
1027
|
const place = file.$class || file.$owner || null;
|
|
1028
1028
|
const host = { mode: body.mode, signal: undefined, save: () => save(s, params.session) };
|
|
1029
1029
|
const env = await createEnv({ place, session: params.session, host });
|
|
1030
|
-
// 9.2: compactModel — дешёвая модель для сжатия (ai/config.js), иначе — модель задачи
|
|
1031
|
-
const llm = await env.
|
|
1030
|
+
// 9.2: compactModel — дешёвая модель для сжатия (ai/config.js или активная локальная Qwen3-4B), иначе — модель задачи
|
|
1031
|
+
const llm = await env.compactLlm(body.model);
|
|
1032
1032
|
const done = await maybeCompact({ llm, items: body.items, host, system: await env.makeSystemParts(), hooks: env.hooks, task: file, force: true });
|
|
1033
1033
|
return { ok: done };
|
|
1034
1034
|
}
|