utilitas 1998.2.48 → 1998.2.49
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 +1 -0
- package/dist/utilitas.lite.mjs +1 -1
- package/dist/utilitas.lite.mjs.map +1 -1
- package/lib/alan.mjs +17 -6
- package/lib/manifest.mjs +1 -1
- package/lib/shot.mjs +3 -3
- package/package.json +1 -1
package/lib/alan.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fileTypeFromBuffer } from 'file-type';
|
|
2
2
|
import { end, loop } from './event.mjs';
|
|
3
3
|
import { createWavHeader } from './media.mjs';
|
|
4
|
-
import { search } from './shot.mjs';
|
|
4
|
+
import { checkSearch, search } from './shot.mjs';
|
|
5
5
|
import { BASE64, BUFFER, DATAURL, MIME_BINARY, STREAM, convert } from './storage.mjs';
|
|
6
6
|
import { create as createUoid } from './uoid.mjs';
|
|
7
7
|
import { distill } from './web.mjs';
|
|
@@ -468,10 +468,21 @@ const tools = [
|
|
|
468
468
|
},
|
|
469
469
|
func: async args => await search(args?.keyword),
|
|
470
470
|
showReq: true,
|
|
471
|
+
depend: checkSearch,
|
|
471
472
|
},
|
|
472
473
|
];
|
|
473
474
|
|
|
474
|
-
const
|
|
475
|
+
const toolsOpenAI = async () => {
|
|
476
|
+
const _tools = [];
|
|
477
|
+
for (const t of tools) {
|
|
478
|
+
(t.depend ? await t.depend() : true) ? _tools.push(t) : log(
|
|
479
|
+
`Tool is not ready: ${t.def.function.name}`
|
|
480
|
+
);
|
|
481
|
+
}
|
|
482
|
+
return _tools;
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
const toolsClaude = async () => (await toolsOpenAI()).map(x => ({
|
|
475
486
|
...x, def: {
|
|
476
487
|
name: x.def.function.name,
|
|
477
488
|
description: x.def.function.description,
|
|
@@ -479,7 +490,7 @@ const toolsClaude = tools.map(x => ({
|
|
|
479
490
|
}
|
|
480
491
|
}));
|
|
481
492
|
|
|
482
|
-
const toolsGemini =
|
|
493
|
+
const toolsGemini = async () => (await toolsOpenAI()).map(x => ({
|
|
483
494
|
...x, def: {
|
|
484
495
|
name: x.def.function.name,
|
|
485
496
|
description: x.def.function.description,
|
|
@@ -971,7 +982,7 @@ const promptChatGPT = async (content, options = {}) => {
|
|
|
971
982
|
modalities?.find?.(x => x === AUDIO)
|
|
972
983
|
&& { voice: DEFAULT_MODELS[OPENAI_VOICE], format: 'pcm16' }
|
|
973
984
|
), ...history, ..._MODEL?.tools ? {
|
|
974
|
-
tools: options.tools ??
|
|
985
|
+
tools: options.tools ?? (await toolsOpenAI()).map(x => x.def),
|
|
975
986
|
} : {}, ...options.jsonMode ? {
|
|
976
987
|
response_format: { type: JSON_OBJECT }
|
|
977
988
|
} : {}, model: options.model, stream: true,
|
|
@@ -1056,7 +1067,7 @@ const promptClaude = async (content, options = {}) => {
|
|
|
1056
1067
|
system, stream: true, ...options.reasoning ?? _MODEL?.reasoning ? {
|
|
1057
1068
|
thinking: options.thinking || { type: 'enabled', budget_tokens: 1024 },
|
|
1058
1069
|
} : {}, ..._MODEL?.tools ? { // https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking
|
|
1059
|
-
tools: options.tools ?? toolsClaude.map(x => x.def),
|
|
1070
|
+
tools: options.tools ?? (await toolsClaude()).map(x => x.def),
|
|
1060
1071
|
tool_choice: { type: 'auto' },
|
|
1061
1072
|
betas: ['token-efficient-tools-2025-02-19'],
|
|
1062
1073
|
// @todo: https://docs.anthropic.com/en/docs/build-with-claude/tool-use/token-efficient-tool-use
|
|
@@ -1168,7 +1179,7 @@ const promptGemini = async (content, options = {}) => {
|
|
|
1168
1179
|
// https://ai.google.dev/gemini-api/docs/function-calling
|
|
1169
1180
|
// { codeExecution: {} },
|
|
1170
1181
|
// { googleSearch: {} },
|
|
1171
|
-
{ functionDeclarations: toolsGemini.map(x => x.def) },
|
|
1182
|
+
{ functionDeclarations: (await toolsGemini()).map(x => x.def) },
|
|
1172
1183
|
],
|
|
1173
1184
|
toolConfig: { functionCallingConfig: { mode: 'AUTO' } },
|
|
1174
1185
|
}
|
package/lib/manifest.mjs
CHANGED
package/lib/shot.mjs
CHANGED
|
@@ -19,6 +19,7 @@ const buf2utf = buf => buf.toString('utf8');
|
|
|
19
19
|
const [_JSON, _PARSED] = ['JSON', 'PARSED'];
|
|
20
20
|
const getJson = async (u, o) => await get(u, { encode: _JSON, ...o || {} });
|
|
21
21
|
const getParsedHtml = async (u, o) => await get(u, { encode: _PARSED, ...o || {} });
|
|
22
|
+
const checkSearch = () => googleApiKey && googleCx;
|
|
22
23
|
|
|
23
24
|
let googleApiKey, googleCx;
|
|
24
25
|
|
|
@@ -185,10 +186,9 @@ const search = async (query, options) => {
|
|
|
185
186
|
|
|
186
187
|
export default get;
|
|
187
188
|
export {
|
|
188
|
-
checkVersion,
|
|
189
|
+
checkSearch, checkVersion,
|
|
189
190
|
get,
|
|
190
|
-
getCurrentIp,
|
|
191
|
-
getCurrentPosition,
|
|
191
|
+
getCurrentIp, getCurrentPosition,
|
|
192
192
|
getJson,
|
|
193
193
|
getParsedHtml,
|
|
194
194
|
getVersionOnNpm, initSearch, search
|