@promptbook/core 0.54.0 → 0.54.1

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.
package/README.md CHANGED
@@ -512,7 +512,7 @@ There are [postprocessing functions](#postprocessing-functions) that can be used
512
512
  Executor is a simple async function that takes **input parameters** and returns **output parameters**.
513
513
  It is constructed by combining execution tools and promptbook to execute together.
514
514
 
515
- ### 🃏 Jokers
515
+ ### 🃏 Jokers (conditions)
516
516
 
517
517
  Joker is a previously defined parameter that is used to bypass some parts of the pipeline.
518
518
  If the joker is present in the template, it is checked to see if it meets the requirements (without postprocessing), and if so, it is used instead of executing that prompt template. There can be multiple wildcards in a prompt template, if so they are checked in order and the first one that meets the requirements is used.
package/esm/index.es.js CHANGED
@@ -448,7 +448,7 @@ function union() {
448
448
  /**
449
449
  * The version of the Promptbook library
450
450
  */
451
- var PROMPTBOOK_VERSION = '0.53.0';
451
+ var PROMPTBOOK_VERSION = '0.54.0';
452
452
 
453
453
  /**
454
454
  * Parses the template and returns the list of all parameter names
@@ -1771,7 +1771,7 @@ function prettifyPromptbookString(promptbookString, options) {
1771
1771
  * @returns Promptbook in string format (.ptbk.md)
1772
1772
  */
1773
1773
  function promptbookJsonToString(promptbookJson) {
1774
- var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e;
1774
+ var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
1775
1775
  var title = promptbookJson.title, promptbookUrl = promptbookJson.promptbookUrl, promptbookVersion = promptbookJson.promptbookVersion, description = promptbookJson.description, parameters = promptbookJson.parameters, promptTemplates = promptbookJson.promptTemplates;
1776
1776
  var promptbookString = "# ".concat(title);
1777
1777
  if (description) {
@@ -1786,24 +1786,37 @@ function promptbookJsonToString(promptbookJson) {
1786
1786
  commands.push("PROMPTBOOK VERSION ".concat(promptbookVersion));
1787
1787
  promptbookString = prettifyMarkdown(promptbookString);
1788
1788
  try {
1789
- for (var parameters_1 = __values(parameters), parameters_1_1 = parameters_1.next(); !parameters_1_1.done; parameters_1_1 = parameters_1.next()) {
1790
- var parameter = parameters_1_1.value;
1791
- var isInput = parameter.isInput, isOutput = parameter.isOutput;
1792
- if (isInput) {
1793
- commands.push("INPUT PARAMETER ".concat(promptTemplateParameterJsonToString(parameter)));
1794
- }
1795
- else if (isOutput) {
1796
- commands.push("OUTPUT PARAMETER ".concat(promptTemplateParameterJsonToString(parameter)));
1797
- }
1789
+ for (var _g = __values(parameters.filter(function (_a) {
1790
+ var isInput = _a.isInput;
1791
+ return isInput;
1792
+ })), _h = _g.next(); !_h.done; _h = _g.next()) {
1793
+ var parameter = _h.value;
1794
+ commands.push("INPUT PARAMETER ".concat(promptTemplateParameterJsonToString(parameter)));
1798
1795
  }
1799
1796
  }
1800
1797
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
1801
1798
  finally {
1802
1799
  try {
1803
- if (parameters_1_1 && !parameters_1_1.done && (_a = parameters_1.return)) _a.call(parameters_1);
1800
+ if (_h && !_h.done && (_a = _g.return)) _a.call(_g);
1804
1801
  }
1805
1802
  finally { if (e_1) throw e_1.error; }
1806
1803
  }
1804
+ try {
1805
+ for (var _j = __values(parameters.filter(function (_a) {
1806
+ var isOutput = _a.isOutput;
1807
+ return isOutput;
1808
+ })), _k = _j.next(); !_k.done; _k = _j.next()) {
1809
+ var parameter = _k.value;
1810
+ commands.push("OUTPUT PARAMETER ".concat(promptTemplateParameterJsonToString(parameter)));
1811
+ }
1812
+ }
1813
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
1814
+ finally {
1815
+ try {
1816
+ if (_k && !_k.done && (_b = _j.return)) _b.call(_j);
1817
+ }
1818
+ finally { if (e_2) throw e_2.error; }
1819
+ }
1807
1820
  promptbookString += '\n\n';
1808
1821
  promptbookString += commands.map(function (command) { return "- ".concat(command); }).join('\n');
1809
1822
  try {
@@ -1853,38 +1866,38 @@ function promptbookJsonToString(promptbookJson) {
1853
1866
  }
1854
1867
  if (jokers) {
1855
1868
  try {
1856
- for (var jokers_1 = (e_3 = void 0, __values(jokers)), jokers_1_1 = jokers_1.next(); !jokers_1_1.done; jokers_1_1 = jokers_1.next()) {
1869
+ for (var jokers_1 = (e_4 = void 0, __values(jokers)), jokers_1_1 = jokers_1.next(); !jokers_1_1.done; jokers_1_1 = jokers_1.next()) {
1857
1870
  var joker = jokers_1_1.value;
1858
1871
  commands_1.push("JOKER {".concat(joker, "}"));
1859
1872
  }
1860
1873
  }
1861
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1874
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
1862
1875
  finally {
1863
1876
  try {
1864
- if (jokers_1_1 && !jokers_1_1.done && (_c = jokers_1.return)) _c.call(jokers_1);
1877
+ if (jokers_1_1 && !jokers_1_1.done && (_d = jokers_1.return)) _d.call(jokers_1);
1865
1878
  }
1866
- finally { if (e_3) throw e_3.error; }
1879
+ finally { if (e_4) throw e_4.error; }
1867
1880
  }
1868
1881
  } /* not else */
1869
1882
  if (postprocessing) {
1870
1883
  try {
1871
- for (var postprocessing_1 = (e_4 = void 0, __values(postprocessing)), postprocessing_1_1 = postprocessing_1.next(); !postprocessing_1_1.done; postprocessing_1_1 = postprocessing_1.next()) {
1884
+ for (var postprocessing_1 = (e_5 = void 0, __values(postprocessing)), postprocessing_1_1 = postprocessing_1.next(); !postprocessing_1_1.done; postprocessing_1_1 = postprocessing_1.next()) {
1872
1885
  var postprocessingFunctionName = postprocessing_1_1.value;
1873
1886
  commands_1.push("POSTPROCESSING `".concat(postprocessingFunctionName, "`"));
1874
1887
  }
1875
1888
  }
1876
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
1889
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
1877
1890
  finally {
1878
1891
  try {
1879
- if (postprocessing_1_1 && !postprocessing_1_1.done && (_d = postprocessing_1.return)) _d.call(postprocessing_1);
1892
+ if (postprocessing_1_1 && !postprocessing_1_1.done && (_e = postprocessing_1.return)) _e.call(postprocessing_1);
1880
1893
  }
1881
- finally { if (e_4) throw e_4.error; }
1894
+ finally { if (e_5) throw e_5.error; }
1882
1895
  }
1883
1896
  } /* not else */
1884
1897
  if (expectations) {
1885
1898
  try {
1886
- for (var _f = (e_5 = void 0, __values(Object.entries(expectations))), _g = _f.next(); !_g.done; _g = _f.next()) {
1887
- var _h = __read(_g.value, 2), unit = _h[0], _j = _h[1], min = _j.min, max = _j.max;
1899
+ for (var _l = (e_6 = void 0, __values(Object.entries(expectations))), _m = _l.next(); !_m.done; _m = _l.next()) {
1900
+ var _o = __read(_m.value, 2), unit = _o[0], _p = _o[1], min = _p.min, max = _p.max;
1888
1901
  if (min === max) {
1889
1902
  commands_1.push("EXPECT EXACTLY ".concat(min, " ").concat(capitalize(unit + (min > 1 ? 's' : ''))));
1890
1903
  }
@@ -1898,12 +1911,12 @@ function promptbookJsonToString(promptbookJson) {
1898
1911
  }
1899
1912
  }
1900
1913
  }
1901
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
1914
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
1902
1915
  finally {
1903
1916
  try {
1904
- if (_g && !_g.done && (_e = _f.return)) _e.call(_f);
1917
+ if (_m && !_m.done && (_f = _l.return)) _f.call(_l);
1905
1918
  }
1906
- finally { if (e_5) throw e_5.error; }
1919
+ finally { if (e_6) throw e_6.error; }
1907
1920
  }
1908
1921
  } /* not else */
1909
1922
  if (expectFormat) {
@@ -1926,12 +1939,12 @@ function promptbookJsonToString(promptbookJson) {
1926
1939
  promptbookString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: !!! If the parameter here has description, add it and use promptTemplateParameterJsonToString
1927
1940
  }
1928
1941
  }
1929
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1942
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
1930
1943
  finally {
1931
1944
  try {
1932
- if (promptTemplates_1_1 && !promptTemplates_1_1.done && (_b = promptTemplates_1.return)) _b.call(promptTemplates_1);
1945
+ if (promptTemplates_1_1 && !promptTemplates_1_1.done && (_c = promptTemplates_1.return)) _c.call(promptTemplates_1);
1933
1946
  }
1934
- finally { if (e_2) throw e_2.error; }
1947
+ finally { if (e_3) throw e_3.error; }
1935
1948
  }
1936
1949
  return promptbookString;
1937
1950
  }