@promptbook/website-crawler 0.81.0-8 → 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
@@ -26,7 +26,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
26
26
  * @generated
27
27
  * @see https://github.com/webgptorg/promptbook
28
28
  */
29
- var PROMPTBOOK_ENGINE_VERSION = '0.81.0-7';
29
+ var PROMPTBOOK_ENGINE_VERSION = '0.81.0-8';
30
30
  /**
31
31
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
32
32
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2485,6 +2485,81 @@ function isPipelinePrepared(pipeline) {
2485
2485
  * - [♨] Are tasks prepared
2486
2486
  */
2487
2487
 
2488
+ /**
2489
+ * Format either small or big number
2490
+ *
2491
+ * @public exported from `@promptbook/utils`
2492
+ */
2493
+ function numberToString(value) {
2494
+ if (value === 0) {
2495
+ return '0';
2496
+ }
2497
+ else if (Number.isNaN(value)) {
2498
+ return VALUE_STRINGS.nan;
2499
+ }
2500
+ else if (value === Infinity) {
2501
+ return VALUE_STRINGS.infinity;
2502
+ }
2503
+ else if (value === -Infinity) {
2504
+ return VALUE_STRINGS.negativeInfinity;
2505
+ }
2506
+ for (var exponent = 0; exponent < 15; exponent++) {
2507
+ var factor = Math.pow(10, exponent);
2508
+ var valueRounded = Math.round(value * factor) / factor;
2509
+ if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
2510
+ return valueRounded.toFixed(exponent);
2511
+ }
2512
+ }
2513
+ return value.toString();
2514
+ }
2515
+
2516
+ /**
2517
+ * Function `valueToString` will convert the given value to string
2518
+ * This is useful and used in the `templateParameters` function
2519
+ *
2520
+ * Note: This function is not just calling `toString` method
2521
+ * It's more complex and can handle this conversion specifically for LLM models
2522
+ * See `VALUE_STRINGS`
2523
+ *
2524
+ * Note: There are 2 similar functions
2525
+ * - `valueToString` converts value to string for LLM models as human-readable string
2526
+ * - `asSerializable` converts value to string to preserve full information to be able to convert it back
2527
+ *
2528
+ * @public exported from `@promptbook/utils`
2529
+ */
2530
+ function valueToString(value) {
2531
+ try {
2532
+ if (value === '') {
2533
+ return VALUE_STRINGS.empty;
2534
+ }
2535
+ else if (value === null) {
2536
+ return VALUE_STRINGS.null;
2537
+ }
2538
+ else if (value === undefined) {
2539
+ return VALUE_STRINGS.undefined;
2540
+ }
2541
+ else if (typeof value === 'string') {
2542
+ return value;
2543
+ }
2544
+ else if (typeof value === 'number') {
2545
+ return numberToString(value);
2546
+ }
2547
+ else if (value instanceof Date) {
2548
+ return value.toISOString();
2549
+ }
2550
+ else {
2551
+ return JSON.stringify(value);
2552
+ }
2553
+ }
2554
+ catch (error) {
2555
+ if (!(error instanceof Error)) {
2556
+ throw error;
2557
+ }
2558
+ console.error(error);
2559
+ return VALUE_STRINGS.unserializable;
2560
+ }
2561
+ }
2562
+
2488
2563
  /**
2489
2564
  * Serializes an error into a [🚉] JSON-serializable object
2490
2565
  *
@@ -4512,81 +4587,6 @@ function extractJsonBlock(markdown) {
4512
4587
  * TODO: [🏢] Make this logic part of `JsonFormatDefinition` or `isValidJsonString`
4513
4588
  */
4514
4589
 
4515
- /**
4516
- * Format either small or big number
4517
- *
4518
- * @public exported from `@promptbook/utils`
4519
- */
4520
- function numberToString(value) {
4521
- if (value === 0) {
4522
- return '0';
4523
- }
4524
- else if (Number.isNaN(value)) {
4525
- return VALUE_STRINGS.nan;
4526
- }
4527
- else if (value === Infinity) {
4528
- return VALUE_STRINGS.infinity;
4529
- }
4530
- else if (value === -Infinity) {
4531
- return VALUE_STRINGS.negativeInfinity;
4532
- }
4533
- for (var exponent = 0; exponent < 15; exponent++) {
4534
- var factor = Math.pow(10, exponent);
4535
- var valueRounded = Math.round(value * factor) / factor;
4536
- if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
4537
- return valueRounded.toFixed(exponent);
4538
- }
4539
- }
4540
- return value.toString();
4541
- }
4542
-
4543
- /**
4544
- * Function `valueToString` will convert the given value to string
4545
- * This is useful and used in the `templateParameters` function
4546
- *
4547
- * Note: This function is not just calling `toString` method
4548
- * It's more complex and can handle this conversion specifically for LLM models
4549
- * See `VALUE_STRINGS`
4550
- *
4551
- * Note: There are 2 similar functions
4552
- * - `valueToString` converts value to string for LLM models as human-readable string
4553
- * - `asSerializable` converts value to string to preserve full information to be able to convert it back
4554
- *
4555
- * @public exported from `@promptbook/utils`
4556
- */
4557
- function valueToString(value) {
4558
- try {
4559
- if (value === '') {
4560
- return VALUE_STRINGS.empty;
4561
- }
4562
- else if (value === null) {
4563
- return VALUE_STRINGS.null;
4564
- }
4565
- else if (value === undefined) {
4566
- return VALUE_STRINGS.undefined;
4567
- }
4568
- else if (typeof value === 'string') {
4569
- return value;
4570
- }
4571
- else if (typeof value === 'number') {
4572
- return numberToString(value);
4573
- }
4574
- else if (value instanceof Date) {
4575
- return value.toISOString();
4576
- }
4577
- else {
4578
- return JSON.stringify(value);
4579
- }
4580
- }
4581
- catch (error) {
4582
- if (!(error instanceof Error)) {
4583
- throw error;
4584
- }
4585
- console.error(error);
4586
- return VALUE_STRINGS.unserializable;
4587
- }
4588
- }
4589
-
4590
4590
  /**
4591
4591
  * Replaces parameters in template with values from parameters object
4592
4592
  *
@@ -5702,7 +5702,10 @@ function executePipeline(options) {
5702
5702
  finally { if (e_2) throw e_2.error; }
5703
5703
  return [7 /*endfinally*/];
5704
5704
  case 19:
5705
- parametersToPass = inputParameters;
5705
+ parametersToPass = Object.fromEntries(Object.entries(inputParameters).map(function (_a) {
5706
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
5707
+ return [key, valueToString(value)];
5708
+ }));
5706
5709
  _g.label = 20;
5707
5710
  case 20:
5708
5711
  _g.trys.push([20, 25, , 28]);