@thanh01.pmt/curriculum-kit 1.0.16 → 1.0.18
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/index.cjs +28 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -10
- package/dist/index.d.ts +23 -10
- package/dist/index.mjs +28 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -13562,6 +13562,31 @@ function resolveStreamBudget(layer, opts) {
|
|
|
13562
13562
|
totalMs: opts?.totalMs ?? (Number.isFinite(envTotal) && envTotal > 0 ? envTotal : layerTotal ?? DEFAULT_STREAM_TOTAL_MS)
|
|
13563
13563
|
};
|
|
13564
13564
|
}
|
|
13565
|
+
function createStreamChunkExtractor() {
|
|
13566
|
+
let thoughtSource = null;
|
|
13567
|
+
return (part) => {
|
|
13568
|
+
if (!part || typeof part !== "object") return {};
|
|
13569
|
+
if (part.type === "reasoning-delta" || part.type === "reasoning") {
|
|
13570
|
+
if (thoughtSource === null) thoughtSource = "mapped";
|
|
13571
|
+
if (thoughtSource !== "mapped") return {};
|
|
13572
|
+
const thought = part.text ?? part.delta ?? part.reasoning ?? "";
|
|
13573
|
+
return thought ? { thought } : {};
|
|
13574
|
+
}
|
|
13575
|
+
if (part.type === "text-delta") {
|
|
13576
|
+
const content = part.text ?? part.delta ?? "";
|
|
13577
|
+
return content ? { content } : {};
|
|
13578
|
+
}
|
|
13579
|
+
if (part.type === "raw") {
|
|
13580
|
+
if (thoughtSource === null) thoughtSource = "raw";
|
|
13581
|
+
if (thoughtSource !== "raw") return {};
|
|
13582
|
+
const raw = part.rawValue ?? part.raw ?? {};
|
|
13583
|
+
const delta = raw?.choices?.[0]?.delta ?? {};
|
|
13584
|
+
const reasoning = delta.reasoning_content ?? delta.reasoning ?? delta.thought ?? "";
|
|
13585
|
+
return reasoning ? { thought: reasoning } : {};
|
|
13586
|
+
}
|
|
13587
|
+
return {};
|
|
13588
|
+
};
|
|
13589
|
+
}
|
|
13565
13590
|
function extractStreamChunk(part) {
|
|
13566
13591
|
if (!part || typeof part !== "object") return {};
|
|
13567
13592
|
if (part.type === "reasoning-delta" || part.type === "reasoning") {
|
|
@@ -13572,15 +13597,6 @@ function extractStreamChunk(part) {
|
|
|
13572
13597
|
const content = part.text ?? part.delta ?? "";
|
|
13573
13598
|
return content ? { content } : {};
|
|
13574
13599
|
}
|
|
13575
|
-
if (part.type === "raw") {
|
|
13576
|
-
const raw = part.rawValue;
|
|
13577
|
-
const delta = raw?.choices?.[0]?.delta;
|
|
13578
|
-
const reasoning = delta?.reasoning_content ?? delta?.reasoning ?? raw?.delta?.reasoning_content ?? raw?.delta?.reasoning;
|
|
13579
|
-
if (typeof reasoning === "string" && reasoning) return { thought: reasoning };
|
|
13580
|
-
const text = delta?.content ?? raw?.delta?.content;
|
|
13581
|
-
if (typeof text === "string" && text) return { content: text };
|
|
13582
|
-
return {};
|
|
13583
|
-
}
|
|
13584
13600
|
return {};
|
|
13585
13601
|
}
|
|
13586
13602
|
function createStreamAbortSignal(budget) {
|
|
@@ -13824,9 +13840,10 @@ THINKING DIRECTIVE: Keep reasoning concise, structured, and focused strictly on
|
|
|
13824
13840
|
abortSignal: abort.signal
|
|
13825
13841
|
});
|
|
13826
13842
|
let fullContent = "";
|
|
13843
|
+
const extract = createStreamChunkExtractor();
|
|
13827
13844
|
for await (const part of streamResult.fullStream) {
|
|
13828
13845
|
abort.kick();
|
|
13829
|
-
const extracted =
|
|
13846
|
+
const extracted = extract(part);
|
|
13830
13847
|
if (extracted.thought) onChunk?.(extracted.thought, "thought");
|
|
13831
13848
|
if (extracted.content) {
|
|
13832
13849
|
fullContent += extracted.content;
|
|
@@ -16909,6 +16926,7 @@ exports.createCurriculumStorage = createCurriculumStorage;
|
|
|
16909
16926
|
exports.createIdleAbortController = createIdleAbortController;
|
|
16910
16927
|
exports.createStreamAbortController = createStreamAbortController;
|
|
16911
16928
|
exports.createStreamAbortSignal = createStreamAbortSignal;
|
|
16929
|
+
exports.createStreamChunkExtractor = createStreamChunkExtractor;
|
|
16912
16930
|
exports.curateMediaLedger = curateMediaLedger;
|
|
16913
16931
|
exports.designerTools = designerTools;
|
|
16914
16932
|
exports.detectProjectPedagogy = detectProjectPedagogy;
|