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
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ZodType, ZodTypeAny } from 'zod';
|
|
2
2
|
export { z } from 'zod';
|
|
3
|
-
import { A as AgentHooks, q as ModelRegistry, I as IConversationManager, b as LLMMessage, S as StreamEvent, T as TokenUsage, G as GadgetRegistry, a as LLMStreamChunk, C as CompactionStrategy, R as ResolvedCompactionConfig, r as CompactionContext, s as CompactionResult, t as LLMist, u as CompactionConfig, v as CompactionEvent, w as CompactionStats, H as HintTemplate, x as GadgetExample, B as BaseGadget, P as ParsedGadgetCall, y as GadgetExecutionResult, z as ProviderAdapter, D as ModelDescriptor, E as ModelSpec, F as LLMGenerationOptions, L as LLMStream } from './mock-stream-
|
|
4
|
-
export { V as AfterGadgetExecutionAction, W as AfterGadgetExecutionControllerContext, X as AfterLLMCallAction, Y as AfterLLMCallControllerContext, Z as AfterLLMErrorAction, K as AgentBuilder, _ as AgentOptions, $ as BeforeGadgetExecutionAction, a0 as BeforeLLMCallAction, a1 as ChunkInterceptorContext, a2 as Controllers, ao as CostEstimate, aj as DEFAULT_COMPACTION_CONFIG, ay as DEFAULT_HINTS, az as DEFAULT_PROMPTS, ak as DEFAULT_SUMMARIZATION_PROMPT, N as EventHandlers, aG as GadgetClass, a3 as GadgetExecutionControllerContext, aH as GadgetOrClass, a4 as GadgetParameterInterceptorContext, a5 as GadgetResultInterceptorContext, au as HintContext, J as HistoryMessage, a6 as Interceptors, a7 as LLMCallControllerContext, a8 as LLMErrorControllerContext, an as LLMMessageBuilder, am as LLMRole, al as LLMistOptions, a9 as MessageInterceptorContext, ah as MessageTurn, d as MockBuilder, f as MockManager, j as MockMatcher, k as MockMatcherContext, l as MockOptions, M as MockProviderAdapter, n as MockRegistration, o as MockResponse, p as MockStats, ap as ModelFeatures, at as ModelIdentifierParser, aq as ModelLimits, ar as ModelPricing, aa as ObserveChunkContext, ai as ObserveCompactionContext, ab as ObserveGadgetCompleteContext, ac as ObserveGadgetStartContext, ad as ObserveLLMCallContext, ae as ObserveLLMCompleteContext, af as ObserveLLMErrorContext, ag as Observers, av as PromptConfig, aw as PromptContext, ax as PromptTemplate, as as ProviderIdentifier, aD as QuickOptions, aI as TextOnlyAction, aJ as TextOnlyContext, aK as TextOnlyCustomHandler, aL as TextOnlyGadgetConfig, aM as TextOnlyHandler, aN as TextOnlyStrategy, O as collectEvents, Q as collectText, aE as complete, c as createMockAdapter, e as createMockClient, h as createMockStream, i as createTextMockStream, g as getMockManager, m as mockLLM, aA as resolveHintTemplate, aB as resolvePromptTemplate, aC as resolveRulesTemplate, U as runWithHandlers, aF as stream } from './mock-stream-
|
|
3
|
+
import { A as AgentHooks, q as ModelRegistry, I as IConversationManager, b as LLMMessage, S as StreamEvent, T as TokenUsage, G as GadgetRegistry, a as LLMStreamChunk, C as CompactionStrategy, R as ResolvedCompactionConfig, r as CompactionContext, s as CompactionResult, t as LLMist, u as CompactionConfig, v as CompactionEvent, w as CompactionStats, H as HintTemplate, x as GadgetExample, B as BaseGadget, P as ParsedGadgetCall, y as GadgetExecutionResult, z as ProviderAdapter, D as ModelDescriptor, E as ModelSpec, F as LLMGenerationOptions, L as LLMStream } from './mock-stream-Cc47j12U.cjs';
|
|
4
|
+
export { V as AfterGadgetExecutionAction, W as AfterGadgetExecutionControllerContext, X as AfterLLMCallAction, Y as AfterLLMCallControllerContext, Z as AfterLLMErrorAction, K as AgentBuilder, _ as AgentOptions, $ as BeforeGadgetExecutionAction, a0 as BeforeLLMCallAction, a1 as ChunkInterceptorContext, a2 as Controllers, ao as CostEstimate, aj as DEFAULT_COMPACTION_CONFIG, ay as DEFAULT_HINTS, az as DEFAULT_PROMPTS, ak as DEFAULT_SUMMARIZATION_PROMPT, N as EventHandlers, aG as GadgetClass, a3 as GadgetExecutionControllerContext, aH as GadgetOrClass, a4 as GadgetParameterInterceptorContext, a5 as GadgetResultInterceptorContext, au as HintContext, J as HistoryMessage, a6 as Interceptors, a7 as LLMCallControllerContext, a8 as LLMErrorControllerContext, an as LLMMessageBuilder, am as LLMRole, al as LLMistOptions, a9 as MessageInterceptorContext, ah as MessageTurn, d as MockBuilder, f as MockManager, j as MockMatcher, k as MockMatcherContext, l as MockOptions, M as MockProviderAdapter, n as MockRegistration, o as MockResponse, p as MockStats, ap as ModelFeatures, at as ModelIdentifierParser, aq as ModelLimits, ar as ModelPricing, aa as ObserveChunkContext, ai as ObserveCompactionContext, ab as ObserveGadgetCompleteContext, ac as ObserveGadgetStartContext, ad as ObserveLLMCallContext, ae as ObserveLLMCompleteContext, af as ObserveLLMErrorContext, ag as Observers, av as PromptConfig, aw as PromptContext, ax as PromptTemplate, as as ProviderIdentifier, aD as QuickOptions, aI as TextOnlyAction, aJ as TextOnlyContext, aK as TextOnlyCustomHandler, aL as TextOnlyGadgetConfig, aM as TextOnlyHandler, aN as TextOnlyStrategy, O as collectEvents, Q as collectText, aE as complete, c as createMockAdapter, e as createMockClient, h as createMockStream, i as createTextMockStream, g as getMockManager, m as mockLLM, aA as resolveHintTemplate, aB as resolvePromptTemplate, aC as resolveRulesTemplate, U as runWithHandlers, aF as stream } from './mock-stream-Cc47j12U.cjs';
|
|
5
5
|
import { Logger, ILogObj } from 'tslog';
|
|
6
6
|
import { MessageCreateParamsStreaming, MessageStreamEvent } from '@anthropic-ai/sdk/resources/messages';
|
|
7
7
|
import OpenAI from 'openai';
|
|
@@ -1786,7 +1786,11 @@ declare function Gadget<TSchema extends ZodType>(config: GadgetConfig<TSchema>):
|
|
|
1786
1786
|
*/
|
|
1787
1787
|
execute(params: Record<string, unknown>): string | Promise<string>;
|
|
1788
1788
|
get instruction(): string;
|
|
1789
|
-
getInstruction(
|
|
1789
|
+
getInstruction(optionsOrArgPrefix?: string | {
|
|
1790
|
+
argPrefix?: string;
|
|
1791
|
+
startPrefix?: string;
|
|
1792
|
+
endPrefix?: string;
|
|
1793
|
+
}): string;
|
|
1790
1794
|
} & {
|
|
1791
1795
|
params: InferSchema<TSchema>;
|
|
1792
1796
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ZodType, ZodTypeAny } from 'zod';
|
|
2
2
|
export { z } from 'zod';
|
|
3
|
-
import { A as AgentHooks, q as ModelRegistry, I as IConversationManager, b as LLMMessage, S as StreamEvent, T as TokenUsage, G as GadgetRegistry, a as LLMStreamChunk, C as CompactionStrategy, R as ResolvedCompactionConfig, r as CompactionContext, s as CompactionResult, t as LLMist, u as CompactionConfig, v as CompactionEvent, w as CompactionStats, H as HintTemplate, x as GadgetExample, B as BaseGadget, P as ParsedGadgetCall, y as GadgetExecutionResult, z as ProviderAdapter, D as ModelDescriptor, E as ModelSpec, F as LLMGenerationOptions, L as LLMStream } from './mock-stream-
|
|
4
|
-
export { V as AfterGadgetExecutionAction, W as AfterGadgetExecutionControllerContext, X as AfterLLMCallAction, Y as AfterLLMCallControllerContext, Z as AfterLLMErrorAction, K as AgentBuilder, _ as AgentOptions, $ as BeforeGadgetExecutionAction, a0 as BeforeLLMCallAction, a1 as ChunkInterceptorContext, a2 as Controllers, ao as CostEstimate, aj as DEFAULT_COMPACTION_CONFIG, ay as DEFAULT_HINTS, az as DEFAULT_PROMPTS, ak as DEFAULT_SUMMARIZATION_PROMPT, N as EventHandlers, aG as GadgetClass, a3 as GadgetExecutionControllerContext, aH as GadgetOrClass, a4 as GadgetParameterInterceptorContext, a5 as GadgetResultInterceptorContext, au as HintContext, J as HistoryMessage, a6 as Interceptors, a7 as LLMCallControllerContext, a8 as LLMErrorControllerContext, an as LLMMessageBuilder, am as LLMRole, al as LLMistOptions, a9 as MessageInterceptorContext, ah as MessageTurn, d as MockBuilder, f as MockManager, j as MockMatcher, k as MockMatcherContext, l as MockOptions, M as MockProviderAdapter, n as MockRegistration, o as MockResponse, p as MockStats, ap as ModelFeatures, at as ModelIdentifierParser, aq as ModelLimits, ar as ModelPricing, aa as ObserveChunkContext, ai as ObserveCompactionContext, ab as ObserveGadgetCompleteContext, ac as ObserveGadgetStartContext, ad as ObserveLLMCallContext, ae as ObserveLLMCompleteContext, af as ObserveLLMErrorContext, ag as Observers, av as PromptConfig, aw as PromptContext, ax as PromptTemplate, as as ProviderIdentifier, aD as QuickOptions, aI as TextOnlyAction, aJ as TextOnlyContext, aK as TextOnlyCustomHandler, aL as TextOnlyGadgetConfig, aM as TextOnlyHandler, aN as TextOnlyStrategy, O as collectEvents, Q as collectText, aE as complete, c as createMockAdapter, e as createMockClient, h as createMockStream, i as createTextMockStream, g as getMockManager, m as mockLLM, aA as resolveHintTemplate, aB as resolvePromptTemplate, aC as resolveRulesTemplate, U as runWithHandlers, aF as stream } from './mock-stream-
|
|
3
|
+
import { A as AgentHooks, q as ModelRegistry, I as IConversationManager, b as LLMMessage, S as StreamEvent, T as TokenUsage, G as GadgetRegistry, a as LLMStreamChunk, C as CompactionStrategy, R as ResolvedCompactionConfig, r as CompactionContext, s as CompactionResult, t as LLMist, u as CompactionConfig, v as CompactionEvent, w as CompactionStats, H as HintTemplate, x as GadgetExample, B as BaseGadget, P as ParsedGadgetCall, y as GadgetExecutionResult, z as ProviderAdapter, D as ModelDescriptor, E as ModelSpec, F as LLMGenerationOptions, L as LLMStream } from './mock-stream-Cc47j12U.js';
|
|
4
|
+
export { V as AfterGadgetExecutionAction, W as AfterGadgetExecutionControllerContext, X as AfterLLMCallAction, Y as AfterLLMCallControllerContext, Z as AfterLLMErrorAction, K as AgentBuilder, _ as AgentOptions, $ as BeforeGadgetExecutionAction, a0 as BeforeLLMCallAction, a1 as ChunkInterceptorContext, a2 as Controllers, ao as CostEstimate, aj as DEFAULT_COMPACTION_CONFIG, ay as DEFAULT_HINTS, az as DEFAULT_PROMPTS, ak as DEFAULT_SUMMARIZATION_PROMPT, N as EventHandlers, aG as GadgetClass, a3 as GadgetExecutionControllerContext, aH as GadgetOrClass, a4 as GadgetParameterInterceptorContext, a5 as GadgetResultInterceptorContext, au as HintContext, J as HistoryMessage, a6 as Interceptors, a7 as LLMCallControllerContext, a8 as LLMErrorControllerContext, an as LLMMessageBuilder, am as LLMRole, al as LLMistOptions, a9 as MessageInterceptorContext, ah as MessageTurn, d as MockBuilder, f as MockManager, j as MockMatcher, k as MockMatcherContext, l as MockOptions, M as MockProviderAdapter, n as MockRegistration, o as MockResponse, p as MockStats, ap as ModelFeatures, at as ModelIdentifierParser, aq as ModelLimits, ar as ModelPricing, aa as ObserveChunkContext, ai as ObserveCompactionContext, ab as ObserveGadgetCompleteContext, ac as ObserveGadgetStartContext, ad as ObserveLLMCallContext, ae as ObserveLLMCompleteContext, af as ObserveLLMErrorContext, ag as Observers, av as PromptConfig, aw as PromptContext, ax as PromptTemplate, as as ProviderIdentifier, aD as QuickOptions, aI as TextOnlyAction, aJ as TextOnlyContext, aK as TextOnlyCustomHandler, aL as TextOnlyGadgetConfig, aM as TextOnlyHandler, aN as TextOnlyStrategy, O as collectEvents, Q as collectText, aE as complete, c as createMockAdapter, e as createMockClient, h as createMockStream, i as createTextMockStream, g as getMockManager, m as mockLLM, aA as resolveHintTemplate, aB as resolvePromptTemplate, aC as resolveRulesTemplate, U as runWithHandlers, aF as stream } from './mock-stream-Cc47j12U.js';
|
|
5
5
|
import { Logger, ILogObj } from 'tslog';
|
|
6
6
|
import { MessageCreateParamsStreaming, MessageStreamEvent } from '@anthropic-ai/sdk/resources/messages';
|
|
7
7
|
import OpenAI from 'openai';
|
|
@@ -1786,7 +1786,11 @@ declare function Gadget<TSchema extends ZodType>(config: GadgetConfig<TSchema>):
|
|
|
1786
1786
|
*/
|
|
1787
1787
|
execute(params: Record<string, unknown>): string | Promise<string>;
|
|
1788
1788
|
get instruction(): string;
|
|
1789
|
-
getInstruction(
|
|
1789
|
+
getInstruction(optionsOrArgPrefix?: string | {
|
|
1790
|
+
argPrefix?: string;
|
|
1791
|
+
startPrefix?: string;
|
|
1792
|
+
endPrefix?: string;
|
|
1793
|
+
}): string;
|
|
1790
1794
|
} & {
|
|
1791
1795
|
params: InferSchema<TSchema>;
|
|
1792
1796
|
};
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
iterationProgressHint,
|
|
6
6
|
parallelGadgetHint,
|
|
7
7
|
z
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-QR5IQXEM.js";
|
|
9
9
|
import {
|
|
10
10
|
AgentBuilder,
|
|
11
11
|
AnthropicMessagesProvider,
|
|
@@ -64,7 +64,7 @@ import {
|
|
|
64
64
|
stream,
|
|
65
65
|
validateAndApplyDefaults,
|
|
66
66
|
validateGadgetParams
|
|
67
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-X5XQ6M5P.js";
|
|
68
68
|
export {
|
|
69
69
|
AgentBuilder,
|
|
70
70
|
AnthropicMessagesProvider,
|
|
@@ -490,10 +490,14 @@ declare abstract class BaseGadget {
|
|
|
490
490
|
* Generate instruction text for the LLM.
|
|
491
491
|
* Combines name, description, and parameter schema into a formatted instruction.
|
|
492
492
|
*
|
|
493
|
-
* @param
|
|
493
|
+
* @param optionsOrArgPrefix - Optional custom prefixes for examples, or just argPrefix string for backwards compatibility
|
|
494
494
|
* @returns Formatted instruction string
|
|
495
495
|
*/
|
|
496
|
-
getInstruction(
|
|
496
|
+
getInstruction(optionsOrArgPrefix?: string | {
|
|
497
|
+
argPrefix?: string;
|
|
498
|
+
startPrefix?: string;
|
|
499
|
+
endPrefix?: string;
|
|
500
|
+
}): string;
|
|
497
501
|
}
|
|
498
502
|
|
|
499
503
|
/**
|
|
@@ -490,10 +490,14 @@ declare abstract class BaseGadget {
|
|
|
490
490
|
* Generate instruction text for the LLM.
|
|
491
491
|
* Combines name, description, and parameter schema into a formatted instruction.
|
|
492
492
|
*
|
|
493
|
-
* @param
|
|
493
|
+
* @param optionsOrArgPrefix - Optional custom prefixes for examples, or just argPrefix string for backwards compatibility
|
|
494
494
|
* @returns Formatted instruction string
|
|
495
495
|
*/
|
|
496
|
-
getInstruction(
|
|
496
|
+
getInstruction(optionsOrArgPrefix?: string | {
|
|
497
|
+
argPrefix?: string;
|
|
498
|
+
startPrefix?: string;
|
|
499
|
+
endPrefix?: string;
|
|
500
|
+
}): string;
|
|
497
501
|
}
|
|
498
502
|
|
|
499
503
|
/**
|
package/dist/testing/index.cjs
CHANGED
|
@@ -829,38 +829,83 @@ function formatParamsAsBlock(params, prefix = "", argPrefix = GADGET_ARG_PREFIX)
|
|
|
829
829
|
}
|
|
830
830
|
return lines.join("\n");
|
|
831
831
|
}
|
|
832
|
-
function
|
|
832
|
+
function formatParamLine(key, propObj, isRequired, indent = "") {
|
|
833
|
+
const type = propObj.type;
|
|
834
|
+
const description = propObj.description;
|
|
835
|
+
const enumValues = propObj.enum;
|
|
836
|
+
let line = `${indent}- ${key}`;
|
|
837
|
+
if (type === "array") {
|
|
838
|
+
const items = propObj.items;
|
|
839
|
+
const itemType = items?.type || "any";
|
|
840
|
+
line += ` (array of ${itemType})`;
|
|
841
|
+
} else if (type === "object" && propObj.properties) {
|
|
842
|
+
line += " (object)";
|
|
843
|
+
} else {
|
|
844
|
+
line += ` (${type})`;
|
|
845
|
+
}
|
|
846
|
+
if (isRequired && indent !== "") {
|
|
847
|
+
line += " [required]";
|
|
848
|
+
}
|
|
849
|
+
if (description) {
|
|
850
|
+
line += `: ${description}`;
|
|
851
|
+
}
|
|
852
|
+
if (enumValues) {
|
|
853
|
+
line += ` - one of: ${enumValues.map((v) => `"${v}"`).join(", ")}`;
|
|
854
|
+
}
|
|
855
|
+
return line;
|
|
856
|
+
}
|
|
857
|
+
function formatSchemaAsPlainText(schema, indent = "", atRoot = true) {
|
|
833
858
|
const lines = [];
|
|
834
859
|
const properties = schema.properties || {};
|
|
835
860
|
const required = schema.required || [];
|
|
836
|
-
|
|
837
|
-
const
|
|
838
|
-
const
|
|
839
|
-
const
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
const itemType = items?.type || "any";
|
|
846
|
-
line += ` (array of ${itemType})`;
|
|
847
|
-
} else if (type === "object" && propObj.properties) {
|
|
848
|
-
line += " (object)";
|
|
849
|
-
} else {
|
|
850
|
-
line += ` (${type})`;
|
|
861
|
+
if (atRoot && indent === "") {
|
|
862
|
+
const requiredProps = [];
|
|
863
|
+
const optionalProps = [];
|
|
864
|
+
for (const [key, prop] of Object.entries(properties)) {
|
|
865
|
+
if (required.includes(key)) {
|
|
866
|
+
requiredProps.push([key, prop]);
|
|
867
|
+
} else {
|
|
868
|
+
optionalProps.push([key, prop]);
|
|
869
|
+
}
|
|
851
870
|
}
|
|
852
|
-
|
|
853
|
-
|
|
871
|
+
const reqCount = requiredProps.length;
|
|
872
|
+
const optCount = optionalProps.length;
|
|
873
|
+
if (reqCount > 0 || optCount > 0) {
|
|
874
|
+
const parts = [];
|
|
875
|
+
if (reqCount > 0) parts.push(`${reqCount} required`);
|
|
876
|
+
if (optCount > 0) parts.push(`${optCount} optional`);
|
|
877
|
+
lines.push(parts.join(", "));
|
|
878
|
+
lines.push("");
|
|
854
879
|
}
|
|
855
|
-
if (
|
|
856
|
-
|
|
880
|
+
if (reqCount > 0) {
|
|
881
|
+
lines.push("REQUIRED Parameters:");
|
|
882
|
+
for (const [key, prop] of requiredProps) {
|
|
883
|
+
lines.push(formatParamLine(key, prop, true, ""));
|
|
884
|
+
const propObj = prop;
|
|
885
|
+
if (propObj.type === "object" && propObj.properties) {
|
|
886
|
+
lines.push(formatSchemaAsPlainText(propObj, " ", false));
|
|
887
|
+
}
|
|
888
|
+
}
|
|
857
889
|
}
|
|
858
|
-
if (
|
|
859
|
-
|
|
890
|
+
if (optCount > 0) {
|
|
891
|
+
if (reqCount > 0) lines.push("");
|
|
892
|
+
lines.push("OPTIONAL Parameters:");
|
|
893
|
+
for (const [key, prop] of optionalProps) {
|
|
894
|
+
lines.push(formatParamLine(key, prop, false, ""));
|
|
895
|
+
const propObj = prop;
|
|
896
|
+
if (propObj.type === "object" && propObj.properties) {
|
|
897
|
+
lines.push(formatSchemaAsPlainText(propObj, " ", false));
|
|
898
|
+
}
|
|
899
|
+
}
|
|
860
900
|
}
|
|
861
|
-
lines.
|
|
862
|
-
|
|
863
|
-
|
|
901
|
+
return lines.join("\n");
|
|
902
|
+
}
|
|
903
|
+
for (const [key, prop] of Object.entries(properties)) {
|
|
904
|
+
const isRequired = required.includes(key);
|
|
905
|
+
lines.push(formatParamLine(key, prop, isRequired, indent));
|
|
906
|
+
const propObj = prop;
|
|
907
|
+
if (propObj.type === "object" && propObj.properties) {
|
|
908
|
+
lines.push(formatSchemaAsPlainText(propObj, indent + " ", false));
|
|
864
909
|
}
|
|
865
910
|
}
|
|
866
911
|
return lines.join("\n");
|
|
@@ -911,10 +956,11 @@ var init_gadget = __esm({
|
|
|
911
956
|
* Generate instruction text for the LLM.
|
|
912
957
|
* Combines name, description, and parameter schema into a formatted instruction.
|
|
913
958
|
*
|
|
914
|
-
* @param
|
|
959
|
+
* @param optionsOrArgPrefix - Optional custom prefixes for examples, or just argPrefix string for backwards compatibility
|
|
915
960
|
* @returns Formatted instruction string
|
|
916
961
|
*/
|
|
917
|
-
getInstruction(
|
|
962
|
+
getInstruction(optionsOrArgPrefix) {
|
|
963
|
+
const options = typeof optionsOrArgPrefix === "string" ? { argPrefix: optionsOrArgPrefix } : optionsOrArgPrefix;
|
|
918
964
|
const parts = [];
|
|
919
965
|
parts.push(this.description);
|
|
920
966
|
if (this.parameterSchema) {
|
|
@@ -928,18 +974,25 @@ var init_gadget = __esm({
|
|
|
928
974
|
}
|
|
929
975
|
if (this.examples && this.examples.length > 0) {
|
|
930
976
|
parts.push("\n\nExamples:");
|
|
931
|
-
const effectiveArgPrefix = argPrefix ?? GADGET_ARG_PREFIX;
|
|
977
|
+
const effectiveArgPrefix = options?.argPrefix ?? GADGET_ARG_PREFIX;
|
|
978
|
+
const effectiveStartPrefix = options?.startPrefix ?? GADGET_START_PREFIX;
|
|
979
|
+
const effectiveEndPrefix = options?.endPrefix ?? GADGET_END_PREFIX;
|
|
980
|
+
const gadgetName = this.name || this.constructor.name;
|
|
932
981
|
this.examples.forEach((example, index) => {
|
|
933
982
|
if (index > 0) {
|
|
934
983
|
parts.push("");
|
|
984
|
+
parts.push("---");
|
|
985
|
+
parts.push("");
|
|
935
986
|
}
|
|
936
987
|
if (example.comment) {
|
|
937
988
|
parts.push(`# ${example.comment}`);
|
|
938
989
|
}
|
|
939
|
-
parts.push(
|
|
990
|
+
parts.push(`${effectiveStartPrefix}${gadgetName}`);
|
|
940
991
|
parts.push(formatParamsAsBlock(example.params, "", effectiveArgPrefix));
|
|
992
|
+
parts.push(effectiveEndPrefix);
|
|
941
993
|
if (example.output !== void 0) {
|
|
942
|
-
parts.push("
|
|
994
|
+
parts.push("");
|
|
995
|
+
parts.push("Expected Output:");
|
|
943
996
|
parts.push(example.output);
|
|
944
997
|
}
|
|
945
998
|
});
|