@promptbook/openai 0.26.0 → 0.27.0-0

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
@@ -191,7 +191,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
191
191
  return OpenAiExecutionTools;
192
192
  }());
193
193
  /**
194
- * TODO: !!!! Allow to use other models - List all from openai
194
+
195
195
  * TODO: Maybe Create some common util for gptChat and gptComplete
196
196
  * TODO: Maybe make custom OpenaiError
197
197
  */
@@ -1,6 +1,5 @@
1
1
  export {};
2
2
  /**
3
3
  * TODO: [🧠] Probbably change syntax MODEL VARIANT -> MODEL
4
- * TODO: !!!! Allow to skip segments SKIP IF {foo} NOT DEFINED
5
- * TODO: !!! Allow to EXPECT 3 words
4
+ * TODO: !!! Allow to skip segments SKIP IF {foo} NOT DEFINED
6
5
  */
@@ -9,7 +9,5 @@ export declare function promptTemplatePipelineStringToJson(promptTemplatePipelin
9
9
  /**
10
10
  * TODO: Report here line/column of error
11
11
  * TODO: Use spaceTrim more effectively
12
- * TODO: !!!! Parameter flags - isInput, isOutput, isInternal, isBeforePostprocessing, isBeforeFinal, canonicalName
13
- * TODO: !!!! Allow to have non-immutable parameters - suffix them with fooPrevious3 -> fooPrevious2 -> fooPrevious1 -> foo
14
- * This must work with other technial parameters
12
+ * TODO: [🧠] Parameter flags - isInput, isOutput, isInternal
15
13
  */
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This error occurs when some expectation is not met in the execution of the pipeline
3
+ */
4
+ export declare class ExpectError extends Error {
5
+ readonly name = "ExpectError";
6
+ constructor(message: string);
7
+ }
8
+ /**
9
+ * TODO: [🧠] Should be this exported from the library
10
+ */
@@ -1,4 +1,4 @@
1
- import { PromptTemplatePipeline } from '../classes/PromptTemplatePipeline';
1
+ import type { PromptTemplatePipeline } from '../classes/PromptTemplatePipeline';
2
2
  import { ExecutionTools } from './ExecutionTools';
3
3
  import { PtpExecutor } from './PtpExecutor';
4
4
  export interface CreatePtpExecutorSettings {
@@ -7,7 +7,7 @@ export interface CreatePtpExecutorSettings {
7
7
  *
8
8
  * @default 3
9
9
  */
10
- readonly maxNaturalExecutionAttempts: number;
10
+ readonly maxExecutionAttempts: number;
11
11
  }
12
12
  /**
13
13
  * Options for creating a PTP (Prompt Template Pipeline) executor
@@ -22,7 +22,7 @@ export declare class OpenAiExecutionTools implements NaturalExecutionTools {
22
22
  gptComplete(prompt: Prompt): Promise<PromptCompletionResult>;
23
23
  }
24
24
  /**
25
- * TODO: !!!! Allow to use other models - List all from openai
25
+
26
26
  * TODO: Maybe Create some common util for gptChat and gptComplete
27
27
  * TODO: Maybe make custom OpenaiError
28
28
  */
@@ -1,4 +1,4 @@
1
- import { number_integer, number_positive_or_zero, string_javascript, string_markdown, string_name, string_prompt, string_template } from '../.././types/typeAliases';
1
+ import { number_integer, number_positive_or_zero, string_javascript, string_javascript_name, string_markdown, string_name, string_prompt, string_template } from '../.././types/typeAliases';
2
2
  import { ExpectFormatCommand } from '../Command';
3
3
  import { ExecutionType } from '../ExecutionTypes';
4
4
  import { ModelRequirements } from '../ModelRequirements';
@@ -12,19 +12,6 @@ export type PromptTemplateJson = NaturalTemplateJson | SimpleTemplateJson | Scri
12
12
  */
13
13
  export interface NaturalTemplateJson extends PromptTemplateJsonCommon {
14
14
  readonly executionType: 'PROMPT_TEMPLATE';
15
- /**
16
- * Expect this amount of each unit in the answer
17
- *
18
- * For example 5 words, 3 sentences, 2 paragraphs, ...
19
- */
20
- readonly expectAmount?: Partial<Record<Lowercase<ExpectationUnit>, {
21
- min?: ExpectationAmount;
22
- max?: ExpectationAmount;
23
- }>>;
24
- /**
25
- * Expect this format of the answer
26
- */
27
- readonly expectFormat?: ExpectFormatCommand['format'];
28
15
  /**
29
16
  * Requirements for the model
30
17
  * - This is required only for executionType PROMPT_TEMPLATE
@@ -97,6 +84,27 @@ interface PromptTemplateJsonCommon {
97
84
  * Content of the template with {placeholders} for parameters
98
85
  */
99
86
  readonly content: (string_prompt | string_javascript | string_markdown) & string_template;
87
+ /**
88
+ * List of postprocessing steps that are executed after the prompt template
89
+ */
90
+ readonly postprocessing?: Array<string_javascript_name>;
91
+ /**
92
+ * Expect this amount of each unit in the answer
93
+ *
94
+ * For example 5 words, 3 sentences, 2 paragraphs, ...
95
+ *
96
+ * Note: Expectations are performed after all postprocessing steps
97
+ */
98
+ readonly expectAmount?: Partial<Record<Lowercase<ExpectationUnit>, {
99
+ min?: ExpectationAmount;
100
+ max?: ExpectationAmount;
101
+ }>>;
102
+ /**
103
+ * Expect this format of the answer
104
+ *
105
+ * Note: Expectations are performed after all postprocessing steps
106
+ */
107
+ readonly expectFormat?: ExpectFormatCommand['format'];
100
108
  /**
101
109
  * Name of the parameter that is the result of the prompt template
102
110
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/openai",
3
- "version": "0.26.0",
3
+ "version": "0.27.0-0",
4
4
  "description": "Library to supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -37,7 +37,7 @@
37
37
  "openai": "4.2.0"
38
38
  },
39
39
  "peerDependencies": {
40
- "@promptbook/core": "0.26.0"
40
+ "@promptbook/core": "0.27.0-0"
41
41
  },
42
42
  "main": "./umd/index.umd.js",
43
43
  "module": "./esm/index.es.js",
package/umd/index.umd.js CHANGED
@@ -199,7 +199,7 @@
199
199
  return OpenAiExecutionTools;
200
200
  }());
201
201
  /**
202
- * TODO: !!!! Allow to use other models - List all from openai
202
+
203
203
  * TODO: Maybe Create some common util for gptChat and gptComplete
204
204
  * TODO: Maybe make custom OpenaiError
205
205
  */
@@ -1,6 +1,5 @@
1
1
  export {};
2
2
  /**
3
3
  * TODO: [🧠] Probbably change syntax MODEL VARIANT -> MODEL
4
- * TODO: !!!! Allow to skip segments SKIP IF {foo} NOT DEFINED
5
- * TODO: !!! Allow to EXPECT 3 words
4
+ * TODO: !!! Allow to skip segments SKIP IF {foo} NOT DEFINED
6
5
  */
@@ -9,7 +9,5 @@ export declare function promptTemplatePipelineStringToJson(promptTemplatePipelin
9
9
  /**
10
10
  * TODO: Report here line/column of error
11
11
  * TODO: Use spaceTrim more effectively
12
- * TODO: !!!! Parameter flags - isInput, isOutput, isInternal, isBeforePostprocessing, isBeforeFinal, canonicalName
13
- * TODO: !!!! Allow to have non-immutable parameters - suffix them with fooPrevious3 -> fooPrevious2 -> fooPrevious1 -> foo
14
- * This must work with other technial parameters
12
+ * TODO: [🧠] Parameter flags - isInput, isOutput, isInternal
15
13
  */
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This error occurs when some expectation is not met in the execution of the pipeline
3
+ */
4
+ export declare class ExpectError extends Error {
5
+ readonly name = "ExpectError";
6
+ constructor(message: string);
7
+ }
8
+ /**
9
+ * TODO: [🧠] Should be this exported from the library
10
+ */
@@ -1,4 +1,4 @@
1
- import { PromptTemplatePipeline } from '../classes/PromptTemplatePipeline';
1
+ import type { PromptTemplatePipeline } from '../classes/PromptTemplatePipeline';
2
2
  import { ExecutionTools } from './ExecutionTools';
3
3
  import { PtpExecutor } from './PtpExecutor';
4
4
  export interface CreatePtpExecutorSettings {
@@ -7,7 +7,7 @@ export interface CreatePtpExecutorSettings {
7
7
  *
8
8
  * @default 3
9
9
  */
10
- readonly maxNaturalExecutionAttempts: number;
10
+ readonly maxExecutionAttempts: number;
11
11
  }
12
12
  /**
13
13
  * Options for creating a PTP (Prompt Template Pipeline) executor
@@ -22,7 +22,7 @@ export declare class OpenAiExecutionTools implements NaturalExecutionTools {
22
22
  gptComplete(prompt: Prompt): Promise<PromptCompletionResult>;
23
23
  }
24
24
  /**
25
- * TODO: !!!! Allow to use other models - List all from openai
25
+
26
26
  * TODO: Maybe Create some common util for gptChat and gptComplete
27
27
  * TODO: Maybe make custom OpenaiError
28
28
  */
@@ -1,4 +1,4 @@
1
- import { number_integer, number_positive_or_zero, string_javascript, string_markdown, string_name, string_prompt, string_template } from '../.././types/typeAliases';
1
+ import { number_integer, number_positive_or_zero, string_javascript, string_javascript_name, string_markdown, string_name, string_prompt, string_template } from '../.././types/typeAliases';
2
2
  import { ExpectFormatCommand } from '../Command';
3
3
  import { ExecutionType } from '../ExecutionTypes';
4
4
  import { ModelRequirements } from '../ModelRequirements';
@@ -12,19 +12,6 @@ export type PromptTemplateJson = NaturalTemplateJson | SimpleTemplateJson | Scri
12
12
  */
13
13
  export interface NaturalTemplateJson extends PromptTemplateJsonCommon {
14
14
  readonly executionType: 'PROMPT_TEMPLATE';
15
- /**
16
- * Expect this amount of each unit in the answer
17
- *
18
- * For example 5 words, 3 sentences, 2 paragraphs, ...
19
- */
20
- readonly expectAmount?: Partial<Record<Lowercase<ExpectationUnit>, {
21
- min?: ExpectationAmount;
22
- max?: ExpectationAmount;
23
- }>>;
24
- /**
25
- * Expect this format of the answer
26
- */
27
- readonly expectFormat?: ExpectFormatCommand['format'];
28
15
  /**
29
16
  * Requirements for the model
30
17
  * - This is required only for executionType PROMPT_TEMPLATE
@@ -97,6 +84,27 @@ interface PromptTemplateJsonCommon {
97
84
  * Content of the template with {placeholders} for parameters
98
85
  */
99
86
  readonly content: (string_prompt | string_javascript | string_markdown) & string_template;
87
+ /**
88
+ * List of postprocessing steps that are executed after the prompt template
89
+ */
90
+ readonly postprocessing?: Array<string_javascript_name>;
91
+ /**
92
+ * Expect this amount of each unit in the answer
93
+ *
94
+ * For example 5 words, 3 sentences, 2 paragraphs, ...
95
+ *
96
+ * Note: Expectations are performed after all postprocessing steps
97
+ */
98
+ readonly expectAmount?: Partial<Record<Lowercase<ExpectationUnit>, {
99
+ min?: ExpectationAmount;
100
+ max?: ExpectationAmount;
101
+ }>>;
102
+ /**
103
+ * Expect this format of the answer
104
+ *
105
+ * Note: Expectations are performed after all postprocessing steps
106
+ */
107
+ readonly expectFormat?: ExpectFormatCommand['format'];
100
108
  /**
101
109
  * Name of the parameter that is the result of the prompt template
102
110
  */