@promptbook/remote-client 0.61.0-22 → 0.61.0-24

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.
Files changed (45) hide show
  1. package/esm/index.es.js +1 -1
  2. package/esm/typings/src/_packages/types.index.d.ts +2 -2
  3. package/esm/typings/src/config.d.ts +8 -4
  4. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +1 -0
  5. package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -0
  6. package/esm/typings/src/execution/PipelineExecutor.d.ts +32 -24
  7. package/esm/typings/src/execution/PromptResultUsage.d.ts +3 -0
  8. package/esm/typings/src/prepare/isPipelinePrepared.d.ts +4 -0
  9. package/esm/typings/src/prepare/preparePipeline.d.ts +0 -1
  10. package/esm/typings/src/prepare/prepareTemplates.d.ts +31 -0
  11. package/esm/typings/src/prepare/unpreparePipeline.d.ts +2 -0
  12. package/esm/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +3 -0
  13. package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +3 -0
  14. package/esm/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +1 -0
  15. package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +3 -0
  16. package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +1 -0
  17. package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -0
  18. package/esm/typings/src/types/PipelineJson/PromptDialogJson.d.ts +4 -3
  19. package/esm/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +10 -0
  20. package/esm/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +1 -0
  21. package/esm/typings/src/types/PipelineJson/ScriptJson.d.ts +5 -2
  22. package/esm/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +5 -2
  23. package/package.json +2 -2
  24. package/umd/index.umd.js +1 -1
  25. package/umd/typings/src/_packages/types.index.d.ts +2 -2
  26. package/umd/typings/src/config.d.ts +8 -4
  27. package/umd/typings/src/conversion/pipelineStringToJsonSync.d.ts +1 -0
  28. package/umd/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -0
  29. package/umd/typings/src/execution/PipelineExecutor.d.ts +32 -24
  30. package/umd/typings/src/execution/PromptResultUsage.d.ts +3 -0
  31. package/umd/typings/src/prepare/isPipelinePrepared.d.ts +4 -0
  32. package/umd/typings/src/prepare/preparePipeline.d.ts +0 -1
  33. package/umd/typings/src/prepare/prepareTemplates.d.ts +31 -0
  34. package/umd/typings/src/prepare/unpreparePipeline.d.ts +2 -0
  35. package/umd/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +3 -0
  36. package/umd/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +3 -0
  37. package/umd/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +1 -0
  38. package/umd/typings/src/types/PipelineJson/PersonaJson.d.ts +3 -0
  39. package/umd/typings/src/types/PipelineJson/PipelineJson.d.ts +1 -0
  40. package/umd/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -0
  41. package/umd/typings/src/types/PipelineJson/PromptDialogJson.d.ts +4 -3
  42. package/umd/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +10 -0
  43. package/umd/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +1 -0
  44. package/umd/typings/src/types/PipelineJson/ScriptJson.d.ts +5 -2
  45. package/umd/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +5 -2
package/esm/index.es.js CHANGED
@@ -214,7 +214,7 @@ var RemoteLlmExecutionTools = /** @class */ (function () {
214
214
  /**
215
215
  * The version of the Promptbook library
216
216
  */
217
- var PROMPTBOOK_VERSION = '0.61.0-21';
217
+ var PROMPTBOOK_VERSION = '0.61.0-23';
218
218
  // TODO: !!!! List here all the versions and annotate + put into script
219
219
 
220
220
  export { PROMPTBOOK_VERSION, RemoteLlmExecutionTools };
@@ -4,7 +4,7 @@ import type { CommonExecutionToolsOptions } from '../execution/CommonExecutionTo
4
4
  import { EmbeddingVector } from '../execution/EmbeddingVector';
5
5
  import type { ExecutionTools } from '../execution/ExecutionTools';
6
6
  import type { AvailableModel, LlmExecutionTools } from '../execution/LlmExecutionTools';
7
- import type { PipelineExecutor } from '../execution/PipelineExecutor';
7
+ import type { PipelineExecutor, PipelineExecutorResult } from '../execution/PipelineExecutor';
8
8
  import type { ChatPromptResult, CommonPromptResult, CompletionPromptResult, EmbeddingPromptResult, PromptResult } from '../execution/PromptResult';
9
9
  import type { PromptResultUsage, PromptResultUsageCounts } from '../execution/PromptResultUsage';
10
10
  import type { ScriptExecutionTools, ScriptExecutionToolsExecuteOptions } from '../execution/ScriptExecutionTools';
@@ -36,7 +36,7 @@ import type { FromtoItems } from '../utils/FromtoItems';
36
36
  import { PROMPTBOOK_VERSION, string_promptbook_version } from '../version';
37
37
  export { PROMPTBOOK_VERSION };
38
38
  export { EXPECTATION_UNITS };
39
- export type { AvailableModel, BlockType, CommonExecutionToolsOptions, EmbeddingVector, ExecutionReportJson, ExecutionTools, ExpectationAmount, ExpectationUnit, Expectations, FromtoItems, KnowledgePiecePreparedJson, KnowledgeSourceJson, KnowledgeSourcePreparedJson, LlmExecutionTools, LlmTemplateJson, ModelRequirements, ModelVariant, Parameters, PersonaJson, PersonaPreparedJson, PipelineCollection, PipelineExecutor, PipelineJson, PipelineString, PreparationJson, Prompt, ChatPromptResult as PromptChatResult, CommonPromptResult as PromptCommonResult, CompletionPromptResult as PromptCompletionResult, PromptDialogJson, EmbeddingPromptResult as PromptEmbeddingResult, PromptResult, PromptResultUsage, PromptResultUsageCounts, PromptTemplateJson, PromptTemplateParameterJson, ReservedParameters, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptJson, ScriptLanguage, SimpleTemplateJson, TaskProgress, UncertainNumber, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, client_id, number_model_temperature, number_seed, string_char, string_char_emoji, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_emails, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_javascript, string_javascript_name, string_license, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_parameter_name, string_parameter_value, string_person_fullname, string_pipeline_url, string_pipeline_url_with_hashtemplate, string_prompt, string_promptbook_documentation_url, string_promptbook_version, string_reserved_parameter_name, string_script, string_semantic_version, string_sha256, string_system_message, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_uri, string_uri_part, string_url, string_url_image, string_uuid, };
39
+ export type { AvailableModel, BlockType, CommonExecutionToolsOptions, EmbeddingVector, ExecutionReportJson, ExecutionTools, ExpectationAmount, ExpectationUnit, Expectations, FromtoItems, KnowledgePiecePreparedJson, KnowledgeSourceJson, KnowledgeSourcePreparedJson, LlmExecutionTools, LlmTemplateJson, ModelRequirements, ModelVariant, Parameters, PersonaJson, PersonaPreparedJson, PipelineCollection, PipelineExecutor, PipelineExecutorResult, PipelineJson, PipelineString, PreparationJson, Prompt, ChatPromptResult as PromptChatResult, CommonPromptResult as PromptCommonResult, CompletionPromptResult as PromptCompletionResult, PromptDialogJson, EmbeddingPromptResult as PromptEmbeddingResult, PromptResult, PromptResultUsage, PromptResultUsageCounts, PromptTemplateJson, PromptTemplateParameterJson, ReservedParameters, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptJson, ScriptLanguage, SimpleTemplateJson, TaskProgress, UncertainNumber, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, client_id, number_model_temperature, number_seed, string_char, string_char_emoji, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_emails, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_javascript, string_javascript_name, string_license, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_parameter_name, string_parameter_value, string_person_fullname, string_pipeline_url, string_pipeline_url_with_hashtemplate, string_prompt, string_promptbook_documentation_url, string_promptbook_version, string_reserved_parameter_name, string_script, string_semantic_version, string_sha256, string_system_message, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_uri, string_uri_part, string_url, string_url_image, string_uuid, };
40
40
  /**
41
41
  * TODO: Delete type aliases (from ../types/typeAliases) that are not exported here
42
42
  */
@@ -36,18 +36,22 @@ export declare const EXECUTIONS_CACHE_DIRNAME = "/.promptbook/executions-cache";
36
36
  * The name of the builded pipeline collection made by CLI `ptbk make` and for lookup in `createCollectionFromDirectory`
37
37
  */
38
38
  export declare const PIPELINE_COLLECTION_BASE_FILENAME = "index";
39
+ /**
40
+ * Nonce which is used for replacing things in strings
41
+ */
42
+ export declare const REPLACING_NONCE = "u$k42k%!V2zo34w7Fu#@QUHYPW";
39
43
  /**
40
44
  * The names of the parameters that are reserved for special purposes
41
45
  */
42
- export declare const RESERVED_PARAMETER_NAMES: readonly ["context", "currentDate"];
46
+ export declare const RESERVED_PARAMETER_NAMES: readonly ["context", "knowledge", "samples", "modelName", "currentDate"];
43
47
  /**
44
48
  * @@@
45
49
  */
46
- export declare const DEBUG_ALLOW_PAYED_TESTING: boolean;
50
+ export declare const RESERVED_PARAMETER_MISSING_VALUE: string;
47
51
  /**
48
- * Nonce which is used for replacing things in strings
52
+ * @@@
49
53
  */
50
- export declare const REPLACING_NONCE = "u$k42k%!V2zo34w7Fu#@QUHYPW";
54
+ export declare const DEBUG_ALLOW_PAYED_TESTING: boolean;
51
55
  /**
52
56
  * TODO: [🔼] Export all to core
53
57
  */
@@ -24,4 +24,5 @@ export declare function pipelineStringToJsonSync(pipelineString: PipelineString)
24
24
  * TODO: [🥞] Not optimal parsing because `splitMarkdownIntoSections` is executed twice with same string, once through `flattenMarkdown` and second directly here
25
25
  * TODO: [♈] Probbably move expectations from templates to parameters
26
26
  * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
27
+ * TODO: [🍙] Make some standart order of json properties
27
28
  */
@@ -10,4 +10,5 @@ export declare function stringifyPipelineJson<TType>(pipeline: TType): string_js
10
10
  * TODO: !!!! Not Working propperly @see https://promptbook.studio/samples/mixed-knowledge.ptbk.md
11
11
  * TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
12
12
  * TODO: [🧠] Maybe more elegant solution than replacing via regex
13
+ * TODO: [🍙] Make some standart order of json properties
13
14
  */
@@ -13,30 +13,38 @@ import type { PromptResultUsage } from './PromptResultUsage';
13
13
  * @see https://github.com/webgptorg/promptbook#executor
14
14
  */
15
15
  export type PipelineExecutor = {
16
- (inputParameters: Parameters, onProgress?: (taskProgress: TaskProgress) => Promisable<void>): Promise<{
17
- /**
18
- * Whether the execution was successful, details are aviable in `executionReport`
19
- */
20
- readonly isSuccessful: boolean;
21
- /**
22
- * Added usage of whole execution, detailed usage is aviable in `executionReport`
23
- */
24
- readonly usage: PromptResultUsage;
25
- /**
26
- * Errors that occured during the execution, details are aviable in `executionReport`
27
- */
28
- readonly errors: Array<PipelineExecutionError | Error>;
29
- /**
30
- * The report of the execution with all details
31
- */
32
- readonly executionReport: ExecutionReportJson;
33
- /**
34
- * Result parameters of the execution
35
- *
36
- * Note: If the execution was not successful, there are only some of the result parameters
37
- */
38
- readonly outputParameters: Parameters;
39
- }>;
16
+ (inputParameters: Parameters, onProgress?: (taskProgress: TaskProgress) => Promisable<void>): Promise<PipelineExecutorResult>;
17
+ };
18
+ /**
19
+ * @@@
20
+ */
21
+ export type PipelineExecutorResult = {
22
+ /**
23
+ * Whether the execution was successful, details are aviable in `executionReport`
24
+ */
25
+ readonly isSuccessful: boolean;
26
+ /**
27
+ * Added usage of whole execution, detailed usage is aviable in `executionReport`
28
+ */
29
+ readonly usage: PromptResultUsage;
30
+ /**
31
+ * Errors that occured during the execution, details are aviable in `executionReport`
32
+ */
33
+ readonly errors: Array<PipelineExecutionError | Error>;
34
+ /**
35
+ * Warnings that occured during the execution, details are aviable in `executionReport`
36
+ */
37
+ readonly warnings: Array<PipelineExecutionError | Error>;
38
+ /**
39
+ * The report of the execution with all details
40
+ */
41
+ readonly executionReport: ExecutionReportJson;
42
+ /**
43
+ * Result parameters of the execution
44
+ *
45
+ * Note: If the execution was not successful, there are only some of the result parameters
46
+ */
47
+ readonly outputParameters: Parameters;
40
48
  };
41
49
  /**
42
50
  * TODO: [🧠] Should this file be in /execution or /types folder?
@@ -24,3 +24,6 @@ export type PromptResultUsage = {
24
24
  * Record of all possible measurable units
25
25
  */
26
26
  export type PromptResultUsageCounts = Record<`${KebabCase<'TOKENS' | ExpectationUnit>}Count`, UncertainNumber>;
27
+ /**
28
+ * TODO: [🍙] Make some standart order of json properties
29
+ */
@@ -7,4 +7,8 @@ export declare function isPipelinePrepared(pipeline: PipelineJson): boolean;
7
7
  * TODO: [🐠] Maybe base this on `makeValidator`
8
8
  * TODO: [🔼] Export via core or utils
9
9
  * TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
10
+ * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
11
+ * - Is context in each template
12
+ * - Are samples prepared
13
+ * - Are templates prepared
10
14
  */
@@ -8,7 +8,6 @@ import type { PrepareOptions } from './PrepareOptions';
8
8
  */
9
9
  export declare function preparePipeline(pipeline: PipelineJson, options: PrepareOptions): Promise<PipelineJson>;
10
10
  /**
11
- * TODO: !!!!! Index the samples and maybe templates
12
11
  * TODO: [🔼] !!! Export via `@promptbook/core`
13
12
  * TODO: Write tests for `preparePipeline`
14
13
  * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
@@ -0,0 +1,31 @@
1
+ import type { PipelineJson } from '../types/PipelineJson/PipelineJson';
2
+ import type { PromptTemplateJson } from '../types/PipelineJson/PromptTemplateJson';
3
+ import type { PrepareOptions } from './PrepareOptions';
4
+ type PrepareTemplateInput = Pick<PipelineJson, 'promptTemplates' | 'parameters'> & {
5
+ /**
6
+ * @@@
7
+ */
8
+ readonly knowledgePiecesCount: number;
9
+ };
10
+ type PreparedTemplates = {
11
+ /**
12
+ * @@@ Sequence of prompt templates that are chained together to form a pipeline
13
+ */
14
+ readonly promptTemplatesPrepared: Array<PromptTemplateJson>;
15
+ };
16
+ /**
17
+ * @@@
18
+ */
19
+ export declare function prepareTemplates(pipeline: PrepareTemplateInput, options: PrepareOptions): Promise<PreparedTemplates>;
20
+ export {};
21
+ /**
22
+ * TODO: [🧠] Add context to each template (if missing)
23
+ * TODO: [🧠] What is better name `prepareTemplate` or `prepareTemplateAndParameters`
24
+ * TODO: !!!!! Index the samples and maybe templates
25
+ * TODO: [🔼] !!! Export via `@promptbook/core`
26
+ * TODO: Write tests for `preparePipeline`
27
+ * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
28
+ * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
29
+ * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
30
+ * TODO: [🧠][🥜]
31
+ */
@@ -5,5 +5,7 @@ import type { PipelineJson } from '../types/PipelineJson/PipelineJson';
5
5
  export declare function unpreparePipeline(pipeline: PipelineJson): PipelineJson;
6
6
  /**
7
7
  * TODO: [🔼] !!! Export via `@promptbook/core`
8
+ * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
8
9
  * TODO: Write tests for `preparePipeline`
10
+ * TODO: [🍙] Make some standart order of json properties
9
11
  */
@@ -65,3 +65,6 @@ export type KnowledgePiecePreparedJson = {
65
65
  */
66
66
  readonly preparationIds: Array<number_id>;
67
67
  };
68
+ /**
69
+ * TODO: [🍙] Make some standart order of json properties
70
+ */
@@ -22,3 +22,6 @@ export type KnowledgeSourcePreparedJson = KnowledgeSourceJson & {
22
22
  */
23
23
  readonly preparationIds: Array<number_id>;
24
24
  };
25
+ /**
26
+ * TODO: [🍙] Make some standart order of json properties
27
+ */
@@ -21,4 +21,5 @@ export type LlmTemplateJson = PromptTemplateJsonCommon & {
21
21
  * TODO: [👙][🧠] Maybe add `knowledge`, `actions` and `instruments` to be available granularly for each template
22
22
  * @see https://github.com/webgptorg/promptbook/discussions/79
23
23
  * TODO: [💕][🧠] Just selecting gpt3 or gpt4 level of model
24
+ * TODO: [🍙] Make some standart order of json properties
24
25
  */
@@ -36,3 +36,6 @@ export type PersonaPreparedJson = PersonaJson & {
36
36
  */
37
37
  readonly preparationIds: Array<number_id>;
38
38
  };
39
+ /**
40
+ * TODO: [🍙] Make some standart order of json properties
41
+ */
@@ -79,6 +79,7 @@ export type PipelineJson = {
79
79
  readonly preparations: Array<PreparationJson>;
80
80
  };
81
81
  /**
82
+ * TODO: [🍙] Make some standart order of json properties
82
83
  * TODO: [🧠] Maybe wrap all {parameterNames} in brackets for example { "resultingParameterName": "{foo}" }
83
84
  * Note: There was a proposal for multiple types of promptbook objects 78816ff33e2705ee1a187aa2eb8affd976d4ea1a
84
85
  * But then immediately reverted back to the single type
@@ -16,6 +16,7 @@ export type PreparationJson = {
16
16
  readonly modelUsage: PromptResultUsage;
17
17
  };
18
18
  /**
19
+ * TODO: [🍙] Make some standart order of json properties
19
20
  * TODO: Maybe put here used `modelName`
20
21
  * TODO: [🍥] When using `date` it changes all samples .ptbk.json files each time so until some more elegant solution omit the time from prepared pipeline
21
22
  */
@@ -4,9 +4,10 @@ import type { PromptTemplateJsonCommon } from './PromptTemplateJsonCommon';
4
4
  *
5
5
  * @see https://github.com/webgptorg/promptbook/discussions/76
6
6
  */
7
- export interface PromptDialogJson extends PromptTemplateJsonCommon {
7
+ export type PromptDialogJson = PromptTemplateJsonCommon & {
8
8
  readonly blockType: 'PROMPT_DIALOG';
9
- }
9
+ };
10
10
  /**
11
11
  * TODO: [🧠][🥜]
12
- */
12
+ * TODO: [🍙] Make some standart order of json properties
13
+ */
@@ -49,8 +49,18 @@ export interface PromptTemplateJsonCommon {
49
49
  readonly blockType: BlockType;
50
50
  /**
51
51
  * Content of the template with {placeholders} for parameters
52
+ *
53
+ * @@@ content vs preparedContent
52
54
  */
53
55
  readonly content: (string_prompt | string_javascript | string_markdown) & string_template;
56
+ /**
57
+ * @@@ Content of the template with {placeholders} for parameters
58
+ *
59
+ * @@@ content vs preparedContent
60
+ *
61
+ * @default "{content}"
62
+ */
63
+ readonly preparedContent?: (string_prompt | string_javascript | string_markdown) & string_template;
54
64
  /**
55
65
  * List of postprocessing steps that are executed after the prompt template
56
66
  *
@@ -32,4 +32,5 @@ export type PromptTemplateParameterJson = {
32
32
  };
33
33
  /**
34
34
  * TODO: [♈] Probbably move expectations from templates to parameters
35
+ * TODO: [🍙] Make some standart order of json properties
35
36
  */
@@ -5,7 +5,7 @@ import type { PromptTemplateJsonCommon } from './PromptTemplateJsonCommon';
5
5
  *
6
6
  * @see https://github.com/webgptorg/promptbook/discussions/77
7
7
  */
8
- export interface ScriptJson extends PromptTemplateJsonCommon {
8
+ export type ScriptJson = PromptTemplateJsonCommon & {
9
9
  readonly blockType: 'SCRIPT';
10
10
  /**
11
11
  * Language of the script
@@ -13,4 +13,7 @@ export interface ScriptJson extends PromptTemplateJsonCommon {
13
13
  *
14
14
  */
15
15
  readonly contentLanguage?: ScriptLanguage;
16
- }
16
+ };
17
+ /**
18
+ * TODO: [🍙] Make some standart order of json properties
19
+ */
@@ -4,6 +4,9 @@ import type { PromptTemplateJsonCommon } from './PromptTemplateJsonCommon';
4
4
  *
5
5
  * @see https://github.com/webgptorg/promptbook/discussions/17
6
6
  */
7
- export interface SimpleTemplateJson extends PromptTemplateJsonCommon {
7
+ export type SimpleTemplateJson = PromptTemplateJsonCommon & {
8
8
  readonly blockType: 'SIMPLE_TEMPLATE';
9
- }
9
+ };
10
+ /**
11
+ * TODO: [🍙] Make some standart order of json properties
12
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/remote-client",
3
- "version": "0.61.0-22",
3
+ "version": "0.61.0-24",
4
4
  "description": "Supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -47,7 +47,7 @@
47
47
  }
48
48
  ],
49
49
  "peerDependencies": {
50
- "@promptbook/core": "0.61.0-22"
50
+ "@promptbook/core": "0.61.0-24"
51
51
  },
52
52
  "main": "./umd/index.umd.js",
53
53
  "module": "./esm/index.es.js",
package/umd/index.umd.js CHANGED
@@ -218,7 +218,7 @@
218
218
  /**
219
219
  * The version of the Promptbook library
220
220
  */
221
- var PROMPTBOOK_VERSION = '0.61.0-21';
221
+ var PROMPTBOOK_VERSION = '0.61.0-23';
222
222
  // TODO: !!!! List here all the versions and annotate + put into script
223
223
 
224
224
  exports.PROMPTBOOK_VERSION = PROMPTBOOK_VERSION;
@@ -4,7 +4,7 @@ import type { CommonExecutionToolsOptions } from '../execution/CommonExecutionTo
4
4
  import { EmbeddingVector } from '../execution/EmbeddingVector';
5
5
  import type { ExecutionTools } from '../execution/ExecutionTools';
6
6
  import type { AvailableModel, LlmExecutionTools } from '../execution/LlmExecutionTools';
7
- import type { PipelineExecutor } from '../execution/PipelineExecutor';
7
+ import type { PipelineExecutor, PipelineExecutorResult } from '../execution/PipelineExecutor';
8
8
  import type { ChatPromptResult, CommonPromptResult, CompletionPromptResult, EmbeddingPromptResult, PromptResult } from '../execution/PromptResult';
9
9
  import type { PromptResultUsage, PromptResultUsageCounts } from '../execution/PromptResultUsage';
10
10
  import type { ScriptExecutionTools, ScriptExecutionToolsExecuteOptions } from '../execution/ScriptExecutionTools';
@@ -36,7 +36,7 @@ import type { FromtoItems } from '../utils/FromtoItems';
36
36
  import { PROMPTBOOK_VERSION, string_promptbook_version } from '../version';
37
37
  export { PROMPTBOOK_VERSION };
38
38
  export { EXPECTATION_UNITS };
39
- export type { AvailableModel, BlockType, CommonExecutionToolsOptions, EmbeddingVector, ExecutionReportJson, ExecutionTools, ExpectationAmount, ExpectationUnit, Expectations, FromtoItems, KnowledgePiecePreparedJson, KnowledgeSourceJson, KnowledgeSourcePreparedJson, LlmExecutionTools, LlmTemplateJson, ModelRequirements, ModelVariant, Parameters, PersonaJson, PersonaPreparedJson, PipelineCollection, PipelineExecutor, PipelineJson, PipelineString, PreparationJson, Prompt, ChatPromptResult as PromptChatResult, CommonPromptResult as PromptCommonResult, CompletionPromptResult as PromptCompletionResult, PromptDialogJson, EmbeddingPromptResult as PromptEmbeddingResult, PromptResult, PromptResultUsage, PromptResultUsageCounts, PromptTemplateJson, PromptTemplateParameterJson, ReservedParameters, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptJson, ScriptLanguage, SimpleTemplateJson, TaskProgress, UncertainNumber, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, client_id, number_model_temperature, number_seed, string_char, string_char_emoji, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_emails, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_javascript, string_javascript_name, string_license, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_parameter_name, string_parameter_value, string_person_fullname, string_pipeline_url, string_pipeline_url_with_hashtemplate, string_prompt, string_promptbook_documentation_url, string_promptbook_version, string_reserved_parameter_name, string_script, string_semantic_version, string_sha256, string_system_message, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_uri, string_uri_part, string_url, string_url_image, string_uuid, };
39
+ export type { AvailableModel, BlockType, CommonExecutionToolsOptions, EmbeddingVector, ExecutionReportJson, ExecutionTools, ExpectationAmount, ExpectationUnit, Expectations, FromtoItems, KnowledgePiecePreparedJson, KnowledgeSourceJson, KnowledgeSourcePreparedJson, LlmExecutionTools, LlmTemplateJson, ModelRequirements, ModelVariant, Parameters, PersonaJson, PersonaPreparedJson, PipelineCollection, PipelineExecutor, PipelineExecutorResult, PipelineJson, PipelineString, PreparationJson, Prompt, ChatPromptResult as PromptChatResult, CommonPromptResult as PromptCommonResult, CompletionPromptResult as PromptCompletionResult, PromptDialogJson, EmbeddingPromptResult as PromptEmbeddingResult, PromptResult, PromptResultUsage, PromptResultUsageCounts, PromptTemplateJson, PromptTemplateParameterJson, ReservedParameters, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptJson, ScriptLanguage, SimpleTemplateJson, TaskProgress, UncertainNumber, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, client_id, number_model_temperature, number_seed, string_char, string_char_emoji, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_emails, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_javascript, string_javascript_name, string_license, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_parameter_name, string_parameter_value, string_person_fullname, string_pipeline_url, string_pipeline_url_with_hashtemplate, string_prompt, string_promptbook_documentation_url, string_promptbook_version, string_reserved_parameter_name, string_script, string_semantic_version, string_sha256, string_system_message, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_uri, string_uri_part, string_url, string_url_image, string_uuid, };
40
40
  /**
41
41
  * TODO: Delete type aliases (from ../types/typeAliases) that are not exported here
42
42
  */
@@ -36,18 +36,22 @@ export declare const EXECUTIONS_CACHE_DIRNAME = "/.promptbook/executions-cache";
36
36
  * The name of the builded pipeline collection made by CLI `ptbk make` and for lookup in `createCollectionFromDirectory`
37
37
  */
38
38
  export declare const PIPELINE_COLLECTION_BASE_FILENAME = "index";
39
+ /**
40
+ * Nonce which is used for replacing things in strings
41
+ */
42
+ export declare const REPLACING_NONCE = "u$k42k%!V2zo34w7Fu#@QUHYPW";
39
43
  /**
40
44
  * The names of the parameters that are reserved for special purposes
41
45
  */
42
- export declare const RESERVED_PARAMETER_NAMES: readonly ["context", "currentDate"];
46
+ export declare const RESERVED_PARAMETER_NAMES: readonly ["context", "knowledge", "samples", "modelName", "currentDate"];
43
47
  /**
44
48
  * @@@
45
49
  */
46
- export declare const DEBUG_ALLOW_PAYED_TESTING: boolean;
50
+ export declare const RESERVED_PARAMETER_MISSING_VALUE: string;
47
51
  /**
48
- * Nonce which is used for replacing things in strings
52
+ * @@@
49
53
  */
50
- export declare const REPLACING_NONCE = "u$k42k%!V2zo34w7Fu#@QUHYPW";
54
+ export declare const DEBUG_ALLOW_PAYED_TESTING: boolean;
51
55
  /**
52
56
  * TODO: [🔼] Export all to core
53
57
  */
@@ -24,4 +24,5 @@ export declare function pipelineStringToJsonSync(pipelineString: PipelineString)
24
24
  * TODO: [🥞] Not optimal parsing because `splitMarkdownIntoSections` is executed twice with same string, once through `flattenMarkdown` and second directly here
25
25
  * TODO: [♈] Probbably move expectations from templates to parameters
26
26
  * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
27
+ * TODO: [🍙] Make some standart order of json properties
27
28
  */
@@ -10,4 +10,5 @@ export declare function stringifyPipelineJson<TType>(pipeline: TType): string_js
10
10
  * TODO: !!!! Not Working propperly @see https://promptbook.studio/samples/mixed-knowledge.ptbk.md
11
11
  * TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
12
12
  * TODO: [🧠] Maybe more elegant solution than replacing via regex
13
+ * TODO: [🍙] Make some standart order of json properties
13
14
  */
@@ -13,30 +13,38 @@ import type { PromptResultUsage } from './PromptResultUsage';
13
13
  * @see https://github.com/webgptorg/promptbook#executor
14
14
  */
15
15
  export type PipelineExecutor = {
16
- (inputParameters: Parameters, onProgress?: (taskProgress: TaskProgress) => Promisable<void>): Promise<{
17
- /**
18
- * Whether the execution was successful, details are aviable in `executionReport`
19
- */
20
- readonly isSuccessful: boolean;
21
- /**
22
- * Added usage of whole execution, detailed usage is aviable in `executionReport`
23
- */
24
- readonly usage: PromptResultUsage;
25
- /**
26
- * Errors that occured during the execution, details are aviable in `executionReport`
27
- */
28
- readonly errors: Array<PipelineExecutionError | Error>;
29
- /**
30
- * The report of the execution with all details
31
- */
32
- readonly executionReport: ExecutionReportJson;
33
- /**
34
- * Result parameters of the execution
35
- *
36
- * Note: If the execution was not successful, there are only some of the result parameters
37
- */
38
- readonly outputParameters: Parameters;
39
- }>;
16
+ (inputParameters: Parameters, onProgress?: (taskProgress: TaskProgress) => Promisable<void>): Promise<PipelineExecutorResult>;
17
+ };
18
+ /**
19
+ * @@@
20
+ */
21
+ export type PipelineExecutorResult = {
22
+ /**
23
+ * Whether the execution was successful, details are aviable in `executionReport`
24
+ */
25
+ readonly isSuccessful: boolean;
26
+ /**
27
+ * Added usage of whole execution, detailed usage is aviable in `executionReport`
28
+ */
29
+ readonly usage: PromptResultUsage;
30
+ /**
31
+ * Errors that occured during the execution, details are aviable in `executionReport`
32
+ */
33
+ readonly errors: Array<PipelineExecutionError | Error>;
34
+ /**
35
+ * Warnings that occured during the execution, details are aviable in `executionReport`
36
+ */
37
+ readonly warnings: Array<PipelineExecutionError | Error>;
38
+ /**
39
+ * The report of the execution with all details
40
+ */
41
+ readonly executionReport: ExecutionReportJson;
42
+ /**
43
+ * Result parameters of the execution
44
+ *
45
+ * Note: If the execution was not successful, there are only some of the result parameters
46
+ */
47
+ readonly outputParameters: Parameters;
40
48
  };
41
49
  /**
42
50
  * TODO: [🧠] Should this file be in /execution or /types folder?
@@ -24,3 +24,6 @@ export type PromptResultUsage = {
24
24
  * Record of all possible measurable units
25
25
  */
26
26
  export type PromptResultUsageCounts = Record<`${KebabCase<'TOKENS' | ExpectationUnit>}Count`, UncertainNumber>;
27
+ /**
28
+ * TODO: [🍙] Make some standart order of json properties
29
+ */
@@ -7,4 +7,8 @@ export declare function isPipelinePrepared(pipeline: PipelineJson): boolean;
7
7
  * TODO: [🐠] Maybe base this on `makeValidator`
8
8
  * TODO: [🔼] Export via core or utils
9
9
  * TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
10
+ * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
11
+ * - Is context in each template
12
+ * - Are samples prepared
13
+ * - Are templates prepared
10
14
  */
@@ -8,7 +8,6 @@ import type { PrepareOptions } from './PrepareOptions';
8
8
  */
9
9
  export declare function preparePipeline(pipeline: PipelineJson, options: PrepareOptions): Promise<PipelineJson>;
10
10
  /**
11
- * TODO: !!!!! Index the samples and maybe templates
12
11
  * TODO: [🔼] !!! Export via `@promptbook/core`
13
12
  * TODO: Write tests for `preparePipeline`
14
13
  * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
@@ -0,0 +1,31 @@
1
+ import type { PipelineJson } from '../types/PipelineJson/PipelineJson';
2
+ import type { PromptTemplateJson } from '../types/PipelineJson/PromptTemplateJson';
3
+ import type { PrepareOptions } from './PrepareOptions';
4
+ type PrepareTemplateInput = Pick<PipelineJson, 'promptTemplates' | 'parameters'> & {
5
+ /**
6
+ * @@@
7
+ */
8
+ readonly knowledgePiecesCount: number;
9
+ };
10
+ type PreparedTemplates = {
11
+ /**
12
+ * @@@ Sequence of prompt templates that are chained together to form a pipeline
13
+ */
14
+ readonly promptTemplatesPrepared: Array<PromptTemplateJson>;
15
+ };
16
+ /**
17
+ * @@@
18
+ */
19
+ export declare function prepareTemplates(pipeline: PrepareTemplateInput, options: PrepareOptions): Promise<PreparedTemplates>;
20
+ export {};
21
+ /**
22
+ * TODO: [🧠] Add context to each template (if missing)
23
+ * TODO: [🧠] What is better name `prepareTemplate` or `prepareTemplateAndParameters`
24
+ * TODO: !!!!! Index the samples and maybe templates
25
+ * TODO: [🔼] !!! Export via `@promptbook/core`
26
+ * TODO: Write tests for `preparePipeline`
27
+ * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
28
+ * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
29
+ * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
30
+ * TODO: [🧠][🥜]
31
+ */
@@ -5,5 +5,7 @@ import type { PipelineJson } from '../types/PipelineJson/PipelineJson';
5
5
  export declare function unpreparePipeline(pipeline: PipelineJson): PipelineJson;
6
6
  /**
7
7
  * TODO: [🔼] !!! Export via `@promptbook/core`
8
+ * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
8
9
  * TODO: Write tests for `preparePipeline`
10
+ * TODO: [🍙] Make some standart order of json properties
9
11
  */
@@ -65,3 +65,6 @@ export type KnowledgePiecePreparedJson = {
65
65
  */
66
66
  readonly preparationIds: Array<number_id>;
67
67
  };
68
+ /**
69
+ * TODO: [🍙] Make some standart order of json properties
70
+ */
@@ -22,3 +22,6 @@ export type KnowledgeSourcePreparedJson = KnowledgeSourceJson & {
22
22
  */
23
23
  readonly preparationIds: Array<number_id>;
24
24
  };
25
+ /**
26
+ * TODO: [🍙] Make some standart order of json properties
27
+ */
@@ -21,4 +21,5 @@ export type LlmTemplateJson = PromptTemplateJsonCommon & {
21
21
  * TODO: [👙][🧠] Maybe add `knowledge`, `actions` and `instruments` to be available granularly for each template
22
22
  * @see https://github.com/webgptorg/promptbook/discussions/79
23
23
  * TODO: [💕][🧠] Just selecting gpt3 or gpt4 level of model
24
+ * TODO: [🍙] Make some standart order of json properties
24
25
  */
@@ -36,3 +36,6 @@ export type PersonaPreparedJson = PersonaJson & {
36
36
  */
37
37
  readonly preparationIds: Array<number_id>;
38
38
  };
39
+ /**
40
+ * TODO: [🍙] Make some standart order of json properties
41
+ */
@@ -79,6 +79,7 @@ export type PipelineJson = {
79
79
  readonly preparations: Array<PreparationJson>;
80
80
  };
81
81
  /**
82
+ * TODO: [🍙] Make some standart order of json properties
82
83
  * TODO: [🧠] Maybe wrap all {parameterNames} in brackets for example { "resultingParameterName": "{foo}" }
83
84
  * Note: There was a proposal for multiple types of promptbook objects 78816ff33e2705ee1a187aa2eb8affd976d4ea1a
84
85
  * But then immediately reverted back to the single type
@@ -16,6 +16,7 @@ export type PreparationJson = {
16
16
  readonly modelUsage: PromptResultUsage;
17
17
  };
18
18
  /**
19
+ * TODO: [🍙] Make some standart order of json properties
19
20
  * TODO: Maybe put here used `modelName`
20
21
  * TODO: [🍥] When using `date` it changes all samples .ptbk.json files each time so until some more elegant solution omit the time from prepared pipeline
21
22
  */
@@ -4,9 +4,10 @@ import type { PromptTemplateJsonCommon } from './PromptTemplateJsonCommon';
4
4
  *
5
5
  * @see https://github.com/webgptorg/promptbook/discussions/76
6
6
  */
7
- export interface PromptDialogJson extends PromptTemplateJsonCommon {
7
+ export type PromptDialogJson = PromptTemplateJsonCommon & {
8
8
  readonly blockType: 'PROMPT_DIALOG';
9
- }
9
+ };
10
10
  /**
11
11
  * TODO: [🧠][🥜]
12
- */
12
+ * TODO: [🍙] Make some standart order of json properties
13
+ */
@@ -49,8 +49,18 @@ export interface PromptTemplateJsonCommon {
49
49
  readonly blockType: BlockType;
50
50
  /**
51
51
  * Content of the template with {placeholders} for parameters
52
+ *
53
+ * @@@ content vs preparedContent
52
54
  */
53
55
  readonly content: (string_prompt | string_javascript | string_markdown) & string_template;
56
+ /**
57
+ * @@@ Content of the template with {placeholders} for parameters
58
+ *
59
+ * @@@ content vs preparedContent
60
+ *
61
+ * @default "{content}"
62
+ */
63
+ readonly preparedContent?: (string_prompt | string_javascript | string_markdown) & string_template;
54
64
  /**
55
65
  * List of postprocessing steps that are executed after the prompt template
56
66
  *
@@ -32,4 +32,5 @@ export type PromptTemplateParameterJson = {
32
32
  };
33
33
  /**
34
34
  * TODO: [♈] Probbably move expectations from templates to parameters
35
+ * TODO: [🍙] Make some standart order of json properties
35
36
  */
@@ -5,7 +5,7 @@ import type { PromptTemplateJsonCommon } from './PromptTemplateJsonCommon';
5
5
  *
6
6
  * @see https://github.com/webgptorg/promptbook/discussions/77
7
7
  */
8
- export interface ScriptJson extends PromptTemplateJsonCommon {
8
+ export type ScriptJson = PromptTemplateJsonCommon & {
9
9
  readonly blockType: 'SCRIPT';
10
10
  /**
11
11
  * Language of the script
@@ -13,4 +13,7 @@ export interface ScriptJson extends PromptTemplateJsonCommon {
13
13
  *
14
14
  */
15
15
  readonly contentLanguage?: ScriptLanguage;
16
- }
16
+ };
17
+ /**
18
+ * TODO: [🍙] Make some standart order of json properties
19
+ */
@@ -4,6 +4,9 @@ import type { PromptTemplateJsonCommon } from './PromptTemplateJsonCommon';
4
4
  *
5
5
  * @see https://github.com/webgptorg/promptbook/discussions/17
6
6
  */
7
- export interface SimpleTemplateJson extends PromptTemplateJsonCommon {
7
+ export type SimpleTemplateJson = PromptTemplateJsonCommon & {
8
8
  readonly blockType: 'SIMPLE_TEMPLATE';
9
- }
9
+ };
10
+ /**
11
+ * TODO: [🍙] Make some standart order of json properties
12
+ */