@promptbook/pdf 0.81.0-7 → 0.81.0-9

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/esm/index.es.js CHANGED
@@ -22,7 +22,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
22
22
  * @generated
23
23
  * @see https://github.com/webgptorg/promptbook
24
24
  */
25
- var PROMPTBOOK_ENGINE_VERSION = '0.81.0-6';
25
+ var PROMPTBOOK_ENGINE_VERSION = '0.81.0-8';
26
26
  /**
27
27
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
28
28
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1847,6 +1847,81 @@ function isPipelinePrepared(pipeline) {
1847
1847
  * - [♨] Are tasks prepared
1848
1848
  */
1849
1849
 
1850
+ /**
1851
+ * Format either small or big number
1852
+ *
1853
+ * @public exported from `@promptbook/utils`
1854
+ */
1855
+ function numberToString(value) {
1856
+ if (value === 0) {
1857
+ return '0';
1858
+ }
1859
+ else if (Number.isNaN(value)) {
1860
+ return VALUE_STRINGS.nan;
1861
+ }
1862
+ else if (value === Infinity) {
1863
+ return VALUE_STRINGS.infinity;
1864
+ }
1865
+ else if (value === -Infinity) {
1866
+ return VALUE_STRINGS.negativeInfinity;
1867
+ }
1868
+ for (var exponent = 0; exponent < 15; exponent++) {
1869
+ var factor = Math.pow(10, exponent);
1870
+ var valueRounded = Math.round(value * factor) / factor;
1871
+ if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
1872
+ return valueRounded.toFixed(exponent);
1873
+ }
1874
+ }
1875
+ return value.toString();
1876
+ }
1877
+
1878
+ /**
1879
+ * Function `valueToString` will convert the given value to string
1880
+ * This is useful and used in the `templateParameters` function
1881
+ *
1882
+ * Note: This function is not just calling `toString` method
1883
+ * It's more complex and can handle this conversion specifically for LLM models
1884
+ * See `VALUE_STRINGS`
1885
+ *
1886
+ * Note: There are 2 similar functions
1887
+ * - `valueToString` converts value to string for LLM models as human-readable string
1888
+ * - `asSerializable` converts value to string to preserve full information to be able to convert it back
1889
+ *
1890
+ * @public exported from `@promptbook/utils`
1891
+ */
1892
+ function valueToString(value) {
1893
+ try {
1894
+ if (value === '') {
1895
+ return VALUE_STRINGS.empty;
1896
+ }
1897
+ else if (value === null) {
1898
+ return VALUE_STRINGS.null;
1899
+ }
1900
+ else if (value === undefined) {
1901
+ return VALUE_STRINGS.undefined;
1902
+ }
1903
+ else if (typeof value === 'string') {
1904
+ return value;
1905
+ }
1906
+ else if (typeof value === 'number') {
1907
+ return numberToString(value);
1908
+ }
1909
+ else if (value instanceof Date) {
1910
+ return value.toISOString();
1911
+ }
1912
+ else {
1913
+ return JSON.stringify(value);
1914
+ }
1915
+ }
1916
+ catch (error) {
1917
+ if (!(error instanceof Error)) {
1918
+ throw error;
1919
+ }
1920
+ console.error(error);
1921
+ return VALUE_STRINGS.unserializable;
1922
+ }
1923
+ }
1924
+
1850
1925
  /**
1851
1926
  * Serializes an error into a [🚉] JSON-serializable object
1852
1927
  *
@@ -4374,81 +4449,6 @@ function extractJsonBlock(markdown) {
4374
4449
  * TODO: [🏢] Make this logic part of `JsonFormatDefinition` or `isValidJsonString`
4375
4450
  */
4376
4451
 
4377
- /**
4378
- * Format either small or big number
4379
- *
4380
- * @public exported from `@promptbook/utils`
4381
- */
4382
- function numberToString(value) {
4383
- if (value === 0) {
4384
- return '0';
4385
- }
4386
- else if (Number.isNaN(value)) {
4387
- return VALUE_STRINGS.nan;
4388
- }
4389
- else if (value === Infinity) {
4390
- return VALUE_STRINGS.infinity;
4391
- }
4392
- else if (value === -Infinity) {
4393
- return VALUE_STRINGS.negativeInfinity;
4394
- }
4395
- for (var exponent = 0; exponent < 15; exponent++) {
4396
- var factor = Math.pow(10, exponent);
4397
- var valueRounded = Math.round(value * factor) / factor;
4398
- if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
4399
- return valueRounded.toFixed(exponent);
4400
- }
4401
- }
4402
- return value.toString();
4403
- }
4404
-
4405
- /**
4406
- * Function `valueToString` will convert the given value to string
4407
- * This is useful and used in the `templateParameters` function
4408
- *
4409
- * Note: This function is not just calling `toString` method
4410
- * It's more complex and can handle this conversion specifically for LLM models
4411
- * See `VALUE_STRINGS`
4412
- *
4413
- * Note: There are 2 similar functions
4414
- * - `valueToString` converts value to string for LLM models as human-readable string
4415
- * - `asSerializable` converts value to string to preserve full information to be able to convert it back
4416
- *
4417
- * @public exported from `@promptbook/utils`
4418
- */
4419
- function valueToString(value) {
4420
- try {
4421
- if (value === '') {
4422
- return VALUE_STRINGS.empty;
4423
- }
4424
- else if (value === null) {
4425
- return VALUE_STRINGS.null;
4426
- }
4427
- else if (value === undefined) {
4428
- return VALUE_STRINGS.undefined;
4429
- }
4430
- else if (typeof value === 'string') {
4431
- return value;
4432
- }
4433
- else if (typeof value === 'number') {
4434
- return numberToString(value);
4435
- }
4436
- else if (value instanceof Date) {
4437
- return value.toISOString();
4438
- }
4439
- else {
4440
- return JSON.stringify(value);
4441
- }
4442
- }
4443
- catch (error) {
4444
- if (!(error instanceof Error)) {
4445
- throw error;
4446
- }
4447
- console.error(error);
4448
- return VALUE_STRINGS.unserializable;
4449
- }
4450
- }
4451
-
4452
4452
  /**
4453
4453
  * Replaces parameters in template with values from parameters object
4454
4454
  *
@@ -5564,7 +5564,10 @@ function executePipeline(options) {
5564
5564
  finally { if (e_2) throw e_2.error; }
5565
5565
  return [7 /*endfinally*/];
5566
5566
  case 19:
5567
- parametersToPass = inputParameters;
5567
+ parametersToPass = Object.fromEntries(Object.entries(inputParameters).map(function (_a) {
5568
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
5569
+ return [key, valueToString(value)];
5570
+ }));
5568
5571
  _g.label = 20;
5569
5572
  case 20:
5570
5573
  _g.trys.push([20, 25, , 28]);