@promptbook/core 0.74.0-0 → 0.74.0-11

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.
Files changed (40) hide show
  1. package/README.md +143 -29
  2. package/esm/index.es.js +388 -373
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/anthropic-claude.index.d.ts +2 -2
  5. package/esm/typings/src/_packages/azure-openai.index.d.ts +2 -2
  6. package/esm/typings/src/_packages/browser.index.d.ts +2 -2
  7. package/esm/typings/src/_packages/cli.index.d.ts +2 -2
  8. package/esm/typings/src/_packages/core.index.d.ts +7 -3
  9. package/esm/typings/src/_packages/documents.index.d.ts +2 -2
  10. package/esm/typings/src/_packages/execute-javascript.index.d.ts +2 -2
  11. package/esm/typings/src/_packages/fake-llm.index.d.ts +2 -2
  12. package/esm/typings/src/_packages/langtail.index.d.ts +2 -2
  13. package/esm/typings/src/_packages/legacy-documents.index.d.ts +2 -2
  14. package/esm/typings/src/_packages/markdown-utils.index.d.ts +2 -2
  15. package/esm/typings/src/_packages/node.index.d.ts +2 -2
  16. package/esm/typings/src/_packages/openai.index.d.ts +2 -2
  17. package/esm/typings/src/_packages/pdf.index.d.ts +2 -2
  18. package/esm/typings/src/_packages/remote-client.index.d.ts +2 -2
  19. package/esm/typings/src/_packages/remote-server.index.d.ts +2 -2
  20. package/esm/typings/src/_packages/utils.index.d.ts +2 -2
  21. package/esm/typings/src/_packages/website-crawler.index.d.ts +2 -2
  22. package/esm/typings/src/cli/cli-commands/make.d.ts +0 -1
  23. package/esm/typings/src/cli/cli-commands/run.d.ts +14 -0
  24. package/esm/typings/src/cli/promptbookCli.d.ts +1 -0
  25. package/esm/typings/src/cli/test/ptbk.d.ts +5 -2
  26. package/esm/typings/src/commands/{PROMPTBOOK_VERSION/PromptbookVersionCommand.d.ts → BOOK_VERSION/BookVersionCommand.d.ts} +4 -4
  27. package/esm/typings/src/commands/BOOK_VERSION/bookVersionCommandParser.d.ts +9 -0
  28. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +1 -1
  29. package/esm/typings/src/commands/index.d.ts +1 -1
  30. package/esm/typings/src/config.d.ts +6 -0
  31. package/esm/typings/src/storage/blackhole/BlackholeStorage.d.ts +33 -0
  32. package/esm/typings/src/storage/memory/MemoryStorage.d.ts +1 -1
  33. package/esm/typings/src/storage/{memory/utils → utils}/PrefixStorage.d.ts +1 -1
  34. package/esm/typings/src/version.d.ts +13 -2
  35. package/package.json +1 -1
  36. package/umd/index.umd.js +391 -373
  37. package/umd/index.umd.js.map +1 -1
  38. package/esm/typings/src/commands/PROMPTBOOK_VERSION/promptbookVersionCommandParser.d.ts +0 -9
  39. /package/esm/typings/src/commands/{PROMPTBOOK_VERSION/promptbookVersionCommand.test.d.ts → BOOK_VERSION/bookVersionCommand.test.d.ts} +0 -0
  40. /package/esm/typings/src/storage/{memory → local-storage}/utils/makePromptbookStorageFromWebStorage.d.ts +0 -0
package/umd/index.umd.js CHANGED
@@ -14,10 +14,20 @@
14
14
 
15
15
  // ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
16
16
  /**
17
- * The version of the Promptbook library
17
+ * The version of the Book language
18
+ *
19
+ * @see https://github.com/webgptorg/book
20
+ */
21
+ var BOOK_LANGUAGE_VERSION = '1.0.0';
22
+ /**
23
+ * The version of the Promptbook engine
24
+ *
25
+ * @see https://github.com/webgptorg/promptbook
26
+ */
27
+ var PROMPTBOOK_ENGINE_VERSION = '0.74.0-10';
28
+ /**
29
+ * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
18
30
  */
19
- var PROMPTBOOK_VERSION = '0.73.0';
20
- // TODO: [main] !!!! List here all the versions and annotate + put into script
21
31
 
22
32
  /*! *****************************************************************************
23
33
  Copyright (c) Microsoft Corporation.
@@ -638,6 +648,13 @@
638
648
  * @public exported from `@promptbook/core`
639
649
  */
640
650
  var CLAIM = "Build responsible, controlled and transparent applications on top of LLM models!";
651
+ // <- TODO: [🐊] Pick the best claim
652
+ /**
653
+ * When the title is not provided, the default title is used
654
+ *
655
+ * @public exported from `@promptbook/core`
656
+ */
657
+ var DEFAULT_TITLE = "Untitled";
641
658
  // <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
642
659
  /**
643
660
  * The maximum number of iterations for a loops
@@ -877,7 +894,7 @@
877
894
  if ( /* version === '1.0.0' || */version === '2.0.0' || version === '3.0.0') {
878
895
  return false;
879
896
  }
880
- // <- TODO: [main] !!! Check isValidPromptbookVersion against PROMPTBOOK_VERSIONS
897
+ // <- TODO: [main] !!! Check isValidPromptbookVersion against PROMPTBOOK_ENGINE_VERSIONS
881
898
  return true;
882
899
  }
883
900
 
@@ -977,7 +994,7 @@
977
994
  if (!url.startsWith('https://')) {
978
995
  return false;
979
996
  }
980
- if (!url.endsWith('.ptbk.md')) {
997
+ if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.ptbk.md') || url.endsWith('.ptbk'))) {
981
998
  return false;
982
999
  }
983
1000
  if (url.includes('#')) {
@@ -1805,6 +1822,188 @@
1805
1822
  },
1806
1823
  });
1807
1824
 
1825
+ /**
1826
+ * @@@
1827
+ *
1828
+ * @public exported from `@promptbook/utils`
1829
+ */
1830
+ function deepClone(objectValue) {
1831
+ return JSON.parse(JSON.stringify(objectValue));
1832
+ /*
1833
+ TODO: [🧠] Is there a better implementation?
1834
+ > const propertyNames = Object.getOwnPropertyNames(objectValue);
1835
+ > for (const propertyName of propertyNames) {
1836
+ > const value = (objectValue as really_any)[propertyName];
1837
+ > if (value && typeof value === 'object') {
1838
+ > deepClone(value);
1839
+ > }
1840
+ > }
1841
+ > return Object.assign({}, objectValue);
1842
+ */
1843
+ }
1844
+ /**
1845
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
1846
+ */
1847
+
1848
+ /**
1849
+ * Function `addUsage` will add multiple usages into one
1850
+ *
1851
+ * Note: If you provide 0 values, it returns ZERO_USAGE
1852
+ *
1853
+ * @public exported from `@promptbook/core`
1854
+ */
1855
+ function addUsage() {
1856
+ var usageItems = [];
1857
+ for (var _i = 0; _i < arguments.length; _i++) {
1858
+ usageItems[_i] = arguments[_i];
1859
+ }
1860
+ return usageItems.reduce(function (acc, item) {
1861
+ var e_1, _a, e_2, _b;
1862
+ var _c;
1863
+ acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
1864
+ try {
1865
+ for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
1866
+ var key = _e.value;
1867
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1868
+ //@ts-ignore
1869
+ if (item.input[key]) {
1870
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1871
+ //@ts-ignore
1872
+ acc.input[key].value += item.input[key].value || 0;
1873
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1874
+ //@ts-ignore
1875
+ if (item.input[key].isUncertain) {
1876
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1877
+ //@ts-ignore
1878
+ acc.input[key].isUncertain = true;
1879
+ }
1880
+ }
1881
+ }
1882
+ }
1883
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1884
+ finally {
1885
+ try {
1886
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
1887
+ }
1888
+ finally { if (e_1) throw e_1.error; }
1889
+ }
1890
+ try {
1891
+ for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
1892
+ var key = _g.value;
1893
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1894
+ //@ts-ignore
1895
+ if (item.output[key]) {
1896
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1897
+ //@ts-ignore
1898
+ acc.output[key].value += item.output[key].value || 0;
1899
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1900
+ //@ts-ignore
1901
+ if (item.output[key].isUncertain) {
1902
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1903
+ //@ts-ignore
1904
+ acc.output[key].isUncertain = true;
1905
+ }
1906
+ }
1907
+ }
1908
+ }
1909
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
1910
+ finally {
1911
+ try {
1912
+ if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
1913
+ }
1914
+ finally { if (e_2) throw e_2.error; }
1915
+ }
1916
+ return acc;
1917
+ }, deepClone(ZERO_USAGE));
1918
+ }
1919
+
1920
+ /**
1921
+ * Intercepts LLM tools and counts total usage of the tools
1922
+ *
1923
+ * @param llmTools LLM tools to be intercepted with usage counting
1924
+ * @returns LLM tools with same functionality with added total cost counting
1925
+ * @public exported from `@promptbook/core`
1926
+ */
1927
+ function countTotalUsage(llmTools) {
1928
+ var _this = this;
1929
+ var totalUsage = ZERO_USAGE;
1930
+ var proxyTools = {
1931
+ get title() {
1932
+ // TODO: [🧠] Maybe put here some suffix
1933
+ return llmTools.title;
1934
+ },
1935
+ get description() {
1936
+ // TODO: [🧠] Maybe put here some suffix
1937
+ return llmTools.description;
1938
+ },
1939
+ checkConfiguration: function () {
1940
+ return __awaiter(this, void 0, void 0, function () {
1941
+ return __generator(this, function (_a) {
1942
+ return [2 /*return*/, /* not await */ llmTools.checkConfiguration()];
1943
+ });
1944
+ });
1945
+ },
1946
+ listModels: function () {
1947
+ return /* not await */ llmTools.listModels();
1948
+ },
1949
+ getTotalUsage: function () {
1950
+ // <- Note: [🥫] Not using getter `get totalUsage` but `getTotalUsage` to allow this object to be proxied
1951
+ return totalUsage;
1952
+ },
1953
+ };
1954
+ if (llmTools.callChatModel !== undefined) {
1955
+ proxyTools.callChatModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
1956
+ var promptResult;
1957
+ return __generator(this, function (_a) {
1958
+ switch (_a.label) {
1959
+ case 0: return [4 /*yield*/, llmTools.callChatModel(prompt)];
1960
+ case 1:
1961
+ promptResult = _a.sent();
1962
+ totalUsage = addUsage(totalUsage, promptResult.usage);
1963
+ return [2 /*return*/, promptResult];
1964
+ }
1965
+ });
1966
+ }); };
1967
+ }
1968
+ if (llmTools.callCompletionModel !== undefined) {
1969
+ proxyTools.callCompletionModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
1970
+ var promptResult;
1971
+ return __generator(this, function (_a) {
1972
+ switch (_a.label) {
1973
+ case 0: return [4 /*yield*/, llmTools.callCompletionModel(prompt)];
1974
+ case 1:
1975
+ promptResult = _a.sent();
1976
+ totalUsage = addUsage(totalUsage, promptResult.usage);
1977
+ return [2 /*return*/, promptResult];
1978
+ }
1979
+ });
1980
+ }); };
1981
+ }
1982
+ if (llmTools.callEmbeddingModel !== undefined) {
1983
+ proxyTools.callEmbeddingModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
1984
+ var promptResult;
1985
+ return __generator(this, function (_a) {
1986
+ switch (_a.label) {
1987
+ case 0: return [4 /*yield*/, llmTools.callEmbeddingModel(prompt)];
1988
+ case 1:
1989
+ promptResult = _a.sent();
1990
+ totalUsage = addUsage(totalUsage, promptResult.usage);
1991
+ return [2 /*return*/, promptResult];
1992
+ }
1993
+ });
1994
+ }); };
1995
+ }
1996
+ // <- Note: [🤖]
1997
+ return proxyTools;
1998
+ }
1999
+ /**
2000
+ * TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
2001
+ * TODO: [🧠] Is there some meaningfull way how to test this util
2002
+ * TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
2003
+ * > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
2004
+ * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
2005
+ */
2006
+
1808
2007
  /**
1809
2008
  * This error indicates errors during the execution of the pipeline
1810
2009
  *
@@ -2113,188 +2312,6 @@
2113
2312
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
2114
2313
  */
2115
2314
 
2116
- /**
2117
- * @@@
2118
- *
2119
- * @public exported from `@promptbook/utils`
2120
- */
2121
- function deepClone(objectValue) {
2122
- return JSON.parse(JSON.stringify(objectValue));
2123
- /*
2124
- TODO: [🧠] Is there a better implementation?
2125
- > const propertyNames = Object.getOwnPropertyNames(objectValue);
2126
- > for (const propertyName of propertyNames) {
2127
- > const value = (objectValue as really_any)[propertyName];
2128
- > if (value && typeof value === 'object') {
2129
- > deepClone(value);
2130
- > }
2131
- > }
2132
- > return Object.assign({}, objectValue);
2133
- */
2134
- }
2135
- /**
2136
- * TODO: [🧠] Is there a way how to meaningfully test this utility
2137
- */
2138
-
2139
- /**
2140
- * Function `addUsage` will add multiple usages into one
2141
- *
2142
- * Note: If you provide 0 values, it returns ZERO_USAGE
2143
- *
2144
- * @public exported from `@promptbook/core`
2145
- */
2146
- function addUsage() {
2147
- var usageItems = [];
2148
- for (var _i = 0; _i < arguments.length; _i++) {
2149
- usageItems[_i] = arguments[_i];
2150
- }
2151
- return usageItems.reduce(function (acc, item) {
2152
- var e_1, _a, e_2, _b;
2153
- var _c;
2154
- acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
2155
- try {
2156
- for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
2157
- var key = _e.value;
2158
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2159
- //@ts-ignore
2160
- if (item.input[key]) {
2161
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2162
- //@ts-ignore
2163
- acc.input[key].value += item.input[key].value || 0;
2164
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2165
- //@ts-ignore
2166
- if (item.input[key].isUncertain) {
2167
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2168
- //@ts-ignore
2169
- acc.input[key].isUncertain = true;
2170
- }
2171
- }
2172
- }
2173
- }
2174
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2175
- finally {
2176
- try {
2177
- if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
2178
- }
2179
- finally { if (e_1) throw e_1.error; }
2180
- }
2181
- try {
2182
- for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
2183
- var key = _g.value;
2184
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2185
- //@ts-ignore
2186
- if (item.output[key]) {
2187
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2188
- //@ts-ignore
2189
- acc.output[key].value += item.output[key].value || 0;
2190
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2191
- //@ts-ignore
2192
- if (item.output[key].isUncertain) {
2193
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2194
- //@ts-ignore
2195
- acc.output[key].isUncertain = true;
2196
- }
2197
- }
2198
- }
2199
- }
2200
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
2201
- finally {
2202
- try {
2203
- if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
2204
- }
2205
- finally { if (e_2) throw e_2.error; }
2206
- }
2207
- return acc;
2208
- }, deepClone(ZERO_USAGE));
2209
- }
2210
-
2211
- /**
2212
- * Intercepts LLM tools and counts total usage of the tools
2213
- *
2214
- * @param llmTools LLM tools to be intercepted with usage counting
2215
- * @returns LLM tools with same functionality with added total cost counting
2216
- * @public exported from `@promptbook/core`
2217
- */
2218
- function countTotalUsage(llmTools) {
2219
- var _this = this;
2220
- var totalUsage = ZERO_USAGE;
2221
- var proxyTools = {
2222
- get title() {
2223
- // TODO: [🧠] Maybe put here some suffix
2224
- return llmTools.title;
2225
- },
2226
- get description() {
2227
- // TODO: [🧠] Maybe put here some suffix
2228
- return llmTools.description;
2229
- },
2230
- checkConfiguration: function () {
2231
- return __awaiter(this, void 0, void 0, function () {
2232
- return __generator(this, function (_a) {
2233
- return [2 /*return*/, /* not await */ llmTools.checkConfiguration()];
2234
- });
2235
- });
2236
- },
2237
- listModels: function () {
2238
- return /* not await */ llmTools.listModels();
2239
- },
2240
- getTotalUsage: function () {
2241
- // <- Note: [🥫] Not using getter `get totalUsage` but `getTotalUsage` to allow this object to be proxied
2242
- return totalUsage;
2243
- },
2244
- };
2245
- if (llmTools.callChatModel !== undefined) {
2246
- proxyTools.callChatModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
2247
- var promptResult;
2248
- return __generator(this, function (_a) {
2249
- switch (_a.label) {
2250
- case 0: return [4 /*yield*/, llmTools.callChatModel(prompt)];
2251
- case 1:
2252
- promptResult = _a.sent();
2253
- totalUsage = addUsage(totalUsage, promptResult.usage);
2254
- return [2 /*return*/, promptResult];
2255
- }
2256
- });
2257
- }); };
2258
- }
2259
- if (llmTools.callCompletionModel !== undefined) {
2260
- proxyTools.callCompletionModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
2261
- var promptResult;
2262
- return __generator(this, function (_a) {
2263
- switch (_a.label) {
2264
- case 0: return [4 /*yield*/, llmTools.callCompletionModel(prompt)];
2265
- case 1:
2266
- promptResult = _a.sent();
2267
- totalUsage = addUsage(totalUsage, promptResult.usage);
2268
- return [2 /*return*/, promptResult];
2269
- }
2270
- });
2271
- }); };
2272
- }
2273
- if (llmTools.callEmbeddingModel !== undefined) {
2274
- proxyTools.callEmbeddingModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
2275
- var promptResult;
2276
- return __generator(this, function (_a) {
2277
- switch (_a.label) {
2278
- case 0: return [4 /*yield*/, llmTools.callEmbeddingModel(prompt)];
2279
- case 1:
2280
- promptResult = _a.sent();
2281
- totalUsage = addUsage(totalUsage, promptResult.usage);
2282
- return [2 /*return*/, promptResult];
2283
- }
2284
- });
2285
- }); };
2286
- }
2287
- // <- Note: [🤖]
2288
- return proxyTools;
2289
- }
2290
- /**
2291
- * TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
2292
- * TODO: [🧠] Is there some meaningfull way how to test this util
2293
- * TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
2294
- * > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
2295
- * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
2296
- */
2297
-
2298
2315
  var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",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:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",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:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",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:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",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}],templates:[{templateType:"PROMPT_TEMPLATE",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:"./promptbook-collection/prepare-persona.ptbk.md"}];
2299
2316
 
2300
2317
  /**
@@ -2699,23 +2716,6 @@
2699
2716
  return union;
2700
2717
  }
2701
2718
 
2702
- /**
2703
- * Just marks a place of place where should be something implemented
2704
- * No side effects.
2705
- *
2706
- * Note: It can be usefull suppressing eslint errors of unused variables
2707
- *
2708
- * @param value any values
2709
- * @returns void
2710
- * @private within the repository
2711
- */
2712
- function TODO_USE() {
2713
- var value = [];
2714
- for (var _i = 0; _i < arguments.length; _i++) {
2715
- value[_i] = arguments[_i];
2716
- }
2717
- }
2718
-
2719
2719
  /**
2720
2720
  * This error indicates problems parsing the format value
2721
2721
  *
@@ -2772,22 +2772,12 @@
2772
2772
  formatName: 'CSV',
2773
2773
  aliases: ['SPREADSHEET', 'TABLE'],
2774
2774
  isValid: function (value, settings, schema) {
2775
- // TODO: Implement CSV validation
2776
- TODO_USE(value /* <- TODO: Use value here */);
2777
- TODO_USE(settings /* <- TODO: Use settings here */);
2778
- TODO_USE(schema /* <- TODO: Use schema here */);
2779
2775
  return true;
2780
2776
  },
2781
2777
  canBeValid: function (partialValue, settings, schema) {
2782
- TODO_USE(partialValue /* <- TODO: Use partialValue here */);
2783
- TODO_USE(settings /* <- TODO: Use settings here */);
2784
- TODO_USE(schema /* <- TODO: Use schema here */);
2785
2778
  return true;
2786
2779
  },
2787
2780
  heal: function (value, settings, schema) {
2788
- TODO_USE(value /* <- TODO: Use partialValue here */);
2789
- TODO_USE(settings /* <- TODO: Use settings here */);
2790
- TODO_USE(schema /* <- TODO: Use schema here */);
2791
2781
  throw new Error('Not implemented');
2792
2782
  },
2793
2783
  subvalueDefinitions: [
@@ -2906,20 +2896,12 @@
2906
2896
  formatName: 'JSON',
2907
2897
  mimeType: 'application/json',
2908
2898
  isValid: function (value, settings, schema) {
2909
- TODO_USE(schema /* <- TODO: Use schema here */);
2910
- TODO_USE(settings /* <- TODO: Use settings here */);
2911
2899
  return isValidJsonString(value);
2912
2900
  },
2913
2901
  canBeValid: function (partialValue, settings, schema) {
2914
- TODO_USE(partialValue /* <- TODO: Use partialValue here */);
2915
- TODO_USE(settings /* <- TODO: Use settings here */);
2916
- TODO_USE(schema /* <- TODO: Use schema here */);
2917
2902
  return true;
2918
2903
  },
2919
2904
  heal: function (value, settings, schema) {
2920
- TODO_USE(value /* <- TODO: Use partialValue here */);
2921
- TODO_USE(settings /* <- TODO: Use settings here */);
2922
- TODO_USE(schema /* <- TODO: Use schema here */);
2923
2905
  throw new Error('Not implemented');
2924
2906
  },
2925
2907
  subvalueDefinitions: [],
@@ -3001,21 +2983,12 @@
3001
2983
  formatName: 'XML',
3002
2984
  mimeType: 'application/xml',
3003
2985
  isValid: function (value, settings, schema) {
3004
- TODO_USE(value /* <- TODO: Use value here */);
3005
- TODO_USE(settings /* <- TODO: Use settings here */);
3006
- TODO_USE(schema /* <- TODO: Use schema here */);
3007
2986
  return true;
3008
2987
  },
3009
2988
  canBeValid: function (partialValue, settings, schema) {
3010
- TODO_USE(partialValue /* <- TODO: Use partialValue here */);
3011
- TODO_USE(settings /* <- TODO: Use settings here */);
3012
- TODO_USE(schema /* <- TODO: Use schema here */);
3013
2989
  return true;
3014
2990
  },
3015
2991
  heal: function (value, settings, schema) {
3016
- TODO_USE(value /* <- TODO: Use partialValue here */);
3017
- TODO_USE(settings /* <- TODO: Use settings here */);
3018
- TODO_USE(schema /* <- TODO: Use schema here */);
3019
2992
  throw new Error('Not implemented');
3020
2993
  },
3021
2994
  subvalueDefinitions: [],
@@ -3248,27 +3221,6 @@
3248
3221
  return [input];
3249
3222
  }
3250
3223
 
3251
- /**
3252
- * Just says that the variable is not used but should be kept
3253
- * No side effects.
3254
- *
3255
- * Note: It can be usefull for:
3256
- *
3257
- * 1) Suppressing eager optimization of unused imports
3258
- * 2) Suppressing eslint errors of unused variables in the tests
3259
- * 3) Keeping the type of the variable for type testing
3260
- *
3261
- * @param value any values
3262
- * @returns void
3263
- * @private within the repository
3264
- */
3265
- function keepUnused() {
3266
- var valuesToKeep = [];
3267
- for (var _i = 0; _i < arguments.length; _i++) {
3268
- valuesToKeep[_i] = arguments[_i];
3269
- }
3270
- }
3271
-
3272
3224
  /**
3273
3225
  * Replaces parameters in template with values from parameters object
3274
3226
  *
@@ -3381,10 +3333,12 @@
3381
3333
  * @public exported from `@promptbook/utils`
3382
3334
  */
3383
3335
  function countPages(text) {
3384
- var sentencesPerPage = 5; // Assuming each page has 5 sentences
3385
- var sentences = text.split(/[.!?]+/).filter(function (sentence) { return sentence.trim() !== ''; });
3386
- var pageCount = Math.ceil(sentences.length / sentencesPerPage);
3387
- return pageCount;
3336
+ if (text === '') {
3337
+ return 0;
3338
+ }
3339
+ var pagesByLinesCount = Math.ceil(countLines(text) / 44);
3340
+ var pagesByCharactersCount = Math.ceil(countCharacters(text) / 2772);
3341
+ return Math.max(pagesByLinesCount, pagesByCharactersCount);
3388
3342
  }
3389
3343
 
3390
3344
  /**
@@ -4045,7 +3999,6 @@
4045
3999
  $ongoingTemplateResult.$resultString = extractJsonBlock($ongoingTemplateResult.$resultString || '');
4046
4000
  }
4047
4001
  catch (error) {
4048
- keepUnused(error);
4049
4002
  throw new ExpectError(spaceTrim.spaceTrim(function (block) { return "\n Expected valid JSON string\n\n ".concat(block(
4050
4003
  /*<- Note: No need for `pipelineIdentification`, it will be catched and added later */ ''), "\n "); }));
4051
4004
  }
@@ -4223,7 +4176,6 @@
4223
4176
  function getContextForTemplate(template) {
4224
4177
  return __awaiter(this, void 0, void 0, function () {
4225
4178
  return __generator(this, function (_a) {
4226
- TODO_USE(template);
4227
4179
  return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [🏍] Implement */];
4228
4180
  });
4229
4181
  });
@@ -4236,11 +4188,9 @@
4236
4188
  */
4237
4189
  function getKnowledgeForTemplate(options) {
4238
4190
  return __awaiter(this, void 0, void 0, function () {
4239
- var preparedPipeline, template;
4191
+ var preparedPipeline;
4240
4192
  return __generator(this, function (_a) {
4241
- preparedPipeline = options.preparedPipeline, template = options.template;
4242
- // TODO: [♨] Implement Better - use real index and keyword search from `template` and {examples}
4243
- TODO_USE(template);
4193
+ preparedPipeline = options.preparedPipeline, options.template;
4244
4194
  return [2 /*return*/, preparedPipeline.knowledgePieces.map(function (_a) {
4245
4195
  var content = _a.content;
4246
4196
  return "- ".concat(content);
@@ -4257,8 +4207,6 @@
4257
4207
  function getExamplesForTemplate(template) {
4258
4208
  return __awaiter(this, void 0, void 0, function () {
4259
4209
  return __generator(this, function (_a) {
4260
- // TODO: [♨] Implement Better - use real index and keyword search
4261
- TODO_USE(template);
4262
4210
  return [2 /*return*/, RESERVED_PARAMETER_MISSING_VALUE /* <- TODO: [♨] Implement */];
4263
4211
  });
4264
4212
  });
@@ -4277,13 +4225,13 @@
4277
4225
  switch (_b.label) {
4278
4226
  case 0:
4279
4227
  preparedPipeline = options.preparedPipeline, template = options.template, pipelineIdentification = options.pipelineIdentification;
4280
- return [4 /*yield*/, getContextForTemplate(template)];
4228
+ return [4 /*yield*/, getContextForTemplate()];
4281
4229
  case 1:
4282
4230
  context = _b.sent();
4283
4231
  return [4 /*yield*/, getKnowledgeForTemplate({ preparedPipeline: preparedPipeline, template: template })];
4284
4232
  case 2:
4285
4233
  knowledge = _b.sent();
4286
- return [4 /*yield*/, getExamplesForTemplate(template)];
4234
+ return [4 /*yield*/, getExamplesForTemplate()];
4287
4235
  case 3:
4288
4236
  examples = _b.sent();
4289
4237
  currentDate = new Date().toISOString();
@@ -4518,7 +4466,7 @@
4518
4466
  executionReport = {
4519
4467
  pipelineUrl: preparedPipeline.pipelineUrl,
4520
4468
  title: preparedPipeline.title,
4521
- promptbookUsedVersion: PROMPTBOOK_VERSION,
4469
+ promptbookUsedVersion: PROMPTBOOK_ENGINE_VERSION,
4522
4470
  promptbookRequestedVersion: preparedPipeline.promptbookVersion,
4523
4471
  description: preparedPipeline.description,
4524
4472
  promptExecutions: [],
@@ -5365,16 +5313,13 @@
5365
5313
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
5366
5314
  var _a;
5367
5315
  return __awaiter(this, void 0, void 0, function () {
5368
- var sourceContent, name, _b, _c, rootDirname, _d,
5369
- // <- TODO: process.cwd() if running in Node.js
5370
- isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType;
5316
+ var sourceContent, name, _b, _c, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
5371
5317
  return __generator(this, function (_e) {
5372
5318
  switch (_e.label) {
5373
5319
  case 0:
5374
5320
  sourceContent = knowledgeSource.sourceContent;
5375
5321
  name = knowledgeSource.name;
5376
- _b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _d = _b.isVerbose, isVerbose = _d === void 0 ? DEFAULT_IS_VERBOSE : _d;
5377
- TODO_USE(isVerbose);
5322
+ _b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _b.isVerbose;
5378
5323
  if (!name) {
5379
5324
  name = sourceContentToName(sourceContent);
5380
5325
  }
@@ -5654,15 +5599,13 @@
5654
5599
  */
5655
5600
  function prepareTemplates(pipeline, tools, options) {
5656
5601
  return __awaiter(this, void 0, void 0, function () {
5657
- var _a, maxParallelCount, templates, parameters, knowledgePiecesCount, templatesPrepared;
5602
+ var _a, maxParallelCount, templates, knowledgePiecesCount, templatesPrepared;
5658
5603
  var _this = this;
5659
5604
  return __generator(this, function (_b) {
5660
5605
  switch (_b.label) {
5661
5606
  case 0:
5662
5607
  _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
5663
- templates = pipeline.templates, parameters = pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
5664
- // TODO: [main] !! Apply examples to each template (if missing and is for the template defined)
5665
- TODO_USE(parameters);
5608
+ templates = pipeline.templates, pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
5666
5609
  templatesPrepared = new Array(templates.length);
5667
5610
  return [4 /*yield*/, forEachAsync(templates, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (template, index) { return __awaiter(_this, void 0, void 0, function () {
5668
5611
  var dependentParameterNames, preparedContent, preparedTemplate;
@@ -5732,7 +5675,7 @@
5732
5675
  currentPreparation = {
5733
5676
  id: 1,
5734
5677
  // TODO: [🍥]> date: $currentDate(),
5735
- promptbookVersion: PROMPTBOOK_VERSION,
5678
+ promptbookVersion: PROMPTBOOK_ENGINE_VERSION,
5736
5679
  usage: ZERO_USAGE,
5737
5680
  };
5738
5681
  preparations = [
@@ -5872,7 +5815,6 @@
5872
5815
  * Note: This is used in `pipelineJsonToString` utility
5873
5816
  */
5874
5817
  stringify: function (command) {
5875
- keepUnused(command);
5876
5818
  return "---"; // <- TODO: [🛋] Implement
5877
5819
  },
5878
5820
  /**
@@ -5881,7 +5823,6 @@
5881
5823
  * Note: This is used in `pipelineJsonToString` utility
5882
5824
  */
5883
5825
  takeFromPipelineJson: function (pipelineJson) {
5884
- keepUnused(pipelineJson);
5885
5826
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
5886
5827
  },
5887
5828
  };
@@ -6046,7 +5987,6 @@
6046
5987
  * Note: This is used in `pipelineJsonToString` utility
6047
5988
  */
6048
5989
  stringify: function (command) {
6049
- keepUnused(command);
6050
5990
  return "---"; // <- TODO: [🛋] Implement
6051
5991
  },
6052
5992
  /**
@@ -6055,7 +5995,6 @@
6055
5995
  * Note: This is used in `pipelineJsonToString` utility
6056
5996
  */
6057
5997
  takeFromTemplateJson: function ($templateJson) {
6058
- keepUnused($templateJson);
6059
5998
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6060
5999
  },
6061
6000
  };
@@ -6287,7 +6226,6 @@
6287
6226
  * Note: This is used in `pipelineJsonToString` utility
6288
6227
  */
6289
6228
  stringify: function (command) {
6290
- keepUnused(command);
6291
6229
  return "---"; // <- TODO: [🛋] Implement
6292
6230
  },
6293
6231
  /**
@@ -6296,7 +6234,6 @@
6296
6234
  * Note: This is used in `pipelineJsonToString` utility
6297
6235
  */
6298
6236
  takeFromTemplateJson: function ($templateJson) {
6299
- keepUnused($templateJson);
6300
6237
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6301
6238
  },
6302
6239
  };
@@ -6615,7 +6552,6 @@
6615
6552
  inputSubparameterNames: inputSubparameterNames,
6616
6553
  outputSubparameterName: outputSubparameterName,
6617
6554
  };
6618
- keepUnused($pipelineJson); // <- TODO: [🧠] Maybe register subparameter from foreach into parameters of the pipeline
6619
6555
  // Note: [🍭] FOREACH apply has some sideeffects on different places in codebase
6620
6556
  },
6621
6557
  /**
@@ -6624,7 +6560,6 @@
6624
6560
  * Note: This is used in `pipelineJsonToString` utility
6625
6561
  */
6626
6562
  stringify: function (command) {
6627
- keepUnused(command);
6628
6563
  return "---"; // <- TODO: [🛋] Implement
6629
6564
  },
6630
6565
  /**
@@ -6633,7 +6568,6 @@
6633
6568
  * Note: This is used in `pipelineJsonToString` utility
6634
6569
  */
6635
6570
  takeFromTemplateJson: function ($templateJson) {
6636
- keepUnused($templateJson);
6637
6571
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6638
6572
  },
6639
6573
  };
@@ -6701,7 +6635,6 @@
6701
6635
  * Note: This is used in `pipelineJsonToString` utility
6702
6636
  */
6703
6637
  stringify: function (command) {
6704
- keepUnused(command);
6705
6638
  return "---"; // <- TODO: [🛋] Implement
6706
6639
  },
6707
6640
  /**
@@ -6710,7 +6643,6 @@
6710
6643
  * Note: This is used in `pipelineJsonToString` utility
6711
6644
  */
6712
6645
  takeFromTemplateJson: function ($templateJson) {
6713
- keepUnused($templateJson);
6714
6646
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6715
6647
  },
6716
6648
  };
@@ -6773,7 +6705,6 @@
6773
6705
  * Note: This is used in `pipelineJsonToString` utility
6774
6706
  */
6775
6707
  stringify: function (command) {
6776
- keepUnused(command);
6777
6708
  return "---"; // <- TODO: [🛋] Implement
6778
6709
  },
6779
6710
  /**
@@ -6782,7 +6713,6 @@
6782
6713
  * Note: This is used in `pipelineJsonToString` utility
6783
6714
  */
6784
6715
  takeFromTemplateJson: function ($templateJson) {
6785
- keepUnused($templateJson);
6786
6716
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6787
6717
  },
6788
6718
  };
@@ -6918,7 +6848,6 @@
6918
6848
  * Note: This is used in `pipelineJsonToString` utility
6919
6849
  */
6920
6850
  stringify: function (command) {
6921
- keepUnused(command);
6922
6851
  return "---"; // <- TODO: [🛋] Implement
6923
6852
  },
6924
6853
  /**
@@ -6927,7 +6856,6 @@
6927
6856
  * Note: This is used in `pipelineJsonToString` utility
6928
6857
  */
6929
6858
  takeFromPipelineJson: function (pipelineJson) {
6930
- keepUnused(pipelineJson);
6931
6859
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6932
6860
  },
6933
6861
  /**
@@ -6936,7 +6864,6 @@
6936
6864
  * Note: This is used in `pipelineJsonToString` utility
6937
6865
  */
6938
6866
  takeFromTemplateJson: function ($templateJson) {
6939
- keepUnused($templateJson);
6940
6867
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
6941
6868
  },
6942
6869
  };
@@ -7010,7 +6937,6 @@
7010
6937
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
7011
6938
  */
7012
6939
  $applyToPipelineJson: function (command, $pipelineJson) {
7013
- keepUnused(command, $pipelineJson);
7014
6940
  // Note: [🍣] Do nothing, its application is implemented separately in `pipelineStringToJsonSync`
7015
6941
  },
7016
6942
  /**
@@ -7019,7 +6945,6 @@
7019
6945
  * Note: `$` is used to indicate that this function mutates given `templateJson`
7020
6946
  */
7021
6947
  $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
7022
- keepUnused(command, $templateJson, $pipelineJson);
7023
6948
  // Note: [🍣] Do nothing, its application is implemented separately in `pipelineStringToJsonSync`
7024
6949
  },
7025
6950
  /**
@@ -7028,7 +6953,6 @@
7028
6953
  * Note: This is used in `pipelineJsonToString` utility
7029
6954
  */
7030
6955
  stringify: function (command) {
7031
- keepUnused(command);
7032
6956
  return "---"; // <- TODO: [🛋] Implement
7033
6957
  },
7034
6958
  /**
@@ -7037,7 +6961,6 @@
7037
6961
  * Note: This is used in `pipelineJsonToString` utility
7038
6962
  */
7039
6963
  takeFromPipelineJson: function (pipelineJson) {
7040
- keepUnused(pipelineJson);
7041
6964
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7042
6965
  },
7043
6966
  /**
@@ -7046,7 +6969,6 @@
7046
6969
  * Note: This is used in `pipelineJsonToString` utility
7047
6970
  */
7048
6971
  takeFromTemplateJson: function ($templateJson) {
7049
- keepUnused($templateJson);
7050
6972
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7051
6973
  },
7052
6974
  };
@@ -7118,7 +7040,6 @@
7118
7040
  * Note: This is used in `pipelineJsonToString` utility
7119
7041
  */
7120
7042
  stringify: function (command) {
7121
- keepUnused(command);
7122
7043
  return "---"; // <- TODO: [🛋] Implement
7123
7044
  },
7124
7045
  /**
@@ -7127,7 +7048,6 @@
7127
7048
  * Note: This is used in `pipelineJsonToString` utility
7128
7049
  */
7129
7050
  takeFromPipelineJson: function (pipelineJson) {
7130
- keepUnused(pipelineJson);
7131
7051
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7132
7052
  },
7133
7053
  /**
@@ -7136,7 +7056,6 @@
7136
7056
  * Note: This is used in `pipelineJsonToString` utility
7137
7057
  */
7138
7058
  takeFromTemplateJson: function ($templateJson) {
7139
- keepUnused($templateJson);
7140
7059
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7141
7060
  },
7142
7061
  };
@@ -7255,7 +7174,6 @@
7255
7174
  * Note: This is used in `pipelineJsonToString` utility
7256
7175
  */
7257
7176
  stringify: function (command) {
7258
- keepUnused(command);
7259
7177
  return "---"; // <- TODO: [🛋] Implement
7260
7178
  },
7261
7179
  /**
@@ -7264,42 +7182,41 @@
7264
7182
  * Note: This is used in `pipelineJsonToString` utility
7265
7183
  */
7266
7184
  takeFromTemplateJson: function ($templateJson) {
7267
- keepUnused($templateJson);
7268
7185
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7269
7186
  },
7270
7187
  };
7271
7188
 
7272
7189
  /**
7273
- * Parses the PROMPTBOOK_VERSION command
7190
+ * Parses the BOOK_VERSION command
7274
7191
  *
7275
7192
  * @see `documentationUrl` for more details
7276
7193
  * @private within the commands folder
7277
7194
  */
7278
- var promptbookVersionCommandParser = {
7195
+ var bookVersionCommandParser = {
7279
7196
  /**
7280
7197
  * Name of the command
7281
7198
  */
7282
- name: 'PROMPTBOOK_VERSION',
7283
- aliasNames: ['PTBK_VERSION', 'PTBK_V', 'PTBKV'],
7199
+ name: 'BOOK_VERSION',
7200
+ aliasNames: ['PTBK_VERSION', 'PROMPTBOOK_VERSION', 'BOOK'],
7284
7201
  /**
7285
7202
  * BOILERPLATE command can be used in:
7286
7203
  */
7287
7204
  isUsedInPipelineHead: true,
7288
7205
  isUsedInPipelineTemplate: false,
7289
7206
  /**
7290
- * Description of the PROMPTBOOK_VERSION command
7207
+ * Description of the BOOK_VERSION command
7291
7208
  */
7292
- description: "Which version of the promptbook is the .ptbk.md using",
7209
+ description: "Which version of the Book language is the .ptbk.md using",
7293
7210
  /**
7294
7211
  * Link to documentation
7295
7212
  */
7296
7213
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/69',
7297
7214
  /**
7298
- * Example usages of the PROMPTBOOK_VERSION command
7215
+ * Example usages of the BOOK_VERSION command
7299
7216
  */
7300
- examples: ["PROMPTBOOK VERSION ".concat(PROMPTBOOK_VERSION), "PTBKV ".concat(PROMPTBOOK_VERSION)],
7217
+ examples: ["BOOK VERSION ".concat(BOOK_LANGUAGE_VERSION), "BOOK ".concat(BOOK_LANGUAGE_VERSION)],
7301
7218
  /**
7302
- * Parses the PROMPTBOOK_VERSION command
7219
+ * Parses the BOOK_VERSION command
7303
7220
  */
7304
7221
  parse: function (input) {
7305
7222
  var args = input.args;
@@ -7310,16 +7227,16 @@
7310
7227
  if (!isValidPromptbookVersion(promptbookVersion)) {
7311
7228
  throw new ParseError("Invalid Promptbook version \"".concat(promptbookVersion, "\""));
7312
7229
  }
7313
- if (args.length > 0) {
7230
+ if (args.length > 0 && !(((args.length === 1 && args[0]) || '').toUpperCase() === 'VERSION')) {
7314
7231
  throw new ParseError("Can not have more than one Promptbook version");
7315
7232
  }
7316
7233
  return {
7317
- type: 'PROMPTBOOK_VERSION',
7234
+ type: 'BOOK_VERSION',
7318
7235
  promptbookVersion: promptbookVersion,
7319
7236
  };
7320
7237
  },
7321
7238
  /**
7322
- * Apply the PROMPTBOOK_VERSION command to the `pipelineJson`
7239
+ * Apply the BOOK_VERSION command to the `pipelineJson`
7323
7240
  *
7324
7241
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
7325
7242
  */
@@ -7328,21 +7245,19 @@
7328
7245
  $pipelineJson.promptbookVersion = command.promptbookVersion;
7329
7246
  },
7330
7247
  /**
7331
- * Converts the PROMPTBOOK_VERSION command back to string
7248
+ * Converts the BOOK_VERSION command back to string
7332
7249
  *
7333
7250
  * Note: This is used in `pipelineJsonToString` utility
7334
7251
  */
7335
7252
  stringify: function (command) {
7336
- keepUnused(command);
7337
7253
  return "---"; // <- TODO: [🛋] Implement
7338
7254
  },
7339
7255
  /**
7340
- * Reads the PROMPTBOOK_VERSION command from the `PipelineJson`
7256
+ * Reads the BOOK_VERSION command from the `PipelineJson`
7341
7257
  *
7342
7258
  * Note: This is used in `pipelineJsonToString` utility
7343
7259
  */
7344
7260
  takeFromPipelineJson: function (pipelineJson) {
7345
- keepUnused(pipelineJson);
7346
7261
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7347
7262
  },
7348
7263
  };
@@ -7436,7 +7351,6 @@
7436
7351
  * Note: This is used in `pipelineJsonToString` utility
7437
7352
  */
7438
7353
  stringify: function (command) {
7439
- keepUnused(command);
7440
7354
  return "---"; // <- TODO: [🛋] Implement
7441
7355
  },
7442
7356
  /**
@@ -7445,7 +7359,6 @@
7445
7359
  * Note: This is used in `pipelineJsonToString` utility
7446
7360
  */
7447
7361
  takeFromPipelineJson: function (pipelineJson) {
7448
- keepUnused(pipelineJson);
7449
7362
  throw new NotYetImplementedError("[\uD83D\uDECB] Not implemented yet"); // <- TODO: [🛋] Implement
7450
7363
  },
7451
7364
  };
@@ -7482,8 +7395,7 @@
7482
7395
  * Parses the ACTION command
7483
7396
  */
7484
7397
  parse: function (input) {
7485
- var args = input.args;
7486
- TODO_USE(args);
7398
+ input.args;
7487
7399
  return {
7488
7400
  type: 'ACTION',
7489
7401
  };
@@ -7494,7 +7406,6 @@
7494
7406
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
7495
7407
  */
7496
7408
  $applyToPipelineJson: function (command, $pipelineJson) {
7497
- keepUnused(command, $pipelineJson);
7498
7409
  console.error(new NotYetImplementedError('[🛠] Actions are not implemented yet'));
7499
7410
  },
7500
7411
  /**
@@ -7503,7 +7414,6 @@
7503
7414
  * Note: This is used in `pipelineJsonToString` utility
7504
7415
  */
7505
7416
  stringify: function (command) {
7506
- keepUnused(command);
7507
7417
  throw new NotYetImplementedError('[🛠] Actions are not implemented yet');
7508
7418
  },
7509
7419
  /**
@@ -7512,7 +7422,6 @@
7512
7422
  * Note: This is used in `pipelineJsonToString` utility
7513
7423
  */
7514
7424
  takeFromPipelineJson: function (pipelineJson) {
7515
- keepUnused(pipelineJson);
7516
7425
  throw new NotYetImplementedError('[🛠] Actions are not implemented yet');
7517
7426
  },
7518
7427
  };
@@ -7552,9 +7461,7 @@
7552
7461
  * Parses the INSTRUMENT command
7553
7462
  */
7554
7463
  parse: function (input) {
7555
- var args = input.args;
7556
- // TODO: [🛠] Implement
7557
- TODO_USE(args);
7464
+ input.args;
7558
7465
  return {
7559
7466
  type: 'INSTRUMENT',
7560
7467
  };
@@ -7565,7 +7472,6 @@
7565
7472
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
7566
7473
  */
7567
7474
  $applyToPipelineJson: function (command, $pipelineJson) {
7568
- keepUnused(command, $pipelineJson);
7569
7475
  console.error(new NotYetImplementedError('[🛠] Instruments are not implemented yet'));
7570
7476
  },
7571
7477
  /**
@@ -7574,7 +7480,6 @@
7574
7480
  * Note: This is used in `pipelineJsonToString` utility
7575
7481
  */
7576
7482
  stringify: function (command) {
7577
- keepUnused(command);
7578
7483
  throw new NotYetImplementedError('[🛠] Instruments are not implemented yet');
7579
7484
  },
7580
7485
  /**
@@ -7583,7 +7488,6 @@
7583
7488
  * Note: This is used in `pipelineJsonToString` utility
7584
7489
  */
7585
7490
  takeFromPipelineJson: function (pipelineJson) {
7586
- keepUnused(pipelineJson);
7587
7491
  throw new NotYetImplementedError('[🛠] Instruments are not implemented yet');
7588
7492
  },
7589
7493
  };
@@ -7648,7 +7552,6 @@
7648
7552
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
7649
7553
  */
7650
7554
  $applyToPipelineJson: function (command, $pipelineJson) {
7651
- keepUnused(command, $pipelineJson);
7652
7555
  throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
7653
7556
  },
7654
7557
  /**
@@ -7657,7 +7560,6 @@
7657
7560
  * Note: `$` is used to indicate that this function mutates given `templateJson`
7658
7561
  */
7659
7562
  $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
7660
- keepUnused(command, $templateJson, $pipelineJson);
7661
7563
  throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
7662
7564
  },
7663
7565
  /**
@@ -7666,7 +7568,6 @@
7666
7568
  * Note: This is used in `pipelineJsonToString` utility
7667
7569
  */
7668
7570
  stringify: function (command) {
7669
- keepUnused(command);
7670
7571
  return "---"; // <- TODO: [🛋] Implement
7671
7572
  },
7672
7573
  /**
@@ -7675,7 +7576,6 @@
7675
7576
  * Note: This is used in `pipelineJsonToString` utility
7676
7577
  */
7677
7578
  takeFromPipelineJson: function (pipelineJson) {
7678
- keepUnused(pipelineJson);
7679
7579
  throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
7680
7580
  },
7681
7581
  /**
@@ -7684,7 +7584,6 @@
7684
7584
  * Note: This is used in `pipelineJsonToString` utility
7685
7585
  */
7686
7586
  takeFromTemplateJson: function ($templateJson) {
7687
- keepUnused($templateJson);
7688
7587
  throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
7689
7588
  },
7690
7589
  };
@@ -7702,7 +7601,7 @@
7702
7601
  modelCommandParser,
7703
7602
  parameterCommandParser,
7704
7603
  postprocessCommandParser,
7705
- promptbookVersionCommandParser,
7604
+ bookVersionCommandParser,
7706
7605
  urlCommandParser,
7707
7606
  knowledgeCommandParser,
7708
7607
  actionCommandParser,
@@ -7854,9 +7753,7 @@
7854
7753
  var _loop_1 = function (commandParser) {
7855
7754
  // <- Note: [🦦] Its strange that this type assertion is needed
7856
7755
  var name_1 = commandParser.name, isUsedInPipelineHead = commandParser.isUsedInPipelineHead, isUsedInPipelineTemplate = commandParser.isUsedInPipelineTemplate, aliasNames = commandParser.aliasNames, deprecatedNames = commandParser.deprecatedNames, parse = commandParser.parse;
7857
- if (just(false)) {
7858
- keepUnused( /* for better indentation */);
7859
- }
7756
+ if (just(false)) ;
7860
7757
  else if (usagePlace === 'PIPELINE_HEAD' && !isUsedInPipelineHead) {
7861
7758
  return "continue";
7862
7759
  }
@@ -8016,7 +7913,7 @@
8016
7913
  return;
8017
7914
  }
8018
7915
  if (!section.startsWith('#')) {
8019
- section = "# Untitled\n\n".concat(section);
7916
+ section = "# ".concat(DEFAULT_TITLE, "\n\n").concat(section);
8020
7917
  }
8021
7918
  sections.push(section);
8022
7919
  buffer = [];
@@ -8080,7 +7977,7 @@
8080
7977
  var e_1, _a;
8081
7978
  var sections = splitMarkdownIntoSections(markdown);
8082
7979
  if (sections.length === 0) {
8083
- return '# Untitled';
7980
+ return "# ".concat(DEFAULT_TITLE);
8084
7981
  }
8085
7982
  var flattenedMarkdown = '';
8086
7983
  var parsedSections = sections.map(parseMarkdownSection);
@@ -8091,7 +7988,7 @@
8091
7988
  }
8092
7989
  else {
8093
7990
  parsedSections.unshift(firstSection);
8094
- flattenedMarkdown += "# Untitled" + "\n\n"; // <- [🧠] Maybe 3 new lines?
7991
+ flattenedMarkdown += "# ".concat(DEFAULT_TITLE) + "\n\n"; // <- [🧠] Maybe 3 new lines?
8095
7992
  }
8096
7993
  try {
8097
7994
  for (var parsedSections_1 = __values(parsedSections), parsedSections_1_1 = parsedSections_1.next(); !parsedSections_1_1.done; parsedSections_1_1 = parsedSections_1.next()) {
@@ -8169,7 +8066,7 @@
8169
8066
  * @public exported from `@promptbook/core`
8170
8067
  */
8171
8068
  function pipelineStringToJsonSync(pipelineString) {
8172
- var e_1, _a, e_2, _b;
8069
+ var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
8173
8070
  var $pipelineJson = {
8174
8071
  title: undefined /* <- Note: [🍙] Putting here placeholder to keep `title` on top at final JSON */,
8175
8072
  pipelineUrl: undefined /* <- Note: Putting here placeholder to keep `pipelineUrl` on top at final JSON */,
@@ -8196,11 +8093,18 @@
8196
8093
  }
8197
8094
  // =============================================================
8198
8095
  // Note: 1️⃣ Parsing of the markdown into object
8096
+ if (pipelineString.startsWith('#!')) {
8097
+ var _e = __read(pipelineString.split('\n')), shebangLine_1 = _e[0], restLines = _e.slice(1);
8098
+ if (!(shebangLine_1 || '').includes('ptbk')) {
8099
+ throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n It seems that you try to parse a book file which has non-standard shebang line for book files:\n Shebang line must contain 'ptbk'\n\n You have:\n ".concat(block(shebangLine_1 || '(empty line)'), "\n\n It should look like this:\n #!/usr/bin/env ptbk\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
8100
+ }
8101
+ pipelineString = restLines.join('\n');
8102
+ }
8199
8103
  pipelineString = removeContentComments(pipelineString);
8200
8104
  pipelineString = flattenMarkdown(pipelineString) /* <- Note: [🥞] */;
8201
8105
  pipelineString = pipelineString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
8202
8106
  pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
8203
- var _c = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _c[0], pipelineSections = _c.slice(1); /* <- Note: [🥞] */
8107
+ var _f = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _f[0], pipelineSections = _f.slice(1); /* <- Note: [🥞] */
8204
8108
  if (pipelineHead === undefined) {
8205
8109
  throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
8206
8110
  }
@@ -8228,6 +8132,8 @@
8228
8132
  if (parameterDescription) {
8229
8133
  existingParameter.description = parameterDescription;
8230
8134
  }
8135
+ existingParameter.isInput = existingParameter.isInput || isInput;
8136
+ existingParameter.isOutput = existingParameter.isOutput || isOutput;
8231
8137
  }
8232
8138
  else {
8233
8139
  $pipelineJson.parameters.push({
@@ -8290,10 +8196,10 @@
8290
8196
  finally { if (e_1) throw e_1.error; }
8291
8197
  }
8292
8198
  var _loop_2 = function (section) {
8293
- var e_3, _d;
8199
+ var e_5, _l, e_6, _m;
8294
8200
  // TODO: Parse template description (the content out of the codeblock and lists)
8295
8201
  var listItems_2 = extractAllListItemsFromMarkdown(section.content);
8296
- var _e = extractOneBlockFromMarkdown(section.content), language = _e.language, content = _e.content;
8202
+ var _o = extractOneBlockFromMarkdown(section.content), language = _o.language, content = _o.content;
8297
8203
  // TODO: [🎾][1] DRY description
8298
8204
  var description_1 = section.content;
8299
8205
  // Note: Remove codeblocks - TODO: [🎾]
@@ -8334,7 +8240,7 @@
8334
8240
  }) === false) {
8335
8241
  templateCommandParser.$applyToTemplateJson({ type: 'TEMPLATE', templateType: 'PROMPT_TEMPLATE' }, $templateJson, $pipelineJson);
8336
8242
  }
8337
- var _loop_3 = function (listItem, command) {
8243
+ var _loop_4 = function (listItem, command) {
8338
8244
  var commandParser = getParserForCommand(command);
8339
8245
  if (commandParser.isUsedInPipelineTemplate !== true /* <- Note: [🦦][4] */) {
8340
8246
  throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n Command ".concat(command.type, " is not allowed in the template of the promptbook ONLY at the pipeline head\n\n ").concat(block(getPipelineIdentification()), "\n "); })); // <- TODO: [🚞]
@@ -8357,17 +8263,17 @@
8357
8263
  };
8358
8264
  try {
8359
8265
  // TODO [♓️] List commands and before apply order them to achieve order-agnostic commands
8360
- for (var commands_1 = (e_3 = void 0, __values(commands)), commands_1_1 = commands_1.next(); !commands_1_1.done; commands_1_1 = commands_1.next()) {
8361
- var _f = commands_1_1.value, listItem = _f.listItem, command = _f.command;
8362
- _loop_3(listItem, command);
8266
+ for (var commands_1 = (e_5 = void 0, __values(commands)), commands_1_1 = commands_1.next(); !commands_1_1.done; commands_1_1 = commands_1.next()) {
8267
+ var _p = commands_1_1.value, listItem = _p.listItem, command = _p.command;
8268
+ _loop_4(listItem, command);
8363
8269
  }
8364
8270
  }
8365
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
8271
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
8366
8272
  finally {
8367
8273
  try {
8368
- if (commands_1_1 && !commands_1_1.done && (_d = commands_1.return)) _d.call(commands_1);
8274
+ if (commands_1_1 && !commands_1_1.done && (_l = commands_1.return)) _l.call(commands_1);
8369
8275
  }
8370
- finally { if (e_3) throw e_3.error; }
8276
+ finally { if (e_5) throw e_5.error; }
8371
8277
  }
8372
8278
  // TODO: [🍧] Should be done in TEMPLATE command
8373
8279
  if ($templateJson.templateType === 'SCRIPT_TEMPLATE') {
@@ -8381,6 +8287,26 @@
8381
8287
  language;
8382
8288
  }
8383
8289
  $templateJson.dependentParameterNames = Array.from(extractParameterNamesFromTemplate($templateJson));
8290
+ try {
8291
+ for (var _q = (e_6 = void 0, __values($templateJson.dependentParameterNames)), _r = _q.next(); !_r.done; _r = _q.next()) {
8292
+ var parameterName = _r.value;
8293
+ // TODO: [🧠] This definition should be made first in the template
8294
+ defineParam({
8295
+ parameterName: parameterName,
8296
+ parameterDescription: null,
8297
+ isInput: false,
8298
+ isOutput: false,
8299
+ // <- Note: In this case null+false+false means that we do not know yet if it is input or output and we will set it later
8300
+ });
8301
+ }
8302
+ }
8303
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
8304
+ finally {
8305
+ try {
8306
+ if (_r && !_r.done && (_m = _q.return)) _m.call(_q);
8307
+ }
8308
+ finally { if (e_6) throw e_6.error; }
8309
+ }
8384
8310
  /*
8385
8311
  // TODO: [🍧] This should be checked in `MODEL` command + better error message
8386
8312
  if ($templateJson.templateType !== 'PROMPT_TEMPLATE' && $templateJson.modelRequirements !== undefined) {
@@ -8422,9 +8348,51 @@
8422
8348
  finally { if (e_2) throw e_2.error; }
8423
8349
  }
8424
8350
  // =============================================================
8425
- // Note: 5️⃣ Cleanup of undefined values
8351
+ // Note: 5️⃣ Mark parameters as INPUT if not explicitly set
8352
+ if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isInput; })) {
8353
+ var _loop_3 = function (parameter) {
8354
+ var isThisParameterResulting = $pipelineJson.templates.some(function (template) { return template.resultingParameterName === parameter.name; });
8355
+ if (!isThisParameterResulting) {
8356
+ parameter.isInput = true;
8357
+ }
8358
+ };
8359
+ try {
8360
+ for (var _g = __values($pipelineJson.parameters), _h = _g.next(); !_h.done; _h = _g.next()) {
8361
+ var parameter = _h.value;
8362
+ _loop_3(parameter);
8363
+ }
8364
+ }
8365
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
8366
+ finally {
8367
+ try {
8368
+ if (_h && !_h.done && (_c = _g.return)) _c.call(_g);
8369
+ }
8370
+ finally { if (e_3) throw e_3.error; }
8371
+ }
8372
+ }
8373
+ // =============================================================
8374
+ // Note: 6️⃣ Mark all non-INPUT parameters as OUTPUT if any OUTPUT is not set
8375
+ if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isOutput; })) {
8376
+ try {
8377
+ for (var _j = __values($pipelineJson.parameters), _k = _j.next(); !_k.done; _k = _j.next()) {
8378
+ var parameter = _k.value;
8379
+ if (!parameter.isInput) {
8380
+ parameter.isOutput = true;
8381
+ }
8382
+ }
8383
+ }
8384
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
8385
+ finally {
8386
+ try {
8387
+ if (_k && !_k.done && (_d = _j.return)) _d.call(_j);
8388
+ }
8389
+ finally { if (e_4) throw e_4.error; }
8390
+ }
8391
+ }
8392
+ // =============================================================
8393
+ // Note: 7️⃣ Cleanup of undefined values
8426
8394
  $pipelineJson.templates.forEach(function (templates) {
8427
- var e_4, _a;
8395
+ var e_7, _a;
8428
8396
  try {
8429
8397
  for (var _b = __values(Object.entries(templates)), _c = _b.next(); !_c.done; _c = _b.next()) {
8430
8398
  var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
@@ -8433,16 +8401,16 @@
8433
8401
  }
8434
8402
  }
8435
8403
  }
8436
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
8404
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
8437
8405
  finally {
8438
8406
  try {
8439
8407
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
8440
8408
  }
8441
- finally { if (e_4) throw e_4.error; }
8409
+ finally { if (e_7) throw e_7.error; }
8442
8410
  }
8443
8411
  });
8444
8412
  $pipelineJson.parameters.forEach(function (parameter) {
8445
- var e_5, _a;
8413
+ var e_8, _a;
8446
8414
  try {
8447
8415
  for (var _b = __values(Object.entries(parameter)), _c = _b.next(); !_c.done; _c = _b.next()) {
8448
8416
  var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
@@ -8451,12 +8419,12 @@
8451
8419
  }
8452
8420
  }
8453
8421
  }
8454
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
8422
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
8455
8423
  finally {
8456
8424
  try {
8457
8425
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
8458
8426
  }
8459
- finally { if (e_5) throw e_5.error; }
8427
+ finally { if (e_8) throw e_8.error; }
8460
8428
  }
8461
8429
  });
8462
8430
  // =============================================================
@@ -8978,7 +8946,7 @@
8978
8946
  */
8979
8947
 
8980
8948
  /**
8981
- * Stores
8949
+ * Stores data in memory (HEAP)
8982
8950
  *
8983
8951
  * @public exported from `@promptbook/core`
8984
8952
  */
@@ -9108,13 +9076,18 @@
9108
9076
  promptResult = _c.sent();
9109
9077
  return [3 /*break*/, 11];
9110
9078
  case 10: throw new PipelineExecutionError("Unknown model variant \"".concat(prompt.modelRequirements.modelVariant, "\""));
9111
- case 11: return [4 /*yield*/, storage.setItem(key, {
9079
+ case 11:
9080
+ // TODO: [🧠] !!!!!! How to do timing in mixed cache / non-cache situation
9081
+ // promptResult.timing: FromtoItems
9082
+ return [4 /*yield*/, storage.setItem(key, {
9112
9083
  date: $currentDate(),
9113
- promptbookVersion: PROMPTBOOK_VERSION,
9084
+ promptbookVersion: PROMPTBOOK_ENGINE_VERSION,
9114
9085
  prompt: prompt,
9115
9086
  promptResult: promptResult,
9116
9087
  })];
9117
9088
  case 12:
9089
+ // TODO: [🧠] !!!!!! How to do timing in mixed cache / non-cache situation
9090
+ // promptResult.timing: FromtoItems
9118
9091
  _c.sent();
9119
9092
  return [2 /*return*/, promptResult];
9120
9093
  }
@@ -9160,8 +9133,7 @@
9160
9133
  function limitTotalUsage(llmTools, options) {
9161
9134
  var _this = this;
9162
9135
  if (options === void 0) { options = {}; }
9163
- var _a = options.maxTotalUsage, maxTotalUsage = _a === void 0 ? ZERO_USAGE : _a, _b = options.storage, storage = _b === void 0 ? new MemoryStorage() : _b;
9164
- TODO_USE(storage);
9136
+ var _a = options.maxTotalUsage, maxTotalUsage = _a === void 0 ? ZERO_USAGE : _a, _b = options.storage; _b === void 0 ? new MemoryStorage() : _b;
9165
9137
  var proxyTools = countTotalUsage(llmTools);
9166
9138
  if (maxTotalUsage.price.value !== 0) {
9167
9139
  throw new NotYetImplementedError('`limitTotalUsage` is not yet implemented for non-zero price');
@@ -9170,7 +9142,6 @@
9170
9142
  if (proxyTools.callChatModel !== undefined) {
9171
9143
  proxyTools.callChatModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
9172
9144
  return __generator(this, function (_a) {
9173
- TODO_USE(prompt);
9174
9145
  throw new LimitReachedError('Cannot call `callChatModel` because you are not allowed to spend any cost');
9175
9146
  });
9176
9147
  }); };
@@ -9178,7 +9149,6 @@
9178
9149
  if (proxyTools.callCompletionModel !== undefined) {
9179
9150
  proxyTools.callCompletionModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
9180
9151
  return __generator(this, function (_a) {
9181
- TODO_USE(prompt);
9182
9152
  throw new LimitReachedError('Cannot call `callCompletionModel` because you are not allowed to spend any cost');
9183
9153
  });
9184
9154
  }); };
@@ -9186,7 +9156,6 @@
9186
9156
  if (proxyTools.callEmbeddingModel !== undefined) {
9187
9157
  proxyTools.callEmbeddingModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
9188
9158
  return __generator(this, function (_a) {
9189
- TODO_USE(prompt);
9190
9159
  throw new LimitReachedError('Cannot call `callEmbeddingModel` because you are not allowed to spend any cost');
9191
9160
  });
9192
9161
  }); };
@@ -9351,8 +9320,6 @@
9351
9320
  };
9352
9321
  },
9353
9322
  createConfigurationFromEnv: function (env) {
9354
- // TODO: Maybe auto-configure (multiple) assistants from env variables
9355
- keepUnused(env);
9356
9323
  return null;
9357
9324
  /*
9358
9325
  if (typeof env.OPENAI_API_KEY === 'string' || typeof env.OPENAI_XXX === 'string') {
@@ -9496,6 +9463,54 @@
9496
9463
  */
9497
9464
  var _WebsiteScraperMetadataRegistration = $scrapersMetadataRegister.register(websiteScraperMetadata);
9498
9465
 
9466
+ /**
9467
+ * Behaves like a storage but forgets everything you put in it
9468
+ *
9469
+ * @public exported from `@promptbook/core`
9470
+ */
9471
+ var BlackholeStorage = /** @class */ (function () {
9472
+ function BlackholeStorage() {
9473
+ }
9474
+ Object.defineProperty(BlackholeStorage.prototype, "length", {
9475
+ /**
9476
+ * Returns the number of key/value pairs currently present in the list associated with the object.
9477
+ */
9478
+ get: function () {
9479
+ return 0;
9480
+ },
9481
+ enumerable: false,
9482
+ configurable: true
9483
+ });
9484
+ /**
9485
+ * Empties the list associated with the object of all key/value pairs, if there are any.
9486
+ */
9487
+ BlackholeStorage.prototype.clear = function () { };
9488
+ /**
9489
+ * Returns the current value associated with the given key, or null if the given key does not exist in the list associated with the object.
9490
+ * @param key
9491
+ */
9492
+ BlackholeStorage.prototype.getItem = function (key) {
9493
+ return null;
9494
+ };
9495
+ /**
9496
+ * Returns the name of the nth key in the list, or null if n is greater than or equal to the number of key/value pairs in the object.
9497
+ */
9498
+ BlackholeStorage.prototype.key = function (index) {
9499
+ return null;
9500
+ };
9501
+ /**
9502
+ * Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
9503
+ */
9504
+ BlackholeStorage.prototype.setItem = function (key, value) {
9505
+ };
9506
+ /**
9507
+ * Removes the key/value pair with the given key from the list associated with the object, if a key/value pair with the given key exists.
9508
+ */
9509
+ BlackholeStorage.prototype.removeItem = function (key) {
9510
+ };
9511
+ return BlackholeStorage;
9512
+ }());
9513
+
9499
9514
  /**
9500
9515
  * This class behaves like LocalStorage but separates keys by prefix
9501
9516
  *
@@ -9851,6 +9866,8 @@
9851
9866
  exports.$scrapersMetadataRegister = $scrapersMetadataRegister;
9852
9867
  exports.$scrapersRegister = $scrapersRegister;
9853
9868
  exports.AbstractFormatError = AbstractFormatError;
9869
+ exports.BOOK_LANGUAGE_VERSION = BOOK_LANGUAGE_VERSION;
9870
+ exports.BlackholeStorage = BlackholeStorage;
9854
9871
  exports.CLAIM = CLAIM;
9855
9872
  exports.CallbackInterfaceTools = CallbackInterfaceTools;
9856
9873
  exports.CollectionError = CollectionError;
@@ -9869,6 +9886,7 @@
9869
9886
  exports.DEFAULT_REMOTE_URL = DEFAULT_REMOTE_URL;
9870
9887
  exports.DEFAULT_REMOTE_URL_PATH = DEFAULT_REMOTE_URL_PATH;
9871
9888
  exports.DEFAULT_SCRAPE_CACHE_DIRNAME = DEFAULT_SCRAPE_CACHE_DIRNAME;
9889
+ exports.DEFAULT_TITLE = DEFAULT_TITLE;
9872
9890
  exports.ERRORS = ERRORS;
9873
9891
  exports.EXPECTATION_UNITS = EXPECTATION_UNITS;
9874
9892
  exports.EnvironmentMismatchError = EnvironmentMismatchError;
@@ -9884,7 +9902,7 @@
9884
9902
  exports.MultipleLlmExecutionTools = MultipleLlmExecutionTools;
9885
9903
  exports.NotFoundError = NotFoundError;
9886
9904
  exports.NotYetImplementedError = NotYetImplementedError;
9887
- exports.PROMPTBOOK_VERSION = PROMPTBOOK_VERSION;
9905
+ exports.PROMPTBOOK_ENGINE_VERSION = PROMPTBOOK_ENGINE_VERSION;
9888
9906
  exports.ParseError = ParseError;
9889
9907
  exports.PipelineExecutionError = PipelineExecutionError;
9890
9908
  exports.PipelineLogicError = PipelineLogicError;