@promptbook/core 0.92.0-20 β†’ 0.92.0-22

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.
@@ -32,6 +32,7 @@ import { DEFAULT_IS_VERBOSE } from '../config';
32
32
  import { SET_IS_VERBOSE } from '../config';
33
33
  import { DEFAULT_IS_AUTO_INSTALLED } from '../config';
34
34
  import { DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME } from '../config';
35
+ import { DEFAULT_RPM } from '../config';
35
36
  import { ORDER_OF_PIPELINE_JSON } from '../constants';
36
37
  import { RESERVED_PARAMETER_NAMES } from '../constants';
37
38
  import { compilePipeline } from '../conversion/compilePipeline';
@@ -81,6 +82,7 @@ import { MANDATORY_CSV_SETTINGS } from '../formats/csv/CsvSettings';
81
82
  import { TextFormatParser } from '../formats/text/TextFormatParser';
82
83
  import { BoilerplateFormfactorDefinition } from '../formfactors/_boilerplate/BoilerplateFormfactorDefinition';
83
84
  import { ChatbotFormfactorDefinition } from '../formfactors/chatbot/ChatbotFormfactorDefinition';
85
+ import { CompletionFormfactorDefinition } from '../formfactors/completion/CompletionFormfactorDefinition';
84
86
  import { GeneratorFormfactorDefinition } from '../formfactors/generator/GeneratorFormfactorDefinition';
85
87
  import { GenericFormfactorDefinition } from '../formfactors/generic/GenericFormfactorDefinition';
86
88
  import { ImageGeneratorFormfactorDefinition } from '../formfactors/image-generator/ImageGeneratorFormfactorDefinition';
@@ -175,6 +177,7 @@ export { DEFAULT_IS_VERBOSE };
175
177
  export { SET_IS_VERBOSE };
176
178
  export { DEFAULT_IS_AUTO_INSTALLED };
177
179
  export { DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME };
180
+ export { DEFAULT_RPM };
178
181
  export { ORDER_OF_PIPELINE_JSON };
179
182
  export { RESERVED_PARAMETER_NAMES };
180
183
  export { compilePipeline };
@@ -224,6 +227,7 @@ export { MANDATORY_CSV_SETTINGS };
224
227
  export { TextFormatParser };
225
228
  export { BoilerplateFormfactorDefinition };
226
229
  export { ChatbotFormfactorDefinition };
230
+ export { CompletionFormfactorDefinition };
227
231
  export { GeneratorFormfactorDefinition };
228
232
  export { GenericFormfactorDefinition };
229
233
  export { ImageGeneratorFormfactorDefinition };
@@ -62,6 +62,7 @@ import type { UsageCounts } from '../execution/Usage';
62
62
  import type { UserInterfaceTools } from '../execution/UserInterfaceTools';
63
63
  import type { UserInterfaceToolsPromptDialogOptions } from '../execution/UserInterfaceTools';
64
64
  import type { FormatSubvalueParser } from '../formats/_common/FormatSubvalueParser';
65
+ import type { FormatSubvalueParserMapValuesOptions } from '../formats/_common/FormatSubvalueParser';
65
66
  import type { CsvSettings } from '../formats/csv/CsvSettings';
66
67
  import type { AbstractFormfactorDefinition } from '../formfactors/_common/AbstractFormfactorDefinition';
67
68
  import type { FormfactorDefinition } from '../formfactors/_common/FormfactorDefinition';
@@ -358,6 +359,7 @@ export type { UsageCounts };
358
359
  export type { UserInterfaceTools };
359
360
  export type { UserInterfaceToolsPromptDialogOptions };
360
361
  export type { FormatSubvalueParser };
362
+ export type { FormatSubvalueParserMapValuesOptions };
361
363
  export type { CsvSettings };
362
364
  export type { AbstractFormfactorDefinition };
363
365
  export type { FormfactorDefinition };
@@ -265,6 +265,14 @@ export declare const DEFAULT_IS_AUTO_INSTALLED = false;
265
265
  * @public exported from `@promptbook/core`
266
266
  */
267
267
  export declare const DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME = "getPipelineCollection";
268
+ /**
269
+ * Default rate limits (requests per minute)
270
+ *
271
+ * Note: Adjust based on the provider tier you are have
272
+ *
273
+ * @public exported from `@promptbook/core`
274
+ */
275
+ export declare const DEFAULT_RPM = 60;
268
276
  /**
269
277
  * @@@
270
278
  *
@@ -1,11 +1,18 @@
1
+ import type { PartialDeep, Promisable } from 'type-fest';
1
2
  import type { TODO_any } from '../../utils/organization/TODO_any';
3
+ import type { PipelineExecutorResult } from '../PipelineExecutorResult';
2
4
  import type { ExecuteAttemptsOptions } from './40-executeAttempts';
3
5
  /**
4
6
  * @@@
5
7
  *
6
8
  * @private internal type of `executeFormatSubvalues`
7
9
  */
8
- type ExecuteFormatCellsOptions = ExecuteAttemptsOptions;
10
+ type ExecuteFormatCellsOptions = ExecuteAttemptsOptions & {
11
+ /**
12
+ * @@@
13
+ */
14
+ readonly onProgress: (newOngoingResult: PartialDeep<PipelineExecutorResult>) => Promisable<void>;
15
+ };
9
16
  /**
10
17
  * @@@
11
18
  *
@@ -24,7 +24,17 @@ export type FormatSubvalueParser<TValue extends string, TSettings extends empty_
24
24
  * For example, if you have a JSON object and you want to map all values to uppercase
25
25
  * Or iterate over all CSV cells @@@
26
26
  */
27
- mapValues(value: TValue, outputParameterName: string_parameter_name, settings: TSettings, mapCallback: (subvalues: Parameters, index: number) => Promisable<string>): Promise<string>;
27
+ mapValues(options: FormatSubvalueParserMapValuesOptions<TValue, TSettings>): Promise<string>;
28
+ };
29
+ /**
30
+ * @@@
31
+ */
32
+ export type FormatSubvalueParserMapValuesOptions<TValue extends string, TSettings extends empty_object> = {
33
+ readonly value: TValue;
34
+ readonly outputParameterName: string_parameter_name;
35
+ readonly settings: TSettings;
36
+ mapCallback: (subvalues: Parameters, index: number) => Promisable<TValue>;
37
+ onProgress(partialResultString: TValue): Promisable<void>;
28
38
  };
29
39
  /**
30
40
  * Note: [πŸ‘©πŸΎβ€πŸ€β€πŸ§‘πŸ½]
@@ -6,6 +6,3 @@
6
6
  * @public exported from `@promptbook/utils`
7
7
  */
8
8
  export declare function jsonParse<T>(value: string): T;
9
- /**
10
- * TODO: !!!! Use in Promptbook.studio
11
- */
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Completion is formfactor that emulates completion models
3
+ *
4
+ * @public exported from `@promptbook/core`
5
+ */
6
+ export declare const CompletionFormfactorDefinition: {
7
+ readonly name: "COMPLETION";
8
+ readonly description: "@@@";
9
+ readonly documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@";
10
+ readonly pipelineInterface: {
11
+ readonly inputParameters: readonly [{
12
+ readonly name: "inputText";
13
+ readonly description: "Input text to be completed";
14
+ readonly isInput: true;
15
+ readonly isOutput: false;
16
+ }, {
17
+ readonly name: "instructions";
18
+ readonly description: "Additional instructions for the model, for example the required length, empty by default";
19
+ readonly isInput: true;
20
+ readonly isOutput: false;
21
+ }];
22
+ readonly outputParameters: readonly [{
23
+ readonly name: "followingText";
24
+ readonly description: "Text that follows the input text";
25
+ readonly isInput: false;
26
+ readonly isOutput: true;
27
+ }];
28
+ };
29
+ };
@@ -36,9 +36,6 @@ export declare const FORMFACTOR_DEFINITIONS: readonly [{
36
36
  readonly outputParameters: readonly [{
37
37
  readonly name: "title";
38
38
  readonly description: "Title of the conversation";
39
- /**
40
- * Note: [πŸ’ž] Ignore a discrepancy between file name and entity name
41
- */
42
39
  readonly isInput: false;
43
40
  readonly isOutput: true;
44
41
  }, {
@@ -132,6 +129,11 @@ export declare const FORMFACTOR_DEFINITIONS: readonly [{
132
129
  readonly isInput: true;
133
130
  readonly isOutput: false;
134
131
  }];
132
+ /**
133
+ * All available formfactor definitions
134
+ *
135
+ * @public exported from `@promptbook/core`
136
+ */
135
137
  readonly outputParameters: readonly [{
136
138
  readonly name: "prompt";
137
139
  readonly description: "Prompt to be used for image generation";
@@ -139,6 +141,29 @@ export declare const FORMFACTOR_DEFINITIONS: readonly [{
139
141
  readonly isOutput: true;
140
142
  }];
141
143
  };
144
+ }, {
145
+ readonly name: "COMPLETION";
146
+ readonly description: "@@@";
147
+ readonly documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@";
148
+ readonly pipelineInterface: {
149
+ readonly inputParameters: readonly [{
150
+ readonly name: "inputText";
151
+ readonly description: "Input text to be completed";
152
+ readonly isInput: true;
153
+ readonly isOutput: false;
154
+ }, {
155
+ readonly name: "instructions";
156
+ readonly description: "Additional instructions for the model, for example the required length, empty by default";
157
+ readonly isInput: true;
158
+ readonly isOutput: false;
159
+ }];
160
+ readonly outputParameters: readonly [{
161
+ readonly name: "followingText";
162
+ readonly description: "Text that follows the input text";
163
+ readonly isInput: false;
164
+ readonly isOutput: true;
165
+ }];
166
+ };
142
167
  }];
143
168
  /**
144
169
  * Note: [πŸ’ž] Ignore a discrepancy between file name and entity name
@@ -23,7 +23,7 @@ export declare const HIGH_LEVEL_ABSTRACTIONS: readonly [{
23
23
  path: string | null;
24
24
  content: import("../pipeline/PipelineString").PipelineString;
25
25
  }[];
26
- readonly formfactorName?: "CHATBOT" | "GENERATOR" | "GENERIC" | "IMAGE_GENERATOR" | "EXPERIMENTAL_MATCHER" | "SHEETS" | "TRANSLATOR" | undefined;
26
+ readonly formfactorName?: "CHATBOT" | "COMPLETION" | "GENERATOR" | "GENERIC" | "IMAGE_GENERATOR" | "EXPERIMENTAL_MATCHER" | "SHEETS" | "TRANSLATOR" | undefined;
27
27
  }>): void;
28
28
  }, {
29
29
  type: "SYNC";
@@ -45,7 +45,7 @@ export declare const HIGH_LEVEL_ABSTRACTIONS: readonly [{
45
45
  path: string | null;
46
46
  content: import("../pipeline/PipelineString").PipelineString;
47
47
  }[];
48
- readonly formfactorName?: "CHATBOT" | "GENERATOR" | "GENERIC" | "IMAGE_GENERATOR" | "EXPERIMENTAL_MATCHER" | "SHEETS" | "TRANSLATOR" | undefined;
48
+ readonly formfactorName?: "CHATBOT" | "COMPLETION" | "GENERATOR" | "GENERIC" | "IMAGE_GENERATOR" | "EXPERIMENTAL_MATCHER" | "SHEETS" | "TRANSLATOR" | undefined;
49
49
  }>): void;
50
50
  }];
51
51
  /**
@@ -2,6 +2,8 @@ import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
2
2
  /**
3
3
  * Migrates the pipeline to the latest version
4
4
  *
5
+ * Note: Migration does not do heavy lifting like calling the LLMs, just lightweight changes of the structure
6
+ *
5
7
  * @public exported from `@promptbook/core`
6
8
  */
7
9
  export declare function migratePipeline(deprecatedPipeline: PipelineJson): PipelineJson;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/core",
3
- "version": "0.92.0-20",
3
+ "version": "0.92.0-22",
4
4
  "description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -27,7 +27,7 @@
27
27
  * @generated
28
28
  * @see https://github.com/webgptorg/promptbook
29
29
  */
30
- const PROMPTBOOK_ENGINE_VERSION = '0.92.0-20';
30
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0-22';
31
31
  /**
32
32
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
33
33
  * Note: [πŸ’ž] Ignore a discrepancy between file name and entity name
@@ -462,6 +462,14 @@
462
462
  * @public exported from `@promptbook/core`
463
463
  */
464
464
  const DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME = `getPipelineCollection`;
465
+ /**
466
+ * Default rate limits (requests per minute)
467
+ *
468
+ * Note: Adjust based on the provider tier you are have
469
+ *
470
+ * @public exported from `@promptbook/core`
471
+ */
472
+ const DEFAULT_RPM = 60;
465
473
  /**
466
474
  * @@@
467
475
  *
@@ -2185,15 +2193,12 @@
2185
2193
  }
2186
2194
  throw new Error(spaceTrim__default["default"]((block) => `
2187
2195
  ${block(error.message)}
2188
-
2196
+
2189
2197
  The JSON text:
2190
2198
  ${block(value)}
2191
2199
  `));
2192
2200
  }
2193
2201
  }
2194
- /**
2195
- * TODO: !!!! Use in Promptbook.studio
2196
- */
2197
2202
 
2198
2203
  /**
2199
2204
  * Recursively converts JSON strings to JSON objects
@@ -2817,7 +2822,8 @@
2817
2822
  subvalueParsers: [
2818
2823
  {
2819
2824
  subvalueName: 'ROW',
2820
- async mapValues(value, outputParameterName, settings, mapCallback) {
2825
+ async mapValues(options) {
2826
+ const { value, outputParameterName, settings, mapCallback, onProgress } = options;
2821
2827
  const csv = csvParse(value, settings);
2822
2828
  if (csv.errors.length !== 0) {
2823
2829
  throw new CsvFormatError(spaceTrim__default["default"]((block) => `
@@ -2833,21 +2839,29 @@
2833
2839
  ${block(value)}
2834
2840
  `));
2835
2841
  }
2836
- const mappedData = await Promise.all(csv.data.map(async (row, index) => {
2842
+ const mappedData = [];
2843
+ for (let index = 0; index < csv.data.length; index++) {
2844
+ const row = csv.data[index];
2837
2845
  if (row[outputParameterName]) {
2838
2846
  throw new CsvFormatError(`Can not overwrite existing column "${outputParameterName}" in CSV row`);
2839
2847
  }
2840
- return {
2848
+ const mappedRow = {
2841
2849
  ...row,
2842
2850
  [outputParameterName]: await mapCallback(row, index),
2843
2851
  };
2844
- }));
2852
+ mappedData.push(mappedRow);
2853
+ if (onProgress) {
2854
+ // Note: Report the CSV with all rows mapped so far
2855
+ await onProgress(papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS }));
2856
+ }
2857
+ }
2845
2858
  return papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
2846
2859
  },
2847
2860
  },
2848
2861
  {
2849
2862
  subvalueName: 'CELL',
2850
- async mapValues(value, outputParameterName, settings, mapCallback) {
2863
+ async mapValues(options) {
2864
+ const { value, settings, mapCallback, onProgress } = options;
2851
2865
  const csv = csvParse(value, settings);
2852
2866
  if (csv.errors.length !== 0) {
2853
2867
  throw new CsvFormatError(spaceTrim__default["default"]((block) => `
@@ -2934,7 +2948,8 @@
2934
2948
  subvalueParsers: [
2935
2949
  {
2936
2950
  subvalueName: 'LINE',
2937
- async mapValues(value, outputParameterName, settings, mapCallback) {
2951
+ async mapValues(options) {
2952
+ const { value, mapCallback, onProgress } = options;
2938
2953
  const lines = value.split('\n');
2939
2954
  const mappedLines = await Promise.all(lines.map((lineContent, lineNumber) =>
2940
2955
  // TODO: [🧠] Maybe option to skip empty line
@@ -4266,7 +4281,7 @@
4266
4281
  * @private internal utility of `createPipelineExecutor`
4267
4282
  */
4268
4283
  async function executeFormatSubvalues(options) {
4269
- const { task, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification } = options;
4284
+ const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, pipelineIdentification } = options;
4270
4285
  if (task.foreach === undefined) {
4271
4286
  return /* not await */ executeAttempts(options);
4272
4287
  }
@@ -4320,21 +4335,32 @@
4320
4335
  formatSettings = csvSettings;
4321
4336
  // <- TODO: [πŸ€Ήβ€β™‚οΈ] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
4322
4337
  }
4323
- const resultString = await subvalueParser.mapValues(parameterValue, task.foreach.outputSubparameterName, formatSettings, async (subparameters, index) => {
4324
- let mappedParameters;
4325
- // TODO: [πŸ€Ήβ€β™‚οΈ][πŸͺ‚] Limit to N concurrent executions
4326
- // TODO: When done [🐚] Report progress also for each subvalue here
4327
- try {
4328
- mappedParameters = mapAvailableToExpectedParameters({
4329
- expectedParameters: Object.fromEntries(task.foreach.inputSubparameterNames.map((subparameterName) => [subparameterName, null])),
4330
- availableParameters: subparameters,
4331
- });
4332
- }
4333
- catch (error) {
4334
- if (!(error instanceof PipelineExecutionError)) {
4335
- throw error;
4338
+ const resultString = await subvalueParser.mapValues({
4339
+ value: parameterValue,
4340
+ outputParameterName: task.foreach.outputSubparameterName,
4341
+ settings: formatSettings,
4342
+ onProgress(partialResultString) {
4343
+ return onProgress(Object.freeze({
4344
+ [task.resultingParameterName]:
4345
+ // <- Note: [πŸ‘©β€πŸ‘©β€πŸ‘§] No need to detect parameter collision here because pipeline checks logic consistency during construction
4346
+ partialResultString,
4347
+ }));
4348
+ },
4349
+ async mapCallback(subparameters, index) {
4350
+ let mappedParameters;
4351
+ // TODO: [πŸ€Ήβ€β™‚οΈ][πŸͺ‚] Limit to N concurrent executions
4352
+ // TODO: When done [🐚] Report progress also for each subvalue here
4353
+ try {
4354
+ mappedParameters = mapAvailableToExpectedParameters({
4355
+ expectedParameters: Object.fromEntries(task.foreach.inputSubparameterNames.map((subparameterName) => [subparameterName, null])),
4356
+ availableParameters: subparameters,
4357
+ });
4336
4358
  }
4337
- throw new PipelineExecutionError(spaceTrim__default["default"]((block) => `
4359
+ catch (error) {
4360
+ if (!(error instanceof PipelineExecutionError)) {
4361
+ throw error;
4362
+ }
4363
+ throw new PipelineExecutionError(spaceTrim__default["default"]((block) => `
4338
4364
  ${error.message}
4339
4365
 
4340
4366
  This is error in FOREACH command
@@ -4343,23 +4369,24 @@
4343
4369
  ${block(pipelineIdentification)}
4344
4370
  Subparameter index: ${index}
4345
4371
  `));
4346
- }
4347
- const allSubparameters = {
4348
- ...parameters,
4349
- ...mappedParameters,
4350
- };
4351
- // Note: [πŸ‘¨β€πŸ‘¨β€πŸ‘§] Now we can freeze `subparameters` because we are sure that all and only used parameters are defined and are not going to be changed
4352
- Object.freeze(allSubparameters);
4353
- const subresultString = await executeAttempts({
4354
- ...options,
4355
- priority: priority + index,
4356
- parameters: allSubparameters,
4357
- pipelineIdentification: spaceTrim__default["default"]((block) => `
4372
+ }
4373
+ const allSubparameters = {
4374
+ ...parameters,
4375
+ ...mappedParameters,
4376
+ };
4377
+ // Note: [πŸ‘¨β€πŸ‘¨β€πŸ‘§] Now we can freeze `subparameters` because we are sure that all and only used parameters are defined and are not going to be changed
4378
+ Object.freeze(allSubparameters);
4379
+ const subresultString = await executeAttempts({
4380
+ ...options,
4381
+ priority: priority + index,
4382
+ parameters: allSubparameters,
4383
+ pipelineIdentification: spaceTrim__default["default"]((block) => `
4358
4384
  ${block(pipelineIdentification)}
4359
4385
  Subparameter index: ${index}
4360
4386
  `),
4361
- });
4362
- return subresultString;
4387
+ });
4388
+ return subresultString;
4389
+ },
4363
4390
  });
4364
4391
  return resultString;
4365
4392
  }
@@ -4533,11 +4560,6 @@
4533
4560
  async function executeTask(options) {
4534
4561
  const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSupressed, } = options;
4535
4562
  const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
4536
- await onProgress({
4537
- outputParameters: {
4538
- [currentTask.resultingParameterName]: '', // <- TODO: [🧠] What is the best value here?
4539
- },
4540
- });
4541
4563
  // Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but it’s good to doublecheck
4542
4564
  const usedParameterNames = extractParameterNamesFromTask(currentTask);
4543
4565
  const dependentParameterNames = new Set(currentTask.dependentParameterNames);
@@ -4612,6 +4634,7 @@
4612
4634
  preparedPipeline,
4613
4635
  tools,
4614
4636
  $executionReport,
4637
+ onProgress,
4615
4638
  pipelineIdentification,
4616
4639
  maxExecutionAttempts,
4617
4640
  maxParallelCount,
@@ -7212,6 +7235,43 @@
7212
7235
  },
7213
7236
  };
7214
7237
 
7238
+ /**
7239
+ * Completion is formfactor that emulates completion models
7240
+ *
7241
+ * @public exported from `@promptbook/core`
7242
+ */
7243
+ const CompletionFormfactorDefinition = {
7244
+ name: 'COMPLETION',
7245
+ description: `@@@`,
7246
+ documentationUrl: `https://github.com/webgptorg/promptbook/discussions/@@`,
7247
+ // <- TODO: https://github.com/webgptorg/promptbook/discussions/new?category=concepts
7248
+ // "πŸ”  Completion Formfactor"
7249
+ pipelineInterface: {
7250
+ inputParameters: [
7251
+ {
7252
+ name: 'inputText',
7253
+ description: `Input text to be completed`,
7254
+ isInput: true,
7255
+ isOutput: false,
7256
+ },
7257
+ {
7258
+ name: 'instructions',
7259
+ description: `Additional instructions for the model, for example the required length, empty by default`,
7260
+ isInput: true,
7261
+ isOutput: false,
7262
+ },
7263
+ ],
7264
+ outputParameters: [
7265
+ {
7266
+ name: 'followingText',
7267
+ description: `Text that follows the input text`,
7268
+ isInput: false,
7269
+ isOutput: true,
7270
+ },
7271
+ ],
7272
+ },
7273
+ };
7274
+
7215
7275
  /**
7216
7276
  * Generator is form of app that @@@
7217
7277
  *
@@ -7396,6 +7456,8 @@
7396
7456
  MatcherFormfactorDefinition,
7397
7457
  GeneratorFormfactorDefinition,
7398
7458
  ImageGeneratorFormfactorDefinition,
7459
+ CompletionFormfactorDefinition,
7460
+ // <- [πŸ›¬] When making new formfactor, copy the _boilerplate and link it here
7399
7461
  ];
7400
7462
  /**
7401
7463
  * Note: [πŸ’ž] Ignore a discrepancy between file name and entity name
@@ -10888,6 +10950,7 @@
10888
10950
  className: 'OpenAiExecutionTools',
10889
10951
  options: {
10890
10952
  apiKey: 'sk-',
10953
+ maxRequestsPerMinute: DEFAULT_RPM,
10891
10954
  },
10892
10955
  };
10893
10956
  },
@@ -10960,20 +11023,28 @@
10960
11023
  /**
10961
11024
  * Migrates the pipeline to the latest version
10962
11025
  *
11026
+ * Note: Migration does not do heavy lifting like calling the LLMs, just lightweight changes of the structure
11027
+ *
10963
11028
  * @public exported from `@promptbook/core`
10964
11029
  */
10965
11030
  function migratePipeline(deprecatedPipeline) {
10966
11031
  /* eslint-disable prefer-const */
10967
11032
  let { pipelineUrl, sourceFile, title, bookVersion, description, formfactorName, parameters, tasks, knowledgeSources, knowledgePieces, personas, preparations, sources, } = deprecatedPipeline;
11033
+ let isChanged = false;
10968
11034
  personas = personas.map((persona) => {
10969
11035
  const migratedPersona = { ...persona }; /* <- TODO: [πŸŒͺ] */
10970
11036
  if (migratedPersona.modelRequirements !== undefined) {
11037
+ isChanged = true;
10971
11038
  migratedPersona.modelsRequirements = [migratedPersona.modelRequirements];
10972
11039
  delete migratedPersona.modelRequirements;
10973
11040
  }
10974
11041
  return migratedPersona;
10975
11042
  });
10976
- return {
11043
+ if (!isChanged) {
11044
+ // Note: If nothing to migrate, return the same pipeline
11045
+ return deprecatedPipeline;
11046
+ }
11047
+ const migratedPipeline = {
10977
11048
  pipelineUrl,
10978
11049
  sourceFile,
10979
11050
  title,
@@ -10989,6 +11060,10 @@
10989
11060
  sources,
10990
11061
  // <- TODO: [πŸ™] Make some standard order of json properties
10991
11062
  };
11063
+ console.info(`Book automatically migrated`, { deprecatedPipeline, migratedPipeline });
11064
+ // console.info(`Book automatically migrated from ${} -> ${}`, {deprecatedPipeline,migratedPipeline})
11065
+ // <- TODO: Report the versions of the migration, DO not migrate backwards, throw `CompatibilityError` when given newer version than current version of the engine and link the NPM + Docker packages
11066
+ return migratedPipeline;
10992
11067
  }
10993
11068
 
10994
11069
  /**
@@ -11440,6 +11515,7 @@
11440
11515
  exports.CallbackInterfaceTools = CallbackInterfaceTools;
11441
11516
  exports.ChatbotFormfactorDefinition = ChatbotFormfactorDefinition;
11442
11517
  exports.CollectionError = CollectionError;
11518
+ exports.CompletionFormfactorDefinition = CompletionFormfactorDefinition;
11443
11519
  exports.CsvFormatError = CsvFormatError;
11444
11520
  exports.CsvFormatParser = CsvFormatParser;
11445
11521
  exports.DEFAULT_BOOKS_DIRNAME = DEFAULT_BOOKS_DIRNAME;
@@ -11459,6 +11535,7 @@
11459
11535
  exports.DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME = DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME;
11460
11536
  exports.DEFAULT_PROMPT_TASK_TITLE = DEFAULT_PROMPT_TASK_TITLE;
11461
11537
  exports.DEFAULT_REMOTE_SERVER_URL = DEFAULT_REMOTE_SERVER_URL;
11538
+ exports.DEFAULT_RPM = DEFAULT_RPM;
11462
11539
  exports.DEFAULT_SCRAPE_CACHE_DIRNAME = DEFAULT_SCRAPE_CACHE_DIRNAME;
11463
11540
  exports.DEFAULT_TASK_TITLE = DEFAULT_TASK_TITLE;
11464
11541
  exports.EXPECTATION_UNITS = EXPECTATION_UNITS;