@promptbook/core 0.75.4 → 0.75.6

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.
@@ -34,11 +34,12 @@ import { stringifyPipelineJson } from '../conversion/utils/stringifyPipelineJson
34
34
  import { validatePipeline } from '../conversion/validation/validatePipeline';
35
35
  import { CallbackInterfaceTools } from '../dialogs/callback/CallbackInterfaceTools';
36
36
  import type { CallbackInterfaceToolsOptions } from '../dialogs/callback/CallbackInterfaceToolsOptions';
37
+ import { BoilerplateError } from '../errors/0-BoilerplateError';
38
+ import { ERRORS } from '../errors/0-index';
37
39
  import { AbstractFormatError } from '../errors/AbstractFormatError';
38
40
  import { CollectionError } from '../errors/CollectionError';
39
41
  import { EnvironmentMismatchError } from '../errors/EnvironmentMismatchError';
40
42
  import { ExpectError } from '../errors/ExpectError';
41
- import { ERRORS } from '../errors/index';
42
43
  import { KnowledgeScrapeError } from '../errors/KnowledgeScrapeError';
43
44
  import { LimitReachedError } from '../errors/LimitReachedError';
44
45
  import { MissingToolsError } from '../errors/MissingToolsError';
@@ -147,11 +148,12 @@ export { stringifyPipelineJson };
147
148
  export { validatePipeline };
148
149
  export { CallbackInterfaceTools };
149
150
  export type { CallbackInterfaceToolsOptions };
151
+ export { BoilerplateError };
152
+ export { ERRORS };
150
153
  export { AbstractFormatError };
151
154
  export { CollectionError };
152
155
  export { EnvironmentMismatchError };
153
156
  export { ExpectError };
154
- export { ERRORS };
155
157
  export { KnowledgeScrapeError };
156
158
  export { LimitReachedError };
157
159
  export { MissingToolsError };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This error indicates @@@
3
+ *
4
+ * @public exported from `@promptbook/core`
5
+ */
6
+ export declare class BoilerplateError extends Error {
7
+ readonly name = "BoilerplateError";
8
+ constructor(message: string);
9
+ }
10
+ /**
11
+ * TODO: @@@ Do not forget to add the error into `0-index.ts` ERRORS
12
+ */
@@ -1,7 +1,11 @@
1
+ import { CsvFormatError } from '../formats/csv/CsvFormatError';
2
+ import { AbstractFormatError } from './AbstractFormatError';
1
3
  import { CollectionError } from './CollectionError';
2
4
  import { EnvironmentMismatchError } from './EnvironmentMismatchError';
3
5
  import { ExpectError } from './ExpectError';
6
+ import { KnowledgeScrapeError } from './KnowledgeScrapeError';
4
7
  import { LimitReachedError } from './LimitReachedError';
8
+ import { MissingToolsError } from './MissingToolsError';
5
9
  import { NotFoundError } from './NotFoundError';
6
10
  import { NotYetImplementedError } from './NotYetImplementedError';
7
11
  import { ParseError } from './ParseError';
@@ -15,10 +19,14 @@ import { UnexpectedError } from './UnexpectedError';
15
19
  * @public exported from `@promptbook/core`
16
20
  */
17
21
  export declare const ERRORS: {
18
- readonly ExpectError: typeof ExpectError;
22
+ readonly AbstractFormatError: typeof AbstractFormatError;
23
+ readonly CsvFormatError: typeof CsvFormatError;
19
24
  readonly CollectionError: typeof CollectionError;
20
25
  readonly EnvironmentMismatchError: typeof EnvironmentMismatchError;
26
+ readonly ExpectError: typeof ExpectError;
27
+ readonly KnowledgeScrapeError: typeof KnowledgeScrapeError;
21
28
  readonly LimitReachedError: typeof LimitReachedError;
29
+ readonly MissingToolsError: typeof MissingToolsError;
22
30
  readonly NotFoundError: typeof NotFoundError;
23
31
  readonly NotYetImplementedError: typeof NotYetImplementedError;
24
32
  readonly ParseError: typeof ParseError;
@@ -29,4 +37,4 @@ export declare const ERRORS: {
29
37
  };
30
38
  /**
31
39
  * Note: [💞] Ignore a discrepancy between file name and entity name
32
- */
40
+ */
@@ -1,4 +1,4 @@
1
- import type { ERRORS } from '../index';
1
+ import type { ERRORS } from '../0-index';
2
2
  /**
3
3
  * Represents a serialized error or custom Promptbook error
4
4
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/core",
3
- "version": "0.75.4",
3
+ "version": "0.75.6",
4
4
  "description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
5
5
  "--note-0": " <- [🐊]",
6
6
  "private": false,
package/umd/index.umd.js CHANGED
@@ -24,7 +24,7 @@
24
24
  *
25
25
  * @see https://github.com/webgptorg/promptbook
26
26
  */
27
- var PROMPTBOOK_ENGINE_VERSION = '0.75.3';
27
+ var PROMPTBOOK_ENGINE_VERSION = '0.75.5';
28
28
  /**
29
29
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
30
30
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2355,6 +2355,42 @@
2355
2355
 
2356
2356
  var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-knowledge-from-markdown.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-knowledge-keywords.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-knowledge-title.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.md",formfactorName:"GENERIC",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-persona.book.md"}];
2357
2357
 
2358
+ /**
2359
+ * This error indicates problems parsing the format value
2360
+ *
2361
+ * For example, when the format value is not a valid JSON or CSV
2362
+ * This is not thrown directly but in extended classes
2363
+ *
2364
+ * @public exported from `@promptbook/core`
2365
+ */
2366
+ var AbstractFormatError = /** @class */ (function (_super) {
2367
+ __extends(AbstractFormatError, _super);
2368
+ // Note: To allow instanceof do not put here error `name`
2369
+ // public readonly name = 'AbstractFormatError';
2370
+ function AbstractFormatError(message) {
2371
+ var _this = _super.call(this, message) || this;
2372
+ Object.setPrototypeOf(_this, AbstractFormatError.prototype);
2373
+ return _this;
2374
+ }
2375
+ return AbstractFormatError;
2376
+ }(Error));
2377
+
2378
+ /**
2379
+ * This error indicates problem with parsing of CSV
2380
+ *
2381
+ * @public exported from `@promptbook/core`
2382
+ */
2383
+ var CsvFormatError = /** @class */ (function (_super) {
2384
+ __extends(CsvFormatError, _super);
2385
+ function CsvFormatError(message) {
2386
+ var _this = _super.call(this, message) || this;
2387
+ _this.name = 'CsvFormatError';
2388
+ Object.setPrototypeOf(_this, CsvFormatError.prototype);
2389
+ return _this;
2390
+ }
2391
+ return CsvFormatError;
2392
+ }(AbstractFormatError));
2393
+
2358
2394
  /**
2359
2395
  * This error indicates that the pipeline collection cannot be propperly loaded
2360
2396
  *
@@ -2406,6 +2442,22 @@
2406
2442
  return ExpectError;
2407
2443
  }(Error));
2408
2444
 
2445
+ /**
2446
+ * This error indicates that the promptbook can not retrieve knowledge from external sources
2447
+ *
2448
+ * @public exported from `@promptbook/core`
2449
+ */
2450
+ var KnowledgeScrapeError = /** @class */ (function (_super) {
2451
+ __extends(KnowledgeScrapeError, _super);
2452
+ function KnowledgeScrapeError(message) {
2453
+ var _this = _super.call(this, message) || this;
2454
+ _this.name = 'KnowledgeScrapeError';
2455
+ Object.setPrototypeOf(_this, KnowledgeScrapeError.prototype);
2456
+ return _this;
2457
+ }
2458
+ return KnowledgeScrapeError;
2459
+ }(Error));
2460
+
2409
2461
  /**
2410
2462
  * This error type indicates that some limit was reached
2411
2463
  *
@@ -2444,10 +2496,14 @@
2444
2496
  * @public exported from `@promptbook/core`
2445
2497
  */
2446
2498
  var ERRORS = {
2447
- ExpectError: ExpectError,
2499
+ AbstractFormatError: AbstractFormatError,
2500
+ CsvFormatError: CsvFormatError,
2448
2501
  CollectionError: CollectionError,
2449
2502
  EnvironmentMismatchError: EnvironmentMismatchError,
2503
+ ExpectError: ExpectError,
2504
+ KnowledgeScrapeError: KnowledgeScrapeError,
2450
2505
  LimitReachedError: LimitReachedError,
2506
+ MissingToolsError: MissingToolsError,
2451
2507
  NotFoundError: NotFoundError,
2452
2508
  NotYetImplementedError: NotYetImplementedError,
2453
2509
  ParseError: ParseError,
@@ -2760,42 +2816,6 @@
2760
2816
  return union;
2761
2817
  }
2762
2818
 
2763
- /**
2764
- * This error indicates problems parsing the format value
2765
- *
2766
- * For example, when the format value is not a valid JSON or CSV
2767
- * This is not thrown directly but in extended classes
2768
- *
2769
- * @public exported from `@promptbook/core`
2770
- */
2771
- var AbstractFormatError = /** @class */ (function (_super) {
2772
- __extends(AbstractFormatError, _super);
2773
- // Note: To allow instanceof do not put here error `name`
2774
- // public readonly name = 'AbstractFormatError';
2775
- function AbstractFormatError(message) {
2776
- var _this = _super.call(this, message) || this;
2777
- Object.setPrototypeOf(_this, AbstractFormatError.prototype);
2778
- return _this;
2779
- }
2780
- return AbstractFormatError;
2781
- }(Error));
2782
-
2783
- /**
2784
- * This error indicates problem with parsing of CSV
2785
- *
2786
- * @public exported from `@promptbook/core`
2787
- */
2788
- var CsvFormatError = /** @class */ (function (_super) {
2789
- __extends(CsvFormatError, _super);
2790
- function CsvFormatError(message) {
2791
- var _this = _super.call(this, message) || this;
2792
- _this.name = 'CsvFormatError';
2793
- Object.setPrototypeOf(_this, CsvFormatError.prototype);
2794
- return _this;
2795
- }
2796
- return CsvFormatError;
2797
- }(AbstractFormatError));
2798
-
2799
2819
  /**
2800
2820
  * @@@
2801
2821
  *
@@ -2836,7 +2856,7 @@
2836
2856
  case 0:
2837
2857
  csv = papaparse.parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
2838
2858
  if (csv.errors.length !== 0) {
2839
- throw new CsvFormatError(spaceTrim__default["default"](function (block) { return "\n CSV parsing error\n\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n "); }));
2859
+ throw new CsvFormatError(spaceTrim__default["default"](function (block) { return "\n CSV parsing error\n\n Error(s) from CSV parsing:\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n\n The CSV setings:\n ").concat(block(JSON.stringify(__assign(__assign({}, settings), MANDATORY_CSV_SETTINGS), null, 2)), "\n\n The CSV data:\n ").concat(block(value), "\n "); }));
2840
2860
  }
2841
2861
  return [4 /*yield*/, Promise.all(csv.data.map(function (row, index) { return __awaiter(_this, void 0, void 0, function () {
2842
2862
  var _a, _b;
@@ -2874,7 +2894,7 @@
2874
2894
  case 0:
2875
2895
  csv = papaparse.parse(value, __assign(__assign({}, settings), MANDATORY_CSV_SETTINGS));
2876
2896
  if (csv.errors.length !== 0) {
2877
- throw new CsvFormatError(spaceTrim__default["default"](function (block) { return "\n CSV parsing error\n\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n "); }));
2897
+ throw new CsvFormatError(spaceTrim__default["default"](function (block) { return "\n CSV parsing error\n\n Error(s) from CSV parsing:\n ".concat(block(csv.errors.map(function (error) { return error.message; }).join('\n\n')), "\n\n The CSV setings:\n ").concat(block(JSON.stringify(__assign(__assign({}, settings), MANDATORY_CSV_SETTINGS), null, 2)), "\n\n The CSV data:\n ").concat(block(value), "\n "); }));
2878
2898
  }
2879
2899
  return [4 /*yield*/, Promise.all(csv.data.map(function (row, rowIndex) { return __awaiter(_this, void 0, void 0, function () {
2880
2900
  var _this = this;
@@ -4934,22 +4954,6 @@
4934
4954
  * TODO: [🏢] !! Check validity of `temperature` in pipeline
4935
4955
  */
4936
4956
 
4937
- /**
4938
- * This error indicates that the promptbook can not retrieve knowledge from external sources
4939
- *
4940
- * @public exported from `@promptbook/core`
4941
- */
4942
- var KnowledgeScrapeError = /** @class */ (function (_super) {
4943
- __extends(KnowledgeScrapeError, _super);
4944
- function KnowledgeScrapeError(message) {
4945
- var _this = _super.call(this, message) || this;
4946
- _this.name = 'KnowledgeScrapeError';
4947
- Object.setPrototypeOf(_this, KnowledgeScrapeError.prototype);
4948
- return _this;
4949
- }
4950
- return KnowledgeScrapeError;
4951
- }(Error));
4952
-
4953
4957
  /**
4954
4958
  * @@@
4955
4959
  *
@@ -9133,6 +9137,25 @@
9133
9137
  return CallbackInterfaceTools;
9134
9138
  }());
9135
9139
 
9140
+ /**
9141
+ * This error indicates @@@
9142
+ *
9143
+ * @public exported from `@promptbook/core`
9144
+ */
9145
+ var BoilerplateError = /** @class */ (function (_super) {
9146
+ __extends(BoilerplateError, _super);
9147
+ function BoilerplateError(message) {
9148
+ var _this = _super.call(this, message) || this;
9149
+ _this.name = 'BoilerplateError';
9150
+ Object.setPrototypeOf(_this, BoilerplateError.prototype);
9151
+ return _this;
9152
+ }
9153
+ return BoilerplateError;
9154
+ }(Error));
9155
+ /**
9156
+ * TODO: @@@ Do not forget to add the error into `0-index.ts` ERRORS
9157
+ */
9158
+
9136
9159
  /**
9137
9160
  * Pretty print an embedding vector for logging
9138
9161
  *
@@ -10463,6 +10486,7 @@
10463
10486
  exports.AbstractFormatError = AbstractFormatError;
10464
10487
  exports.BOOK_LANGUAGE_VERSION = BOOK_LANGUAGE_VERSION;
10465
10488
  exports.BlackholeStorage = BlackholeStorage;
10489
+ exports.BoilerplateError = BoilerplateError;
10466
10490
  exports.BoilerplateFormfactorDefinition = BoilerplateFormfactorDefinition;
10467
10491
  exports.CLAIM = CLAIM;
10468
10492
  exports.CallbackInterfaceTools = CallbackInterfaceTools;