odant-work 1.0.58 → 1.0.59
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 +15 -14
- package/$server/$folder/$file/$task/class.js +36 -5
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/voice-ui.js +295 -94
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/voice.js +121 -2
- package/MODELS/$ai/$folder/$class/$ai/class.js +1 -1
- package/MODELS/$ai/$folder/$class/$ai/handlers/pages/form/trainer/$handler/trainer.js +45 -0
- package/package.json +1 -1
- package/scripts/check-ignored-code.mjs +1 -1
- package/sources/data/progress.md +4 -0
- package/sources/modules/agent/voice.js +329 -9
- package/sources/modules/trainer/index.js +50 -0
- package/sources/server/access/gateway.js +1 -1
- package/sources/server/class.js +34 -3
|
@@ -953,6 +953,8 @@ export const TRAINER_METHODS = Object.freeze({
|
|
|
953
953
|
maxOutput: Number(d.maxOutput || d.$public?.maxOutput) || 8192,
|
|
954
954
|
capabilities: effCaps,
|
|
955
955
|
efforts: Array.isArray(d.efforts) ? d.efforts : [],
|
|
956
|
+
voice: String(d.voice || ''),
|
|
957
|
+
instructions: String(d.instructions || ''),
|
|
956
958
|
weightsDir: resolvedWeightsRel,
|
|
957
959
|
primaryFile: resolvedPrimaryFile,
|
|
958
960
|
enabled: d.enabled !== false,
|
|
@@ -1752,6 +1754,54 @@ export const TRAINER_METHODS = Object.freeze({
|
|
|
1752
1754
|
return localEngine.installDeps(list);
|
|
1753
1755
|
},
|
|
1754
1756
|
},
|
|
1757
|
+
/** Сохранить голос/интонацию по умолчанию в карточке локальной TTS-модели ($ai/class.js). */
|
|
1758
|
+
trainer_set_model_voice: {
|
|
1759
|
+
level: 'admin',
|
|
1760
|
+
fn: async function (p = {}) {
|
|
1761
|
+
const args = mergeTrainerArgs(p);
|
|
1762
|
+
const modelId = String(args.modelId || this?.id || '').trim();
|
|
1763
|
+
if (!modelId)
|
|
1764
|
+
throw new Error('Не указан идентификатор модели');
|
|
1765
|
+
const clsPath = path.join(process.cwd(), 'MODELS', 'Local', modelId, '$ai', 'class.js');
|
|
1766
|
+
if (!fs.existsSync(clsPath))
|
|
1767
|
+
throw new Error(`Файл описания модели не найден: MODELS/Local/${modelId}/$ai/class.js`);
|
|
1768
|
+
const rawCls = fs.readFileSync(clsPath, 'utf-8');
|
|
1769
|
+
const mJson = rawCls.match(/export\s+default\s+(\{[\s\S]*\})\s*;?\s*$/);
|
|
1770
|
+
if (!mJson)
|
|
1771
|
+
throw new Error('Не удалось разобрать формат class.js модели');
|
|
1772
|
+
const parsed = JSON.parse(mJson[1]);
|
|
1773
|
+
const nextVoice = args.voice !== undefined ? String(args.voice || '').trim() : undefined;
|
|
1774
|
+
const nextInst = args.instructions !== undefined ? String(args.instructions || '').trim() : undefined;
|
|
1775
|
+
if (nextVoice !== undefined) {
|
|
1776
|
+
if (nextVoice) parsed.voice = nextVoice;
|
|
1777
|
+
else delete parsed.voice;
|
|
1778
|
+
}
|
|
1779
|
+
if (nextInst !== undefined) {
|
|
1780
|
+
if (nextInst) parsed.instructions = nextInst;
|
|
1781
|
+
else delete parsed.instructions;
|
|
1782
|
+
}
|
|
1783
|
+
fs.writeFileSync(
|
|
1784
|
+
clsPath,
|
|
1785
|
+
`/**\n * Локальная модель ИИ: ${parsed.label || modelId} (${parsed.modality || 'audio'})\n * Репозиторий Hugging Face: ${parsed.hfRepo || 'локальный'}\n */\nexport default ${JSON.stringify(parsed, null, 4)};\n`,
|
|
1786
|
+
'utf-8'
|
|
1787
|
+
);
|
|
1788
|
+
if (this?.DATA) {
|
|
1789
|
+
if (nextVoice !== undefined) this.DATA.voice = parsed.voice || '';
|
|
1790
|
+
if (nextInst !== undefined) this.DATA.instructions = parsed.instructions || '';
|
|
1791
|
+
}
|
|
1792
|
+
this?.reset?.();
|
|
1793
|
+
try {
|
|
1794
|
+
const localNode = await globalThis.WORK?.get_item?.('/MODELS/Local');
|
|
1795
|
+
localNode?.reset?.();
|
|
1796
|
+
}
|
|
1797
|
+
catch { /* ignore */ }
|
|
1798
|
+
return {
|
|
1799
|
+
ok: true,
|
|
1800
|
+
voice: parsed.voice || '',
|
|
1801
|
+
instructions: parsed.instructions || '',
|
|
1802
|
+
};
|
|
1803
|
+
},
|
|
1804
|
+
},
|
|
1755
1805
|
});
|
|
1756
1806
|
|
|
1757
1807
|
export function attachTrainerMethods($class) {
|
|
@@ -41,7 +41,7 @@ export const MEMBERS = Object.freeze({
|
|
|
41
41
|
roles: L.READ, members: L.READ, is_data_type: L.READ, reset: L.READ,
|
|
42
42
|
work_zone: L.READ, places: L.READ,
|
|
43
43
|
data_access: L.READ, link_tree: L.READ, search_tree: L.USER,
|
|
44
|
-
voice_config: L.READ, dot_look: L.READ, voice_speak: L.CALL, voice_transcribe: L.CALL, voice_interim: L.CALL,
|
|
44
|
+
voice_config: L.READ, dot_look: L.READ, voice_speak: L.CALL, voice_transcribe: L.CALL, voice_interim: L.CALL, voice_set_prefs: L.USER,
|
|
45
45
|
// геттеры (свойства и списки)
|
|
46
46
|
size: L.READ, METADATA: L.READ, type: L.READ, type_chain: L.READ, label: L.READ, icon: L.READ,
|
|
47
47
|
id: L.READ, name: L.READ, path: L.READ, short: L.READ, online: L.READ, lastModified: L.READ,
|
package/sources/server/class.js
CHANGED
|
@@ -798,7 +798,25 @@ export class $class extends $folder {
|
|
|
798
798
|
/** Голосовой режим на уровне класса/подразделения/кабинета (до создания файла .task). */
|
|
799
799
|
async voice_config(params = {}) {
|
|
800
800
|
await this.assertAccess(params, $class.ACCESS_LEVEL.READ);
|
|
801
|
-
return (await WORK_AGENT_CORE()).voice.voiceConfig(this);
|
|
801
|
+
return (await WORK_AGENT_CORE()).voice.voiceConfig(this, { uid: params.session?.principal?.id || params.session?.uid });
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
async voice_set_prefs(params = {}) {
|
|
805
|
+
await this.assertAccess(params, $class.ACCESS_LEVEL.READ);
|
|
806
|
+
let payload = {};
|
|
807
|
+
if (typeof params.post === 'string') {
|
|
808
|
+
try { payload = JSON.parse(params.post) || {}; } catch { payload = {}; }
|
|
809
|
+
}
|
|
810
|
+
else if (params.post && typeof params.post === 'object') {
|
|
811
|
+
payload = params.post;
|
|
812
|
+
}
|
|
813
|
+
const uid = params.session?.principal?.id || params.session?.uid;
|
|
814
|
+
return (await WORK_AGENT_CORE()).voice.setUserVoicePrefs({
|
|
815
|
+
uid,
|
|
816
|
+
ttsModel: params.ttsModel ?? payload.ttsModel,
|
|
817
|
+
ttsVoice: params.ttsVoice ?? payload.ttsVoice,
|
|
818
|
+
ttsInstructions: params.ttsInstructions ?? payload.ttsInstructions,
|
|
819
|
+
});
|
|
802
820
|
}
|
|
803
821
|
|
|
804
822
|
async dot_look(params = {}) {
|
|
@@ -808,8 +826,21 @@ export class $class extends $folder {
|
|
|
808
826
|
|
|
809
827
|
async voice_speak(params = {}) {
|
|
810
828
|
await this.assertAccess(params, $class.ACCESS_LEVEL.READ);
|
|
811
|
-
|
|
812
|
-
|
|
829
|
+
let payload = {};
|
|
830
|
+
if (typeof params.post === 'string') {
|
|
831
|
+
const raw = params.post.trim();
|
|
832
|
+
if (raw.startsWith('{')) {
|
|
833
|
+
try { payload = JSON.parse(raw) || {}; } catch { payload = { text: params.post }; }
|
|
834
|
+
}
|
|
835
|
+
else {
|
|
836
|
+
payload = { text: params.post };
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
else if (params.post && typeof params.post === 'object') {
|
|
840
|
+
payload = params.post;
|
|
841
|
+
}
|
|
842
|
+
const text = params.text ?? payload.text;
|
|
843
|
+
return (await WORK_AGENT_CORE()).voice.speak(this, { text, language: params.language ?? payload.language, instructions: params.instructions ?? payload.instructions, voice: params.voice ?? payload.voice, ttsModel: params.ttsModel ?? payload.ttsModel, uid: params.session?.principal?.id || params.session?.uid });
|
|
813
844
|
}
|
|
814
845
|
|
|
815
846
|
async voice_transcribe(params = {}) {
|