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
|
@@ -3917,6 +3917,7 @@ var init_builder = __esm({
|
|
|
3917
3917
|
gadgetOutputLimitPercent;
|
|
3918
3918
|
compactionConfig;
|
|
3919
3919
|
signal;
|
|
3920
|
+
trailingMessage;
|
|
3920
3921
|
constructor(client) {
|
|
3921
3922
|
this.client = client;
|
|
3922
3923
|
}
|
|
@@ -4392,6 +4393,31 @@ var init_builder = __esm({
|
|
|
4392
4393
|
this.signal = signal;
|
|
4393
4394
|
return this;
|
|
4394
4395
|
}
|
|
4396
|
+
/**
|
|
4397
|
+
* Add an ephemeral trailing message that appears at the end of each LLM request.
|
|
4398
|
+
*
|
|
4399
|
+
* The message is NOT persisted to conversation history - it only appears in the
|
|
4400
|
+
* current LLM call. This is useful for injecting context-specific instructions
|
|
4401
|
+
* or reminders without polluting the conversation history.
|
|
4402
|
+
*
|
|
4403
|
+
* @param message - Static string or function that generates the message
|
|
4404
|
+
* @returns This builder for chaining
|
|
4405
|
+
*
|
|
4406
|
+
* @example
|
|
4407
|
+
* ```typescript
|
|
4408
|
+
* // Static message
|
|
4409
|
+
* .withTrailingMessage("Always respond in JSON format.")
|
|
4410
|
+
*
|
|
4411
|
+
* // Dynamic message based on iteration
|
|
4412
|
+
* .withTrailingMessage((ctx) =>
|
|
4413
|
+
* `[Iteration ${ctx.iteration}/${ctx.maxIterations}] Stay focused on the task.`
|
|
4414
|
+
* )
|
|
4415
|
+
* ```
|
|
4416
|
+
*/
|
|
4417
|
+
withTrailingMessage(message) {
|
|
4418
|
+
this.trailingMessage = message;
|
|
4419
|
+
return this;
|
|
4420
|
+
}
|
|
4395
4421
|
/**
|
|
4396
4422
|
* Add a synthetic gadget call to the conversation history.
|
|
4397
4423
|
*
|
|
@@ -4433,6 +4459,36 @@ ${endPrefix}`
|
|
|
4433
4459
|
});
|
|
4434
4460
|
return this;
|
|
4435
4461
|
}
|
|
4462
|
+
/**
|
|
4463
|
+
* Compose the final hooks, including trailing message if configured.
|
|
4464
|
+
*/
|
|
4465
|
+
composeHooks() {
|
|
4466
|
+
if (!this.trailingMessage) {
|
|
4467
|
+
return this.hooks;
|
|
4468
|
+
}
|
|
4469
|
+
const trailingMsg = this.trailingMessage;
|
|
4470
|
+
const existingBeforeLLMCall = this.hooks?.controllers?.beforeLLMCall;
|
|
4471
|
+
const trailingMessageController = async (ctx) => {
|
|
4472
|
+
const result = existingBeforeLLMCall ? await existingBeforeLLMCall(ctx) : { action: "proceed" };
|
|
4473
|
+
if (result.action === "skip") {
|
|
4474
|
+
return result;
|
|
4475
|
+
}
|
|
4476
|
+
const messages = [...result.modifiedOptions?.messages || ctx.options.messages];
|
|
4477
|
+
const content = typeof trailingMsg === "function" ? trailingMsg({ iteration: ctx.iteration, maxIterations: ctx.maxIterations }) : trailingMsg;
|
|
4478
|
+
messages.push({ role: "user", content });
|
|
4479
|
+
return {
|
|
4480
|
+
action: "proceed",
|
|
4481
|
+
modifiedOptions: { ...result.modifiedOptions, messages }
|
|
4482
|
+
};
|
|
4483
|
+
};
|
|
4484
|
+
return {
|
|
4485
|
+
...this.hooks,
|
|
4486
|
+
controllers: {
|
|
4487
|
+
...this.hooks?.controllers,
|
|
4488
|
+
beforeLLMCall: trailingMessageController
|
|
4489
|
+
}
|
|
4490
|
+
};
|
|
4491
|
+
}
|
|
4436
4492
|
/**
|
|
4437
4493
|
* Format parameters as block format with JSON Pointer paths.
|
|
4438
4494
|
*/
|
|
@@ -4494,7 +4550,7 @@ ${endPrefix}`
|
|
|
4494
4550
|
maxIterations: this.maxIterations,
|
|
4495
4551
|
temperature: this.temperature,
|
|
4496
4552
|
logger: this.logger,
|
|
4497
|
-
hooks: this.
|
|
4553
|
+
hooks: this.composeHooks(),
|
|
4498
4554
|
promptConfig: this.promptConfig,
|
|
4499
4555
|
initialMessages: this.initialMessages,
|
|
4500
4556
|
onHumanInputRequired: this.onHumanInputRequired,
|
|
@@ -4598,7 +4654,7 @@ ${endPrefix}`
|
|
|
4598
4654
|
maxIterations: this.maxIterations,
|
|
4599
4655
|
temperature: this.temperature,
|
|
4600
4656
|
logger: this.logger,
|
|
4601
|
-
hooks: this.
|
|
4657
|
+
hooks: this.composeHooks(),
|
|
4602
4658
|
promptConfig: this.promptConfig,
|
|
4603
4659
|
initialMessages: this.initialMessages,
|
|
4604
4660
|
onHumanInputRequired: this.onHumanInputRequired,
|
|
@@ -8060,4 +8116,4 @@ export {
|
|
|
8060
8116
|
MockPromptRecorder,
|
|
8061
8117
|
waitFor
|
|
8062
8118
|
};
|
|
8063
|
-
//# sourceMappingURL=chunk-
|
|
8119
|
+
//# sourceMappingURL=chunk-E52IO2NO.js.map
|