utilitas 1999.1.85 → 1999.1.87
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 +37 -17
- package/lib/manifest.mjs +1 -1
- package/package.json +1 -1
package/lib/alan.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
MIME_JPEG, MIME_MOV, MIME_MPEG, MIME_MP4, MIME_MPG, MIME_AVI, MIME_WMV,
|
|
11
11
|
MIME_MPEGPS, MIME_FLV, MIME_GIF, MIME_WEBP, MIME_PDF, MIME_AAC, MIME_FLAC,
|
|
12
12
|
MIME_MP3, MIME_MPEGA, MIME_M4A, MIME_MPGA, MIME_OPUS, MIME_PCM, MIME_WAV,
|
|
13
|
-
MIME_WEBM, MIME_TGPP, MIME_PCM16, STREAM, convert, formatDataURL
|
|
13
|
+
MIME_WEBM, MIME_TGPP, MIME_PCM16, MIME_OGG, STREAM, convert, formatDataURL
|
|
14
14
|
} from './storage.mjs';
|
|
15
15
|
|
|
16
16
|
import {
|
|
@@ -123,7 +123,10 @@ const GEMINI_RULES = {
|
|
|
123
123
|
MIME_WMV, MIME_MPEGPS, MIME_FLV, MIME_PDF, MIME_AAC, MIME_FLAC,
|
|
124
124
|
MIME_MP3, MIME_MPEGA, MIME_M4A, MIME_MPGA, MIME_OPUS, MIME_PCM,
|
|
125
125
|
MIME_WAV, MIME_WEBM, MIME_TGPP,
|
|
126
|
-
],
|
|
126
|
+
], supportedAudioTypes: [MIME_WAV, MIME_OGG, MIME_OPUS],
|
|
127
|
+
audio: 'gemini-2.5-flash-exp-native-audio-thinking-dialog',
|
|
128
|
+
defaultProvider: GEMINI,
|
|
129
|
+
// gemini-2.5-flash-preview-native-audio-dialog
|
|
127
130
|
};
|
|
128
131
|
|
|
129
132
|
const DEEPSEEK_R1_RULES = {
|
|
@@ -203,7 +206,7 @@ for (const n in MODELS) {
|
|
|
203
206
|
const DEFAULT_MODELS = {
|
|
204
207
|
[OPENAI]: GPT_5,
|
|
205
208
|
[SILICONFLOW]: SF_DEEPSEEK_R1,
|
|
206
|
-
[GEMINI]:
|
|
209
|
+
[GEMINI]: GEMINI_25_PRO,
|
|
207
210
|
[ANTHROPIC]: CLOUD_41_OPUS,
|
|
208
211
|
[VERTEX_ANTHROPIC]: CLOUD_41_OPUS,
|
|
209
212
|
[JINA]: JINA_DEEPSEARCH,
|
|
@@ -557,7 +560,7 @@ const countTokens = async (input, options) => {
|
|
|
557
560
|
);
|
|
558
561
|
};
|
|
559
562
|
|
|
560
|
-
const
|
|
563
|
+
const selectVisionModel = options => {
|
|
561
564
|
assert(
|
|
562
565
|
MODELS[options.model]?.vision,
|
|
563
566
|
`Vision modality is not supported by model: ${options.model}`
|
|
@@ -566,7 +569,7 @@ const selectGptVisionModel = options => {
|
|
|
566
569
|
? MODELS[options.model].vision : null;
|
|
567
570
|
};
|
|
568
571
|
|
|
569
|
-
const
|
|
572
|
+
const selectAudioModel = options => {
|
|
570
573
|
assert(
|
|
571
574
|
MODELS[options.model]?.audio,
|
|
572
575
|
`Audio modality is not supported by model: ${options.model}`
|
|
@@ -577,17 +580,17 @@ const selectGptAudioModel = options => {
|
|
|
577
580
|
|
|
578
581
|
const buildGptMessage = (content, options) => {
|
|
579
582
|
content = content || '';
|
|
580
|
-
let alterModel = options?.audioMode &&
|
|
583
|
+
let alterModel = options?.audioMode && selectAudioModel(options);
|
|
581
584
|
const attachments = (options?.attachments || []).map(x => {
|
|
582
585
|
assert(MODELS[options?.model], 'Model is required.');
|
|
583
586
|
if (MODELS[options.model]?.supportedMimeTypes?.includes?.(x.mime_type)) {
|
|
584
|
-
alterModel =
|
|
587
|
+
alterModel = selectVisionModel(options); // URL or Base64URL
|
|
585
588
|
return {
|
|
586
589
|
type: 'image_url',
|
|
587
590
|
image_url: { url: x.url, detail: 'high' },
|
|
588
591
|
};
|
|
589
592
|
} else if (MODELS[options.model]?.supportedDocTypes?.includes?.(x.mime_type)) {
|
|
590
|
-
alterModel =
|
|
593
|
+
alterModel = selectVisionModel(options);
|
|
591
594
|
return {
|
|
592
595
|
type: 'file',
|
|
593
596
|
file: {
|
|
@@ -597,7 +600,7 @@ const buildGptMessage = (content, options) => {
|
|
|
597
600
|
},
|
|
598
601
|
};
|
|
599
602
|
} else if (MODELS[options.model]?.supportedAudioTypes?.includes?.(x.mime_type)) {
|
|
600
|
-
alterModel =
|
|
603
|
+
alterModel = selectAudioModel(options);
|
|
601
604
|
return {
|
|
602
605
|
type: 'input_audio',
|
|
603
606
|
input_audio: { data: x.data, format: WAV },
|
|
@@ -627,9 +630,24 @@ const buildGeminiParts = (text, attachments) => {
|
|
|
627
630
|
|
|
628
631
|
const buildGeminiMessage = (content, options) => {
|
|
629
632
|
content = content || '';
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
+
// @todo: for future audio mode support
|
|
634
|
+
// let alterModel = options?.audioMode && selectAudioModel(options);
|
|
635
|
+
const attachments = (
|
|
636
|
+
options?.attachments?.length ? options.attachments : []
|
|
637
|
+
).map(x => {
|
|
638
|
+
// assert(MODELS[options?.model], 'Model is required.');
|
|
639
|
+
// if (MODELS[options.model]?.supportedAudioTypes?.includes?.(x.mime_type)
|
|
640
|
+
// && !options.imageMode) {
|
|
641
|
+
// alterModel = selectAudioModel(options);
|
|
642
|
+
// }
|
|
643
|
+
return {
|
|
644
|
+
inlineData: { mimeType: x.mime_type, data: x.data }
|
|
645
|
+
};
|
|
646
|
+
});
|
|
647
|
+
// if (alterModel) {
|
|
648
|
+
// options.model = alterModel;
|
|
649
|
+
// options.audioMode = true;
|
|
650
|
+
// }
|
|
633
651
|
return String.isString(content) ? (options?.history ? {
|
|
634
652
|
role: options?.role || user,
|
|
635
653
|
parts: buildGeminiParts(content, attachments),
|
|
@@ -1190,17 +1208,19 @@ const promptGemini = async (aiId, content, options = {}) => {
|
|
|
1190
1208
|
options.imageMode = true;
|
|
1191
1209
|
model = MODELS[options.model];
|
|
1192
1210
|
}
|
|
1211
|
+
options.flavor = GEMINI;
|
|
1193
1212
|
const { systemPrompt: systemInstruction, history, prompt }
|
|
1194
|
-
= await buildPrompts(model, content,
|
|
1213
|
+
= await buildPrompts(model, content, options);
|
|
1214
|
+
const responseModalities = options.modalities
|
|
1215
|
+
|| (options.imageMode ? [TEXT, IMAGE] : undefined)
|
|
1216
|
+
|| (options.audioMode ? [TEXT, AUDIO] : undefined);
|
|
1195
1217
|
const chat = client.chats.create({
|
|
1196
1218
|
model: options.model, history, config: {
|
|
1197
1219
|
responseMimeType: options.jsonMode ? MIME_JSON : MIME_TEXT,
|
|
1198
1220
|
...model.reasoning ? {
|
|
1199
1221
|
thinkingConfig: { includeThoughts: true },
|
|
1200
|
-
} : {}, systemInstruction,
|
|
1201
|
-
|
|
1202
|
-
options.imageMode ? [TEXT, IMAGE] : undefined
|
|
1203
|
-
), ...options?.config || {}, ...model?.tools && !options.jsonMode
|
|
1222
|
+
} : {}, systemInstruction, responseModalities,
|
|
1223
|
+
...options?.config || {}, ...model?.tools && !options.jsonMode
|
|
1204
1224
|
&& ![GEMINI_20_FLASH].includes(options.model)
|
|
1205
1225
|
? (options.tools ?? {
|
|
1206
1226
|
tools: [
|
package/lib/manifest.mjs
CHANGED