@isdk/ai-tool 0.0.2
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.cn.md +261 -0
- package/README.md +3 -0
- package/dist/chunk-EZFPVSGF.mjs +22 -0
- package/dist/chunk-PKECBABP.mjs +5085 -0
- package/dist/funcs.d.mts +6 -0
- package/dist/funcs.d.ts +6 -0
- package/dist/funcs.js +5016 -0
- package/dist/funcs.mjs +37 -0
- package/dist/index-D4KjfAKl.d.mts +606 -0
- package/dist/index-D4KjfAKl.d.ts +606 -0
- package/dist/index.d.mts +1097 -0
- package/dist/index.d.ts +1097 -0
- package/dist/index.js +5239 -0
- package/dist/index.mjs +399 -0
- package/dist/test/util.d.mts +7 -0
- package/dist/test/util.d.ts +7 -0
- package/dist/test/util.js +98 -0
- package/dist/test/util.mjs +61 -0
- package/docs/.nojekyll +1 -0
- package/docs/README.md +5 -0
- package/docs/classes/AbortError.md +359 -0
- package/docs/classes/AlreadyExistsError.md +339 -0
- package/docs/classes/BaseError.md +346 -0
- package/docs/classes/ClientTools.md +2705 -0
- package/docs/classes/CommonError.md +368 -0
- package/docs/classes/ConfigFile.md +346 -0
- package/docs/classes/EventClient.md +3183 -0
- package/docs/classes/EventServer.md +3138 -0
- package/docs/classes/EventToolFunc.md +2498 -0
- package/docs/classes/FStringPromptTemplate.md +1236 -0
- package/docs/classes/FewShotPromptTemplate.md +1286 -0
- package/docs/classes/GolangPromptTemplate.md +1236 -0
- package/docs/classes/HFEnvironment.md +212 -0
- package/docs/classes/HFInterpreter.md +386 -0
- package/docs/classes/HFTemplate.md +79 -0
- package/docs/classes/HfPromptTemplate.md +1236 -0
- package/docs/classes/NotFoundError.md +339 -0
- package/docs/classes/NotImplementationError.md +339 -0
- package/docs/classes/PromptExampleSelector.md +207 -0
- package/docs/classes/PromptTemplate.md +1163 -0
- package/docs/classes/ReadableStreamError.md +359 -0
- package/docs/classes/ResClientTools.md +2859 -0
- package/docs/classes/ResServerTools.md +2783 -0
- package/docs/classes/SSEChannel.md +289 -0
- package/docs/classes/ServerTools.md +2633 -0
- package/docs/classes/ToolFunc.md +2124 -0
- package/docs/enums/ErrorCode.md +217 -0
- package/docs/enums/XXHashAlgorithm.md +30 -0
- package/docs/interfaces/AIChatAssistantMessageParam.md +84 -0
- package/docs/interfaces/AIChatContentPartImage.md +36 -0
- package/docs/interfaces/AIChatContentPartText.md +30 -0
- package/docs/interfaces/AIChatMessageParamBase.md +35 -0
- package/docs/interfaces/AIChatMessageToolCall.md +48 -0
- package/docs/interfaces/AIChatSystemMessageParam.md +51 -0
- package/docs/interfaces/AIChatToolMessageParam.md +62 -0
- package/docs/interfaces/AIChatUserMessageParam.md +95 -0
- package/docs/interfaces/AIResult.md +65 -0
- package/docs/interfaces/AIStreamCallbacksAndOptions.md +158 -0
- package/docs/interfaces/AIStreamParser.md +33 -0
- package/docs/interfaces/AIStreamParserOptions.md +23 -0
- package/docs/interfaces/BaseFunc.md +145 -0
- package/docs/interfaces/BaseFuncItem.md +99 -0
- package/docs/interfaces/ClientFuncItem.md +181 -0
- package/docs/interfaces/DotenvExpandOptions.md +51 -0
- package/docs/interfaces/DotenvExpandOutput.md +30 -0
- package/docs/interfaces/DotenvParseInput.md +7 -0
- package/docs/interfaces/DotenvParseOutput.md +7 -0
- package/docs/interfaces/DotenvPopulateInput.md +7 -0
- package/docs/interfaces/EventClientFuncParams.md +66 -0
- package/docs/interfaces/EventServerFuncParams.md +79 -0
- package/docs/interfaces/FewShotPromptTemplateOptions.md +179 -0
- package/docs/interfaces/FuncItem.md +130 -0
- package/docs/interfaces/FuncParam.md +67 -0
- package/docs/interfaces/FuncParams.md +7 -0
- package/docs/interfaces/Funcs.md +7 -0
- package/docs/interfaces/IOptions.md +30 -0
- package/docs/interfaces/JsonFilter.md +7 -0
- package/docs/interfaces/PromptExampleSelectorOptions.md +39 -0
- package/docs/interfaces/PromptTemplateOptions.md +84 -0
- package/docs/interfaces/RemoteFuncItem.md +167 -0
- package/docs/interfaces/ResClientFuncParams.md +34 -0
- package/docs/interfaces/ResServerFuncParams.md +79 -0
- package/docs/interfaces/SanitizeFilenameOptions.md +30 -0
- package/docs/interfaces/ServerFuncItem.md +192 -0
- package/docs/interfaces/ServerFuncParams.md +44 -0
- package/docs/modules.md +2707 -0
- package/package.json +112 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1097 @@
|
|
|
1
|
+
import { B as BaseError, A as AIModelNameRules } from './index-D4KjfAKl.js';
|
|
2
|
+
export { d as AIModelNameRule, c as AIModelNameRuleFn, m as AbortError, i as AbortErrorCode, b as ActionName, a as ActionNames, l as AlreadyExistsError, h as AlreadyExistsErrorCode, u as BaseFunc, r as BaseFuncItem, y as ClientFuncItem, D as ClientToolFuncSchema, z as ClientTools, C as CommonError, f as ErrorCode, E as ErrorCodeType, a1 as EventClient, a0 as EventClientFuncParams, a4 as EventServer, a3 as EventServerFuncParams, M as EventToolFunc, s as FuncItem, p as FuncParam, F as FuncParamType, q as FuncParams, v as Funcs, I as InternalErrorCode, k as NotFoundError, g as NotFoundErrorCode, j as NotImplementationError, N as NotImplementedErrorCode, P as PASSING_SCORE, e as RemoteFuncItem, R as RemoteToolFuncSchema, a6 as ResClientFuncParams, a7 as ResClientTools, a8 as ResClientToolsSchema, a9 as ResServerFuncParams, aa as ResServerTools, ab as ResServerToolsSchema, o as SSEChannel, S as SSEChannelAlreadyClosedErrCode, H as ServerFuncItem, G as ServerFuncParams, K as ServerToolFuncSchema, J as ServerTools, T as TFunc, w as ToolFunc, x as ToolFuncSchema, _ as _lrucache, n as createError, Q as createLRUCache, O as event, a2 as eventClient, a5 as eventServer, W as getDefaultSimilarPassingScore, X as isSimilar, U as lrucache, Z as mergeSegments, L as registerCoreTools, $ as segments, V as similarity, Y as splitSegments, t as throwError } from './index-D4KjfAKl.js';
|
|
3
|
+
import { BaseFactory } from 'custom-factory';
|
|
4
|
+
import * as custom_ability from 'custom-ability';
|
|
5
|
+
import { Event } from 'events-ex';
|
|
6
|
+
import * as _base32768 from 'base32768';
|
|
7
|
+
export { NIL as uuidNIL, parse as uuidParse, stringify as uuidStringify, validate as uuidValidate, version as uuidVersion, v1 as uuidv1, v4 as uuidv4, v5 as uuidv5 } from 'uuid';
|
|
8
|
+
export * from 'json-canonicalize';
|
|
9
|
+
export { stringify as stringifyYaml } from 'yaml';
|
|
10
|
+
export { mimeType } from 'mime-type/with-db';
|
|
11
|
+
export { Config as ConfigFile } from 'load-config-file';
|
|
12
|
+
import 'property-manager';
|
|
13
|
+
import 'secondary-cache';
|
|
14
|
+
import 'http';
|
|
15
|
+
import 'abstract-error';
|
|
16
|
+
|
|
17
|
+
declare const AITextGenerationFinishReasons: readonly ["stop", "length", "content-filter", "tool-calls", "abort", "error", "other", null];
|
|
18
|
+
type AITextGenerationFinishReason = typeof AITextGenerationFinishReasons[number];
|
|
19
|
+
interface AIResult<TValue = any, TOptions = any> {
|
|
20
|
+
/**
|
|
21
|
+
* The generated value.
|
|
22
|
+
*/
|
|
23
|
+
content?: TValue;
|
|
24
|
+
/**
|
|
25
|
+
* The reason why the generation stopped.
|
|
26
|
+
*/
|
|
27
|
+
finishReason?: AITextGenerationFinishReason;
|
|
28
|
+
options?: TOptions;
|
|
29
|
+
/**
|
|
30
|
+
* for stream mode
|
|
31
|
+
*/
|
|
32
|
+
stop?: boolean;
|
|
33
|
+
}
|
|
34
|
+
declare const AIMessageTypes: readonly ["human", "ai", "generic", "system", "tool"];
|
|
35
|
+
type AIMessageType = typeof AIMessageTypes[number];
|
|
36
|
+
declare const AIChatRoles: readonly ["user", "assistant", "system", "tool", "tool_calls"];
|
|
37
|
+
type AIChatRole = (typeof AIChatRoles[number]) & string;
|
|
38
|
+
type AIChatMessageParam = AIChatSystemMessageParam | AIChatUserMessageParam | AIChatAssistantMessageParam | AIChatToolMessageParam;
|
|
39
|
+
interface AIChatMessageParamBase {
|
|
40
|
+
role: string;
|
|
41
|
+
[name: string]: any;
|
|
42
|
+
}
|
|
43
|
+
interface AIChatSystemMessageParam extends AIChatMessageParamBase {
|
|
44
|
+
role: 'system';
|
|
45
|
+
content: string;
|
|
46
|
+
templateFormat?: string;
|
|
47
|
+
}
|
|
48
|
+
interface AIChatUserMessageParam extends AIChatMessageParamBase {
|
|
49
|
+
role: 'user';
|
|
50
|
+
content: string | Array<AIChatContentPart>;
|
|
51
|
+
createdAt?: Date | string;
|
|
52
|
+
updatedAt?: Date | string;
|
|
53
|
+
charId?: string;
|
|
54
|
+
from?: 'speech' | string;
|
|
55
|
+
templateFormat?: string;
|
|
56
|
+
}
|
|
57
|
+
type AIChatContentPart = AIChatContentPartText | AIChatContentPartImage;
|
|
58
|
+
interface AIChatContentPartImage {
|
|
59
|
+
type: 'image_url';
|
|
60
|
+
image_url: {
|
|
61
|
+
url: string;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
interface AIChatContentPartText {
|
|
65
|
+
type: 'text';
|
|
66
|
+
text: string;
|
|
67
|
+
}
|
|
68
|
+
interface AIChatAssistantMessageParam extends AIChatMessageParamBase {
|
|
69
|
+
role: 'assistant';
|
|
70
|
+
content?: string | null;
|
|
71
|
+
tool_calls?: Array<AIChatMessageToolCall>;
|
|
72
|
+
createdAt?: Date | string;
|
|
73
|
+
updatedAt?: Date | string;
|
|
74
|
+
templateFormat?: string;
|
|
75
|
+
}
|
|
76
|
+
interface AIChatMessageToolCall {
|
|
77
|
+
type: 'function';
|
|
78
|
+
id: string;
|
|
79
|
+
function: {
|
|
80
|
+
arguments: string;
|
|
81
|
+
name: string;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
interface AIChatToolMessageParam extends AIChatMessageParamBase {
|
|
85
|
+
role: 'tool';
|
|
86
|
+
content: string;
|
|
87
|
+
tool_call_id: string;
|
|
88
|
+
templateFormat?: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Prompt Type
|
|
93
|
+
* defaults to `chat`
|
|
94
|
+
*/
|
|
95
|
+
declare const PromptTypes: readonly ["chat", "char", "plan"];
|
|
96
|
+
type PromptType = typeof PromptTypes[number];
|
|
97
|
+
declare const PromptTemplateTypes: readonly ["internal", "hf", "fill"];
|
|
98
|
+
type PromptTemplateType = typeof PromptTemplateTypes[number];
|
|
99
|
+
|
|
100
|
+
declare const defaultTemplateFormat = "default";
|
|
101
|
+
interface PromptTemplateOptions {
|
|
102
|
+
template?: string;
|
|
103
|
+
data?: Record<string, any>;
|
|
104
|
+
templateFormat?: string;
|
|
105
|
+
inputVariables?: string[];
|
|
106
|
+
compiledTemplate?: any;
|
|
107
|
+
ignoreInitialize?: boolean;
|
|
108
|
+
[name: string]: any;
|
|
109
|
+
}
|
|
110
|
+
declare class PromptTemplate extends BaseFactory {
|
|
111
|
+
compiledTemplate: any;
|
|
112
|
+
template: string;
|
|
113
|
+
templateFormat: string | undefined;
|
|
114
|
+
data: Record<string, any> | undefined;
|
|
115
|
+
inputVariables: string[] | undefined;
|
|
116
|
+
static from(template?: string | PromptTemplateOptions, options?: PromptTemplateOptions): PromptTemplate;
|
|
117
|
+
static format(options: PromptTemplateOptions): Promise<string>;
|
|
118
|
+
/**
|
|
119
|
+
* If the given options.template is the template, perform formatting using that template.
|
|
120
|
+
* @param options - The options object to check for being a template and to format.
|
|
121
|
+
* @returns A Promise that resolves to the formatted result if options is a template; otherwise, no value is returned.
|
|
122
|
+
*/
|
|
123
|
+
static formatIf(options: PromptTemplateOptions): Promise<string | undefined>;
|
|
124
|
+
static isTemplate(templateOpt: PromptTemplateOptions): any;
|
|
125
|
+
/**
|
|
126
|
+
* Validate/filter the data in inputVariables
|
|
127
|
+
* @param data
|
|
128
|
+
* @returns
|
|
129
|
+
*/
|
|
130
|
+
filterData(data: Record<string, any>): Record<string, any>;
|
|
131
|
+
constructor(template?: string | PromptTemplateOptions, options?: PromptTemplateOptions);
|
|
132
|
+
_initialize(options?: PromptTemplateOptions): void;
|
|
133
|
+
initialize(options?: PromptTemplateOptions): void;
|
|
134
|
+
_format(data: Record<string, any>): string | Promise<string>;
|
|
135
|
+
format(data?: Record<string, any>): Promise<string>;
|
|
136
|
+
/**
|
|
137
|
+
* it can make sense to "partial" a prompt template - eg pass in a subset of the required values, as to create a new prompt template which expects only the remaining subset of values.
|
|
138
|
+
* @param data the partial data
|
|
139
|
+
* @returns the new partial PromptTemplate instance
|
|
140
|
+
*/
|
|
141
|
+
partial(data: Record<string, any>): PromptTemplate;
|
|
142
|
+
toJSON(options?: PromptTemplateOptions): PromptTemplateOptions;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
type PromptExamples<T = any> = Iterable<PromiseLike<T> | T> | AsyncIterable<T>;
|
|
146
|
+
interface PromptExampleSelectorOptions {
|
|
147
|
+
/**
|
|
148
|
+
* The maximum count of the selected examples, or `undefined` if no limit.
|
|
149
|
+
*/
|
|
150
|
+
maxLength?: number;
|
|
151
|
+
/**
|
|
152
|
+
* The threshold probability (0-1) at which a sample is selected.
|
|
153
|
+
* If `true`, defaults to 0.5; if `false`, disable it.
|
|
154
|
+
*/
|
|
155
|
+
threshold?: number | boolean;
|
|
156
|
+
[name: string]: any;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* The `PromptExampleSelector` class provides a mechanism to selectively choose examples from a given set based on
|
|
160
|
+
* configurable options such as maximum length and probability threshold. This class is meant to be extended and customized
|
|
161
|
+
* with an implementation of the `selectExample` method.
|
|
162
|
+
*
|
|
163
|
+
* @template T The type of the prompt examples.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
*
|
|
167
|
+
* // Custom selector that selects examples based on a custom condition
|
|
168
|
+
* class MyPromptExampleSelector extends PromptExampleSelector<string> {
|
|
169
|
+
* selectExample(example: string, threshold?: number): string | void {
|
|
170
|
+
* if (example.includes('keyword')) {
|
|
171
|
+
* return super.selectExample(example, threshold);
|
|
172
|
+
* }
|
|
173
|
+
* }
|
|
174
|
+
* }
|
|
175
|
+
*
|
|
176
|
+
* // Create an instance with examples and options
|
|
177
|
+
* const examples = ['example1', 'keyword1', 'keyword2', 'keyword3', 'example2', 'keyword4'];
|
|
178
|
+
* const selector = new MyPromptExampleSelector(examples, { maxLength: 2, threshold: 0.8 });
|
|
179
|
+
*
|
|
180
|
+
* // Iterate through selected examples
|
|
181
|
+
* for await (const selectedExample of selector) {
|
|
182
|
+
* console.log(selectedExample);
|
|
183
|
+
* }
|
|
184
|
+
*
|
|
185
|
+
*/
|
|
186
|
+
declare class PromptExampleSelector<T = any> {
|
|
187
|
+
maxLength: number | undefined;
|
|
188
|
+
/**
|
|
189
|
+
* The probability threshold (0-1) for selecting an example. If `undefined`, no filtering by probability occurs.
|
|
190
|
+
*/
|
|
191
|
+
threshold: number | undefined;
|
|
192
|
+
/**
|
|
193
|
+
* The collection of prompt examples.
|
|
194
|
+
*/
|
|
195
|
+
examples: PromptExamples<T>;
|
|
196
|
+
/**
|
|
197
|
+
* Constructs a new `PromptExampleSelector` instance with the given examples and options.
|
|
198
|
+
* @param examples - The prompt examples to select from.
|
|
199
|
+
* @param options - An optional configuration object.
|
|
200
|
+
*/
|
|
201
|
+
constructor(examples: PromptExamples<T>, options?: PromptExampleSelectorOptions);
|
|
202
|
+
/**
|
|
203
|
+
* Initializes the selector with examples and options.
|
|
204
|
+
* @param examples - The prompt examples to select from.
|
|
205
|
+
* @param options - An optional configuration object.
|
|
206
|
+
*/
|
|
207
|
+
initialize(examples: PromptExamples<T>, options?: PromptExampleSelectorOptions): void;
|
|
208
|
+
/**
|
|
209
|
+
* Select an example. Can overwrite this in subclasses.
|
|
210
|
+
* @param example - The example to potentially select.
|
|
211
|
+
* @param [threshold] - report the current probability [0-1) for the selecting example.
|
|
212
|
+
* @returns The selected example, or `undefined` if not selected.
|
|
213
|
+
*/
|
|
214
|
+
selectExample(example: T, threshold?: number): T | void;
|
|
215
|
+
/**
|
|
216
|
+
* Asynchronously selects examples from the given examples, applying the configured threshold (if any).
|
|
217
|
+
* @param examples - The examples to select from. Defaults to the selector's examples if not provided.
|
|
218
|
+
* @returns An asynchronous iterator yielding selected examples.
|
|
219
|
+
*/
|
|
220
|
+
selectExamples(examples?: PromptExamples<T>): AsyncGenerator<Awaited<T>, void, unknown>;
|
|
221
|
+
/**
|
|
222
|
+
* Returns an asynchronous iterator for the selected examples.
|
|
223
|
+
* @returns An asynchronous iterator over the selected examples.
|
|
224
|
+
*/
|
|
225
|
+
[Symbol.asyncIterator](): AsyncGenerator<Awaited<T>, void, unknown>;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Represents tokens that our language understands in parsing.
|
|
230
|
+
*/
|
|
231
|
+
declare const TOKEN_TYPES: Readonly<{
|
|
232
|
+
Text: "Text";
|
|
233
|
+
NumericLiteral: "NumericLiteral";
|
|
234
|
+
BooleanLiteral: "BooleanLiteral";
|
|
235
|
+
StringLiteral: "StringLiteral";
|
|
236
|
+
Identifier: "Identifier";
|
|
237
|
+
Equals: "Equals";
|
|
238
|
+
OpenParen: "OpenParen";
|
|
239
|
+
CloseParen: "CloseParen";
|
|
240
|
+
OpenStatement: "OpenStatement";
|
|
241
|
+
CloseStatement: "CloseStatement";
|
|
242
|
+
OpenExpression: "OpenExpression";
|
|
243
|
+
CloseExpression: "CloseExpression";
|
|
244
|
+
OpenSquareBracket: "OpenSquareBracket";
|
|
245
|
+
CloseSquareBracket: "CloseSquareBracket";
|
|
246
|
+
OpenCurlyBracket: "OpenCurlyBracket";
|
|
247
|
+
CloseCurlyBracket: "CloseCurlyBracket";
|
|
248
|
+
Comma: "Comma";
|
|
249
|
+
Dot: "Dot";
|
|
250
|
+
Colon: "Colon";
|
|
251
|
+
Pipe: "Pipe";
|
|
252
|
+
CallOperator: "CallOperator";
|
|
253
|
+
AdditiveBinaryOperator: "AdditiveBinaryOperator";
|
|
254
|
+
MultiplicativeBinaryOperator: "MultiplicativeBinaryOperator";
|
|
255
|
+
ComparisonBinaryOperator: "ComparisonBinaryOperator";
|
|
256
|
+
UnaryOperator: "UnaryOperator";
|
|
257
|
+
Set: "Set";
|
|
258
|
+
If: "If";
|
|
259
|
+
For: "For";
|
|
260
|
+
In: "In";
|
|
261
|
+
Is: "Is";
|
|
262
|
+
NotIn: "NotIn";
|
|
263
|
+
Else: "Else";
|
|
264
|
+
EndIf: "EndIf";
|
|
265
|
+
ElseIf: "ElseIf";
|
|
266
|
+
EndFor: "EndFor";
|
|
267
|
+
And: "And";
|
|
268
|
+
Or: "Or";
|
|
269
|
+
Not: "UnaryOperator";
|
|
270
|
+
}>;
|
|
271
|
+
type TokenType = keyof typeof TOKEN_TYPES;
|
|
272
|
+
/**
|
|
273
|
+
* Represents a single token in the template.
|
|
274
|
+
*/
|
|
275
|
+
declare class Token {
|
|
276
|
+
value: string;
|
|
277
|
+
type: TokenType;
|
|
278
|
+
/**
|
|
279
|
+
* Constructs a new Token.
|
|
280
|
+
* @param {string} value The raw value as seen inside the source code.
|
|
281
|
+
* @param {TokenType} type The type of token.
|
|
282
|
+
*/
|
|
283
|
+
constructor(value: string, type: TokenType);
|
|
284
|
+
}
|
|
285
|
+
interface PreprocessOptions {
|
|
286
|
+
trim_blocks?: boolean;
|
|
287
|
+
lstrip_blocks?: boolean;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Generate a list of tokens from a source string.
|
|
291
|
+
*/
|
|
292
|
+
declare function tokenize(source: string, options?: PreprocessOptions): Token[];
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Statements do not result in a value at runtime. They contain one or more expressions internally.
|
|
296
|
+
*/
|
|
297
|
+
declare class Statement {
|
|
298
|
+
isStatement: boolean;
|
|
299
|
+
type: string;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Defines a block which contains many statements. Each chat template corresponds to one Program.
|
|
303
|
+
*/
|
|
304
|
+
declare class Program extends Statement {
|
|
305
|
+
body: Statement[];
|
|
306
|
+
type: string;
|
|
307
|
+
constructor(body: Statement[]);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Generate the Abstract Syntax Tree (AST) from a list of tokens.
|
|
312
|
+
* Operator precedence can be found here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_precedence#table
|
|
313
|
+
*/
|
|
314
|
+
declare function parse(tokens: Token[]): Program;
|
|
315
|
+
|
|
316
|
+
type AnyRuntimeValue = NumericValue | StringValue | BooleanValue | ObjectValue | ArrayValue | FunctionValue | NullValue | UndefinedValue;
|
|
317
|
+
/**
|
|
318
|
+
* Abstract base class for all Runtime values.
|
|
319
|
+
* Should not be instantiated directly.
|
|
320
|
+
*/
|
|
321
|
+
declare abstract class RuntimeValue<T> {
|
|
322
|
+
type: string;
|
|
323
|
+
value: T;
|
|
324
|
+
/**
|
|
325
|
+
* A collection of built-in functions for this type.
|
|
326
|
+
*/
|
|
327
|
+
builtins: Map<string, AnyRuntimeValue>;
|
|
328
|
+
/**
|
|
329
|
+
* Creates a new RuntimeValue.
|
|
330
|
+
*/
|
|
331
|
+
constructor(value?: T);
|
|
332
|
+
/**
|
|
333
|
+
* Determines truthiness or falsiness of the runtime value.
|
|
334
|
+
* This function should be overridden by subclasses if it has custom truthiness criteria.
|
|
335
|
+
* @returns {BooleanValue} BooleanValue(true) if the value is truthy, BooleanValue(false) otherwise.
|
|
336
|
+
*/
|
|
337
|
+
__bool__(): BooleanValue;
|
|
338
|
+
toString(): string;
|
|
339
|
+
toJSON(): any;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Represents a numeric value at runtime.
|
|
343
|
+
*/
|
|
344
|
+
declare class NumericValue extends RuntimeValue<number> {
|
|
345
|
+
type: string;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Represents a string value at runtime.
|
|
349
|
+
*/
|
|
350
|
+
declare class StringValue extends RuntimeValue<string> {
|
|
351
|
+
type: string;
|
|
352
|
+
builtins: Map<string, AnyRuntimeValue>;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Represents a boolean value at runtime.
|
|
356
|
+
*/
|
|
357
|
+
declare class BooleanValue extends RuntimeValue<boolean> {
|
|
358
|
+
type: string;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Represents an Object value at runtime.
|
|
362
|
+
*/
|
|
363
|
+
declare class ObjectValue extends RuntimeValue<Map<string, AnyRuntimeValue>> {
|
|
364
|
+
orgValue?: Record<string, any> | undefined;
|
|
365
|
+
type: string;
|
|
366
|
+
constructor(value: Map<string, AnyRuntimeValue>, orgValue?: Record<string, any> | undefined);
|
|
367
|
+
toString(): string;
|
|
368
|
+
toJSON(): Record<string, any>;
|
|
369
|
+
/**
|
|
370
|
+
* NOTE: necessary to override since all JavaScript arrays are considered truthy,
|
|
371
|
+
* while only non-empty Python arrays are consider truthy.
|
|
372
|
+
*
|
|
373
|
+
* e.g.,
|
|
374
|
+
* - JavaScript: {} && 5 -> 5
|
|
375
|
+
* - Python: {} and 5 -> {}
|
|
376
|
+
*/
|
|
377
|
+
__bool__(): BooleanValue;
|
|
378
|
+
builtins: Map<string, AnyRuntimeValue>;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Represents an Array value at runtime.
|
|
382
|
+
*/
|
|
383
|
+
declare class ArrayValue extends RuntimeValue<AnyRuntimeValue[]> {
|
|
384
|
+
type: string;
|
|
385
|
+
builtins: Map<string, AnyRuntimeValue>;
|
|
386
|
+
/**
|
|
387
|
+
* NOTE: necessary to override since all JavaScript arrays are considered truthy,
|
|
388
|
+
* while only non-empty Python arrays are consider truthy.
|
|
389
|
+
*
|
|
390
|
+
* e.g.,
|
|
391
|
+
* - JavaScript: [] && 5 -> 5
|
|
392
|
+
* - Python: [] and 5 -> []
|
|
393
|
+
*/
|
|
394
|
+
__bool__(): BooleanValue;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Represents a Function value at runtime.
|
|
398
|
+
*/
|
|
399
|
+
declare class FunctionValue extends RuntimeValue<(args: AnyRuntimeValue[], scope: Environment) => AnyRuntimeValue> {
|
|
400
|
+
type: string;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Represents a Null value at runtime.
|
|
404
|
+
*/
|
|
405
|
+
declare class NullValue extends RuntimeValue<null> {
|
|
406
|
+
type: string;
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Represents an Undefined value at runtime.
|
|
410
|
+
*/
|
|
411
|
+
declare class UndefinedValue extends RuntimeValue<undefined> {
|
|
412
|
+
type: string;
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Represents the current environment (scope) at runtime.
|
|
416
|
+
*/
|
|
417
|
+
declare class Environment {
|
|
418
|
+
parent?: Environment | undefined;
|
|
419
|
+
/**
|
|
420
|
+
* The variables declared in this environment.
|
|
421
|
+
*/
|
|
422
|
+
variables: Map<string, AnyRuntimeValue>;
|
|
423
|
+
/**
|
|
424
|
+
* The tests available in this environment.
|
|
425
|
+
*/
|
|
426
|
+
tests: Map<string, (...value: AnyRuntimeValue[]) => boolean>;
|
|
427
|
+
constructor(parent?: Environment | undefined);
|
|
428
|
+
/**
|
|
429
|
+
* Set the value of a variable in the current environment.
|
|
430
|
+
*/
|
|
431
|
+
set(name: string, value: unknown): AnyRuntimeValue;
|
|
432
|
+
private declareVariable;
|
|
433
|
+
/**
|
|
434
|
+
* Set variable in the current scope.
|
|
435
|
+
* See https://jinja.palletsprojects.com/en/3.0.x/templates/#assignments for more information.
|
|
436
|
+
*/
|
|
437
|
+
setVariable(name: string, value: AnyRuntimeValue): AnyRuntimeValue;
|
|
438
|
+
/**
|
|
439
|
+
* Resolve the environment in which the variable is declared.
|
|
440
|
+
* @param {string} name The name of the variable.
|
|
441
|
+
* @returns {Environment} The environment in which the variable is declared.
|
|
442
|
+
*/
|
|
443
|
+
private resolve;
|
|
444
|
+
lookupVariable(name: string): AnyRuntimeValue;
|
|
445
|
+
}
|
|
446
|
+
declare class Interpreter {
|
|
447
|
+
global: Environment;
|
|
448
|
+
constructor(env?: Environment);
|
|
449
|
+
/**
|
|
450
|
+
* Run the program.
|
|
451
|
+
*/
|
|
452
|
+
run(program: Program): AnyRuntimeValue;
|
|
453
|
+
/**
|
|
454
|
+
* Evaluates expressions following the binary operation type.
|
|
455
|
+
*/
|
|
456
|
+
private evaluateBinaryExpression;
|
|
457
|
+
/**
|
|
458
|
+
* Evaluates expressions following the filter operation type.
|
|
459
|
+
*/
|
|
460
|
+
private evaluateFilterExpression;
|
|
461
|
+
/**
|
|
462
|
+
* Evaluates expressions following the test operation type.
|
|
463
|
+
*/
|
|
464
|
+
private evaluateTestExpression;
|
|
465
|
+
/**
|
|
466
|
+
* Evaluates expressions following the unary operation type.
|
|
467
|
+
*/
|
|
468
|
+
private evaluateUnaryExpression;
|
|
469
|
+
private evalProgram;
|
|
470
|
+
private evaluateBlock;
|
|
471
|
+
private evaluateIdentifier;
|
|
472
|
+
private evaluateCallExpression;
|
|
473
|
+
private evaluateSliceExpression;
|
|
474
|
+
private evaluateMemberExpression;
|
|
475
|
+
private evaluateSet;
|
|
476
|
+
private evaluateIf;
|
|
477
|
+
private evaluateFor;
|
|
478
|
+
evaluate(statement: Statement | undefined, environment: Environment): AnyRuntimeValue;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
declare function randomInt(to: number, from?: number): number;
|
|
482
|
+
/**
|
|
483
|
+
* Selects an element from the given object, array, or string.
|
|
484
|
+
* @param obj Can be an object, array, or string to select from.
|
|
485
|
+
* @param index Optional, specifies the index or key to select. Negative values indicate indices from the end.
|
|
486
|
+
* @returns The selected element, or `undefined` if the input is empty or not provided.
|
|
487
|
+
*
|
|
488
|
+
* @example
|
|
489
|
+
* // Selecting an element from an array
|
|
490
|
+
* const array = ['apple', 'banana', 'cherry']
|
|
491
|
+
* console.log(select(array)) // Random element from the array
|
|
492
|
+
* console.log(select(array, 1)) // Second element
|
|
493
|
+
* console.log(select(array, -1)) // Last element
|
|
494
|
+
*
|
|
495
|
+
* @example
|
|
496
|
+
* // Selecting a property from an object
|
|
497
|
+
* const obj = { fruit1: 'apple', fruit2: 'banana', fruit3: 'cherry' }
|
|
498
|
+
* console.log(select(obj)) // Random property from the object
|
|
499
|
+
* console.log(select(obj, 'fruit2')) // Property with key 'fruit2'
|
|
500
|
+
*
|
|
501
|
+
* @example
|
|
502
|
+
* // Selecting a character from a string
|
|
503
|
+
* const str = 'hello'
|
|
504
|
+
* console.log(select(str)) // Random character from the string
|
|
505
|
+
* console.log(select(str, 1)) // Second character
|
|
506
|
+
* console.log(select(str, -1)) // Last character
|
|
507
|
+
*/
|
|
508
|
+
declare function select(obj: any | any[], index?: number | string): any;
|
|
509
|
+
declare const builtins: {
|
|
510
|
+
randomInt: typeof randomInt;
|
|
511
|
+
select: typeof select;
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* @file Jinja templating engine
|
|
516
|
+
*
|
|
517
|
+
* A minimalistic JavaScript reimplementation of the [Jinja](https://github.com/pallets/jinja) templating engine,
|
|
518
|
+
* to support the chat templates. Special thanks to [Tyler Laceby](https://github.com/tlaceby) for his amazing
|
|
519
|
+
* ["Guide to Interpreters"](https://github.com/tlaceby/guide-to-interpreters-series) tutorial series,
|
|
520
|
+
* which provided the basis for this implementation.
|
|
521
|
+
*
|
|
522
|
+
* See the [Transformers documentation](https://huggingface.co/docs/transformers/main/en/chat_templating) for more information.
|
|
523
|
+
*
|
|
524
|
+
* @module index
|
|
525
|
+
*/
|
|
526
|
+
|
|
527
|
+
declare class EnvironmentEx extends Environment {
|
|
528
|
+
parent?: EnvironmentEx | undefined;
|
|
529
|
+
constructor(parent?: EnvironmentEx | undefined);
|
|
530
|
+
assign(items: Record<string, unknown>): void;
|
|
531
|
+
clear(): void;
|
|
532
|
+
}
|
|
533
|
+
declare class Template {
|
|
534
|
+
parsed: Program;
|
|
535
|
+
static global: EnvironmentEx;
|
|
536
|
+
/**
|
|
537
|
+
* @param {string} template The template string
|
|
538
|
+
*/
|
|
539
|
+
constructor(template: string, options?: PreprocessOptions);
|
|
540
|
+
render(items: Record<string, unknown>): string;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
declare class HfPromptTemplate extends PromptTemplate {
|
|
544
|
+
compiledTemplate: Template;
|
|
545
|
+
static isTemplate(templateOpt: PromptTemplateOptions | string): boolean;
|
|
546
|
+
getVariables(template?: Template): string[];
|
|
547
|
+
_initialize(options?: PromptTemplateOptions): void;
|
|
548
|
+
_format(data: Record<string, any>): string;
|
|
549
|
+
}
|
|
550
|
+
declare function createHfValueFunc(fn: Function): (_data: any) => Function;
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Type that represents a node in a parsed format string. It can be either
|
|
554
|
+
* a literal text or a variable name.
|
|
555
|
+
*/
|
|
556
|
+
type FStringPromptTemplateNode = {
|
|
557
|
+
type: "literal";
|
|
558
|
+
text: string;
|
|
559
|
+
} | {
|
|
560
|
+
type: "variable";
|
|
561
|
+
name: string;
|
|
562
|
+
};
|
|
563
|
+
/**
|
|
564
|
+
* Type that represents a function that takes a template string and
|
|
565
|
+
* returns an array of `ParsedFStringNode`.
|
|
566
|
+
*
|
|
567
|
+
* extract from langchain.js/langchain-core/src/prompts/template.ts
|
|
568
|
+
*/
|
|
569
|
+
declare function parseFString(template: string): FStringPromptTemplateNode[];
|
|
570
|
+
/**
|
|
571
|
+
* Type that represents a function that takes a template string and a set
|
|
572
|
+
* of input values, and returns a string where all variables in the
|
|
573
|
+
* template have been replaced with their corresponding values.
|
|
574
|
+
*/
|
|
575
|
+
declare function interpolateFString(nodes: FStringPromptTemplateNode[], values: Record<string, any>): string;
|
|
576
|
+
|
|
577
|
+
declare class FStringPromptTemplate extends PromptTemplate {
|
|
578
|
+
compiledTemplate: FStringPromptTemplateNode[];
|
|
579
|
+
static isTemplate(templateOpt: PromptTemplateOptions | string): boolean;
|
|
580
|
+
getVariables(template?: FStringPromptTemplateNode[]): string[];
|
|
581
|
+
_initialize(options?: PromptTemplateOptions): void;
|
|
582
|
+
_format(data: Record<string, any>): string;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
declare class GolangPromptTemplate extends PromptTemplate {
|
|
586
|
+
static isTemplate(templateOpt: PromptTemplateOptions | string): boolean | undefined;
|
|
587
|
+
getVariables(template: string): string[];
|
|
588
|
+
_initialize(options?: PromptTemplateOptions): void;
|
|
589
|
+
_format(data: Record<string, any>): string;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
declare function sortedValues<T>(values: Record<string, T>): T[];
|
|
593
|
+
interface FewShotPromptTemplateOptions<T = any> extends PromptTemplateOptions {
|
|
594
|
+
/**
|
|
595
|
+
* The few shot examples to use in the prompt.
|
|
596
|
+
*/
|
|
597
|
+
examples: PromptExamples<T>;
|
|
598
|
+
/**
|
|
599
|
+
* An {@link PromptTemplate} used to format a single example.
|
|
600
|
+
*/
|
|
601
|
+
examplePrompt: PromptTemplate | PromptTemplateOptions;
|
|
602
|
+
/**
|
|
603
|
+
* String separator used to join the prefix, the examples, and suffix.
|
|
604
|
+
*/
|
|
605
|
+
exampleSeparator?: string;
|
|
606
|
+
/**
|
|
607
|
+
* A prompt template string to put before the examples.
|
|
608
|
+
*
|
|
609
|
+
* @defaultValue `""`
|
|
610
|
+
*/
|
|
611
|
+
prefix?: string;
|
|
612
|
+
/**
|
|
613
|
+
* A prompt template string to put after the examples.
|
|
614
|
+
*/
|
|
615
|
+
suffix?: string;
|
|
616
|
+
}
|
|
617
|
+
declare class FewShotPromptTemplate<T = any> extends PromptTemplate {
|
|
618
|
+
examples: PromptExamples<T>;
|
|
619
|
+
examplePrompt: PromptTemplate | undefined;
|
|
620
|
+
suffix: string;
|
|
621
|
+
exampleSeparator: string;
|
|
622
|
+
prefix: string;
|
|
623
|
+
static from<T = any>(options: FewShotPromptTemplateOptions<T>): FewShotPromptTemplate<T>;
|
|
624
|
+
constructor(options: FewShotPromptTemplateOptions<T>);
|
|
625
|
+
_initialize(options?: FewShotPromptTemplateOptions<T>): void;
|
|
626
|
+
_format(data: Record<string, any>): Promise<string>;
|
|
627
|
+
toJSON(options?: this): FewShotPromptTemplateOptions<T>;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* Parse and interpolate template
|
|
632
|
+
* @param str golang style template
|
|
633
|
+
* @param variables object of variables to insert
|
|
634
|
+
*/
|
|
635
|
+
declare function interpolateGolangTemplate(str: string, variables: Record<string, any>, initVars?: boolean): string;
|
|
636
|
+
|
|
637
|
+
declare function interpolateEnv(value: string, processEnv: any, parsed: any): any;
|
|
638
|
+
/**
|
|
639
|
+
* Expand environment variables in the parsed object
|
|
640
|
+
* @param options.processEnv Specify an object to write your secrets to. Defaults to `process.env` environment variables.
|
|
641
|
+
* @param options.parsed Specify an object to provide the value of environment variables.
|
|
642
|
+
*
|
|
643
|
+
* Follows these rules to handle environment variable expansion:
|
|
644
|
+
*
|
|
645
|
+
* 1. Simple Variable Expansion: If a string contains `$KEY`, it will be replaced by the value of the environment variable named `KEY`.
|
|
646
|
+
* 2. Braced Variable Expansion: When a string contains `${KEY}`, it also looks up the environment variable named `KEY`.
|
|
647
|
+
* This syntax is typically used to disambiguate variable names that contain special characters.
|
|
648
|
+
* 3. Escaped Dollar Sign: If you want to include a literal `$` followed by a variable name, you can escape it with a backslash (`\$KEY`).
|
|
649
|
+
* This ensures the `$` character is treated as part of the literal string rather than a variable reference.
|
|
650
|
+
* 4. Default Value: In the case of `${KEY:-default}` or `${KEY-default}`, the engine first tries to expand the KEY environment variable.
|
|
651
|
+
* If there's no such environment variable, it will use default as the fallback value.
|
|
652
|
+
*
|
|
653
|
+
* @example
|
|
654
|
+
* const myEnv = {}
|
|
655
|
+
* const env = {
|
|
656
|
+
* processEnv: myEnv,
|
|
657
|
+
* parsed: {
|
|
658
|
+
* WORD: 'World',
|
|
659
|
+
* HELLO: 'Hello ${WORD}'
|
|
660
|
+
* }
|
|
661
|
+
* }
|
|
662
|
+
* expandEnv.expand(env)
|
|
663
|
+
*
|
|
664
|
+
* console.log(myEnv.HELLO) // Hello World
|
|
665
|
+
* console.log(process.env.HELLO) // undefined
|
|
666
|
+
*/
|
|
667
|
+
declare function expandEnv(options: DotenvExpandOptions): DotenvExpandOptions;
|
|
668
|
+
/**
|
|
669
|
+
* Expands environment variables in an object/array or string.
|
|
670
|
+
*
|
|
671
|
+
* This function replaces placeholders like `${VAR}` in strings and recursively
|
|
672
|
+
* processes objects and arrays with environment variable references.
|
|
673
|
+
*
|
|
674
|
+
* @param obj - The object/array or string to be processed. Can be any value, but
|
|
675
|
+
* primarily designed for objects, array and strings.
|
|
676
|
+
* @param options - Configuration options:
|
|
677
|
+
* - processEnv: - An object to source environment variables from, defaults to `process.env`.
|
|
678
|
+
* - parsed: - Specify an object to provide the value of environment variables.
|
|
679
|
+
* @returns - Returns the expanded object or string.
|
|
680
|
+
*
|
|
681
|
+
* @example
|
|
682
|
+
* const obj = {
|
|
683
|
+
* name: 'MyApp',
|
|
684
|
+
* envVar: '${ENV_VAR_NAME}',
|
|
685
|
+
* config: {
|
|
686
|
+
* url: 'http://${HOST}:${PORT}'
|
|
687
|
+
* },
|
|
688
|
+
* list: ['item1', '${ITEM2}']
|
|
689
|
+
* };
|
|
690
|
+
* // the expandedObj will have the actual values instead of placeholders.
|
|
691
|
+
* const expandedObj = expandObjEnv(obj, { processEnv: myCustomEnv }); // Assuming 'ENV_VAR_NAME' is defined as 'Production' and 'HOST', 'PORT', 'ITEM2' are set,
|
|
692
|
+
*
|
|
693
|
+
*/
|
|
694
|
+
declare function expandObjEnv(obj: any, options?: DotenvExpandOptions, parsedObjs?: WeakSet<any>): any;
|
|
695
|
+
interface DotenvPopulateInput {
|
|
696
|
+
[name: string]: string | undefined;
|
|
697
|
+
}
|
|
698
|
+
interface DotenvParseInput {
|
|
699
|
+
[name: string]: string | undefined;
|
|
700
|
+
}
|
|
701
|
+
interface DotenvParseOutput {
|
|
702
|
+
[name: string]: string | undefined;
|
|
703
|
+
}
|
|
704
|
+
interface DotenvExpandOptions {
|
|
705
|
+
error?: Error;
|
|
706
|
+
/**
|
|
707
|
+
* Default: `process.env`
|
|
708
|
+
*
|
|
709
|
+
* Specify an object to write your secrets to. Defaults to process.env environment variables.
|
|
710
|
+
*
|
|
711
|
+
* example: `const processEnv = {}; require('dotenv').config({ processEnv: processEnv })`
|
|
712
|
+
*/
|
|
713
|
+
processEnv?: DotenvPopulateInput;
|
|
714
|
+
/**
|
|
715
|
+
* Default: `object`
|
|
716
|
+
*
|
|
717
|
+
* Object coming from dotenv's parsed result.
|
|
718
|
+
*/
|
|
719
|
+
parsed?: DotenvParseInput;
|
|
720
|
+
}
|
|
721
|
+
interface DotenvExpandOutput {
|
|
722
|
+
error?: Error;
|
|
723
|
+
parsed?: DotenvParseOutput;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* Splits a text into sentences.
|
|
728
|
+
* This function is used to split a text into separate sentences, based on punctuation marks such as '.', '?', or '!' and other rules.
|
|
729
|
+
* @param {string} text - The input string that needs to be split into sentences.
|
|
730
|
+
* @param {boolean} best - A boolean flag indicating if the function should use the best possible sentence splitting method (default is true).
|
|
731
|
+
* If set to false, it will not perform any additional processing and simply split on newline characters ('\n').
|
|
732
|
+
* @returns {string[]} An array of strings where each string represents a sentence in the input text.
|
|
733
|
+
*
|
|
734
|
+
* Example:
|
|
735
|
+
* const text = "Hello world! How are you today? I am fine.";
|
|
736
|
+
* console.log(splitSentence(text)); // returns ['Hello world!', 'How are you today?', 'I am fine.']
|
|
737
|
+
*/
|
|
738
|
+
declare function splitSentence(text: string, best?: boolean): string[];
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* Truncates(Round) a number to a specified number of decimal places.
|
|
742
|
+
*
|
|
743
|
+
* @param {number} n - The number to truncate.
|
|
744
|
+
* @param {number} dec - The number of decimal places to truncate to (default is 2).
|
|
745
|
+
* @param {number} up - The amount to round up by before truncating (default is 0.5).
|
|
746
|
+
*
|
|
747
|
+
* @example
|
|
748
|
+
* // returns 1.235
|
|
749
|
+
* truncTo(1.2345, 3)
|
|
750
|
+
*
|
|
751
|
+
* @example
|
|
752
|
+
* // returns 1.24
|
|
753
|
+
* truncTo(1.2345, 2, 0.6)
|
|
754
|
+
*
|
|
755
|
+
* @returns {number} The truncated number.
|
|
756
|
+
*/
|
|
757
|
+
declare function truncTo(n: number, dec?: number, up?: number): number;
|
|
758
|
+
|
|
759
|
+
declare function wait(ms: number): Promise<void>;
|
|
760
|
+
|
|
761
|
+
declare const EventName = "event";
|
|
762
|
+
declare const EventBusName = "event-bus";
|
|
763
|
+
type EventListenerFn = (this: Event, name: string, ...args: any) => any;
|
|
764
|
+
type EventErrorListenerFn = (this: Event, err: Error, name: string, ...args: any) => any;
|
|
765
|
+
declare const backendEventable: custom_ability.AbilityFn;
|
|
766
|
+
|
|
767
|
+
declare const RStreamErrCode = 600;
|
|
768
|
+
declare const ResponseRStreamErrCode = 601;
|
|
769
|
+
declare class ReadableStreamError extends BaseError {
|
|
770
|
+
constructor(msg: string, code?: number);
|
|
771
|
+
}
|
|
772
|
+
declare function getResponseErrorReadableStream(body?: ReadableStream<Uint8Array> | null): ReadableStream<any>;
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* Creates an empty ReadableStream that immediately closes upon creation.
|
|
776
|
+
* This function is used as a fallback for creating a ReadableStream when the response body is null or undefined,
|
|
777
|
+
* ensuring that the subsequent pipeline processing doesn't fail due to a lack of a stream.
|
|
778
|
+
*
|
|
779
|
+
* @returns {ReadableStream} An empty and closed ReadableStream instance.
|
|
780
|
+
*/
|
|
781
|
+
declare function createEmptyReadableStream(): ReadableStream;
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* Configuration options and helper callback methods for AIStream stream lifecycle events.
|
|
785
|
+
* @interface
|
|
786
|
+
*/
|
|
787
|
+
interface AIStreamCallbacksAndOptions {
|
|
788
|
+
/** `onStart`: Called once when the stream is initialized. */
|
|
789
|
+
onStart?: () => Promise<void> | void;
|
|
790
|
+
/** `onCompletion`: Called for each tokenized message. */
|
|
791
|
+
onCompletion?: (completion: string) => Promise<void> | void;
|
|
792
|
+
/** `onFinal`: Called once when the stream is closed with the final completion message. */
|
|
793
|
+
onFinal?: (completion: string) => Promise<void> | void;
|
|
794
|
+
/** `onToken`: Called for each tokenized message. */
|
|
795
|
+
onToken?: (token: string) => Promise<void> | void;
|
|
796
|
+
/** `onText`: Called for each text chunk. */
|
|
797
|
+
onText?: (text: string) => Promise<void> | void;
|
|
798
|
+
/**
|
|
799
|
+
* A flag for enabling the experimental_StreamData class and the new protocol.
|
|
800
|
+
* @see https://github.com/vercel-labs/ai/pull/425
|
|
801
|
+
*
|
|
802
|
+
* When StreamData is rolled out, this will be removed and the new protocol will be used by default.
|
|
803
|
+
*/
|
|
804
|
+
experimental_streamData?: boolean;
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* Options for the AIStreamParser.
|
|
808
|
+
* @interface
|
|
809
|
+
* @property {string} event - The event (type) from the server side event stream.
|
|
810
|
+
*/
|
|
811
|
+
interface AIStreamParserOptions {
|
|
812
|
+
event?: string;
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* Custom parser for AIStream data.
|
|
816
|
+
* @interface
|
|
817
|
+
* @param {string} data - The data to be parsed.
|
|
818
|
+
* @param {AIStreamParserOptions} options - The options for the parser.
|
|
819
|
+
* @returns The parsed data or void.
|
|
820
|
+
*/
|
|
821
|
+
interface AIStreamParser<T = any, TOptions = any> {
|
|
822
|
+
(data: string, options: AIStreamParserOptions): AIResult<T, TOptions> | void;
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Creates a TransformStream that parses events from an EventSource stream using a custom parser.
|
|
826
|
+
* @param {AIStreamParser} customParser - Function to handle event data.
|
|
827
|
+
* @returns TransformStream parsing events.
|
|
828
|
+
*/
|
|
829
|
+
declare function createEventStreamTransformer<TValue = any, TOptions = any>(customParser?: AIStreamParser): TransformStream<Uint8Array, AIResult<TValue, TOptions>>;
|
|
830
|
+
/**
|
|
831
|
+
* Creates a transform stream that encodes input messages and invokes optional callback functions.
|
|
832
|
+
* The transform stream uses the provided callbacks to execute custom logic at different stages of the stream's lifecycle.
|
|
833
|
+
* - `onStart`: Called once when the stream is initialized.
|
|
834
|
+
* - `onToken`: Called for each tokenized message.
|
|
835
|
+
* - `onCompletion`: Called every time an AIStream completion message is received. This can occur multiple times when using e.g. OpenAI functions
|
|
836
|
+
* - `onFinal`: Called once when the stream is closed with the final completion message.
|
|
837
|
+
*
|
|
838
|
+
* This function is useful when you want to process a stream of messages and perform specific actions during the stream's lifecycle.
|
|
839
|
+
*
|
|
840
|
+
* @param {AIStreamCallbacksAndOptions} [callbacks] - An object containing the callback functions.
|
|
841
|
+
* @return {TransformStream<string, Uint8Array>} A transform stream that encodes input messages as Uint8Array and allows the execution of custom logic through callbacks.
|
|
842
|
+
*
|
|
843
|
+
* @example
|
|
844
|
+
* const callbacks = {
|
|
845
|
+
* onStart: async () => console.log('Stream started'),
|
|
846
|
+
* onToken: async (token) => console.log(`Token: ${token}`),
|
|
847
|
+
* onCompletion: async (completion) => console.log(`Completion: ${completion}`)
|
|
848
|
+
* onFinal: async () => data.close()
|
|
849
|
+
* };
|
|
850
|
+
* const transformer = createCallbacksTransformer(callbacks);
|
|
851
|
+
*/
|
|
852
|
+
declare function createCallbacksTransformer(cb: AIStreamCallbacksAndOptions | undefined): TransformStream<AIResult, Uint8Array>;
|
|
853
|
+
/**
|
|
854
|
+
* Returns a stateful function that, when invoked, trims leading whitespace
|
|
855
|
+
* from the input text. The trimming only occurs on the first invocation, ensuring that
|
|
856
|
+
* subsequent calls do not alter the input text. This is particularly useful in scenarios
|
|
857
|
+
* where a text stream is being processed and only the initial whitespace should be removed.
|
|
858
|
+
*
|
|
859
|
+
* @return {function(string): string} A function that takes a string as input and returns a string
|
|
860
|
+
* with leading whitespace removed if it is the first invocation; otherwise, it returns the input unchanged.
|
|
861
|
+
*
|
|
862
|
+
* @example
|
|
863
|
+
* const trimStart = trimStartOfStreamHelper();
|
|
864
|
+
* const output1 = trimStart(" text"); // "text"
|
|
865
|
+
* const output2 = trimStart(" text"); // " text"
|
|
866
|
+
*
|
|
867
|
+
*/
|
|
868
|
+
declare function trimStartOfStreamHelper(): (text: string) => string;
|
|
869
|
+
/**
|
|
870
|
+
* Returns a ReadableStream created from the response, parsed and handled with custom logic.
|
|
871
|
+
* The stream goes through two transformation stages, first parsing the events and then
|
|
872
|
+
* invoking the provided callbacks.
|
|
873
|
+
*
|
|
874
|
+
* For 2xx HTTP responses:
|
|
875
|
+
* - The function continues with standard stream processing.
|
|
876
|
+
*
|
|
877
|
+
* For non-2xx HTTP responses:
|
|
878
|
+
* - If the response body is defined, it asynchronously extracts and decodes the response body.
|
|
879
|
+
* - It then creates a custom ReadableStream to propagate a detailed error message.
|
|
880
|
+
*
|
|
881
|
+
* @param {Response} response - The response.
|
|
882
|
+
* @param {AIStreamParser} customParser - The custom parser function.
|
|
883
|
+
* @param {AIStreamCallbacksAndOptions} callbacks - The callbacks.
|
|
884
|
+
* @return {ReadableStream} The AIStream.
|
|
885
|
+
* @throws Will throw an error if the response is not OK.
|
|
886
|
+
*/
|
|
887
|
+
declare function AIStream<T = any, TOptions = any>(response: Response, customParser?: AIStreamParser<T, TOptions>): ReadableStream<AIResult<T, TOptions>>;
|
|
888
|
+
/**
|
|
889
|
+
* Implements ReadableStream.from(asyncIterable), which isn't documented in MDN and isn't implemented in node.
|
|
890
|
+
* https://github.com/whatwg/streams/commit/8d7a0bf26eb2cc23e884ddbaac7c1da4b91cf2bc
|
|
891
|
+
*/
|
|
892
|
+
declare function readableFromAsyncIterable<T>(iterable: AsyncIterable<T>): ReadableStream<T>;
|
|
893
|
+
|
|
894
|
+
declare function uuid(ver?: 1 | 4 | 5, encode?: boolean): string;
|
|
895
|
+
|
|
896
|
+
declare const base32768: typeof _base32768;
|
|
897
|
+
|
|
898
|
+
declare function xxhash32(value: string | object, radix?: number): string;
|
|
899
|
+
declare function xxhash64(value: string | object, radix?: number): string;
|
|
900
|
+
declare enum XXHashAlgorithm {
|
|
901
|
+
xxhash64 = 111,
|
|
902
|
+
xxhash32 = 112
|
|
903
|
+
}
|
|
904
|
+
type HashValue = string | ArrayBuffer | Buffer;
|
|
905
|
+
declare function xxhash(value: HashValue, hashAlgo?: XXHashAlgorithm, seed?: number): Uint8Array;
|
|
906
|
+
declare function xxhashAsStr(value: string | Uint8Array, hashAlgo?: XXHashAlgorithm, seed?: number): string;
|
|
907
|
+
|
|
908
|
+
/**
|
|
909
|
+
* Regular expression pattern for reserved characters in a filename.
|
|
910
|
+
* do not use /g global option here: when the regex is executed multiple times, it will always begin where it left off last time.
|
|
911
|
+
*/
|
|
912
|
+
declare const FilenameReservedRegex: RegExp;
|
|
913
|
+
/**
|
|
914
|
+
* Regular expression pattern for reserved names on Windows systems.
|
|
915
|
+
*/
|
|
916
|
+
declare const WindowsReservedNameRegex: RegExp;
|
|
917
|
+
/**
|
|
918
|
+
* Returns a new regular expression instance for reserved filename characters with the 'g' flag.
|
|
919
|
+
* use this to reset the with global option
|
|
920
|
+
* @returns A compiled regular expression for reserved filename characters.
|
|
921
|
+
*/
|
|
922
|
+
declare function filenameReservedRegex(): RegExp;
|
|
923
|
+
/**
|
|
924
|
+
* Returns a new regular expression instance for control characters in a filename with the 'g' flag.
|
|
925
|
+
* @returns A compiled regular expression for control characters in a filename.
|
|
926
|
+
*/
|
|
927
|
+
declare function reControlCharsRegex(): RegExp;
|
|
928
|
+
/**
|
|
929
|
+
* Validates if a given string is a valid filename.
|
|
930
|
+
* @param {string} filename - The filename to be validated.
|
|
931
|
+
* @returns True if the filename is valid, false otherwise.
|
|
932
|
+
* @throws {TypeError} If the input is not a string.
|
|
933
|
+
* @example
|
|
934
|
+
* isValidFilename('myFile.txt'); // Returns true
|
|
935
|
+
* isValidFilename('my<file.txt'); // Returns false
|
|
936
|
+
*/
|
|
937
|
+
declare function isValidFilename(filename: string): boolean | "";
|
|
938
|
+
/**
|
|
939
|
+
* Validates whether the given filepath is valid.
|
|
940
|
+
* @param filepath - The filepath to be checked, represented as a string.
|
|
941
|
+
* @returns A boolean indicating whether the filepath is valid. Returns true if valid; false otherwise.
|
|
942
|
+
*/
|
|
943
|
+
declare function isValidFilepath(filepath: string): boolean;
|
|
944
|
+
interface SanitizeFilenameOptions {
|
|
945
|
+
replacement?: string;
|
|
946
|
+
maxLength?: number;
|
|
947
|
+
}
|
|
948
|
+
/**
|
|
949
|
+
* Sanitizes a given filename by replacing invalid characters with a specified replacement character or a default.
|
|
950
|
+
* @param filename - The filename to sanitize, represented as a string.
|
|
951
|
+
* @param options - An optional object containing configuration options:
|
|
952
|
+
* - `replacement` {string} - The character to replace invalid characters with. Default is '!'. Cannot contain reserved filename characters.
|
|
953
|
+
* - `maxLength` {number} - The maximum length of the sanitized filename. Default is `MAX_FILENAME_LENGTH`.
|
|
954
|
+
* @returns The sanitized filename.
|
|
955
|
+
* @throws {Error} - If the `replacement` contains reserved filename characters or control characters.
|
|
956
|
+
*/
|
|
957
|
+
declare function sanitizeFilename(filename: string, options?: SanitizeFilenameOptions): string;
|
|
958
|
+
/**
|
|
959
|
+
* Sanitizes each part of a file path and reassembles it, ensuring the path is valid according to provided options.
|
|
960
|
+
* @param filepath - The file path to sanitize, represented as a string.
|
|
961
|
+
* @param options - Optional settings for sanitization, extending `SanitizeFilenameOptions`. Allows customization of replacement characters and maximum filename length.
|
|
962
|
+
* @returns The sanitized file path as a string.
|
|
963
|
+
*/
|
|
964
|
+
declare function sanitizeFilepath(filepath: string, options?: SanitizeFilenameOptions): string;
|
|
965
|
+
/**
|
|
966
|
+
* Retrieves multi-level file extension
|
|
967
|
+
* @param filename The file name
|
|
968
|
+
* @param level The level, default is 1, indicating the number of extension levels to retrieve
|
|
969
|
+
* @returns Returns a concatenated string of multiple extensions, or an empty string if no extension is found
|
|
970
|
+
*/
|
|
971
|
+
declare function getMultiLevelExtname(filename: string, level?: number): string;
|
|
972
|
+
/**
|
|
973
|
+
* Calculates the level of an extension name.
|
|
974
|
+
*
|
|
975
|
+
* The level represents the number of dots ('.') in the extension name, excluding the first dot which separates
|
|
976
|
+
* the base filename from the extension. For example, the level of ".txt" is 1, and the level of ".tar.gz" is 2.
|
|
977
|
+
*
|
|
978
|
+
* @param extName - The extension name to analyze. It should start with a dot ('.').
|
|
979
|
+
* @returns The level of the extension name, which is the count of dots minus one.
|
|
980
|
+
*
|
|
981
|
+
* @example
|
|
982
|
+
* ```typescript
|
|
983
|
+
* // Returns 0
|
|
984
|
+
* extNameLevel("no-file-ext");
|
|
985
|
+
*
|
|
986
|
+
* // Returns 2
|
|
987
|
+
* extNameLevel(".tar.gz");
|
|
988
|
+
*
|
|
989
|
+
* // Returns 1
|
|
990
|
+
* extNameLevel(".json5");
|
|
991
|
+
* ```
|
|
992
|
+
*/
|
|
993
|
+
declare function extNameLevel(extName: string): number;
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* Checks if the provided model name matches the given rule.
|
|
997
|
+
* @param modelName The name of the model to check.
|
|
998
|
+
* @param rule An optional rule that can be a string, an array of strings, a regular expression, or a function.
|
|
999
|
+
* @returns matched result if the model name matches the rule, undefined otherwise.
|
|
1000
|
+
* @example
|
|
1001
|
+
* IsModelNameMatched("gpt-3", "gpt-3") // returns true
|
|
1002
|
+
* IsModelNameMatched("GPT-3", "gpt-3") // returns true
|
|
1003
|
+
* IsModelNameMatched("GPT-3", ["gpt-3", "gpt-4"]) // returns true
|
|
1004
|
+
* IsModelNameMatched("gpt-3", /^gpt-\d+$/) // returns true
|
|
1005
|
+
* IsModelNameMatched("gpt-3", (modelName) => modelName.startsWith("gpt-")) // returns true
|
|
1006
|
+
* IsModelNameMatched("gpt-2", "gpt-3") // returns false
|
|
1007
|
+
* IsModelNameMatched("gpt-2", ["gpt-3", "gpt-4"]) // returns false
|
|
1008
|
+
* IsModelNameMatched("gpt-2", /^gpt-\d+$/) // returns false
|
|
1009
|
+
* IsModelNameMatched("gpt-2", (modelName) => modelName.startsWith("gpt-")) // returns false
|
|
1010
|
+
*/
|
|
1011
|
+
declare function isModelNameMatched(modelName: string, rule?: AIModelNameRules): string | RegExpExecArray | undefined;
|
|
1012
|
+
|
|
1013
|
+
/**
|
|
1014
|
+
* Retrieves all string keys from the given enumeration(number).
|
|
1015
|
+
*
|
|
1016
|
+
* @param enumType - The enumeration type with numeric values for which to retrieve keys.
|
|
1017
|
+
* @returns An array containing all string keys of the specified enumeration.
|
|
1018
|
+
*/
|
|
1019
|
+
declare function getAllEnumKeys<T extends object>(enumType: T): Array<keyof typeof enumType>;
|
|
1020
|
+
|
|
1021
|
+
/**
|
|
1022
|
+
* Parses a JavaScript string into a JSON object.
|
|
1023
|
+
* @param input The string to be parsed into JSON.
|
|
1024
|
+
* @returns The parsed JSON object. If parsing fails, undefined is returned.
|
|
1025
|
+
*
|
|
1026
|
+
* @example
|
|
1027
|
+
* // This will return a JSON object with key 'name' and value 'John'.
|
|
1028
|
+
* const jsonString = '({name: "John"})';
|
|
1029
|
+
* const json = parseJsJson(jsonString);
|
|
1030
|
+
* console.log(json); // { name: 'John' }
|
|
1031
|
+
*/
|
|
1032
|
+
declare function parseJsJson(input: string): any;
|
|
1033
|
+
|
|
1034
|
+
/**
|
|
1035
|
+
* Retrieves an array of all key paths as strings for a nested object or array.
|
|
1036
|
+
* @param value - The object or array to extract the paths from.
|
|
1037
|
+
* @returns - An array of strings containing all the key paths.
|
|
1038
|
+
*
|
|
1039
|
+
* @example
|
|
1040
|
+
* ```
|
|
1041
|
+
* const obj = { a: { b: { c: 1 } }, d: [0, { e: 2 }] };
|
|
1042
|
+
* console.log(getKeysPath(obj)); // Output: ['a.b.c', 'd[0]', 'd[1].e']
|
|
1043
|
+
* ```
|
|
1044
|
+
*/
|
|
1045
|
+
declare function getKeysPath<TValue extends object>(value: TValue): string[];
|
|
1046
|
+
|
|
1047
|
+
declare function createEndWithRepetitionDetector(repetitionThreshold: number): (value: string) => boolean;
|
|
1048
|
+
|
|
1049
|
+
/**
|
|
1050
|
+
* Loads a file from given paths, optionally searching for specific extensions.
|
|
1051
|
+
*
|
|
1052
|
+
* @param filename - The base filename to search for, without any file extension.
|
|
1053
|
+
* @param searchPaths - An array of directories to search for the file. Defaults to the current directory (`"."`) if not provided.
|
|
1054
|
+
* @param extNames - An array of file extensions to try, in order of preference. If not provided, the file will be searched for
|
|
1055
|
+
* without any extension.
|
|
1056
|
+
*
|
|
1057
|
+
* @returns The contents of the found file as a Buffer.
|
|
1058
|
+
* @throws {NotFoundError} If the file is not found in any of the search paths.
|
|
1059
|
+
*
|
|
1060
|
+
* @example
|
|
1061
|
+
* ```typescript
|
|
1062
|
+
* const content = loadFileFromPaths('config', ['/etc', '/usr/local/etc'], ['.json', '.yaml']);
|
|
1063
|
+
* ```
|
|
1064
|
+
*/
|
|
1065
|
+
declare function loadFileFromPaths(filename: string, searchPaths?: string[], extNames?: string[]): Buffer;
|
|
1066
|
+
declare function loadTextFromPaths(filename: string, searchPaths?: string[], extNames?: string[], encoding?: BufferEncoding): string;
|
|
1067
|
+
|
|
1068
|
+
declare function registerYamlTag(tags: any): void;
|
|
1069
|
+
declare function parseYaml(content: string): any;
|
|
1070
|
+
|
|
1071
|
+
declare function getConfigFileNames(directoryPath: string): string[];
|
|
1072
|
+
declare function getConfigs(directoryPath: string): any[];
|
|
1073
|
+
declare function saveConfigFile(filename: string, config: any, extLevel?: number): void;
|
|
1074
|
+
|
|
1075
|
+
interface JsonFilter {
|
|
1076
|
+
[key: string]: any;
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* Converts a filter object to a SQLite WHERE clause.
|
|
1080
|
+
* @param {JsonFilter} filter - The filter object to convert.
|
|
1081
|
+
* @returns {string} The generated WHERE clause.
|
|
1082
|
+
* @example
|
|
1083
|
+
* const jsonFilter: Filter = {
|
|
1084
|
+
* $and: [
|
|
1085
|
+
* { age: { $gt: 18, $lt: 30 } },
|
|
1086
|
+
* { name: { $like: 'John%', $nlike: 'Doe%' } },
|
|
1087
|
+
* { hobbies: { $in: ['reading', 'writing'] } },
|
|
1088
|
+
* { $or: [{ gender: 'male' }, { country: 'USA' }] },
|
|
1089
|
+
* { $and: [{ status: 'active' }, { registered: new Date('2020-01-01') }] },
|
|
1090
|
+
* ],
|
|
1091
|
+
* };
|
|
1092
|
+
*
|
|
1093
|
+
* console.log(jsonFilterToWhere(jsonFilter)); // Outputs a WHERE clause based on the given filter
|
|
1094
|
+
*/
|
|
1095
|
+
declare function jsonFilterToWhere(filter: JsonFilter | JsonFilter[], wrapKey?: (k: string) => string): string;
|
|
1096
|
+
|
|
1097
|
+
export { type AIChatAssistantMessageParam, type AIChatContentPart, type AIChatContentPartImage, type AIChatContentPartText, type AIChatMessageParam, type AIChatMessageParamBase, type AIChatMessageToolCall, type AIChatRole, AIChatRoles, type AIChatSystemMessageParam, type AIChatToolMessageParam, type AIChatUserMessageParam, type AIMessageType, AIMessageTypes, AIModelNameRules, type AIResult, AIStream, type AIStreamCallbacksAndOptions, type AIStreamParser, type AIStreamParserOptions, type AITextGenerationFinishReason, AITextGenerationFinishReasons, BaseError, type DotenvExpandOptions, type DotenvExpandOutput, type DotenvParseInput, type DotenvParseOutput, type DotenvPopulateInput, EventBusName, type EventErrorListenerFn, type EventListenerFn, EventName, FStringPromptTemplate, type FStringPromptTemplateNode, FewShotPromptTemplate, type FewShotPromptTemplateOptions, FilenameReservedRegex, GolangPromptTemplate, builtins as HFBuiltins, EnvironmentEx as HFEnvironment, Interpreter as HFInterpreter, Template as HFTemplate, HfPromptTemplate, type JsonFilter, PromptExampleSelector, type PromptExampleSelectorOptions, type PromptExamples, PromptTemplate, type PromptTemplateOptions, type PromptTemplateType, PromptTemplateTypes, type PromptType, PromptTypes, RStreamErrCode, ReadableStreamError, ResponseRStreamErrCode, type SanitizeFilenameOptions, WindowsReservedNameRegex, XXHashAlgorithm, backendEventable, base32768, createCallbacksTransformer, createEmptyReadableStream, createEndWithRepetitionDetector, createEventStreamTransformer, createHfValueFunc, defaultTemplateFormat, expandEnv, expandObjEnv, extNameLevel, filenameReservedRegex, getAllEnumKeys, getConfigFileNames, getConfigs, getKeysPath, getMultiLevelExtname, getResponseErrorReadableStream, parse as hfParse, tokenize as hfTokenize, interpolateEnv, interpolateFString, interpolateGolangTemplate, isModelNameMatched, isValidFilename, isValidFilepath, jsonFilterToWhere, loadFileFromPaths, loadTextFromPaths, parseFString, parseJsJson, parseYaml, reControlCharsRegex, readableFromAsyncIterable, registerYamlTag, sanitizeFilename, sanitizeFilepath, saveConfigFile, sortedValues, splitSentence, trimStartOfStreamHelper, truncTo, uuid, wait, xxhash, xxhash32, xxhash64, xxhashAsStr };
|