llmist 0.1.3 → 0.1.5
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 +67 -12
- package/dist/{chunk-TP7HE3MN.js → chunk-J3NCIWMY.js} +34 -36
- package/dist/chunk-J3NCIWMY.js.map +1 -0
- package/dist/{chunk-JEBGLCDW.js → chunk-MO5ONHPZ.js} +2 -2
- package/dist/{chunk-DCW33WV7.js → chunk-PVHHXDCV.js} +2 -2
- package/dist/cli.cjs +161 -92
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +130 -59
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +368 -75
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +376 -50
- package/dist/index.d.ts +376 -50
- package/dist/index.js +338 -43
- package/dist/index.js.map +1 -1
- package/dist/{mock-stream-D4erlo7B.d.cts → mock-stream-C2sBQlvc.d.cts} +1 -2
- package/dist/{mock-stream-D4erlo7B.d.ts → mock-stream-C2sBQlvc.d.ts} +1 -2
- package/dist/testing/index.cjs +33 -35
- 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 +2 -2
- package/package.json +2 -2
- package/dist/chunk-TP7HE3MN.js.map +0 -1
- /package/dist/{chunk-JEBGLCDW.js.map → chunk-MO5ONHPZ.js.map} +0 -0
- /package/dist/{chunk-DCW33WV7.js.map → chunk-PVHHXDCV.js.map} +0 -0
|
@@ -108,7 +108,6 @@ declare class StreamParser {
|
|
|
108
108
|
private readonly startPrefix;
|
|
109
109
|
private readonly endPrefix;
|
|
110
110
|
private readonly parameterFormat;
|
|
111
|
-
private invocationCounter;
|
|
112
111
|
constructor(options?: StreamParserOptions);
|
|
113
112
|
private takeTextUntil;
|
|
114
113
|
/**
|
|
@@ -291,7 +290,7 @@ declare class LLMMessageBuilder {
|
|
|
291
290
|
startPrefix?: string;
|
|
292
291
|
endPrefix?: string;
|
|
293
292
|
}): this;
|
|
294
|
-
private
|
|
293
|
+
private buildGadgetsSection;
|
|
295
294
|
private buildUsageSection;
|
|
296
295
|
private buildExamplesSection;
|
|
297
296
|
private buildRulesSection;
|
package/dist/testing/index.cjs
CHANGED
|
@@ -488,14 +488,15 @@ var init_messages = __esm({
|
|
|
488
488
|
context
|
|
489
489
|
);
|
|
490
490
|
parts.push(mainInstruction);
|
|
491
|
-
parts.push(this.
|
|
491
|
+
parts.push(this.buildGadgetsSection(gadgets, parameterFormat));
|
|
492
492
|
parts.push(this.buildUsageSection(parameterFormat, context));
|
|
493
493
|
this.messages.push({ role: "system", content: parts.join("") });
|
|
494
494
|
return this;
|
|
495
495
|
}
|
|
496
|
-
|
|
496
|
+
buildGadgetsSection(gadgets, parameterFormat) {
|
|
497
497
|
const parts = [];
|
|
498
|
-
parts.push("
|
|
498
|
+
parts.push("\n\nAVAILABLE GADGETS");
|
|
499
|
+
parts.push("\n=================\n");
|
|
499
500
|
for (const gadget of gadgets) {
|
|
500
501
|
const gadgetName = gadget.name ?? gadget.constructor.name;
|
|
501
502
|
const instruction = gadget.getInstruction(parameterFormat);
|
|
@@ -503,18 +504,17 @@ var init_messages = __esm({
|
|
|
503
504
|
const schemaIndex = instruction.indexOf(schemaMarker);
|
|
504
505
|
const description = (schemaIndex !== -1 ? instruction.substring(0, schemaIndex) : instruction).trim();
|
|
505
506
|
const schema = schemaIndex !== -1 ? instruction.substring(schemaIndex + schemaMarker.length).trim() : "";
|
|
506
|
-
parts.push("\n <gadget>");
|
|
507
507
|
parts.push(`
|
|
508
|
-
|
|
508
|
+
GADGET: ${gadgetName}`);
|
|
509
509
|
parts.push(`
|
|
510
|
-
|
|
510
|
+
${description}`);
|
|
511
511
|
if (schema) {
|
|
512
512
|
parts.push(`
|
|
513
|
-
|
|
514
|
-
${
|
|
515
|
-
|
|
513
|
+
|
|
514
|
+
PARAMETERS (${parameterFormat.toUpperCase()}):
|
|
515
|
+
${schema}`);
|
|
516
516
|
}
|
|
517
|
-
parts.push("\n
|
|
517
|
+
parts.push("\n\n---");
|
|
518
518
|
}
|
|
519
519
|
return parts.join("");
|
|
520
520
|
}
|
|
@@ -529,26 +529,26 @@ ${schema}
|
|
|
529
529
|
DEFAULT_PROMPTS.formatDescriptionJson,
|
|
530
530
|
context
|
|
531
531
|
);
|
|
532
|
-
parts.push("
|
|
532
|
+
parts.push("\n\nHOW TO INVOKE GADGETS");
|
|
533
|
+
parts.push("\n=====================\n");
|
|
533
534
|
const criticalUsage = resolvePromptTemplate(
|
|
534
535
|
this.promptConfig.criticalUsage,
|
|
535
536
|
DEFAULT_PROMPTS.criticalUsage,
|
|
536
537
|
context
|
|
537
538
|
);
|
|
538
539
|
parts.push(`
|
|
539
|
-
|
|
540
|
-
|
|
540
|
+
CRITICAL: ${criticalUsage}
|
|
541
|
+
`);
|
|
542
|
+
parts.push("\nFORMAT:");
|
|
541
543
|
parts.push(`
|
|
542
|
-
|
|
544
|
+
1. Start marker: ${this.startPrefix}gadget_name`);
|
|
543
545
|
parts.push(`
|
|
544
|
-
|
|
546
|
+
2. ${formatDescription}`);
|
|
545
547
|
parts.push(`
|
|
546
|
-
|
|
547
|
-
parts.push("\n </format>");
|
|
548
|
+
3. End marker: ${this.endPrefix}`);
|
|
548
549
|
parts.push(this.buildExamplesSection(parameterFormat, context));
|
|
549
550
|
parts.push(this.buildRulesSection(context));
|
|
550
|
-
parts.push("\n
|
|
551
|
-
parts.push("\n</GADGETS>\n\n");
|
|
551
|
+
parts.push("\n");
|
|
552
552
|
return parts.join("");
|
|
553
553
|
}
|
|
554
554
|
buildExamplesSection(parameterFormat, context) {
|
|
@@ -556,7 +556,6 @@ ${schema}
|
|
|
556
556
|
return this.promptConfig.customExamples(context);
|
|
557
557
|
}
|
|
558
558
|
const parts = [];
|
|
559
|
-
parts.push("\n <examples>");
|
|
560
559
|
const singleExample = parameterFormat === "yaml" ? `${this.startPrefix}translate
|
|
561
560
|
from: English
|
|
562
561
|
to: Polish
|
|
@@ -565,9 +564,10 @@ ${this.endPrefix}` : `${this.startPrefix}translate
|
|
|
565
564
|
{"from": "English", "to": "Polish", "content": "Paris is the capital of France."}
|
|
566
565
|
${this.endPrefix}`;
|
|
567
566
|
parts.push(`
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
567
|
+
|
|
568
|
+
EXAMPLE (Single Gadget):
|
|
569
|
+
|
|
570
|
+
${singleExample}`);
|
|
571
571
|
const multipleExample = parameterFormat === "yaml" ? `${this.startPrefix}translate
|
|
572
572
|
from: English
|
|
573
573
|
to: Polish
|
|
@@ -584,21 +584,20 @@ ${this.startPrefix}analyze
|
|
|
584
584
|
{"type": "economic_analysis", "matter": "Polish Economy", "question": "Polish arms exports 2025."}
|
|
585
585
|
${this.endPrefix}`;
|
|
586
586
|
parts.push(`
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
587
|
+
|
|
588
|
+
EXAMPLE (Multiple Gadgets):
|
|
589
|
+
|
|
590
|
+
${multipleExample}`);
|
|
591
591
|
return parts.join("");
|
|
592
592
|
}
|
|
593
593
|
buildRulesSection(context) {
|
|
594
594
|
const parts = [];
|
|
595
|
-
parts.push("\n
|
|
595
|
+
parts.push("\n\nRULES:");
|
|
596
596
|
const rules = resolveRulesTemplate(this.promptConfig.rules, context);
|
|
597
597
|
for (const rule of rules) {
|
|
598
598
|
parts.push(`
|
|
599
|
-
|
|
599
|
+
- ${rule}`);
|
|
600
600
|
}
|
|
601
|
-
parts.push("\n </rules>");
|
|
602
601
|
return parts.join("");
|
|
603
602
|
}
|
|
604
603
|
addUser(content, metadata) {
|
|
@@ -1139,19 +1138,19 @@ var init_executor = __esm({
|
|
|
1139
1138
|
});
|
|
1140
1139
|
|
|
1141
1140
|
// src/gadgets/parser.ts
|
|
1142
|
-
var yaml, StreamParser;
|
|
1141
|
+
var yaml, globalInvocationCounter, StreamParser;
|
|
1143
1142
|
var init_parser = __esm({
|
|
1144
1143
|
"src/gadgets/parser.ts"() {
|
|
1145
1144
|
"use strict";
|
|
1146
1145
|
yaml = __toESM(require("js-yaml"), 1);
|
|
1147
1146
|
init_constants();
|
|
1147
|
+
globalInvocationCounter = 0;
|
|
1148
1148
|
StreamParser = class {
|
|
1149
1149
|
buffer = "";
|
|
1150
1150
|
lastReportedTextLength = 0;
|
|
1151
1151
|
startPrefix;
|
|
1152
1152
|
endPrefix;
|
|
1153
1153
|
parameterFormat;
|
|
1154
|
-
invocationCounter = 0;
|
|
1155
1154
|
constructor(options = {}) {
|
|
1156
1155
|
this.startPrefix = options.startPrefix ?? GADGET_START_PREFIX;
|
|
1157
1156
|
this.endPrefix = options.endPrefix ?? GADGET_END_PREFIX;
|
|
@@ -1218,7 +1217,7 @@ var init_parser = __esm({
|
|
|
1218
1217
|
invocationId = parts[1];
|
|
1219
1218
|
} else {
|
|
1220
1219
|
actualGadgetName = gadgetName;
|
|
1221
|
-
invocationId = `
|
|
1220
|
+
invocationId = `gadget_${++globalInvocationCounter}`;
|
|
1222
1221
|
}
|
|
1223
1222
|
const contentStartIndex = metadataEndIndex + 1;
|
|
1224
1223
|
let partEndIndex;
|
|
@@ -1275,11 +1274,10 @@ var init_parser = __esm({
|
|
|
1275
1274
|
yield { type: "text", content: remainingText };
|
|
1276
1275
|
}
|
|
1277
1276
|
}
|
|
1278
|
-
// Reset parser state
|
|
1277
|
+
// Reset parser state (note: global invocation counter is NOT reset to ensure unique IDs)
|
|
1279
1278
|
reset() {
|
|
1280
1279
|
this.buffer = "";
|
|
1281
1280
|
this.lastReportedTextLength = 0;
|
|
1282
|
-
this.invocationCounter = 0;
|
|
1283
1281
|
}
|
|
1284
1282
|
};
|
|
1285
1283
|
}
|