@promptbook/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.
@@ -9,6 +9,7 @@ import { $provideScrapersForNode } from '../scrapers/_common/register/$provideSc
9
9
  import { FileCacheStorage } from '../storage/file-cache-storage/FileCacheStorage';
10
10
  import { $execCommand } from '../utils/execCommand/$execCommand';
11
11
  import { $execCommands } from '../utils/execCommand/$execCommands';
12
+ import { wizzard } from '../wizzard/wizzard';
12
13
  export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
13
14
  export { createCollectionFromDirectory };
14
15
  export { $provideExecutablesForNode };
@@ -20,3 +21,4 @@ export { $provideScrapersForNode };
20
21
  export { FileCacheStorage };
21
22
  export { $execCommand };
22
23
  export { $execCommands };
24
+ export { wizzard };
@@ -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,12 +1,21 @@
1
+ import type { PipelineCollection } from '../../collection/PipelineCollection';
1
2
  import type { string_formfactor_name } from '../../formfactors/_common/string_formfactor_name';
2
3
  import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
4
+ /**
5
+ * @@@
6
+ *
7
+ * @singleton
8
+ * @private internal cache of `getBookTemplate`
9
+ */
10
+ export declare let templatesPipelineCollection: PipelineCollection | null;
3
11
  /**
4
12
  * Get template for new book
5
13
  *
6
14
  * @public exported from `@promptbook/templates`
7
15
  */
8
- export declare function getBookTemplate(formfactorName: string_formfactor_name): Promise<PipelineJson | null>;
16
+ export declare function getBookTemplate(formfactorName: string_formfactor_name): PipelineJson;
9
17
  /**
18
+ * TODO: !!!!!! Test
10
19
  * TODO: [🧠] Which is the best place for this function
11
20
  * TODO: !!!!!! `book string template notation
12
21
  */
@@ -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
@@ -0,0 +1,19 @@
1
+ import { Promisable } from 'type-fest';
2
+ import type { PipelineExecutorResult } from '../execution/PipelineExecutorResult';
3
+ import type { TaskProgress } from '../types/TaskProgress';
4
+ import type { InputParameters } from '../types/typeAliases';
5
+ import type { string_pipeline_url } from '../types/typeAliases';
6
+ /**
7
+ * @@@
8
+ *
9
+ * @public exported from `@promptbook/node`
10
+ */
11
+ export declare const wizzard: {
12
+ /**
13
+ * @@@!!!!!!
14
+ */
15
+ execute(book: string_pipeline_url, inputParameters: InputParameters, onProgress?: ((taskProgress: TaskProgress) => Promisable<void>) | undefined): Promise<PipelineExecutorResult>;
16
+ };
17
+ /**
18
+ * TODO: !!!!!! Add to readmes - one markdown here imported in all packages
19
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/documents",
3
- "version": "0.81.0-7",
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/documents.index.d.ts",
56
56
  "peerDependencies": {
57
- "@promptbook/core": "0.81.0-7"
57
+ "@promptbook/core": "0.81.0-9"
58
58
  },
59
59
  "dependencies": {
60
60
  "colors": "1.4.0",
package/umd/index.umd.js CHANGED
@@ -25,7 +25,7 @@
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 @@
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 @@
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 @@
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]);