utilitas 1998.2.6 → 1998.2.8
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/dist/utilitas.lite.mjs +1 -1
- package/dist/utilitas.lite.mjs.map +1 -1
- package/lib/alan.mjs +9 -5
- package/lib/bot.mjs +18 -16
- package/lib/manifest.mjs +1 -1
- package/package.json +1 -1
package/lib/alan.mjs
CHANGED
|
@@ -543,11 +543,15 @@ const packResp = async (resp, options) => {
|
|
|
543
543
|
// DeepSeek R1 {
|
|
544
544
|
let lines = (richText || txt).split('\n');
|
|
545
545
|
const indexOfEnd = lines.indexOf(THINK_END);
|
|
546
|
-
if (lines[0] === THINK_STR
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
546
|
+
if (lines[0] === THINK_STR) {
|
|
547
|
+
if (indexOfEnd === -1) {
|
|
548
|
+
lines.shift();
|
|
549
|
+
} else {
|
|
550
|
+
lines[0] = MD_CODE + THINK;
|
|
551
|
+
lines[indexOfEnd] = MD_CODE;
|
|
552
|
+
lines.slice(1, indexOfEnd).join('').trim()
|
|
553
|
+
|| (lines = lines.slice(indexOfEnd + 1));
|
|
554
|
+
}
|
|
551
555
|
richText = lines.join('\n').trim();
|
|
552
556
|
}
|
|
553
557
|
// }
|
package/lib/bot.mjs
CHANGED
|
@@ -646,20 +646,21 @@ const subconscious = [{
|
|
|
646
646
|
try {
|
|
647
647
|
const url = await getFileUrl(ctx.m.voice.file_id);
|
|
648
648
|
const file = await getFile(ctx.m.voice.file_id, BUFFER_ENCODE);
|
|
649
|
+
const analyze = async () => {
|
|
650
|
+
const resp = await ignoreErrFunc(
|
|
651
|
+
async () => await ctx._.speech?.stt(file), logOptions
|
|
652
|
+
) || ' ';
|
|
653
|
+
log(`STT: '${resp}'`);
|
|
654
|
+
ctx.collect(resp);
|
|
655
|
+
};
|
|
649
656
|
if (bot._.supportedMimeTypes.has(wav)) {
|
|
650
657
|
ctx.collect({
|
|
651
|
-
mime_type: wav, url,
|
|
658
|
+
mime_type: wav, url, analyze,
|
|
652
659
|
data: await convertAudioTo16kNanoPcmWave(file, {
|
|
653
660
|
input: BUFFER, expected: BASE64,
|
|
654
661
|
}),
|
|
655
662
|
}, 'PROMPT');
|
|
656
|
-
} else {
|
|
657
|
-
const resp = await ignoreErrFunc(
|
|
658
|
-
async () => await ctx._.speech?.stt(file), logOptions
|
|
659
|
-
) || ' ';
|
|
660
|
-
log(`STT: '${resp}'`);
|
|
661
|
-
ctx.collect(resp);
|
|
662
|
-
}
|
|
663
|
+
} else { await analyze(); }
|
|
663
664
|
} catch (err) { return await ctx.er(err); }
|
|
664
665
|
}
|
|
665
666
|
await next();
|
|
@@ -699,7 +700,7 @@ const subconscious = [{
|
|
|
699
700
|
if (member) {
|
|
700
701
|
if (member?.id === ctx.botInfo.id) { return ctx.end(); }
|
|
701
702
|
ctx.collect(lines([
|
|
702
|
-
`Say ${ctx.m.new_chat_member ? 'hello' : '
|
|
703
|
+
`Say ${ctx.m.new_chat_member ? 'hello' : 'goodbye'} to:`,
|
|
703
704
|
uList([
|
|
704
705
|
// `id: ${member.id}`,
|
|
705
706
|
// `is_bot: ${member.is_bot}`,
|
|
@@ -807,12 +808,7 @@ const subconscious = [{
|
|
|
807
808
|
try {
|
|
808
809
|
const url = await getFileUrl(f.fileId);
|
|
809
810
|
const file = (await get(url, BUFFER_ENCODE)).content;
|
|
810
|
-
|
|
811
|
-
ctx.collect({
|
|
812
|
-
mime_type: f.mime_type, url,
|
|
813
|
-
data: base64Encode(file, true),
|
|
814
|
-
}, 'PROMPT');
|
|
815
|
-
} else if (f.ocrFunc) {
|
|
811
|
+
const analyze = async () => {
|
|
816
812
|
const content = trim(ensureArray(
|
|
817
813
|
await ignoreErrFunc(async () => await f.ocrFunc(
|
|
818
814
|
file, BUFFER_ENCODE
|
|
@@ -826,7 +822,13 @@ const subconscious = [{
|
|
|
826
822
|
content
|
|
827
823
|
]), 'VISION');
|
|
828
824
|
}
|
|
829
|
-
}
|
|
825
|
+
};
|
|
826
|
+
if (f.asPrompt) {
|
|
827
|
+
ctx.collect({
|
|
828
|
+
mime_type: f.mime_type, url, analyze,
|
|
829
|
+
data: base64Encode(file, true),
|
|
830
|
+
}, 'PROMPT');
|
|
831
|
+
} else if (f.ocrFunc) { await analyze(); }
|
|
830
832
|
} catch (err) { return await ctx.er(err); }
|
|
831
833
|
}
|
|
832
834
|
}
|
package/lib/manifest.mjs
CHANGED