utilitas 1998.2.19 → 1998.2.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 +1 -1
- package/dist/utilitas.lite.mjs +1 -1
- package/dist/utilitas.lite.mjs.map +1 -1
- package/lib/alan.mjs +18 -5
- package/lib/manifest.mjs +1 -1
- package/package.json +1 -1
package/lib/alan.mjs
CHANGED
|
@@ -318,6 +318,7 @@ const MODELS = {
|
|
|
318
318
|
tokenLimitsITPM: 40000,
|
|
319
319
|
tokenLimitsOTPM: 8000,
|
|
320
320
|
trainingData: 'Apr 2024', // ?
|
|
321
|
+
reasoning: true,
|
|
321
322
|
supportedMimeTypes: [
|
|
322
323
|
png, jpeg, gif, webp, pdf,
|
|
323
324
|
],
|
|
@@ -706,6 +707,7 @@ const promptChatGPT = async (content, options = {}) => {
|
|
|
706
707
|
await packGptResp(chunk, { ...options || {}, processing: true })
|
|
707
708
|
), LOG);
|
|
708
709
|
}
|
|
710
|
+
chunk.choices?.[0] || (chunk.choices = [{}]); // handle empty choices for Azure APIs
|
|
709
711
|
chunk.choices[0].message = {
|
|
710
712
|
content: resultText,
|
|
711
713
|
...resultAudio.length ? { audio: { data: resultAudio } } : {},
|
|
@@ -743,16 +745,27 @@ const promptOllama = async (content, options = {}) => {
|
|
|
743
745
|
const promptClaude = async (content, options = {}) => {
|
|
744
746
|
const { client } = await getClaudeClient(options);
|
|
745
747
|
options.model = options?.model || DEFAULT_MODELS[CLAUDE];
|
|
748
|
+
const reasoning = options?.reasoning ?? MODELS[options.model]?.reasoning;
|
|
746
749
|
const resp = await client.messages.create({
|
|
747
750
|
model: options.model, max_tokens: MODELS[options.model].maxOutputTokens,
|
|
748
751
|
messages: [
|
|
749
752
|
...options?.messages || [], buildClaudeMessage(content, options)
|
|
750
|
-
], stream: !!options?.stream,
|
|
753
|
+
], stream: !!options?.stream, ...reasoning ? {
|
|
754
|
+
thinking: options?.thinking || { type: 'enabled', budget_tokens: 1024 },
|
|
755
|
+
} : {} // https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking
|
|
751
756
|
});
|
|
752
|
-
let [event, result] = [null, ''];
|
|
757
|
+
let [event, result, thinkEnd] = [null, '', ''];
|
|
753
758
|
if (options?.stream) {
|
|
754
759
|
for await (event of resp) {
|
|
755
|
-
|
|
760
|
+
let [thkDelta, txtDelta] = [
|
|
761
|
+
event?.content_block?.thinking || event?.delta?.thinking || '',
|
|
762
|
+
event?.content_block?.text || event?.delta?.text || '',
|
|
763
|
+
];
|
|
764
|
+
if (reasoning) {
|
|
765
|
+
!result && thkDelta && (thkDelta = `${THINK_STR}\n${thkDelta}`);
|
|
766
|
+
result && txtDelta && !thinkEnd && (thinkEnd = thkDelta = `${thkDelta}\n${THINK_END}\n\n`);
|
|
767
|
+
}
|
|
768
|
+
const delta = thkDelta + txtDelta;
|
|
756
769
|
if (delta === '') { continue; }
|
|
757
770
|
result += delta;
|
|
758
771
|
event.content = { text: options?.delta ? delta : result };
|
|
@@ -852,7 +865,7 @@ const promptGemini = async (content, options) => {
|
|
|
852
865
|
// Google's bug: history is not allowed while using inline_data?
|
|
853
866
|
assert(!(
|
|
854
867
|
options?.jsonMode && MODELS[genModel]?.json == false
|
|
855
|
-
), `This model does not support JSON output: ${genModel}`);
|
|
868
|
+
), `This model does not support JSON output: ${genModel} `);
|
|
856
869
|
const chat = generative.startChat({
|
|
857
870
|
history: options?.messages && !options?.attachments?.length
|
|
858
871
|
? options.messages : [],
|
|
@@ -948,7 +961,7 @@ const listGptFineTuningEvents = async (job_id, options) => {
|
|
|
948
961
|
|
|
949
962
|
const tailGptFineTuningEvents = async (job_id, options) => {
|
|
950
963
|
assert(job_id, 'Job ID is required.');
|
|
951
|
-
const [loopName, listOpts] = [`GPT
|
|
964
|
+
const [loopName, listOpts] = [`GPT - ${job_id} `, {
|
|
952
965
|
...options, params: { ...options?.params, order: 'ascending' }
|
|
953
966
|
}];
|
|
954
967
|
let lastEvent;
|
package/lib/manifest.mjs
CHANGED