llmist 1.3.0 → 1.4.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/README.md +10 -18
- package/dist/chunk-UEEESLOA.js +974 -0
- package/dist/chunk-UEEESLOA.js.map +1 -0
- package/dist/{chunk-RZTAKIDE.js → chunk-VGZCFUPX.js} +4627 -3211
- package/dist/chunk-VGZCFUPX.js.map +1 -0
- package/dist/cli.cjs +1321 -245
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1190 -215
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +52 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +20 -973
- package/dist/index.js.map +1 -1
- package/dist/{mock-stream-DNt-HBTn.d.cts → mock-stream-DD5yJM44.d.cts} +65 -0
- package/dist/{mock-stream-DNt-HBTn.d.ts → mock-stream-DD5yJM44.d.ts} +65 -0
- package/dist/testing/index.cjs +52 -10
- 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 -2
- package/package.json +3 -1
- package/dist/chunk-RZTAKIDE.js.map +0 -1
- package/dist/chunk-TFIKR2RK.js +0 -1394
- package/dist/chunk-TFIKR2RK.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -3307,6 +3307,8 @@ var init_agent = __esm({
|
|
|
3307
3307
|
outputLimitCharLimit;
|
|
3308
3308
|
// Context compaction
|
|
3309
3309
|
compactionManager;
|
|
3310
|
+
// Cancellation
|
|
3311
|
+
signal;
|
|
3310
3312
|
/**
|
|
3311
3313
|
* Creates a new Agent instance.
|
|
3312
3314
|
* @internal This constructor is private. Use LLMist.createAgent() or AgentBuilder instead.
|
|
@@ -3374,6 +3376,7 @@ var init_agent = __esm({
|
|
|
3374
3376
|
options.compactionConfig
|
|
3375
3377
|
);
|
|
3376
3378
|
}
|
|
3379
|
+
this.signal = options.signal;
|
|
3377
3380
|
}
|
|
3378
3381
|
/**
|
|
3379
3382
|
* Get the gadget registry for this agent.
|
|
@@ -3491,7 +3494,8 @@ var init_agent = __esm({
|
|
|
3491
3494
|
model: this.model,
|
|
3492
3495
|
messages: this.conversation.getMessages(),
|
|
3493
3496
|
temperature: this.temperature,
|
|
3494
|
-
maxTokens: this.defaultMaxTokens
|
|
3497
|
+
maxTokens: this.defaultMaxTokens,
|
|
3498
|
+
signal: this.signal
|
|
3495
3499
|
};
|
|
3496
3500
|
await this.safeObserve(async () => {
|
|
3497
3501
|
if (this.hooks.observers?.onLLMCallStart) {
|
|
@@ -4109,7 +4113,7 @@ var init_base_provider = __esm({
|
|
|
4109
4113
|
async *stream(options, descriptor, spec) {
|
|
4110
4114
|
const preparedMessages = this.prepareMessages(options.messages);
|
|
4111
4115
|
const payload = this.buildRequestPayload(options, descriptor, spec, preparedMessages);
|
|
4112
|
-
const rawStream = await this.executeStreamRequest(payload);
|
|
4116
|
+
const rawStream = await this.executeStreamRequest(payload, options.signal);
|
|
4113
4117
|
yield* this.wrapStream(rawStream);
|
|
4114
4118
|
}
|
|
4115
4119
|
/**
|
|
@@ -4227,9 +4231,9 @@ var init_anthropic = __esm({
|
|
|
4227
4231
|
};
|
|
4228
4232
|
return payload;
|
|
4229
4233
|
}
|
|
4230
|
-
async executeStreamRequest(payload) {
|
|
4234
|
+
async executeStreamRequest(payload, signal) {
|
|
4231
4235
|
const client = this.client;
|
|
4232
|
-
const stream2 = await client.messages.create(payload);
|
|
4236
|
+
const stream2 = await client.messages.create(payload, signal ? { signal } : void 0);
|
|
4233
4237
|
return stream2;
|
|
4234
4238
|
}
|
|
4235
4239
|
async *wrapStream(iterable) {
|
|
@@ -4561,9 +4565,15 @@ var init_gemini = __esm({
|
|
|
4561
4565
|
config
|
|
4562
4566
|
};
|
|
4563
4567
|
}
|
|
4564
|
-
async executeStreamRequest(payload) {
|
|
4568
|
+
async executeStreamRequest(payload, signal) {
|
|
4565
4569
|
const client = this.client;
|
|
4566
|
-
const streamResponse = await client.models.generateContentStream(
|
|
4570
|
+
const streamResponse = await client.models.generateContentStream({
|
|
4571
|
+
...payload,
|
|
4572
|
+
config: {
|
|
4573
|
+
...payload.config,
|
|
4574
|
+
...signal ? { abortSignal: signal } : {}
|
|
4575
|
+
}
|
|
4576
|
+
});
|
|
4567
4577
|
return streamResponse;
|
|
4568
4578
|
}
|
|
4569
4579
|
/**
|
|
@@ -5152,9 +5162,9 @@ var init_openai = __esm({
|
|
|
5152
5162
|
...shouldIncludeTemperature ? { temperature } : {}
|
|
5153
5163
|
};
|
|
5154
5164
|
}
|
|
5155
|
-
async executeStreamRequest(payload) {
|
|
5165
|
+
async executeStreamRequest(payload, signal) {
|
|
5156
5166
|
const client = this.client;
|
|
5157
|
-
const stream2 = await client.chat.completions.create(payload);
|
|
5167
|
+
const stream2 = await client.chat.completions.create(payload, signal ? { signal } : void 0);
|
|
5158
5168
|
return stream2;
|
|
5159
5169
|
}
|
|
5160
5170
|
async *wrapStream(iterable) {
|
|
@@ -5817,6 +5827,7 @@ var init_builder = __esm({
|
|
|
5817
5827
|
gadgetOutputLimit;
|
|
5818
5828
|
gadgetOutputLimitPercent;
|
|
5819
5829
|
compactionConfig;
|
|
5830
|
+
signal;
|
|
5820
5831
|
constructor(client) {
|
|
5821
5832
|
this.client = client;
|
|
5822
5833
|
}
|
|
@@ -6263,6 +6274,35 @@ var init_builder = __esm({
|
|
|
6263
6274
|
this.compactionConfig = { enabled: false };
|
|
6264
6275
|
return this;
|
|
6265
6276
|
}
|
|
6277
|
+
/**
|
|
6278
|
+
* Set an abort signal for cancelling requests mid-flight.
|
|
6279
|
+
*
|
|
6280
|
+
* When the signal is aborted, the current LLM request will be cancelled
|
|
6281
|
+
* and the agent loop will exit gracefully.
|
|
6282
|
+
*
|
|
6283
|
+
* @param signal - AbortSignal from an AbortController
|
|
6284
|
+
* @returns This builder for chaining
|
|
6285
|
+
*
|
|
6286
|
+
* @example
|
|
6287
|
+
* ```typescript
|
|
6288
|
+
* const controller = new AbortController();
|
|
6289
|
+
*
|
|
6290
|
+
* // Cancel after 30 seconds
|
|
6291
|
+
* setTimeout(() => controller.abort(), 30000);
|
|
6292
|
+
*
|
|
6293
|
+
* const agent = LLMist.createAgent()
|
|
6294
|
+
* .withModel("sonnet")
|
|
6295
|
+
* .withSignal(controller.signal)
|
|
6296
|
+
* .ask("Write a long story");
|
|
6297
|
+
*
|
|
6298
|
+
* // Or cancel on user action
|
|
6299
|
+
* document.getElementById("cancel").onclick = () => controller.abort();
|
|
6300
|
+
* ```
|
|
6301
|
+
*/
|
|
6302
|
+
withSignal(signal) {
|
|
6303
|
+
this.signal = signal;
|
|
6304
|
+
return this;
|
|
6305
|
+
}
|
|
6266
6306
|
/**
|
|
6267
6307
|
* Add a synthetic gadget call to the conversation history.
|
|
6268
6308
|
*
|
|
@@ -6379,7 +6419,8 @@ ${endPrefix}`
|
|
|
6379
6419
|
defaultGadgetTimeoutMs: this.defaultGadgetTimeoutMs,
|
|
6380
6420
|
gadgetOutputLimit: this.gadgetOutputLimit,
|
|
6381
6421
|
gadgetOutputLimitPercent: this.gadgetOutputLimitPercent,
|
|
6382
|
-
compactionConfig: this.compactionConfig
|
|
6422
|
+
compactionConfig: this.compactionConfig,
|
|
6423
|
+
signal: this.signal
|
|
6383
6424
|
};
|
|
6384
6425
|
return new Agent(AGENT_INTERNAL_KEY, options);
|
|
6385
6426
|
}
|
|
@@ -6482,7 +6523,8 @@ ${endPrefix}`
|
|
|
6482
6523
|
defaultGadgetTimeoutMs: this.defaultGadgetTimeoutMs,
|
|
6483
6524
|
gadgetOutputLimit: this.gadgetOutputLimit,
|
|
6484
6525
|
gadgetOutputLimitPercent: this.gadgetOutputLimitPercent,
|
|
6485
|
-
compactionConfig: this.compactionConfig
|
|
6526
|
+
compactionConfig: this.compactionConfig,
|
|
6527
|
+
signal: this.signal
|
|
6486
6528
|
};
|
|
6487
6529
|
return new Agent(AGENT_INTERNAL_KEY, options);
|
|
6488
6530
|
}
|