@promptbook/legacy-documents 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
@@ -25,7 +25,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
25
25
  * @generated
26
26
  * @see https://github.com/webgptorg/promptbook
27
27
  */
28
- var PROMPTBOOK_ENGINE_VERSION = '0.81.0-6';
28
+ var PROMPTBOOK_ENGINE_VERSION = '0.81.0-8';
29
29
  /**
30
30
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
31
31
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2523,6 +2523,81 @@ function isPipelinePrepared(pipeline) {
2523
2523
  * - [♨] Are tasks prepared
2524
2524
  */
2525
2525
 
2526
+ /**
2527
+ * Format either small or big number
2528
+ *
2529
+ * @public exported from `@promptbook/utils`
2530
+ */
2531
+ function numberToString(value) {
2532
+ if (value === 0) {
2533
+ return '0';
2534
+ }
2535
+ else if (Number.isNaN(value)) {
2536
+ return VALUE_STRINGS.nan;
2537
+ }
2538
+ else if (value === Infinity) {
2539
+ return VALUE_STRINGS.infinity;
2540
+ }
2541
+ else if (value === -Infinity) {
2542
+ return VALUE_STRINGS.negativeInfinity;
2543
+ }
2544
+ for (var exponent = 0; exponent < 15; exponent++) {
2545
+ var factor = Math.pow(10, exponent);
2546
+ var valueRounded = Math.round(value * factor) / factor;
2547
+ if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
2548
+ return valueRounded.toFixed(exponent);
2549
+ }
2550
+ }
2551
+ return value.toString();
2552
+ }
2553
+
2554
+ /**
2555
+ * Function `valueToString` will convert the given value to string
2556
+ * This is useful and used in the `templateParameters` function
2557
+ *
2558
+ * Note: This function is not just calling `toString` method
2559
+ * It's more complex and can handle this conversion specifically for LLM models
2560
+ * See `VALUE_STRINGS`
2561
+ *
2562
+ * Note: There are 2 similar functions
2563
+ * - `valueToString` converts value to string for LLM models as human-readable string
2564
+ * - `asSerializable` converts value to string to preserve full information to be able to convert it back
2565
+ *
2566
+ * @public exported from `@promptbook/utils`
2567
+ */
2568
+ function valueToString(value) {
2569
+ try {
2570
+ if (value === '') {
2571
+ return VALUE_STRINGS.empty;
2572
+ }
2573
+ else if (value === null) {
2574
+ return VALUE_STRINGS.null;
2575
+ }
2576
+ else if (value === undefined) {
2577
+ return VALUE_STRINGS.undefined;
2578
+ }
2579
+ else if (typeof value === 'string') {
2580
+ return value;
2581
+ }
2582
+ else if (typeof value === 'number') {
2583
+ return numberToString(value);
2584
+ }
2585
+ else if (value instanceof Date) {
2586
+ return value.toISOString();
2587
+ }
2588
+ else {
2589
+ return JSON.stringify(value);
2590
+ }
2591
+ }
2592
+ catch (error) {
2593
+ if (!(error instanceof Error)) {
2594
+ throw error;
2595
+ }
2596
+ console.error(error);
2597
+ return VALUE_STRINGS.unserializable;
2598
+ }
2599
+ }
2600
+
2526
2601
  /**
2527
2602
  * Serializes an error into a [🚉] JSON-serializable object
2528
2603
  *
@@ -4655,81 +4730,6 @@ function extractJsonBlock(markdown) {
4655
4730
  * TODO: [🏢] Make this logic part of `JsonFormatDefinition` or `isValidJsonString`
4656
4731
  */
4657
4732
 
4658
- /**
4659
- * Format either small or big number
4660
- *
4661
- * @public exported from `@promptbook/utils`
4662
- */
4663
- function numberToString(value) {
4664
- if (value === 0) {
4665
- return '0';
4666
- }
4667
- else if (Number.isNaN(value)) {
4668
- return VALUE_STRINGS.nan;
4669
- }
4670
- else if (value === Infinity) {
4671
- return VALUE_STRINGS.infinity;
4672
- }
4673
- else if (value === -Infinity) {
4674
- return VALUE_STRINGS.negativeInfinity;
4675
- }
4676
- for (var exponent = 0; exponent < 15; exponent++) {
4677
- var factor = Math.pow(10, exponent);
4678
- var valueRounded = Math.round(value * factor) / factor;
4679
- if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
4680
- return valueRounded.toFixed(exponent);
4681
- }
4682
- }
4683
- return value.toString();
4684
- }
4685
-
4686
- /**
4687
- * Function `valueToString` will convert the given value to string
4688
- * This is useful and used in the `templateParameters` function
4689
- *
4690
- * Note: This function is not just calling `toString` method
4691
- * It's more complex and can handle this conversion specifically for LLM models
4692
- * See `VALUE_STRINGS`
4693
- *
4694
- * Note: There are 2 similar functions
4695
- * - `valueToString` converts value to string for LLM models as human-readable string
4696
- * - `asSerializable` converts value to string to preserve full information to be able to convert it back
4697
- *
4698
- * @public exported from `@promptbook/utils`
4699
- */
4700
- function valueToString(value) {
4701
- try {
4702
- if (value === '') {
4703
- return VALUE_STRINGS.empty;
4704
- }
4705
- else if (value === null) {
4706
- return VALUE_STRINGS.null;
4707
- }
4708
- else if (value === undefined) {
4709
- return VALUE_STRINGS.undefined;
4710
- }
4711
- else if (typeof value === 'string') {
4712
- return value;
4713
- }
4714
- else if (typeof value === 'number') {
4715
- return numberToString(value);
4716
- }
4717
- else if (value instanceof Date) {
4718
- return value.toISOString();
4719
- }
4720
- else {
4721
- return JSON.stringify(value);
4722
- }
4723
- }
4724
- catch (error) {
4725
- if (!(error instanceof Error)) {
4726
- throw error;
4727
- }
4728
- console.error(error);
4729
- return VALUE_STRINGS.unserializable;
4730
- }
4731
- }
4732
-
4733
4733
  /**
4734
4734
  * Replaces parameters in template with values from parameters object
4735
4735
  *
@@ -5845,7 +5845,10 @@ function executePipeline(options) {
5845
5845
  finally { if (e_2) throw e_2.error; }
5846
5846
  return [7 /*endfinally*/];
5847
5847
  case 19:
5848
- parametersToPass = inputParameters;
5848
+ parametersToPass = Object.fromEntries(Object.entries(inputParameters).map(function (_a) {
5849
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
5850
+ return [key, valueToString(value)];
5851
+ }));
5849
5852
  _g.label = 20;
5850
5853
  case 20:
5851
5854
  _g.trys.push([20, 25, , 28]);