@promptbook/markdown-utils 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.
@@ -143,6 +143,7 @@ import type { string_name } from '../types/typeAliases';
143
143
  import type { string_parameter_name } from '../types/typeAliases';
144
144
  import type { string_parameter_value } from '../types/typeAliases';
145
145
  import type { Parameters } from '../types/typeAliases';
146
+ import type { InputParameters } from '../types/typeAliases';
146
147
  import type { string_reserved_parameter_name } from '../types/typeAliases';
147
148
  import type { ReservedParameters } from '../types/typeAliases';
148
149
  import type { string_title } from '../types/typeAliases';
@@ -407,6 +408,7 @@ export type { string_name };
407
408
  export type { string_parameter_name };
408
409
  export type { string_parameter_value };
409
410
  export type { Parameters };
411
+ export type { InputParameters };
410
412
  export type { string_reserved_parameter_name };
411
413
  export type { ReservedParameters };
412
414
  export type { string_title };
@@ -1,6 +1,6 @@
1
1
  import type { Promisable } from 'type-fest';
2
2
  import type { TaskProgress } from '../types/TaskProgress';
3
- import type { Parameters } from '../types/typeAliases';
3
+ import type { InputParameters } from '../types/typeAliases';
4
4
  import type { PipelineExecutorResult } from './PipelineExecutorResult';
5
5
  /**
6
6
  * Executor is a simple async function that takes INPUT PARAMETERs and returns result parameters _(along with all intermediate parameters and INPUT PARAMETERs = it extends input object)_.
@@ -11,7 +11,7 @@ import type { PipelineExecutorResult } from './PipelineExecutorResult';
11
11
  * @see https://github.com/webgptorg/promptbook#executor
12
12
  */
13
13
  export type PipelineExecutor = {
14
- (inputParameters: Parameters, onProgress?: (taskProgress: TaskProgress) => Promisable<void>): Promise<PipelineExecutorResult>;
14
+ (inputParameters: InputParameters, onProgress?: (taskProgress: TaskProgress) => Promisable<void>): Promise<PipelineExecutorResult>;
15
15
  };
16
16
  /**
17
17
  * TODO: [🐚] Change onProgress to object that represents the running execution, can be subscribed via RxJS to and also awaited
@@ -1,7 +1,7 @@
1
1
  import type { Promisable, ReadonlyDeep } from 'type-fest';
2
2
  import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
3
3
  import type { TaskProgress } from '../../types/TaskProgress';
4
- import type { Parameters } from '../../types/typeAliases';
4
+ import type { InputParameters } from '../../types/typeAliases';
5
5
  import type { PipelineExecutorResult } from '../PipelineExecutorResult';
6
6
  import type { CreatePipelineExecutorOptions } from './00-CreatePipelineExecutorOptions';
7
7
  /**
@@ -13,7 +13,7 @@ type ExecutePipelineOptions = Required<CreatePipelineExecutorOptions> & {
13
13
  /**
14
14
  * @@@
15
15
  */
16
- readonly inputParameters: Readonly<Parameters>;
16
+ readonly inputParameters: Readonly<InputParameters>;
17
17
  /**
18
18
  * @@@
19
19
  */
@@ -1,5 +1,6 @@
1
1
  import type { TupleToUnion } from 'type-fest';
2
2
  import { RESERVED_PARAMETER_NAMES } from '../constants';
3
+ import type { really_unknown } from '../utils/organization/really_unknown';
3
4
  /**
4
5
  * Semantic helper
5
6
  */
@@ -107,6 +108,13 @@ export type string_parameter_value = string;
107
108
  * @see https://ptbk.io/parameters
108
109
  */
109
110
  export type Parameters = Exclude<Record<string_parameter_name, string_parameter_value>, ReservedParameters>;
111
+ /**
112
+ * Parameters to pass to execution of the pipeline
113
+ *
114
+ * Note: [🚉] This should be fully serializable as JSON
115
+ * @see https://ptbk.io/parameters
116
+ */
117
+ export type InputParameters = Exclude<Record<string_parameter_name, really_unknown>, ReservedParameters>;
110
118
  /**
111
119
  * Semantic helper
112
120
  * Unique identifier of reserved parameter
@@ -1,7 +1,7 @@
1
1
  import { Promisable } from 'type-fest';
2
2
  import type { PipelineExecutorResult } from '../execution/PipelineExecutorResult';
3
3
  import type { TaskProgress } from '../types/TaskProgress';
4
- import type { Parameters } from '../types/typeAliases';
4
+ import type { InputParameters } from '../types/typeAliases';
5
5
  import type { string_pipeline_url } from '../types/typeAliases';
6
6
  /**
7
7
  * @@@
@@ -12,7 +12,7 @@ export declare const wizzard: {
12
12
  /**
13
13
  * @@@!!!!!!
14
14
  */
15
- run(book: string_pipeline_url, inputParameters: Parameters, onProgress?: ((taskProgress: TaskProgress) => Promisable<void>) | undefined): Promise<PipelineExecutorResult>;
15
+ execute(book: string_pipeline_url, inputParameters: InputParameters, onProgress?: ((taskProgress: TaskProgress) => Promisable<void>) | undefined): Promise<PipelineExecutorResult>;
16
16
  };
17
17
  /**
18
18
  * TODO: !!!!!! Add to readmes - one markdown here imported in all packages
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/markdown-utils",
3
- "version": "0.81.0-8",
3
+ "version": "0.81.0-9",
4
4
  "description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
5
5
  "--note-0": " <- [🐊]",
6
6
  "private": false,
package/umd/index.umd.js CHANGED
@@ -24,7 +24,7 @@
24
24
  * @generated
25
25
  * @see https://github.com/webgptorg/promptbook
26
26
  */
27
- var PROMPTBOOK_ENGINE_VERSION = '0.81.0-7';
27
+ var PROMPTBOOK_ENGINE_VERSION = '0.81.0-8';
28
28
  /**
29
29
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
30
30
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2031,6 +2031,81 @@
2031
2031
  * - [♨] Are tasks prepared
2032
2032
  */
2033
2033
 
2034
+ /**
2035
+ * Format either small or big number
2036
+ *
2037
+ * @public exported from `@promptbook/utils`
2038
+ */
2039
+ function numberToString(value) {
2040
+ if (value === 0) {
2041
+ return '0';
2042
+ }
2043
+ else if (Number.isNaN(value)) {
2044
+ return VALUE_STRINGS.nan;
2045
+ }
2046
+ else if (value === Infinity) {
2047
+ return VALUE_STRINGS.infinity;
2048
+ }
2049
+ else if (value === -Infinity) {
2050
+ return VALUE_STRINGS.negativeInfinity;
2051
+ }
2052
+ for (var exponent = 0; exponent < 15; exponent++) {
2053
+ var factor = Math.pow(10, exponent);
2054
+ var valueRounded = Math.round(value * factor) / factor;
2055
+ if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
2056
+ return valueRounded.toFixed(exponent);
2057
+ }
2058
+ }
2059
+ return value.toString();
2060
+ }
2061
+
2062
+ /**
2063
+ * Function `valueToString` will convert the given value to string
2064
+ * This is useful and used in the `templateParameters` function
2065
+ *
2066
+ * Note: This function is not just calling `toString` method
2067
+ * It's more complex and can handle this conversion specifically for LLM models
2068
+ * See `VALUE_STRINGS`
2069
+ *
2070
+ * Note: There are 2 similar functions
2071
+ * - `valueToString` converts value to string for LLM models as human-readable string
2072
+ * - `asSerializable` converts value to string to preserve full information to be able to convert it back
2073
+ *
2074
+ * @public exported from `@promptbook/utils`
2075
+ */
2076
+ function valueToString(value) {
2077
+ try {
2078
+ if (value === '') {
2079
+ return VALUE_STRINGS.empty;
2080
+ }
2081
+ else if (value === null) {
2082
+ return VALUE_STRINGS.null;
2083
+ }
2084
+ else if (value === undefined) {
2085
+ return VALUE_STRINGS.undefined;
2086
+ }
2087
+ else if (typeof value === 'string') {
2088
+ return value;
2089
+ }
2090
+ else if (typeof value === 'number') {
2091
+ return numberToString(value);
2092
+ }
2093
+ else if (value instanceof Date) {
2094
+ return value.toISOString();
2095
+ }
2096
+ else {
2097
+ return JSON.stringify(value);
2098
+ }
2099
+ }
2100
+ catch (error) {
2101
+ if (!(error instanceof Error)) {
2102
+ throw error;
2103
+ }
2104
+ console.error(error);
2105
+ return VALUE_STRINGS.unserializable;
2106
+ }
2107
+ }
2108
+
2034
2109
  /**
2035
2110
  * Serializes an error into a [🚉] JSON-serializable object
2036
2111
  *
@@ -4421,81 +4496,6 @@
4421
4496
  return mappedParameters;
4422
4497
  }
4423
4498
 
4424
- /**
4425
- * Format either small or big number
4426
- *
4427
- * @public exported from `@promptbook/utils`
4428
- */
4429
- function numberToString(value) {
4430
- if (value === 0) {
4431
- return '0';
4432
- }
4433
- else if (Number.isNaN(value)) {
4434
- return VALUE_STRINGS.nan;
4435
- }
4436
- else if (value === Infinity) {
4437
- return VALUE_STRINGS.infinity;
4438
- }
4439
- else if (value === -Infinity) {
4440
- return VALUE_STRINGS.negativeInfinity;
4441
- }
4442
- for (var exponent = 0; exponent < 15; exponent++) {
4443
- var factor = Math.pow(10, exponent);
4444
- var valueRounded = Math.round(value * factor) / factor;
4445
- if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
4446
- return valueRounded.toFixed(exponent);
4447
- }
4448
- }
4449
- return value.toString();
4450
- }
4451
-
4452
- /**
4453
- * Function `valueToString` will convert the given value to string
4454
- * This is useful and used in the `templateParameters` function
4455
- *
4456
- * Note: This function is not just calling `toString` method
4457
- * It's more complex and can handle this conversion specifically for LLM models
4458
- * See `VALUE_STRINGS`
4459
- *
4460
- * Note: There are 2 similar functions
4461
- * - `valueToString` converts value to string for LLM models as human-readable string
4462
- * - `asSerializable` converts value to string to preserve full information to be able to convert it back
4463
- *
4464
- * @public exported from `@promptbook/utils`
4465
- */
4466
- function valueToString(value) {
4467
- try {
4468
- if (value === '') {
4469
- return VALUE_STRINGS.empty;
4470
- }
4471
- else if (value === null) {
4472
- return VALUE_STRINGS.null;
4473
- }
4474
- else if (value === undefined) {
4475
- return VALUE_STRINGS.undefined;
4476
- }
4477
- else if (typeof value === 'string') {
4478
- return value;
4479
- }
4480
- else if (typeof value === 'number') {
4481
- return numberToString(value);
4482
- }
4483
- else if (value instanceof Date) {
4484
- return value.toISOString();
4485
- }
4486
- else {
4487
- return JSON.stringify(value);
4488
- }
4489
- }
4490
- catch (error) {
4491
- if (!(error instanceof Error)) {
4492
- throw error;
4493
- }
4494
- console.error(error);
4495
- return VALUE_STRINGS.unserializable;
4496
- }
4497
- }
4498
-
4499
4499
  /**
4500
4500
  * Replaces parameters in template with values from parameters object
4501
4501
  *
@@ -5611,7 +5611,10 @@
5611
5611
  finally { if (e_2) throw e_2.error; }
5612
5612
  return [7 /*endfinally*/];
5613
5613
  case 19:
5614
- parametersToPass = inputParameters;
5614
+ parametersToPass = Object.fromEntries(Object.entries(inputParameters).map(function (_a) {
5615
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
5616
+ return [key, valueToString(value)];
5617
+ }));
5615
5618
  _g.label = 20;
5616
5619
  case 20:
5617
5620
  _g.trys.push([20, 25, , 28]);