@promptbook/node 0.84.0-13 β†’ 0.84.0-15

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.
@@ -12,6 +12,8 @@ import { LOGO_LIGHT_SRC } from '../config';
12
12
  import { LOGO_DARK_SRC } from '../config';
13
13
  import { DEFAULT_BOOK_TITLE } from '../config';
14
14
  import { DEFAULT_TASK_TITLE } from '../config';
15
+ import { DEFAULT_PROMPT_TASK_TITLE } from '../config';
16
+ import { DEFAULT_BOOK_OUTPUT_PARAMETER_NAME } from '../config';
15
17
  import { MAX_FILENAME_LENGTH } from '../config';
16
18
  import { DEFAULT_INTERMEDIATE_FILES_STRATEGY } from '../config';
17
19
  import { DEFAULT_MAX_PARALLEL_COUNT } from '../config';
@@ -139,6 +141,8 @@ export { LOGO_LIGHT_SRC };
139
141
  export { LOGO_DARK_SRC };
140
142
  export { DEFAULT_BOOK_TITLE };
141
143
  export { DEFAULT_TASK_TITLE };
144
+ export { DEFAULT_PROMPT_TASK_TITLE };
145
+ export { DEFAULT_BOOK_OUTPUT_PARAMETER_NAME };
142
146
  export { MAX_FILENAME_LENGTH };
143
147
  export { DEFAULT_INTERMEDIATE_FILES_STRATEGY };
144
148
  export { DEFAULT_MAX_PARALLEL_COUNT };
@@ -65,6 +65,18 @@ export declare const DEFAULT_BOOK_TITLE = "\u2728 Untitled Book";
65
65
  * @public exported from `@promptbook/core`
66
66
  */
67
67
  export declare const DEFAULT_TASK_TITLE = "Task";
68
+ /**
69
+ * When the title of the prompt task is not provided, the default title is used
70
+ *
71
+ * @public exported from `@promptbook/core`
72
+ */
73
+ export declare const DEFAULT_PROMPT_TASK_TITLE = "Prompt";
74
+ /**
75
+ * When the pipeline is flat and no name of return parameter is provided, this name is used
76
+ *
77
+ * @public exported from `@promptbook/core`
78
+ */
79
+ export declare const DEFAULT_BOOK_OUTPUT_PARAMETER_NAME = "result";
68
80
  /**
69
81
  * Warning message for the generated sections and files files
70
82
  *
@@ -0,0 +1,10 @@
1
+ import type { string_file_extension } from '../../types/typeAliases';
2
+ import type { string_mime_type } from '../../types/typeAliases';
3
+ /**
4
+ * Convert mime type to file extension
5
+ *
6
+ * Note: If the mime type is invalid, `null` is returned
7
+ *
8
+ * @private within the repository
9
+ */
10
+ export declare function mimeTypeToExtension(value: string_mime_type): string_file_extension | null;
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@promptbook/node",
3
- "version": "0.84.0-13",
3
+ "version": "0.84.0-15",
4
4
  "description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
5
- "--note-0": " <- [🐊]",
6
5
  "private": false,
7
6
  "sideEffects": false,
8
7
  "repository": {
@@ -12,7 +11,6 @@
12
11
  "contributors": [
13
12
  "Pavol HejnΓ½ <pavol@ptbk.io> (https://www.pavolhejny.com/)"
14
13
  ],
15
- "--todo-0": "TODO: [❇️] Make better list of keywords",
16
14
  "keywords": [
17
15
  "ai",
18
16
  "llm",
@@ -35,26 +33,16 @@
35
33
  "anthropic",
36
34
  "LLMOps"
37
35
  ],
38
- "license": "CC-BY-4.0",
36
+ "license": "SEE LICENSE IN LICENSE.md",
39
37
  "bugs": {
40
38
  "url": "https://github.com/webgptorg/promptbook/issues"
41
39
  },
42
40
  "homepage": "https://www.npmjs.com/package/@promptbook/core",
43
- "funding": [
44
- {
45
- "type": "individual",
46
- "url": "https://buymeacoffee.com/hejny"
47
- },
48
- {
49
- "type": "github",
50
- "url": "https://github.com/webgptorg/promptbook/blob/main/README.md#%EF%B8%8F-contributing"
51
- }
52
- ],
53
41
  "main": "./umd/index.umd.js",
54
42
  "module": "./esm/index.es.js",
55
43
  "typings": "./esm/typings/src/_packages/node.index.d.ts",
56
44
  "peerDependencies": {
57
- "@promptbook/core": "0.84.0-13"
45
+ "@promptbook/core": "0.84.0-15"
58
46
  },
59
47
  "dependencies": {
60
48
  "colors": "1.4.0",
package/umd/index.umd.js CHANGED
@@ -45,7 +45,7 @@
45
45
  * @generated
46
46
  * @see https://github.com/webgptorg/promptbook
47
47
  */
48
- var PROMPTBOOK_ENGINE_VERSION = '0.84.0-12';
48
+ var PROMPTBOOK_ENGINE_VERSION = '0.84.0-14';
49
49
  /**
50
50
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
51
51
  * Note: [πŸ’ž] Ignore a discrepancy between file name and entity name
@@ -222,6 +222,12 @@
222
222
  * @public exported from `@promptbook/core`
223
223
  */
224
224
  var DEFAULT_TASK_TITLE = "Task";
225
+ /**
226
+ * When the pipeline is flat and no name of return parameter is provided, this name is used
227
+ *
228
+ * @public exported from `@promptbook/core`
229
+ */
230
+ var DEFAULT_BOOK_OUTPUT_PARAMETER_NAME = 'result';
225
231
  // <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
226
232
  /**
227
233
  * The maximum number of iterations for a loops
@@ -5487,6 +5493,17 @@
5487
5493
  * TODO: [πŸ–‡] What about symlinks?
5488
5494
  */
5489
5495
 
5496
+ /**
5497
+ * Convert mime type to file extension
5498
+ *
5499
+ * Note: If the mime type is invalid, `null` is returned
5500
+ *
5501
+ * @private within the repository
5502
+ */
5503
+ function mimeTypeToExtension(value) {
5504
+ return mimeTypes.extension(value) || null;
5505
+ }
5506
+
5490
5507
  /**
5491
5508
  * Removes emojis from a string and fix whitespaces
5492
5509
  *
@@ -5580,7 +5597,7 @@
5580
5597
  case 1:
5581
5598
  response_1 = _l.sent();
5582
5599
  mimeType = ((_a = response_1.headers.get('content-type')) === null || _a === void 0 ? void 0 : _a.split(';')[0]) || 'text/html';
5583
- if (tools.fs === undefined || !url.endsWith('.pdf')) {
5600
+ if (tools.fs === undefined || !url.endsWith('.pdf' /* <- TODO: [πŸ’΅] */)) {
5584
5601
  return [2 /*return*/, {
5585
5602
  source: name,
5586
5603
  filename: null,
@@ -5625,7 +5642,7 @@
5625
5642
  basename = url.split('/').pop() || titleToName(url);
5626
5643
  hash = sha256__default["default"](hexEncoder__default["default"].parse(url)).toString( /* hex */);
5627
5644
  rootDirname_1 = path.join(process.cwd(), DEFAULT_DOWNLOAD_CACHE_DIRNAME);
5628
- filepath = path.join.apply(void 0, __spreadArray(__spreadArray([], __read(nameToSubfolderPath(hash /* <- TODO: [🎎] Maybe add some SHA256 prefix */)), false), ["".concat(basename.substring(0, MAX_FILENAME_LENGTH), ".pdf")], false));
5645
+ filepath = path.join.apply(void 0, __spreadArray(__spreadArray([], __read(nameToSubfolderPath(hash /* <- TODO: [🎎] Maybe add some SHA256 prefix */)), false), ["".concat(basename.substring(0, MAX_FILENAME_LENGTH), ".").concat(mimeTypeToExtension(mimeType))], false));
5629
5646
  return [4 /*yield*/, tools.fs.mkdir(path.dirname(path.join(rootDirname_1, filepath)), { recursive: true })];
5630
5647
  case 2:
5631
5648
  _l.sent();
@@ -5636,9 +5653,9 @@
5636
5653
  case 3: return [4 /*yield*/, _g.apply(_f, _h.concat([_k.apply(_j, [_l.sent()])]))];
5637
5654
  case 4:
5638
5655
  _l.sent();
5639
- // TODO: !!!!!!!! Check the file security
5656
+ // TODO: [πŸ’΅] Check the file security
5640
5657
  // TODO: !!!!!!!! Check the file size (if it is not too big)
5641
- // TODO: !!!!!!!! Delete the file
5658
+ // TODO: !!!!!!!! Delete the file after the scraping is done
5642
5659
  return [2 /*return*/, makeKnowledgeSourceHandler({ name: name, knowledgeSourceContent: filepath }, tools, __assign(__assign({}, options), { rootDirname: rootDirname_1 }))];
5643
5660
  case 5:
5644
5661
  if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 7];
@@ -8759,12 +8776,15 @@
8759
8776
  pipelineString = removeMarkdownComments(pipelineString);
8760
8777
  pipelineString = spaceTrim__default["default"](pipelineString);
8761
8778
  var isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
8762
- var isLastLineReturnStatement = pipelineString.split('\n').pop().split('`').join('').startsWith('->');
8763
- // TODO: Also (double)check
8779
+ //const isLastLineReturnStatement = pipelineString.split('\n').pop()!.split('`').join('').startsWith('->');
8780
+ var isBacktickBlockUsed = pipelineString.includes('```');
8781
+ var isQuoteBlocksUsed = /^>\s+/m.test(pipelineString);
8782
+ var isBlocksUsed = isBacktickBlockUsed || isQuoteBlocksUsed;
8783
+ // TODO: [πŸ§‰] Also (double)check
8764
8784
  // > const usedCommands
8765
8785
  // > const isBlocksUsed
8766
8786
  // > const returnStatementCount
8767
- var isFlat = !isMarkdownBeginningWithHeadline && isLastLineReturnStatement;
8787
+ var isFlat = !isMarkdownBeginningWithHeadline && !isBlocksUsed; /* && isLastLineReturnStatement */
8768
8788
  return isFlat;
8769
8789
  }
8770
8790
 
@@ -8778,9 +8798,26 @@
8778
8798
  return pipelineString;
8779
8799
  }
8780
8800
  var pipelineStringLines = pipelineString.split('\n');
8781
- var returnStatement = pipelineStringLines.pop();
8801
+ var potentialReturnStatement = pipelineStringLines.pop();
8802
+ var returnStatement;
8803
+ if (/(-|=)>\s*\{.*\}/.test(potentialReturnStatement)) {
8804
+ // Note: Last line is return statement
8805
+ returnStatement = potentialReturnStatement;
8806
+ }
8807
+ else {
8808
+ // Note: Last line is not a return statement
8809
+ returnStatement = "-> {".concat(DEFAULT_BOOK_OUTPUT_PARAMETER_NAME, "}");
8810
+ pipelineStringLines.push(potentialReturnStatement);
8811
+ }
8782
8812
  var prompt = spaceTrim__default["default"](pipelineStringLines.join('\n'));
8783
- pipelineString = validatePipelineString(spaceTrim__default["default"](function (block) { return "\n # ".concat(DEFAULT_BOOK_TITLE, "\n\n ## Prompt\n\n ```\n ").concat(block(prompt), "\n ```\n\n ").concat(returnStatement, "\n "); }));
8813
+ var quotedPrompt;
8814
+ if (prompt.split('\n').length <= 1) {
8815
+ quotedPrompt = "> ".concat(prompt);
8816
+ }
8817
+ else {
8818
+ quotedPrompt = spaceTrim__default["default"](function (block) { return "\n ```\n ".concat(block(prompt.split('`').join('\\`')), "\n ```\n "); });
8819
+ }
8820
+ pipelineString = validatePipelineString(spaceTrim__default["default"](function (block) { return "\n # ".concat(DEFAULT_BOOK_TITLE, "\n\n ## Prompt\n\n ").concat(block(quotedPrompt), "\n\n ").concat(returnStatement, "\n "); }));
8784
8821
  // <- TODO: Maybe use book` notation
8785
8822
  return pipelineString;
8786
8823
  }