llmist 1.4.0 → 1.6.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-UEEESLOA.js → chunk-QR5IQXEM.js} +2 -2
- package/dist/{chunk-VGZCFUPX.js → chunk-X5XQ6M5P.js} +84 -31
- package/dist/chunk-X5XQ6M5P.js.map +1 -0
- package/dist/cli.cjs +1667 -1060
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1581 -1027
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +83 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +2 -2
- package/dist/{mock-stream-DD5yJM44.d.cts → mock-stream-Cc47j12U.d.cts} +6 -2
- package/dist/{mock-stream-DD5yJM44.d.ts → mock-stream-Cc47j12U.d.ts} +6 -2
- package/dist/testing/index.cjs +83 -30
- 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-VGZCFUPX.js.map +0 -1
- /package/dist/{chunk-UEEESLOA.js.map → chunk-QR5IQXEM.js.map} +0 -0
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
init_strategy,
|
|
31
31
|
init_stream_processor,
|
|
32
32
|
resolveHintTemplate
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-X5XQ6M5P.js";
|
|
34
34
|
|
|
35
35
|
// src/index.ts
|
|
36
36
|
init_builder();
|
|
@@ -971,4 +971,4 @@ export {
|
|
|
971
971
|
Gadget,
|
|
972
972
|
z
|
|
973
973
|
};
|
|
974
|
-
//# sourceMappingURL=chunk-
|
|
974
|
+
//# sourceMappingURL=chunk-QR5IQXEM.js.map
|
|
@@ -844,38 +844,83 @@ function formatParamsAsBlock(params, prefix = "", argPrefix = GADGET_ARG_PREFIX)
|
|
|
844
844
|
}
|
|
845
845
|
return lines.join("\n");
|
|
846
846
|
}
|
|
847
|
-
function
|
|
847
|
+
function formatParamLine(key, propObj, isRequired, indent = "") {
|
|
848
|
+
const type = propObj.type;
|
|
849
|
+
const description = propObj.description;
|
|
850
|
+
const enumValues = propObj.enum;
|
|
851
|
+
let line = `${indent}- ${key}`;
|
|
852
|
+
if (type === "array") {
|
|
853
|
+
const items = propObj.items;
|
|
854
|
+
const itemType = items?.type || "any";
|
|
855
|
+
line += ` (array of ${itemType})`;
|
|
856
|
+
} else if (type === "object" && propObj.properties) {
|
|
857
|
+
line += " (object)";
|
|
858
|
+
} else {
|
|
859
|
+
line += ` (${type})`;
|
|
860
|
+
}
|
|
861
|
+
if (isRequired && indent !== "") {
|
|
862
|
+
line += " [required]";
|
|
863
|
+
}
|
|
864
|
+
if (description) {
|
|
865
|
+
line += `: ${description}`;
|
|
866
|
+
}
|
|
867
|
+
if (enumValues) {
|
|
868
|
+
line += ` - one of: ${enumValues.map((v) => `"${v}"`).join(", ")}`;
|
|
869
|
+
}
|
|
870
|
+
return line;
|
|
871
|
+
}
|
|
872
|
+
function formatSchemaAsPlainText(schema, indent = "", atRoot = true) {
|
|
848
873
|
const lines = [];
|
|
849
874
|
const properties = schema.properties || {};
|
|
850
875
|
const required = schema.required || [];
|
|
851
|
-
|
|
852
|
-
const
|
|
853
|
-
const
|
|
854
|
-
const
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
const itemType = items?.type || "any";
|
|
861
|
-
line += ` (array of ${itemType})`;
|
|
862
|
-
} else if (type === "object" && propObj.properties) {
|
|
863
|
-
line += " (object)";
|
|
864
|
-
} else {
|
|
865
|
-
line += ` (${type})`;
|
|
876
|
+
if (atRoot && indent === "") {
|
|
877
|
+
const requiredProps = [];
|
|
878
|
+
const optionalProps = [];
|
|
879
|
+
for (const [key, prop] of Object.entries(properties)) {
|
|
880
|
+
if (required.includes(key)) {
|
|
881
|
+
requiredProps.push([key, prop]);
|
|
882
|
+
} else {
|
|
883
|
+
optionalProps.push([key, prop]);
|
|
884
|
+
}
|
|
866
885
|
}
|
|
867
|
-
|
|
868
|
-
|
|
886
|
+
const reqCount = requiredProps.length;
|
|
887
|
+
const optCount = optionalProps.length;
|
|
888
|
+
if (reqCount > 0 || optCount > 0) {
|
|
889
|
+
const parts = [];
|
|
890
|
+
if (reqCount > 0) parts.push(`${reqCount} required`);
|
|
891
|
+
if (optCount > 0) parts.push(`${optCount} optional`);
|
|
892
|
+
lines.push(parts.join(", "));
|
|
893
|
+
lines.push("");
|
|
869
894
|
}
|
|
870
|
-
if (
|
|
871
|
-
|
|
895
|
+
if (reqCount > 0) {
|
|
896
|
+
lines.push("REQUIRED Parameters:");
|
|
897
|
+
for (const [key, prop] of requiredProps) {
|
|
898
|
+
lines.push(formatParamLine(key, prop, true, ""));
|
|
899
|
+
const propObj = prop;
|
|
900
|
+
if (propObj.type === "object" && propObj.properties) {
|
|
901
|
+
lines.push(formatSchemaAsPlainText(propObj, " ", false));
|
|
902
|
+
}
|
|
903
|
+
}
|
|
872
904
|
}
|
|
873
|
-
if (
|
|
874
|
-
|
|
905
|
+
if (optCount > 0) {
|
|
906
|
+
if (reqCount > 0) lines.push("");
|
|
907
|
+
lines.push("OPTIONAL Parameters:");
|
|
908
|
+
for (const [key, prop] of optionalProps) {
|
|
909
|
+
lines.push(formatParamLine(key, prop, false, ""));
|
|
910
|
+
const propObj = prop;
|
|
911
|
+
if (propObj.type === "object" && propObj.properties) {
|
|
912
|
+
lines.push(formatSchemaAsPlainText(propObj, " ", false));
|
|
913
|
+
}
|
|
914
|
+
}
|
|
875
915
|
}
|
|
876
|
-
lines.
|
|
877
|
-
|
|
878
|
-
|
|
916
|
+
return lines.join("\n");
|
|
917
|
+
}
|
|
918
|
+
for (const [key, prop] of Object.entries(properties)) {
|
|
919
|
+
const isRequired = required.includes(key);
|
|
920
|
+
lines.push(formatParamLine(key, prop, isRequired, indent));
|
|
921
|
+
const propObj = prop;
|
|
922
|
+
if (propObj.type === "object" && propObj.properties) {
|
|
923
|
+
lines.push(formatSchemaAsPlainText(propObj, indent + " ", false));
|
|
879
924
|
}
|
|
880
925
|
}
|
|
881
926
|
return lines.join("\n");
|
|
@@ -926,10 +971,11 @@ var init_gadget = __esm({
|
|
|
926
971
|
* Generate instruction text for the LLM.
|
|
927
972
|
* Combines name, description, and parameter schema into a formatted instruction.
|
|
928
973
|
*
|
|
929
|
-
* @param
|
|
974
|
+
* @param optionsOrArgPrefix - Optional custom prefixes for examples, or just argPrefix string for backwards compatibility
|
|
930
975
|
* @returns Formatted instruction string
|
|
931
976
|
*/
|
|
932
|
-
getInstruction(
|
|
977
|
+
getInstruction(optionsOrArgPrefix) {
|
|
978
|
+
const options = typeof optionsOrArgPrefix === "string" ? { argPrefix: optionsOrArgPrefix } : optionsOrArgPrefix;
|
|
933
979
|
const parts = [];
|
|
934
980
|
parts.push(this.description);
|
|
935
981
|
if (this.parameterSchema) {
|
|
@@ -943,18 +989,25 @@ var init_gadget = __esm({
|
|
|
943
989
|
}
|
|
944
990
|
if (this.examples && this.examples.length > 0) {
|
|
945
991
|
parts.push("\n\nExamples:");
|
|
946
|
-
const effectiveArgPrefix = argPrefix ?? GADGET_ARG_PREFIX;
|
|
992
|
+
const effectiveArgPrefix = options?.argPrefix ?? GADGET_ARG_PREFIX;
|
|
993
|
+
const effectiveStartPrefix = options?.startPrefix ?? GADGET_START_PREFIX;
|
|
994
|
+
const effectiveEndPrefix = options?.endPrefix ?? GADGET_END_PREFIX;
|
|
995
|
+
const gadgetName = this.name || this.constructor.name;
|
|
947
996
|
this.examples.forEach((example, index) => {
|
|
948
997
|
if (index > 0) {
|
|
949
998
|
parts.push("");
|
|
999
|
+
parts.push("---");
|
|
1000
|
+
parts.push("");
|
|
950
1001
|
}
|
|
951
1002
|
if (example.comment) {
|
|
952
1003
|
parts.push(`# ${example.comment}`);
|
|
953
1004
|
}
|
|
954
|
-
parts.push(
|
|
1005
|
+
parts.push(`${effectiveStartPrefix}${gadgetName}`);
|
|
955
1006
|
parts.push(formatParamsAsBlock(example.params, "", effectiveArgPrefix));
|
|
1007
|
+
parts.push(effectiveEndPrefix);
|
|
956
1008
|
if (example.output !== void 0) {
|
|
957
|
-
parts.push("
|
|
1009
|
+
parts.push("");
|
|
1010
|
+
parts.push("Expected Output:");
|
|
958
1011
|
parts.push(example.output);
|
|
959
1012
|
}
|
|
960
1013
|
});
|
|
@@ -7979,4 +8032,4 @@ export {
|
|
|
7979
8032
|
MockPromptRecorder,
|
|
7980
8033
|
waitFor
|
|
7981
8034
|
};
|
|
7982
|
-
//# sourceMappingURL=chunk-
|
|
8035
|
+
//# sourceMappingURL=chunk-X5XQ6M5P.js.map
|