copilot-api-plus 1.0.48 → 1.0.50
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/main.js +1 -4
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -2875,7 +2875,6 @@ const truncateMessages = async (payload, model) => {
|
|
|
2875
2875
|
const tokenCount = await getTokenCount(payload, model);
|
|
2876
2876
|
const safeLimit = Math.floor(maxPromptTokens * .95);
|
|
2877
2877
|
if (tokenCount.input <= safeLimit) return payload;
|
|
2878
|
-
console.log(`Context too long (${tokenCount.input}/${maxPromptTokens} tokens), truncating...`);
|
|
2879
2878
|
const groups = groupMessages(payload.messages);
|
|
2880
2879
|
const systemGroups = groups.filter((g) => g.isSystem);
|
|
2881
2880
|
const conversationGroups = groups.filter((g) => !g.isSystem);
|
|
@@ -2902,7 +2901,7 @@ const truncateMessages = async (payload, model) => {
|
|
|
2902
2901
|
if (newTokenCount.input <= safeLimit) {
|
|
2903
2902
|
if (dropCount > 0) {
|
|
2904
2903
|
const droppedMessages = conversationGroups.slice(0, dropCount).reduce((sum, g) => sum + g.messages.length, 0);
|
|
2905
|
-
console.log(`Truncated
|
|
2904
|
+
console.log(`Truncated: ${tokenCount.input} -> ${newTokenCount.input} tokens (-${droppedMessages} msgs)`);
|
|
2906
2905
|
}
|
|
2907
2906
|
return truncatedPayload;
|
|
2908
2907
|
}
|
|
@@ -3054,7 +3053,6 @@ async function handleCompletion$1(c) {
|
|
|
3054
3053
|
cacheReadTokens: parsed.usage.prompt_tokens_details?.cached_tokens
|
|
3055
3054
|
};
|
|
3056
3055
|
setTokenUsage(usage);
|
|
3057
|
-
console.log(`[${formatTokenUsage(usage)}]`);
|
|
3058
3056
|
}
|
|
3059
3057
|
}
|
|
3060
3058
|
} catch {}
|
|
@@ -3531,7 +3529,6 @@ async function handleCompletion(c) {
|
|
|
3531
3529
|
cacheReadTokens: chunk.usage.prompt_tokens_details?.cached_tokens
|
|
3532
3530
|
};
|
|
3533
3531
|
setTokenUsage(usage);
|
|
3534
|
-
console.log(`[${formatTokenUsage(usage)}]`);
|
|
3535
3532
|
}
|
|
3536
3533
|
for (const event of events$1) await stream.writeSSE({
|
|
3537
3534
|
event: event.type,
|