llmist 1.6.2 → 1.7.0
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/{chunk-T3DIKQWU.js → chunk-E52IO2NO.js} +59 -3
- package/dist/chunk-E52IO2NO.js.map +1 -0
- package/dist/{chunk-TDRPJP2Q.js → chunk-JGORHSHC.js} +2 -2
- package/dist/chunk-JGORHSHC.js.map +1 -0
- package/dist/cli.cjs +59 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +3 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +58 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{mock-stream-Cc47j12U.d.cts → mock-stream-BMuFlQI1.d.cts} +38 -1
- package/dist/{mock-stream-Cc47j12U.d.ts → mock-stream-BMuFlQI1.d.ts} +38 -1
- package/dist/testing/index.cjs +58 -2
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +2 -2
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-T3DIKQWU.js.map +0 -1
- package/dist/chunk-TDRPJP2Q.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -5909,6 +5909,7 @@ var init_builder = __esm({
|
|
|
5909
5909
|
gadgetOutputLimitPercent;
|
|
5910
5910
|
compactionConfig;
|
|
5911
5911
|
signal;
|
|
5912
|
+
trailingMessage;
|
|
5912
5913
|
constructor(client) {
|
|
5913
5914
|
this.client = client;
|
|
5914
5915
|
}
|
|
@@ -6384,6 +6385,31 @@ var init_builder = __esm({
|
|
|
6384
6385
|
this.signal = signal;
|
|
6385
6386
|
return this;
|
|
6386
6387
|
}
|
|
6388
|
+
/**
|
|
6389
|
+
* Add an ephemeral trailing message that appears at the end of each LLM request.
|
|
6390
|
+
*
|
|
6391
|
+
* The message is NOT persisted to conversation history - it only appears in the
|
|
6392
|
+
* current LLM call. This is useful for injecting context-specific instructions
|
|
6393
|
+
* or reminders without polluting the conversation history.
|
|
6394
|
+
*
|
|
6395
|
+
* @param message - Static string or function that generates the message
|
|
6396
|
+
* @returns This builder for chaining
|
|
6397
|
+
*
|
|
6398
|
+
* @example
|
|
6399
|
+
* ```typescript
|
|
6400
|
+
* // Static message
|
|
6401
|
+
* .withTrailingMessage("Always respond in JSON format.")
|
|
6402
|
+
*
|
|
6403
|
+
* // Dynamic message based on iteration
|
|
6404
|
+
* .withTrailingMessage((ctx) =>
|
|
6405
|
+
* `[Iteration ${ctx.iteration}/${ctx.maxIterations}] Stay focused on the task.`
|
|
6406
|
+
* )
|
|
6407
|
+
* ```
|
|
6408
|
+
*/
|
|
6409
|
+
withTrailingMessage(message) {
|
|
6410
|
+
this.trailingMessage = message;
|
|
6411
|
+
return this;
|
|
6412
|
+
}
|
|
6387
6413
|
/**
|
|
6388
6414
|
* Add a synthetic gadget call to the conversation history.
|
|
6389
6415
|
*
|
|
@@ -6425,6 +6451,36 @@ ${endPrefix}`
|
|
|
6425
6451
|
});
|
|
6426
6452
|
return this;
|
|
6427
6453
|
}
|
|
6454
|
+
/**
|
|
6455
|
+
* Compose the final hooks, including trailing message if configured.
|
|
6456
|
+
*/
|
|
6457
|
+
composeHooks() {
|
|
6458
|
+
if (!this.trailingMessage) {
|
|
6459
|
+
return this.hooks;
|
|
6460
|
+
}
|
|
6461
|
+
const trailingMsg = this.trailingMessage;
|
|
6462
|
+
const existingBeforeLLMCall = this.hooks?.controllers?.beforeLLMCall;
|
|
6463
|
+
const trailingMessageController = async (ctx) => {
|
|
6464
|
+
const result = existingBeforeLLMCall ? await existingBeforeLLMCall(ctx) : { action: "proceed" };
|
|
6465
|
+
if (result.action === "skip") {
|
|
6466
|
+
return result;
|
|
6467
|
+
}
|
|
6468
|
+
const messages = [...result.modifiedOptions?.messages || ctx.options.messages];
|
|
6469
|
+
const content = typeof trailingMsg === "function" ? trailingMsg({ iteration: ctx.iteration, maxIterations: ctx.maxIterations }) : trailingMsg;
|
|
6470
|
+
messages.push({ role: "user", content });
|
|
6471
|
+
return {
|
|
6472
|
+
action: "proceed",
|
|
6473
|
+
modifiedOptions: { ...result.modifiedOptions, messages }
|
|
6474
|
+
};
|
|
6475
|
+
};
|
|
6476
|
+
return {
|
|
6477
|
+
...this.hooks,
|
|
6478
|
+
controllers: {
|
|
6479
|
+
...this.hooks?.controllers,
|
|
6480
|
+
beforeLLMCall: trailingMessageController
|
|
6481
|
+
}
|
|
6482
|
+
};
|
|
6483
|
+
}
|
|
6428
6484
|
/**
|
|
6429
6485
|
* Format parameters as block format with JSON Pointer paths.
|
|
6430
6486
|
*/
|
|
@@ -6486,7 +6542,7 @@ ${endPrefix}`
|
|
|
6486
6542
|
maxIterations: this.maxIterations,
|
|
6487
6543
|
temperature: this.temperature,
|
|
6488
6544
|
logger: this.logger,
|
|
6489
|
-
hooks: this.
|
|
6545
|
+
hooks: this.composeHooks(),
|
|
6490
6546
|
promptConfig: this.promptConfig,
|
|
6491
6547
|
initialMessages: this.initialMessages,
|
|
6492
6548
|
onHumanInputRequired: this.onHumanInputRequired,
|
|
@@ -6590,7 +6646,7 @@ ${endPrefix}`
|
|
|
6590
6646
|
maxIterations: this.maxIterations,
|
|
6591
6647
|
temperature: this.temperature,
|
|
6592
6648
|
logger: this.logger,
|
|
6593
|
-
hooks: this.
|
|
6649
|
+
hooks: this.composeHooks(),
|
|
6594
6650
|
promptConfig: this.promptConfig,
|
|
6595
6651
|
initialMessages: this.initialMessages,
|
|
6596
6652
|
onHumanInputRequired: this.onHumanInputRequired,
|