@promptbook/editable 0.92.0-20 → 0.92.0-22

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.
@@ -1,11 +1,18 @@
1
+ import type { PartialDeep, Promisable } from 'type-fest';
1
2
  import type { TODO_any } from '../../utils/organization/TODO_any';
3
+ import type { PipelineExecutorResult } from '../PipelineExecutorResult';
2
4
  import type { ExecuteAttemptsOptions } from './40-executeAttempts';
3
5
  /**
4
6
  * @@@
5
7
  *
6
8
  * @private internal type of `executeFormatSubvalues`
7
9
  */
8
- type ExecuteFormatCellsOptions = ExecuteAttemptsOptions;
10
+ type ExecuteFormatCellsOptions = ExecuteAttemptsOptions & {
11
+ /**
12
+ * @@@
13
+ */
14
+ readonly onProgress: (newOngoingResult: PartialDeep<PipelineExecutorResult>) => Promisable<void>;
15
+ };
9
16
  /**
10
17
  * @@@
11
18
  *
@@ -24,7 +24,17 @@ export type FormatSubvalueParser<TValue extends string, TSettings extends empty_
24
24
  * For example, if you have a JSON object and you want to map all values to uppercase
25
25
  * Or iterate over all CSV cells @@@
26
26
  */
27
- mapValues(value: TValue, outputParameterName: string_parameter_name, settings: TSettings, mapCallback: (subvalues: Parameters, index: number) => Promisable<string>): Promise<string>;
27
+ mapValues(options: FormatSubvalueParserMapValuesOptions<TValue, TSettings>): Promise<string>;
28
+ };
29
+ /**
30
+ * @@@
31
+ */
32
+ export type FormatSubvalueParserMapValuesOptions<TValue extends string, TSettings extends empty_object> = {
33
+ readonly value: TValue;
34
+ readonly outputParameterName: string_parameter_name;
35
+ readonly settings: TSettings;
36
+ mapCallback: (subvalues: Parameters, index: number) => Promisable<TValue>;
37
+ onProgress(partialResultString: TValue): Promisable<void>;
28
38
  };
29
39
  /**
30
40
  * Note: [👩🏾‍🤝‍🧑🏽]
@@ -6,6 +6,3 @@
6
6
  * @public exported from `@promptbook/utils`
7
7
  */
8
8
  export declare function jsonParse<T>(value: string): T;
9
- /**
10
- * TODO: !!!! Use in Promptbook.studio
11
- */
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Completion is formfactor that emulates completion models
3
+ *
4
+ * @public exported from `@promptbook/core`
5
+ */
6
+ export declare const CompletionFormfactorDefinition: {
7
+ readonly name: "COMPLETION";
8
+ readonly description: "@@@";
9
+ readonly documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@";
10
+ readonly pipelineInterface: {
11
+ readonly inputParameters: readonly [{
12
+ readonly name: "inputText";
13
+ readonly description: "Input text to be completed";
14
+ readonly isInput: true;
15
+ readonly isOutput: false;
16
+ }, {
17
+ readonly name: "instructions";
18
+ readonly description: "Additional instructions for the model, for example the required length, empty by default";
19
+ readonly isInput: true;
20
+ readonly isOutput: false;
21
+ }];
22
+ readonly outputParameters: readonly [{
23
+ readonly name: "followingText";
24
+ readonly description: "Text that follows the input text";
25
+ readonly isInput: false;
26
+ readonly isOutput: true;
27
+ }];
28
+ };
29
+ };
@@ -36,9 +36,6 @@ export declare const FORMFACTOR_DEFINITIONS: readonly [{
36
36
  readonly outputParameters: readonly [{
37
37
  readonly name: "title";
38
38
  readonly description: "Title of the conversation";
39
- /**
40
- * Note: [💞] Ignore a discrepancy between file name and entity name
41
- */
42
39
  readonly isInput: false;
43
40
  readonly isOutput: true;
44
41
  }, {
@@ -132,6 +129,11 @@ export declare const FORMFACTOR_DEFINITIONS: readonly [{
132
129
  readonly isInput: true;
133
130
  readonly isOutput: false;
134
131
  }];
132
+ /**
133
+ * All available formfactor definitions
134
+ *
135
+ * @public exported from `@promptbook/core`
136
+ */
135
137
  readonly outputParameters: readonly [{
136
138
  readonly name: "prompt";
137
139
  readonly description: "Prompt to be used for image generation";
@@ -139,6 +141,29 @@ export declare const FORMFACTOR_DEFINITIONS: readonly [{
139
141
  readonly isOutput: true;
140
142
  }];
141
143
  };
144
+ }, {
145
+ readonly name: "COMPLETION";
146
+ readonly description: "@@@";
147
+ readonly documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@";
148
+ readonly pipelineInterface: {
149
+ readonly inputParameters: readonly [{
150
+ readonly name: "inputText";
151
+ readonly description: "Input text to be completed";
152
+ readonly isInput: true;
153
+ readonly isOutput: false;
154
+ }, {
155
+ readonly name: "instructions";
156
+ readonly description: "Additional instructions for the model, for example the required length, empty by default";
157
+ readonly isInput: true;
158
+ readonly isOutput: false;
159
+ }];
160
+ readonly outputParameters: readonly [{
161
+ readonly name: "followingText";
162
+ readonly description: "Text that follows the input text";
163
+ readonly isInput: false;
164
+ readonly isOutput: true;
165
+ }];
166
+ };
142
167
  }];
143
168
  /**
144
169
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -23,7 +23,7 @@ export declare const HIGH_LEVEL_ABSTRACTIONS: readonly [{
23
23
  path: string | null;
24
24
  content: import("../pipeline/PipelineString").PipelineString;
25
25
  }[];
26
- readonly formfactorName?: "CHATBOT" | "GENERATOR" | "GENERIC" | "IMAGE_GENERATOR" | "EXPERIMENTAL_MATCHER" | "SHEETS" | "TRANSLATOR" | undefined;
26
+ readonly formfactorName?: "CHATBOT" | "COMPLETION" | "GENERATOR" | "GENERIC" | "IMAGE_GENERATOR" | "EXPERIMENTAL_MATCHER" | "SHEETS" | "TRANSLATOR" | undefined;
27
27
  }>): void;
28
28
  }, {
29
29
  type: "SYNC";
@@ -45,7 +45,7 @@ export declare const HIGH_LEVEL_ABSTRACTIONS: readonly [{
45
45
  path: string | null;
46
46
  content: import("../pipeline/PipelineString").PipelineString;
47
47
  }[];
48
- readonly formfactorName?: "CHATBOT" | "GENERATOR" | "GENERIC" | "IMAGE_GENERATOR" | "EXPERIMENTAL_MATCHER" | "SHEETS" | "TRANSLATOR" | undefined;
48
+ readonly formfactorName?: "CHATBOT" | "COMPLETION" | "GENERATOR" | "GENERIC" | "IMAGE_GENERATOR" | "EXPERIMENTAL_MATCHER" | "SHEETS" | "TRANSLATOR" | undefined;
49
49
  }>): void;
50
50
  }];
51
51
  /**
@@ -2,6 +2,8 @@ import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
2
2
  /**
3
3
  * Migrates the pipeline to the latest version
4
4
  *
5
+ * Note: Migration does not do heavy lifting like calling the LLMs, just lightweight changes of the structure
6
+ *
5
7
  * @public exported from `@promptbook/core`
6
8
  */
7
9
  export declare function migratePipeline(deprecatedPipeline: PipelineJson): PipelineJson;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/editable",
3
- "version": "0.92.0-20",
3
+ "version": "0.92.0-22",
4
4
  "description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -51,7 +51,7 @@
51
51
  "module": "./esm/index.es.js",
52
52
  "typings": "./esm/typings/src/_packages/editable.index.d.ts",
53
53
  "peerDependencies": {
54
- "@promptbook/core": "0.92.0-20"
54
+ "@promptbook/core": "0.92.0-22"
55
55
  },
56
56
  "dependencies": {
57
57
  "crypto-js": "4.2.0",
package/umd/index.umd.js CHANGED
@@ -23,7 +23,7 @@
23
23
  * @generated
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- const PROMPTBOOK_ENGINE_VERSION = '0.92.0-20';
26
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0-22';
27
27
  /**
28
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
29
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -794,7 +794,8 @@
794
794
  subvalueParsers: [
795
795
  {
796
796
  subvalueName: 'ROW',
797
- async mapValues(value, outputParameterName, settings, mapCallback) {
797
+ async mapValues(options) {
798
+ const { value, outputParameterName, settings, mapCallback, onProgress } = options;
798
799
  const csv = csvParse(value, settings);
799
800
  if (csv.errors.length !== 0) {
800
801
  throw new CsvFormatError(spaceTrim__default["default"]((block) => `
@@ -810,21 +811,29 @@
810
811
  ${block(value)}
811
812
  `));
812
813
  }
813
- const mappedData = await Promise.all(csv.data.map(async (row, index) => {
814
+ const mappedData = [];
815
+ for (let index = 0; index < csv.data.length; index++) {
816
+ const row = csv.data[index];
814
817
  if (row[outputParameterName]) {
815
818
  throw new CsvFormatError(`Can not overwrite existing column "${outputParameterName}" in CSV row`);
816
819
  }
817
- return {
820
+ const mappedRow = {
818
821
  ...row,
819
822
  [outputParameterName]: await mapCallback(row, index),
820
823
  };
821
- }));
824
+ mappedData.push(mappedRow);
825
+ if (onProgress) {
826
+ // Note: Report the CSV with all rows mapped so far
827
+ await onProgress(papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS }));
828
+ }
829
+ }
822
830
  return papaparse.unparse(mappedData, { ...settings, ...MANDATORY_CSV_SETTINGS });
823
831
  },
824
832
  },
825
833
  {
826
834
  subvalueName: 'CELL',
827
- async mapValues(value, outputParameterName, settings, mapCallback) {
835
+ async mapValues(options) {
836
+ const { value, settings, mapCallback, onProgress } = options;
828
837
  const csv = csvParse(value, settings);
829
838
  if (csv.errors.length !== 0) {
830
839
  throw new CsvFormatError(spaceTrim__default["default"]((block) => `
@@ -933,7 +942,8 @@
933
942
  subvalueParsers: [
934
943
  {
935
944
  subvalueName: 'LINE',
936
- async mapValues(value, outputParameterName, settings, mapCallback) {
945
+ async mapValues(options) {
946
+ const { value, mapCallback, onProgress } = options;
937
947
  const lines = value.split('\n');
938
948
  const mappedLines = await Promise.all(lines.map((lineContent, lineNumber) =>
939
949
  // TODO: [🧠] Maybe option to skip empty line
@@ -2046,6 +2056,43 @@
2046
2056
  },
2047
2057
  };
2048
2058
 
2059
+ /**
2060
+ * Completion is formfactor that emulates completion models
2061
+ *
2062
+ * @public exported from `@promptbook/core`
2063
+ */
2064
+ const CompletionFormfactorDefinition = {
2065
+ name: 'COMPLETION',
2066
+ description: `@@@`,
2067
+ documentationUrl: `https://github.com/webgptorg/promptbook/discussions/@@`,
2068
+ // <- TODO: https://github.com/webgptorg/promptbook/discussions/new?category=concepts
2069
+ // "🔠 Completion Formfactor"
2070
+ pipelineInterface: {
2071
+ inputParameters: [
2072
+ {
2073
+ name: 'inputText',
2074
+ description: `Input text to be completed`,
2075
+ isInput: true,
2076
+ isOutput: false,
2077
+ },
2078
+ {
2079
+ name: 'instructions',
2080
+ description: `Additional instructions for the model, for example the required length, empty by default`,
2081
+ isInput: true,
2082
+ isOutput: false,
2083
+ },
2084
+ ],
2085
+ outputParameters: [
2086
+ {
2087
+ name: 'followingText',
2088
+ description: `Text that follows the input text`,
2089
+ isInput: false,
2090
+ isOutput: true,
2091
+ },
2092
+ ],
2093
+ },
2094
+ };
2095
+
2049
2096
  /**
2050
2097
  * Generator is form of app that @@@
2051
2098
  *
@@ -2230,6 +2277,8 @@
2230
2277
  MatcherFormfactorDefinition,
2231
2278
  GeneratorFormfactorDefinition,
2232
2279
  ImageGeneratorFormfactorDefinition,
2280
+ CompletionFormfactorDefinition,
2281
+ // <- [🛬] When making new formfactor, copy the _boilerplate and link it here
2233
2282
  ];
2234
2283
  /**
2235
2284
  * Note: [💞] Ignore a discrepancy between file name and entity name