@promptbook/core 0.92.0-19 → 0.92.0-21

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';
@@ -105,6 +107,7 @@ import { joinLlmExecutionTools } from '../llm-providers/multiple/joinLlmExecutio
105
107
  import { MultipleLlmExecutionTools } from '../llm-providers/multiple/MultipleLlmExecutionTools';
106
108
  import { _OpenAiMetadataRegistration } from '../llm-providers/openai/register-configuration';
107
109
  import { _OpenAiAssistantMetadataRegistration } from '../llm-providers/openai/register-configuration';
110
+ import { migratePipeline } from '../migrations/migratePipeline';
108
111
  import { preparePersona } from '../personas/preparePersona';
109
112
  import { book } from '../pipeline/book-notation';
110
113
  import { isValidPipelineString } from '../pipeline/isValidPipelineString';
@@ -174,6 +177,7 @@ export { DEFAULT_IS_VERBOSE };
174
177
  export { SET_IS_VERBOSE };
175
178
  export { DEFAULT_IS_AUTO_INSTALLED };
176
179
  export { DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME };
180
+ export { DEFAULT_RPM };
177
181
  export { ORDER_OF_PIPELINE_JSON };
178
182
  export { RESERVED_PARAMETER_NAMES };
179
183
  export { compilePipeline };
@@ -223,6 +227,7 @@ export { MANDATORY_CSV_SETTINGS };
223
227
  export { TextFormatParser };
224
228
  export { BoilerplateFormfactorDefinition };
225
229
  export { ChatbotFormfactorDefinition };
230
+ export { CompletionFormfactorDefinition };
226
231
  export { GeneratorFormfactorDefinition };
227
232
  export { GenericFormfactorDefinition };
228
233
  export { ImageGeneratorFormfactorDefinition };
@@ -247,6 +252,7 @@ export { joinLlmExecutionTools };
247
252
  export { MultipleLlmExecutionTools };
248
253
  export { _OpenAiMetadataRegistration };
249
254
  export { _OpenAiAssistantMetadataRegistration };
255
+ export { migratePipeline };
250
256
  export { preparePersona };
251
257
  export { book };
252
258
  export { isValidPipelineString };
@@ -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
  *
@@ -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
  /**
@@ -0,0 +1,9 @@
1
+ import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
2
+ /**
3
+ * Migrates the pipeline to the latest version
4
+ *
5
+ * Note: Migration does not do heavy lifting like calling the LLMs, just lightweight changes of the structure
6
+ *
7
+ * @public exported from `@promptbook/core`
8
+ */
9
+ export declare function migratePipeline(deprecatedPipeline: PipelineJson): PipelineJson;
@@ -103,6 +103,7 @@ export type PipelineJson = {
103
103
  }>;
104
104
  };
105
105
  /**
106
+ * TODO: [🌪] Make type for deprecated pipelines
106
107
  * TODO: [🛳] Default PERSONA for the pipeline `defaultPersonaName` (same as `defaultModelRequirements`)
107
108
  * TODO: [🍙] Make some standard order of json properties
108
109
  * TODO: [🧠] Maybe wrap all {parameterNames} in brackets for example { "resultingParameterName": "{foo}" }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/core",
3
- "version": "0.92.0-19",
3
+ "version": "0.92.0-21",
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-19';
30
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0-21';
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
@@ -7212,6 +7217,43 @@
7212
7217
  },
7213
7218
  };
7214
7219
 
7220
+ /**
7221
+ * Completion is formfactor that emulates completion models
7222
+ *
7223
+ * @public exported from `@promptbook/core`
7224
+ */
7225
+ const CompletionFormfactorDefinition = {
7226
+ name: 'COMPLETION',
7227
+ description: `@@@`,
7228
+ documentationUrl: `https://github.com/webgptorg/promptbook/discussions/@@`,
7229
+ // <- TODO: https://github.com/webgptorg/promptbook/discussions/new?category=concepts
7230
+ // "🔠 Completion Formfactor"
7231
+ pipelineInterface: {
7232
+ inputParameters: [
7233
+ {
7234
+ name: 'inputText',
7235
+ description: `Input text to be completed`,
7236
+ isInput: true,
7237
+ isOutput: false,
7238
+ },
7239
+ {
7240
+ name: 'instructions',
7241
+ description: `Additional instructions for the model, for example the required length, empty by default`,
7242
+ isInput: true,
7243
+ isOutput: false,
7244
+ },
7245
+ ],
7246
+ outputParameters: [
7247
+ {
7248
+ name: 'followingText',
7249
+ description: `Text that follows the input text`,
7250
+ isInput: false,
7251
+ isOutput: true,
7252
+ },
7253
+ ],
7254
+ },
7255
+ };
7256
+
7215
7257
  /**
7216
7258
  * Generator is form of app that @@@
7217
7259
  *
@@ -7396,6 +7438,8 @@
7396
7438
  MatcherFormfactorDefinition,
7397
7439
  GeneratorFormfactorDefinition,
7398
7440
  ImageGeneratorFormfactorDefinition,
7441
+ CompletionFormfactorDefinition,
7442
+ // <- [🛬] When making new formfactor, copy the _boilerplate and link it here
7399
7443
  ];
7400
7444
  /**
7401
7445
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -10888,6 +10932,7 @@
10888
10932
  className: 'OpenAiExecutionTools',
10889
10933
  options: {
10890
10934
  apiKey: 'sk-',
10935
+ maxRequestsPerMinute: DEFAULT_RPM,
10891
10936
  },
10892
10937
  };
10893
10938
  },
@@ -10957,6 +11002,52 @@
10957
11002
  * Note: [💞] Ignore a discrepancy between file name and entity name
10958
11003
  */
10959
11004
 
11005
+ /**
11006
+ * Migrates the pipeline to the latest version
11007
+ *
11008
+ * Note: Migration does not do heavy lifting like calling the LLMs, just lightweight changes of the structure
11009
+ *
11010
+ * @public exported from `@promptbook/core`
11011
+ */
11012
+ function migratePipeline(deprecatedPipeline) {
11013
+ /* eslint-disable prefer-const */
11014
+ let { pipelineUrl, sourceFile, title, bookVersion, description, formfactorName, parameters, tasks, knowledgeSources, knowledgePieces, personas, preparations, sources, } = deprecatedPipeline;
11015
+ let isChanged = false;
11016
+ personas = personas.map((persona) => {
11017
+ const migratedPersona = { ...persona }; /* <- TODO: [🌪] */
11018
+ if (migratedPersona.modelRequirements !== undefined) {
11019
+ isChanged = true;
11020
+ migratedPersona.modelsRequirements = [migratedPersona.modelRequirements];
11021
+ delete migratedPersona.modelRequirements;
11022
+ }
11023
+ return migratedPersona;
11024
+ });
11025
+ if (!isChanged) {
11026
+ // Note: If nothing to migrate, return the same pipeline
11027
+ return deprecatedPipeline;
11028
+ }
11029
+ const migratedPipeline = {
11030
+ pipelineUrl,
11031
+ sourceFile,
11032
+ title,
11033
+ bookVersion,
11034
+ description,
11035
+ formfactorName,
11036
+ parameters,
11037
+ tasks,
11038
+ knowledgeSources,
11039
+ knowledgePieces,
11040
+ personas,
11041
+ preparations,
11042
+ sources,
11043
+ // <- TODO: [🍙] Make some standard order of json properties
11044
+ };
11045
+ console.info(`Book automatically migrated`, { deprecatedPipeline, migratedPipeline });
11046
+ // console.info(`Book automatically migrated from ${} -> ${}`, {deprecatedPipeline,migratedPipeline})
11047
+ // <- 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
11048
+ return migratedPipeline;
11049
+ }
11050
+
10960
11051
  /**
10961
11052
  * Function `isValidPipelineString` will validate the if the string is a valid pipeline string
10962
11053
  * It does not check if the string is fully logically correct, but if it is a string that can be a pipeline string or the string looks completely different.
@@ -11406,6 +11497,7 @@
11406
11497
  exports.CallbackInterfaceTools = CallbackInterfaceTools;
11407
11498
  exports.ChatbotFormfactorDefinition = ChatbotFormfactorDefinition;
11408
11499
  exports.CollectionError = CollectionError;
11500
+ exports.CompletionFormfactorDefinition = CompletionFormfactorDefinition;
11409
11501
  exports.CsvFormatError = CsvFormatError;
11410
11502
  exports.CsvFormatParser = CsvFormatParser;
11411
11503
  exports.DEFAULT_BOOKS_DIRNAME = DEFAULT_BOOKS_DIRNAME;
@@ -11425,6 +11517,7 @@
11425
11517
  exports.DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME = DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME;
11426
11518
  exports.DEFAULT_PROMPT_TASK_TITLE = DEFAULT_PROMPT_TASK_TITLE;
11427
11519
  exports.DEFAULT_REMOTE_SERVER_URL = DEFAULT_REMOTE_SERVER_URL;
11520
+ exports.DEFAULT_RPM = DEFAULT_RPM;
11428
11521
  exports.DEFAULT_SCRAPE_CACHE_DIRNAME = DEFAULT_SCRAPE_CACHE_DIRNAME;
11429
11522
  exports.DEFAULT_TASK_TITLE = DEFAULT_TASK_TITLE;
11430
11523
  exports.EXPECTATION_UNITS = EXPECTATION_UNITS;
@@ -11515,6 +11608,7 @@
11515
11608
  exports.joinLlmExecutionTools = joinLlmExecutionTools;
11516
11609
  exports.limitTotalUsage = limitTotalUsage;
11517
11610
  exports.makeKnowledgeSourceHandler = makeKnowledgeSourceHandler;
11611
+ exports.migratePipeline = migratePipeline;
11518
11612
  exports.parsePipeline = parsePipeline;
11519
11613
  exports.pipelineJsonToString = pipelineJsonToString;
11520
11614
  exports.prepareKnowledgePieces = prepareKnowledgePieces;