utilitas 2000.3.19 → 2000.3.21
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 +2 -1
- package/config.sample.json +51 -1
- package/dist/utilitas.lite.mjs +1 -1
- package/dist/utilitas.lite.mjs.map +1 -1
- package/lib/alan.mjs +24 -21
- package/lib/cache.mjs +9 -1
- package/lib/manifest.mjs +1 -1
- package/package.json +1 -1
package/lib/alan.mjs
CHANGED
|
@@ -45,18 +45,18 @@ You may be provided with some tools(functions) to help you gather information an
|
|
|
45
45
|
const _NEED = ['js-tiktoken', 'OpenAI'];
|
|
46
46
|
|
|
47
47
|
const [
|
|
48
|
-
OPENAI, GEMINI, OLLAMA, NOVA,
|
|
48
|
+
OPENAI, GEMINI, OLLAMA, NOVA, DEEPSEEK_32, MD_CODE, CLOUD_OPUS_45, AUDIO,
|
|
49
49
|
WAV, ATTACHMENTS, OPENAI_VOICE, GPT_REASONING_EFFORT, THINK, THINK_STR,
|
|
50
50
|
THINK_END, TOOLS_STR, TOOLS_END, TOOLS, TEXT, OK, FUNC, GPT_51,
|
|
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
54
|
hour, gb, trimTailing, trimBeginning, GEMINI_30_PRO_IMAGE, IMAGE, JINA,
|
|
55
|
-
JINA_DEEPSEARCH, SILICONFLOW,
|
|
55
|
+
JINA_DEEPSEARCH, SILICONFLOW, SF_DEEPSEEK_32, MAX_TIRE, OPENROUTER_API,
|
|
56
56
|
OPENROUTER, AUTO, TOOL, S_OPENAI, S_GOOGLE, S_ANTHROPIC, ONLINE,
|
|
57
57
|
GEMINI_30_PRO, GEMINI_25_FLASH,
|
|
58
58
|
] = [
|
|
59
|
-
'OpenAI', 'Gemini', 'Ollama', 'nova', 'deepseek-
|
|
59
|
+
'OpenAI', 'Gemini', 'Ollama', 'nova', 'deepseek-3.2-speciale', '```',
|
|
60
60
|
'claude-opus-4.5', 'audio', 'wav', '[ATTACHMENTS]', 'OPENAI_VOICE',
|
|
61
61
|
'medium', 'think', '<think>', '</think>', '<tools>', '</tools>',
|
|
62
62
|
'tools', 'text', 'OK', 'function', 'gpt-5.1', 'gpt-5.1-codex',
|
|
@@ -67,7 +67,7 @@ const [
|
|
|
67
67
|
x => 1024 * 1024 * 1024 * x, x => x.replace(/[\.\s]*$/, ''),
|
|
68
68
|
x => x.replace(/^[\.\s]*/, ''), 'gemini-3-pro-image-preview', 'image',
|
|
69
69
|
'Jina', 'jina-deepsearch-v1', 'SiliconFlow',
|
|
70
|
-
'
|
|
70
|
+
'deepseek-ai/DeepSeek-V3.2-exp', 768 * 768,
|
|
71
71
|
'https://openrouter.ai/api/v1', 'OpenRouter', 'openrouter/auto', 'tool',
|
|
72
72
|
'openai', 'google', 'anthropic', ':online', 'gemini-3-pro-preview',
|
|
73
73
|
'gemini-2.5-flash-preview-09-2025',
|
|
@@ -120,9 +120,9 @@ const GEMINI_RULES = {
|
|
|
120
120
|
defaultProvider: OPENROUTER,
|
|
121
121
|
};
|
|
122
122
|
|
|
123
|
-
const
|
|
124
|
-
icon: '🐬', contextWindow: kT(
|
|
125
|
-
reasoning: true,
|
|
123
|
+
const DEEPSEEK_32_RULES = {
|
|
124
|
+
icon: '🐬', contextWindow: kT(163.8), maxOutputTokens: k(65.5),
|
|
125
|
+
json: true, tools: true, reasoning: true,
|
|
126
126
|
};
|
|
127
127
|
|
|
128
128
|
// https://platform.openai.com/docs/models
|
|
@@ -158,8 +158,8 @@ const MODELS = {
|
|
|
158
158
|
reasoning: true, json: true, vision: true,
|
|
159
159
|
deepsearch: true, defaultProvider: JINA,
|
|
160
160
|
},
|
|
161
|
-
[
|
|
162
|
-
[
|
|
161
|
+
[DEEPSEEK_32]: DEEPSEEK_32_RULES,
|
|
162
|
+
[SF_DEEPSEEK_32]: { ...DEEPSEEK_32_RULES, defaultProvider: SILICONFLOW },
|
|
163
163
|
[CLOUD_OPUS_45]: {
|
|
164
164
|
source: S_ANTHROPIC, icon: '✳️',
|
|
165
165
|
contextWindow: kT(200), maxOutputTokens: kT(64),
|
|
@@ -242,7 +242,7 @@ for (const n in MODELS) {
|
|
|
242
242
|
// Default models for each provider
|
|
243
243
|
const DEFAULT_MODELS = {
|
|
244
244
|
[OPENROUTER]: GEMINI_25_FLASH,
|
|
245
|
-
[SILICONFLOW]:
|
|
245
|
+
[SILICONFLOW]: SF_DEEPSEEK_32,
|
|
246
246
|
[JINA]: JINA_DEEPSEARCH,
|
|
247
247
|
[OLLAMA]: GEMMA_3_27B,
|
|
248
248
|
[OPENAI_VOICE]: NOVA,
|
|
@@ -314,7 +314,7 @@ const tools = [
|
|
|
314
314
|
}
|
|
315
315
|
},
|
|
316
316
|
func: async args => (await distill(args?.url))?.summary,
|
|
317
|
-
showReq: true,
|
|
317
|
+
showReq: true,
|
|
318
318
|
},
|
|
319
319
|
{
|
|
320
320
|
def: {
|
|
@@ -338,16 +338,20 @@ const tools = [
|
|
|
338
338
|
num: args?.num || 10, start: args?.start || 1,
|
|
339
339
|
image: args?.image || false
|
|
340
340
|
}),
|
|
341
|
-
showReq: true,
|
|
341
|
+
showReq: true, depend: checkSearch,
|
|
342
342
|
},
|
|
343
343
|
];
|
|
344
344
|
|
|
345
345
|
const packTools = async () => {
|
|
346
346
|
const _tools = [];
|
|
347
347
|
for (const t of tools) {
|
|
348
|
-
(t.depend ? await t.depend() : true)
|
|
349
|
-
|
|
350
|
-
)
|
|
348
|
+
if (t.depend ? await t.depend() : true) {
|
|
349
|
+
_tools.push(t);
|
|
350
|
+
} else if (t.def.function.name === 'searchWeb') {
|
|
351
|
+
log(`Tool (${t.def.function.name}) is not ready, fallback to openrouter:online.`);
|
|
352
|
+
} else {
|
|
353
|
+
log(`Tool (${t.def.function.name}) is not ready.`);
|
|
354
|
+
}
|
|
351
355
|
}
|
|
352
356
|
return _tools;
|
|
353
357
|
};
|
|
@@ -838,12 +842,11 @@ const promptOpenAI = async (aiId, content, options = {}) => {
|
|
|
838
842
|
modalities = [TEXT, IMAGE];
|
|
839
843
|
}
|
|
840
844
|
const googleImageMode = source === S_GOOGLE && modalities?.includes?.(IMAGE);
|
|
841
|
-
|
|
842
|
-
const ext =
|
|
845
|
+
const packedTools = _tools.map(x => x.def);
|
|
846
|
+
const ext = provider === OPENROUTER && !packedTools?.find(
|
|
847
|
+
x => x.function.name === 'searchWeb'
|
|
848
|
+
) && !options.jsonMode ? ONLINE : '';
|
|
843
849
|
const targetModel = `${isOpenrouter(provider, model) ? `${source}/` : ''}${options.model}${ext}`;
|
|
844
|
-
const packedTools = (targetModel.endsWith(ONLINE)
|
|
845
|
-
? _tools.filter(x => x?.replaced !== ONLINE)
|
|
846
|
-
: _tools).map(x => x.def);
|
|
847
850
|
if (source === S_GOOGLE) {
|
|
848
851
|
packedTools.push(...[
|
|
849
852
|
{ googleSearch: {} }, { codeExecution: {} }, { urlContext: {} },
|
|
@@ -1152,7 +1155,7 @@ export {
|
|
|
1152
1155
|
ATTACHMENTS,
|
|
1153
1156
|
CLOUD_OPUS_45,
|
|
1154
1157
|
CODE_INTERPRETER,
|
|
1155
|
-
|
|
1158
|
+
DEEPSEEK_32,
|
|
1156
1159
|
DEFAULT_MODELS,
|
|
1157
1160
|
FEATURE_ICONS,
|
|
1158
1161
|
FUNCTION,
|
package/lib/cache.mjs
CHANGED
|
@@ -23,7 +23,14 @@ const init = async (options) => {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
assert(redis, 'Redis has not been initialized.', 501);
|
|
26
|
-
return
|
|
26
|
+
return redis;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const end = async () => {
|
|
30
|
+
if (redis) {
|
|
31
|
+
await redis.quit();
|
|
32
|
+
redis = null;
|
|
33
|
+
}
|
|
27
34
|
};
|
|
28
35
|
|
|
29
36
|
const assertKey = key => {
|
|
@@ -47,6 +54,7 @@ export {
|
|
|
47
54
|
init,
|
|
48
55
|
set,
|
|
49
56
|
setEx,
|
|
57
|
+
end,
|
|
50
58
|
};
|
|
51
59
|
|
|
52
60
|
|
package/lib/manifest.mjs
CHANGED