utilitas 1998.2.57 → 1998.2.58
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 +26 -11
- package/lib/manifest.mjs +1 -1
- package/package.json +1 -1
package/lib/alan.mjs
CHANGED
|
@@ -54,7 +54,7 @@ const [
|
|
|
54
54
|
CLAUDE_35_HAIKU, CLOUD_37_SONNET, AUDIO, WAV, CHATGPT_MINI, ATTACHMENTS,
|
|
55
55
|
CHAT, OPENAI_VOICE, MEDIUM, LOW, HIGH, GPT_REASONING_EFFORT, THINK,
|
|
56
56
|
THINK_STR, THINK_END, AZURE, TOOLS_STR, TOOLS_END, TOOLS, TEXT, THINKING,
|
|
57
|
-
OK, FUNC, GPT_45,
|
|
57
|
+
OK, FUNC, GPT_45, REDACTED_THINKING,
|
|
58
58
|
] = [
|
|
59
59
|
'OPENAI', 'GEMINI', 'CHATGPT', 'OPENAI_EMBEDDING', 'GEMINI_EMEDDING',
|
|
60
60
|
'OPENAI_TRAINING', 'OLLAMA', 'CLAUDE', 'gpt-4o-mini', 'gpt-4o', 'o1',
|
|
@@ -67,7 +67,7 @@ const [
|
|
|
67
67
|
'[ATTACHMENTS]', 'CHAT', 'OPENAI_VOICE', 'medium', 'low', 'high',
|
|
68
68
|
'medium', 'think', '<think>', '</think>', 'AZURE', '<tools>',
|
|
69
69
|
'</tools>', 'tools', 'text', 'thinking', 'OK', 'function',
|
|
70
|
-
'gpt-4.5-preview',
|
|
70
|
+
'gpt-4.5-preview', 'redacted_thinking',
|
|
71
71
|
];
|
|
72
72
|
|
|
73
73
|
const [
|
|
@@ -1054,23 +1054,36 @@ const promptClaude = async (content, options = {}) => {
|
|
|
1054
1054
|
options.model = options.model || DEFAULT_MODELS[CLAUDE];
|
|
1055
1055
|
let [
|
|
1056
1056
|
_MODEL, event, text, thinking, signature, result, thinkEnd, tool_use,
|
|
1057
|
-
responded
|
|
1057
|
+
responded, redacted_thinking,
|
|
1058
1058
|
] = [
|
|
1059
1059
|
MODELS[options.model], null, '', '', '', options.result ?? '', '',
|
|
1060
|
-
[], false
|
|
1060
|
+
[], false, [],
|
|
1061
1061
|
];
|
|
1062
|
+
// https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking
|
|
1063
|
+
options?.test_redacted_thinking && !options?.result && (
|
|
1064
|
+
content += '\n\nANTHROPIC_MAGIC_STRING_TRIGGER_REDACTED_THINKING_'
|
|
1065
|
+
+ '46C9A13E193C177646C7398A98432ECCCE4C1253D5E2D82641AC0E52CC2876CB'
|
|
1066
|
+
);
|
|
1062
1067
|
const { client } = await getClaudeClient(options);
|
|
1063
1068
|
const { systemPrompt: system, history }
|
|
1064
1069
|
= await buildPrompts(_MODEL, content, { ...options, flavor: CLAUDE });
|
|
1065
1070
|
const resp = await client.beta.messages.create({
|
|
1066
|
-
model: options.model,
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1071
|
+
model: options.model,
|
|
1072
|
+
max_tokens: options?.extendedThinking ? 128000 : _MODEL.maxOutputTokens,
|
|
1073
|
+
...history, system, stream: true,
|
|
1074
|
+
...options.reasoning ?? _MODEL?.reasoning ? {
|
|
1075
|
+
thinking: options.thinking || {
|
|
1076
|
+
type: 'enabled',
|
|
1077
|
+
budget_tokens: options?.extendedThinking ? 16000 : 1024,
|
|
1078
|
+
},
|
|
1079
|
+
} : {}, ..._MODEL?.tools ? {
|
|
1070
1080
|
tools: options.tools ?? (await toolsClaude()).map(x => x.def),
|
|
1071
|
-
tool_choice: { type: 'auto' },
|
|
1072
|
-
|
|
1073
|
-
|
|
1081
|
+
tool_choice: { type: 'auto' }, betas: [
|
|
1082
|
+
// https://docs.anthropic.com/en/docs/build-with-claude/tool-use/token-efficient-tool-use
|
|
1083
|
+
'token-efficient-tools-2025-02-19',
|
|
1084
|
+
// https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking
|
|
1085
|
+
...options?.extendedThinking ? ['output-128k-2025-02-19'] : [],
|
|
1086
|
+
],
|
|
1074
1087
|
} : {},
|
|
1075
1088
|
});
|
|
1076
1089
|
for await (const chunk of resp) {
|
|
@@ -1083,6 +1096,7 @@ const promptClaude = async (content, options = {}) => {
|
|
|
1083
1096
|
&& (deltaThink = `${THINK_STR}\n${deltaThink}`);
|
|
1084
1097
|
thinking && deltaText && !thinkEnd
|
|
1085
1098
|
&& (thinkEnd = deltaThink = `${deltaThink}\n${THINK_END}\n\n`);
|
|
1099
|
+
event?.type === REDACTED_THINKING && redacted_thinking.push(event);
|
|
1086
1100
|
if (event?.type === 'tool_use') {
|
|
1087
1101
|
tool_use.push({ ...event, input: '' });
|
|
1088
1102
|
} else if (event.partial_json) {
|
|
@@ -1099,6 +1113,7 @@ const promptClaude = async (content, options = {}) => {
|
|
|
1099
1113
|
event = {
|
|
1100
1114
|
role: assistant, content: [
|
|
1101
1115
|
...thinking ? [{ type: THINKING, thinking, signature }] : [],
|
|
1116
|
+
...redacted_thinking,
|
|
1102
1117
|
...text ? [{ type: TEXT, text }] : [], ...tool_use,
|
|
1103
1118
|
]
|
|
1104
1119
|
};
|
package/lib/manifest.mjs
CHANGED