@lloyal-labs/sdk 1.5.4 → 1.5.6
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/deltas.d.ts +4 -0
- package/dist/deltas.d.ts.map +1 -1
- package/dist/deltas.js +14 -2
- package/dist/deltas.js.map +1 -1
- package/package.json +1 -1
package/dist/deltas.d.ts
CHANGED
|
@@ -26,6 +26,10 @@ export declare function buildUserDelta(ctx: SessionContext, content: string, opt
|
|
|
26
26
|
* single token array suitable for `branch.prefill()`. Used by
|
|
27
27
|
* {@link useAgentPool} to inject tool results back into agent context.
|
|
28
28
|
*
|
|
29
|
+
* For templates that require a user message (e.g. Qwen 3.5), the native layer
|
|
30
|
+
* (`chat_in::format`) retries with a synthetic user and strips it, so the
|
|
31
|
+
* caller always receives correctly formatted output.
|
|
32
|
+
*
|
|
29
33
|
* @param ctx - Active session context
|
|
30
34
|
* @param resultStr - JSON-serialized tool result
|
|
31
35
|
* @param callId - Tool call identifier from the model's parsed output
|
package/dist/deltas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deltas.d.ts","sourceRoot":"","sources":["../src/deltas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,cAAc,EACnB,OAAO,EAAE,MAAM,EACf,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAC5B,MAAM,EAAE,CASV;AAED
|
|
1
|
+
{"version":3,"file":"deltas.d.ts","sourceRoot":"","sources":["../src/deltas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,cAAc,EACnB,OAAO,EAAE,MAAM,EACf,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAC5B,MAAM,EAAE,CASV;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,MAAM,EAAE,CAkBV"}
|
package/dist/deltas.js
CHANGED
|
@@ -33,6 +33,10 @@ function buildUserDelta(ctx, content, opts = {}) {
|
|
|
33
33
|
* single token array suitable for `branch.prefill()`. Used by
|
|
34
34
|
* {@link useAgentPool} to inject tool results back into agent context.
|
|
35
35
|
*
|
|
36
|
+
* For templates that require a user message (e.g. Qwen 3.5), the native layer
|
|
37
|
+
* (`chat_in::format`) retries with a synthetic user and strips it, so the
|
|
38
|
+
* caller always receives correctly formatted output.
|
|
39
|
+
*
|
|
36
40
|
* @param ctx - Active session context
|
|
37
41
|
* @param resultStr - JSON-serialized tool result
|
|
38
42
|
* @param callId - Tool call identifier from the model's parsed output
|
|
@@ -42,11 +46,19 @@ function buildUserDelta(ctx, content, opts = {}) {
|
|
|
42
46
|
*/
|
|
43
47
|
function buildToolResultDelta(ctx, resultStr, callId) {
|
|
44
48
|
const sep = ctx.getTurnSeparator();
|
|
45
|
-
const { prompt } = ctx.formatChatSync(JSON.stringify([
|
|
49
|
+
const { prompt, generationPrompt } = ctx.formatChatSync(JSON.stringify([
|
|
46
50
|
{ role: 'system', content: '' },
|
|
47
51
|
{ role: 'tool', content: resultStr, tool_call_id: callId },
|
|
48
52
|
]));
|
|
49
53
|
const delta = ctx.tokenizeSync(prompt, false);
|
|
50
|
-
|
|
54
|
+
// Append generation prompt (e.g. "<|im_start|>assistant\n<think>\n" for thinking models).
|
|
55
|
+
// For non-thinking models this is "<|im_start|>assistant\n" which is already
|
|
56
|
+
// included in prompt by formatChatSync. Tokenizing it again would double it,
|
|
57
|
+
// so only append when it's NOT already a suffix of prompt.
|
|
58
|
+
let genTokens = [];
|
|
59
|
+
if (generationPrompt && !prompt.endsWith(generationPrompt)) {
|
|
60
|
+
genTokens = ctx.tokenizeSync(generationPrompt, false);
|
|
61
|
+
}
|
|
62
|
+
return [...sep, ...delta, ...genTokens];
|
|
51
63
|
}
|
|
52
64
|
//# sourceMappingURL=deltas.js.map
|
package/dist/deltas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deltas.js","sourceRoot":"","sources":["../src/deltas.ts"],"names":[],"mappings":";;AAmBA,wCAaC;
|
|
1
|
+
{"version":3,"file":"deltas.js","sourceRoot":"","sources":["../src/deltas.ts"],"names":[],"mappings":";;AAmBA,wCAaC;AAoBD,oDAsBC;AAxED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,cAAc,CAC5B,GAAmB,EACnB,OAAe,EACf,OAA2B,EAAE;IAE7B,MAAM,GAAG,GAAG,GAAG,CAAC,gBAAgB,EAAE,CAAC;IACnC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACxD,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,cAAc,CACnC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,EAC5E,OAAO,CACR,CAAC;IACF,MAAM,KAAK,GAAG,GAAG,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9C,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC;AAC5B,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,oBAAoB,CAClC,GAAmB,EACnB,SAAiB,EACjB,MAAc;IAEd,MAAM,GAAG,GAAG,GAAG,CAAC,gBAAg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