llmist 0.4.1 → 0.5.1
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 +4 -1
- package/dist/{chunk-QVDGTUQN.js → chunk-LKIBXQ5I.js} +3 -2
- package/dist/chunk-LKIBXQ5I.js.map +1 -0
- package/dist/{chunk-LQE7TKKW.js → chunk-MH4TQ5AD.js} +429 -60
- package/dist/chunk-MH4TQ5AD.js.map +1 -0
- package/dist/{chunk-A4GRCCXF.js → chunk-VF2WOCHM.js} +2 -2
- package/dist/cli.cjs +1201 -165
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +773 -107
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +431 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -4
- package/dist/index.d.ts +19 -4
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/{mock-stream-C0vOqI3L.d.cts → mock-stream-C8mBXRzJ.d.cts} +58 -3
- package/dist/{mock-stream-C0vOqI3L.d.ts → mock-stream-C8mBXRzJ.d.ts} +58 -3
- package/dist/testing/index.cjs +429 -60
- 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 +5 -1
- package/dist/chunk-LQE7TKKW.js.map +0 -1
- package/dist/chunk-QVDGTUQN.js.map +0 -1
- /package/dist/{chunk-A4GRCCXF.js.map → chunk-VF2WOCHM.js.map} +0 -0
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
import { Logger, ILogObj } from 'tslog';
|
|
2
2
|
import { ZodTypeAny } from 'zod';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Example of gadget usage to help LLMs understand proper invocation.
|
|
6
|
+
*
|
|
7
|
+
* Examples are rendered alongside the schema in `getInstruction()` to provide
|
|
8
|
+
* concrete usage patterns for the LLM.
|
|
9
|
+
*
|
|
10
|
+
* @template TParams - Inferred parameter type from Zod schema (defaults to Record<string, unknown>)
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const calculator = createGadget({
|
|
15
|
+
* schema: z.object({ a: z.number(), b: z.number() }),
|
|
16
|
+
* examples: [
|
|
17
|
+
* { params: { a: 5, b: 3 }, output: "8", comment: "Addition example" }
|
|
18
|
+
* ],
|
|
19
|
+
* // ...
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
interface GadgetExample<TParams = Record<string, unknown>> {
|
|
24
|
+
/** Example parameter values (typed to match schema) */
|
|
25
|
+
params: TParams;
|
|
26
|
+
/** Optional expected output/result string */
|
|
27
|
+
output?: string;
|
|
28
|
+
/** Optional description explaining what this example demonstrates */
|
|
29
|
+
comment?: string;
|
|
30
|
+
}
|
|
4
31
|
interface GadgetExecutionResult {
|
|
5
32
|
gadgetName: string;
|
|
6
33
|
invocationId: string;
|
|
@@ -89,7 +116,7 @@ type TextOnlyAction = {
|
|
|
89
116
|
parameters: Record<string, unknown>;
|
|
90
117
|
};
|
|
91
118
|
|
|
92
|
-
type ParameterFormat = "json" | "yaml" | "auto";
|
|
119
|
+
type ParameterFormat = "json" | "yaml" | "toml" | "auto";
|
|
93
120
|
interface StreamParserOptions {
|
|
94
121
|
startPrefix?: string;
|
|
95
122
|
endPrefix?: string;
|
|
@@ -110,6 +137,11 @@ declare class StreamParser {
|
|
|
110
137
|
private readonly parameterFormat;
|
|
111
138
|
constructor(options?: StreamParserOptions);
|
|
112
139
|
private takeTextUntil;
|
|
140
|
+
/**
|
|
141
|
+
* Parse gadget name, handling both old format (name:invocationId) and new format (just name).
|
|
142
|
+
* For new format, generates a unique invocation ID.
|
|
143
|
+
*/
|
|
144
|
+
private parseGadgetName;
|
|
113
145
|
/**
|
|
114
146
|
* Parse parameter string according to configured format
|
|
115
147
|
*/
|
|
@@ -149,6 +181,14 @@ declare abstract class BaseGadget {
|
|
|
149
181
|
* Set to 0 or undefined to disable timeout for this gadget.
|
|
150
182
|
*/
|
|
151
183
|
timeoutMs?: number;
|
|
184
|
+
/**
|
|
185
|
+
* Optional usage examples to help LLMs understand proper invocation.
|
|
186
|
+
* Examples are rendered in getInstruction() alongside the schema.
|
|
187
|
+
*
|
|
188
|
+
* Note: Uses broader `unknown` type to allow typed examples from subclasses
|
|
189
|
+
* while maintaining runtime compatibility.
|
|
190
|
+
*/
|
|
191
|
+
examples?: GadgetExample<unknown>[];
|
|
152
192
|
/**
|
|
153
193
|
* Execute the gadget with the given parameters.
|
|
154
194
|
* Can be synchronous or asynchronous.
|
|
@@ -167,7 +207,7 @@ declare abstract class BaseGadget {
|
|
|
167
207
|
* Generate instruction text for the LLM with format-specific schema.
|
|
168
208
|
* Combines name, description, and parameter schema into a formatted instruction.
|
|
169
209
|
*
|
|
170
|
-
* @param format - Format for the schema representation ('json' | 'yaml' | 'auto')
|
|
210
|
+
* @param format - Format for the schema representation ('json' | 'yaml' | 'toml' | 'auto')
|
|
171
211
|
* @returns Formatted instruction string
|
|
172
212
|
*/
|
|
173
213
|
getInstruction(format?: ParameterFormat): string;
|
|
@@ -232,6 +272,11 @@ interface PromptConfig {
|
|
|
232
272
|
* Default: "Parameters in JSON format (valid JSON object)"
|
|
233
273
|
*/
|
|
234
274
|
formatDescriptionJson?: PromptTemplate;
|
|
275
|
+
/**
|
|
276
|
+
* Format description for TOML parameter format.
|
|
277
|
+
* Default: "Parameters in TOML format (key = value pairs, use triple-quotes for multiline)"
|
|
278
|
+
*/
|
|
279
|
+
formatDescriptionToml?: PromptTemplate;
|
|
235
280
|
/**
|
|
236
281
|
* Rules that appear in the rules section.
|
|
237
282
|
* Can be an array of strings or a function that returns an array.
|
|
@@ -248,6 +293,11 @@ interface PromptConfig {
|
|
|
248
293
|
* Default: "\n\nInput Schema (YAML):"
|
|
249
294
|
*/
|
|
250
295
|
schemaLabelYaml?: PromptTemplate;
|
|
296
|
+
/**
|
|
297
|
+
* Schema label for TOML format.
|
|
298
|
+
* Default: "\n\nInput Schema (TOML):"
|
|
299
|
+
*/
|
|
300
|
+
schemaLabelToml?: PromptTemplate;
|
|
251
301
|
/**
|
|
252
302
|
* Custom examples to show in the examples section.
|
|
253
303
|
* If provided, replaces the default examples entirely.
|
|
@@ -285,6 +335,11 @@ declare class LLMMessageBuilder {
|
|
|
285
335
|
private endPrefix;
|
|
286
336
|
private promptConfig;
|
|
287
337
|
constructor(promptConfig?: PromptConfig);
|
|
338
|
+
/**
|
|
339
|
+
* Set custom prefixes for gadget markers.
|
|
340
|
+
* Used to configure history builder to match system prompt markers.
|
|
341
|
+
*/
|
|
342
|
+
withPrefixes(startPrefix: string, endPrefix: string): this;
|
|
288
343
|
addSystem(content: string, metadata?: Record<string, unknown>): this;
|
|
289
344
|
addGadgets(gadgets: BaseGadget[], parameterFormat?: ParameterFormat, options?: {
|
|
290
345
|
startPrefix?: string;
|
|
@@ -2598,4 +2653,4 @@ declare function createTextMockStream(text: string, options?: {
|
|
|
2598
2653
|
usage?: MockResponse["usage"];
|
|
2599
2654
|
}): LLMStream;
|
|
2600
2655
|
|
|
2601
|
-
export { type
|
|
2656
|
+
export { type MessageInterceptorContext as $, type AgentHooks as A, BaseGadget as B, collectText as C, runWithHandlers as D, type EventHandlers as E, type AfterGadgetExecutionAction as F, GadgetRegistry as G, type HistoryMessage as H, type AfterGadgetExecutionControllerContext as I, type AfterLLMCallAction as J, type AfterLLMCallControllerContext as K, type LLMMessage as L, MockProviderAdapter as M, type AfterLLMErrorAction as N, type AgentOptions as O, type ParameterFormat as P, type BeforeGadgetExecutionAction as Q, type BeforeLLMCallAction as R, type StreamEvent as S, type ChunkInterceptorContext as T, type Controllers as U, type GadgetExecutionControllerContext as V, type GadgetParameterInterceptorContext as W, type GadgetResultInterceptorContext as X, type Interceptors as Y, type LLMCallControllerContext as Z, type LLMErrorControllerContext as _, MockBuilder as a, type ObserveChunkContext as a0, type ObserveGadgetCompleteContext as a1, type ObserveGadgetStartContext as a2, type ObserveLLMCallContext as a3, type ObserveLLMCompleteContext as a4, type ObserveLLMErrorContext as a5, type Observers as a6, type LLMistOptions as a7, LLMist as a8, type LLMRole as a9, LLMMessageBuilder as aa, type CostEstimate as ab, type ModelFeatures as ac, type ModelLimits as ad, type ModelPricing as ae, type ProviderIdentifier as af, type TokenUsage as ag, ModelIdentifierParser as ah, type PromptConfig as ai, type PromptContext as aj, type PromptTemplate as ak, DEFAULT_PROMPTS as al, resolvePromptTemplate as am, resolveRulesTemplate as an, type QuickOptions as ao, complete as ap, stream as aq, StreamParser as ar, type GadgetClass as as, type GadgetOrClass as at, type TextOnlyAction as au, type TextOnlyContext as av, type TextOnlyCustomHandler as aw, type TextOnlyGadgetConfig as ax, type TextOnlyHandler as ay, type TextOnlyStrategy as az, createMockClient as b, createMockAdapter as c, MockManager as d, createMockStream as e, createTextMockStream as f, getMockManager as g, type MockMatcher as h, type MockMatcherContext as i, type MockOptions as j, type MockRegistration as k, type MockResponse as l, mockLLM as m, type MockStats as n, ModelRegistry as o, type LLMStreamChunk as p, type GadgetExample as q, type ParsedGadgetCall as r, type GadgetExecutionResult as s, type ProviderAdapter as t, type ModelDescriptor as u, type ModelSpec as v, type LLMGenerationOptions as w, type LLMStream as x, AgentBuilder as y, collectEvents as z };
|