utilitas 2000.2.3 → 2000.2.5
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/README.md +3 -3
- package/dist/utilitas.lite.mjs +1 -1
- package/dist/utilitas.lite.mjs.map +1 -1
- package/lib/alan.mjs +22 -12
- package/lib/manifest.mjs +1 -1
- package/package.json +1 -1
package/lib/alan.mjs
CHANGED
|
@@ -51,10 +51,10 @@ const [
|
|
|
51
51
|
GPT_51_CODEX, GPT_5_IMAGE, GEMMA_3_27B, ANTHROPIC, v8k, ais,
|
|
52
52
|
MAX_TOOL_RECURSION, LOG, name, user, system, assistant, MODEL, JSON_OBJECT,
|
|
53
53
|
tokenSafeRatio, CONTENT_IS_REQUIRED, OPENAI_HI_RES_SIZE, k, kT, m, minute,
|
|
54
|
-
hour, gb, trimTailing,
|
|
55
|
-
SILICONFLOW, SF_DEEPSEEK_R1, MAX_TIRE, OPENROUTER_API,
|
|
56
|
-
TOOL, S_OPENAI, S_GOOGLE, S_ANTHROPIC, ONLINE,
|
|
57
|
-
GEMINI_25_FLASH,
|
|
54
|
+
hour, gb, trimTailing, trimBeginning, GEMINI_30_PRO_IMAGE, IMAGE, JINA,
|
|
55
|
+
JINA_DEEPSEARCH, SILICONFLOW, SF_DEEPSEEK_R1, MAX_TIRE, OPENROUTER_API,
|
|
56
|
+
OPENROUTER, AUTO, TOOL, S_OPENAI, S_GOOGLE, S_ANTHROPIC, ONLINE,
|
|
57
|
+
GEMINI_30_PRO, GEMINI_25_FLASH,
|
|
58
58
|
] = [
|
|
59
59
|
'OpenAI', 'Gemini', 'Ollama', 'nova', 'deepseek-r1', '```',
|
|
60
60
|
'claude-sonnet-4.5', 'audio', 'wav', '[ATTACHMENTS]', 'OPENAI_VOICE',
|
|
@@ -65,8 +65,9 @@ const [
|
|
|
65
65
|
'json_object', 1.1, 'Content is required.', 2048 * 2048, x => 1024 * x,
|
|
66
66
|
x => 1000 * x, x => 1024 * 1024 * x, x => 60 * x, x => 60 * 60 * x,
|
|
67
67
|
x => 1024 * 1024 * 1024 * x, x => x.replace(/[\.\s]*$/, ''),
|
|
68
|
-
'gemini-
|
|
69
|
-
'
|
|
68
|
+
x => x.replace(/^[\.\s]*/, ''), 'gemini-3-pro-image-preview', 'image',
|
|
69
|
+
'Jina', 'jina-deepsearch-v1', 'SiliconFlow',
|
|
70
|
+
'Pro/deepseek-ai/DeepSeek-R1', 768 * 768,
|
|
70
71
|
'https://openrouter.ai/api/v1', 'OpenRouter', 'openrouter/auto', 'tool',
|
|
71
72
|
'openai', 'google', 'anthropic', ':online', 'gemini-3-pro-preview',
|
|
72
73
|
'gemini-2.5-flash-preview-09-2025',
|
|
@@ -143,7 +144,7 @@ const MODELS = {
|
|
|
143
144
|
reasoning: true, tools: true,
|
|
144
145
|
},
|
|
145
146
|
// models with unique capabilities
|
|
146
|
-
[
|
|
147
|
+
[GEMINI_30_PRO_IMAGE]: {
|
|
147
148
|
...GEMINI_RULES, icon: '🍌', label: 'Nano Banana',
|
|
148
149
|
contextWindow: k(64), maxOutputTokens: k(32),
|
|
149
150
|
fast: true, image: true,
|
|
@@ -613,6 +614,9 @@ const packResp = async (resp, options) => {
|
|
|
613
614
|
input: BUFFER, expected: BUFFER, suffix: 'pcm.wav', ...options
|
|
614
615
|
}), mime: audioMimeType,
|
|
615
616
|
}));
|
|
617
|
+
// bug fix: Google Gemini returns duplicate first image: {
|
|
618
|
+
images && images.length > 1 && images.shift();
|
|
619
|
+
// }
|
|
616
620
|
images = await Promise.all(
|
|
617
621
|
images.map(async x => ({
|
|
618
622
|
data: await convert(x.buffer, {
|
|
@@ -722,6 +726,8 @@ const buildPrompts = async (model, input, options = {}) => {
|
|
|
722
726
|
if (options.messages?.length) {
|
|
723
727
|
options.messages?.shift();
|
|
724
728
|
msgBuilder();
|
|
729
|
+
} else if (options.Beginning) {
|
|
730
|
+
content = '...' + trimBeginning(trimBeginning(content).slice(1));
|
|
725
731
|
} else {
|
|
726
732
|
content = trimTailing(trimTailing(content).slice(0, -1)) + '...';
|
|
727
733
|
} // @todo: audioCostTokens (needs to calculate the audio length):
|
|
@@ -814,7 +820,7 @@ const promptOpenAI = async (aiId, content, options = {}) => {
|
|
|
814
820
|
} else if (!modalities && model.image) {
|
|
815
821
|
modalities = [TEXT, IMAGE];
|
|
816
822
|
}
|
|
817
|
-
const googleImageMode = source === S_GOOGLE && modalities?.
|
|
823
|
+
const googleImageMode = source === S_GOOGLE && modalities?.includes?.(IMAGE);
|
|
818
824
|
// pricy: https://openrouter.ai/docs/features/web-search
|
|
819
825
|
const ext = ''; // options.jsonMode ? '' : ONLINE;
|
|
820
826
|
const targetModel = `${isOpenrouter(provider, model) ? `${source}/` : ''}${options.model}${ext}`;
|
|
@@ -828,10 +834,14 @@ const promptOpenAI = async (aiId, content, options = {}) => {
|
|
|
828
834
|
modalities, audio: options.audio || (
|
|
829
835
|
modalities?.find?.(x => x === AUDIO)
|
|
830
836
|
&& { voice: DEFAULT_MODELS[OPENAI_VOICE], format: 'pcm16' }
|
|
831
|
-
), ...model?.tools
|
|
837
|
+
), ...model?.tools ? {
|
|
832
838
|
tools: options.tools ?? packedTools, tool_choice: 'auto',
|
|
833
|
-
} : {}, store: true, stream: true,
|
|
834
|
-
|
|
839
|
+
} : {}, store: true, stream: true, ...googleImageMode ? {
|
|
840
|
+
// bug: image_size not working
|
|
841
|
+
// https://openrouter.ai/docs/features/multimodal/image-generation
|
|
842
|
+
// https://openrouter.ai/google/gemini-3-pro-image-preview/api
|
|
843
|
+
image_config: { aspect_ratio: '16:9', image_size: '4K' },
|
|
844
|
+
} : {}, reasoning: { effort: options.reasoning_effort },
|
|
835
845
|
});
|
|
836
846
|
for await (event of resp) {
|
|
837
847
|
// print(JSON.stringify(event, null, 2));
|
|
@@ -1124,7 +1134,7 @@ export {
|
|
|
1124
1134
|
FEATURE_ICONS,
|
|
1125
1135
|
FUNCTION,
|
|
1126
1136
|
GEMINI_25_FLASH,
|
|
1127
|
-
|
|
1137
|
+
GEMINI_30_PRO_IMAGE,
|
|
1128
1138
|
GPT_51,
|
|
1129
1139
|
INSTRUCTIONS,
|
|
1130
1140
|
MODELS,
|
package/lib/manifest.mjs
CHANGED