utilitas 1998.2.45 → 1998.2.46
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 +10 -8
- package/lib/manifest.mjs +1 -1
- package/package.json +1 -1
package/lib/alan.mjs
CHANGED
|
@@ -645,8 +645,9 @@ const buildClaudeMessage = (text, options) => {
|
|
|
645
645
|
});
|
|
646
646
|
return String.isString(text) ? {
|
|
647
647
|
role: options?.role || user, content: [...attachments, {
|
|
648
|
-
type: TEXT, text,
|
|
649
|
-
|
|
648
|
+
type: TEXT, text, ...options.cache_control ? {
|
|
649
|
+
cache_control: { type: 'ephemeral' },
|
|
650
|
+
} : {},
|
|
650
651
|
}],
|
|
651
652
|
} : text;
|
|
652
653
|
};
|
|
@@ -771,8 +772,8 @@ const buildPrompts = async (model, input, options = {}) => {
|
|
|
771
772
|
options.reasoning && !model?.reasoning
|
|
772
773
|
), `This model does not support reasoning: ${options.model}`);
|
|
773
774
|
let [systemPrompt, history, content, prompt, _system, _user, _assistant] = [
|
|
774
|
-
null, null, input || ATTACHMENTS, null,
|
|
775
|
-
{ role: system }, { role: user }, { role: assistant }
|
|
775
|
+
null, null, input || ATTACHMENTS, null, // length hack: ATTACHMENTS
|
|
776
|
+
{ role: system }, { role: user }, { role: assistant },
|
|
776
777
|
];
|
|
777
778
|
options.systemPrompt = options.systemPrompt || INSTRUCTIONS;
|
|
778
779
|
options.attachments = (
|
|
@@ -787,7 +788,7 @@ const buildPrompts = async (model, input, options = {}) => {
|
|
|
787
788
|
break;
|
|
788
789
|
case CLAUDE:
|
|
789
790
|
systemPrompt = options.systemPrompt;
|
|
790
|
-
prompt = buildClaudeMessage(content, options)
|
|
791
|
+
prompt = buildClaudeMessage(content, { ...options, cache_control: true });
|
|
791
792
|
break;
|
|
792
793
|
case OLLAMA:
|
|
793
794
|
systemPrompt = buildOllamaMessage(options.systemPrompt, _system);
|
|
@@ -801,7 +802,7 @@ const buildPrompts = async (model, input, options = {}) => {
|
|
|
801
802
|
}
|
|
802
803
|
const msgBuilder = () => {
|
|
803
804
|
history = [];
|
|
804
|
-
(options.messages?.length ? options.messages : []).map(x => {
|
|
805
|
+
(options.messages?.length ? options.messages : []).map((x, i) => {
|
|
805
806
|
switch (options.flavor) {
|
|
806
807
|
case CHATGPT:
|
|
807
808
|
history.push(buildGptMessage(x.request, _user));
|
|
@@ -812,8 +813,8 @@ const buildPrompts = async (model, input, options = {}) => {
|
|
|
812
813
|
history.push(buildClaudeMessage(x.response, _assistant));
|
|
813
814
|
break;
|
|
814
815
|
case OLLAMA:
|
|
815
|
-
history.push(
|
|
816
|
-
history.push(
|
|
816
|
+
history.push(buildOllamaMessage(x.request, _user));
|
|
817
|
+
history.push(buildOllamaMessage(x.response, _assistant));
|
|
817
818
|
break;
|
|
818
819
|
case GEMINI:
|
|
819
820
|
if (options.attachments?.length) { return; }
|
|
@@ -849,6 +850,7 @@ const buildPrompts = async (model, input, options = {}) => {
|
|
|
849
850
|
content = trimTailing(trimTailing(content).slice(0, -1)) + '...';
|
|
850
851
|
}
|
|
851
852
|
}, model.maxInputTokens - options.attachments?.length * ATTACHMENT_TOKEN_COST);
|
|
853
|
+
print(JSON.stringify(history));
|
|
852
854
|
return { systemPrompt, history, prompt };
|
|
853
855
|
};
|
|
854
856
|
|
package/lib/manifest.mjs
CHANGED