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