@promptbook/openai 0.35.1 → 0.36.2

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 (104) hide show
  1. package/README.md +1 -1
  2. package/esm/index.es.js +1 -1
  3. package/esm/typings/_packages/core.index.d.ts +8 -8
  4. package/esm/typings/_packages/remote-server.index.d.ts +2 -2
  5. package/esm/typings/_packages/types.index.d.ts +8 -8
  6. package/esm/typings/classes/PromptbookLibrary.d.ts +61 -0
  7. package/esm/typings/conversion/_importPromptbook.d.ts +12 -0
  8. package/esm/typings/conversion/promptbookStringToJson.d.ts +13 -0
  9. package/esm/typings/conversion/validatePromptbookJson.d.ts +26 -0
  10. package/{umd/typings/execution/PtpExecutor.d.ts → esm/typings/execution/PromptbookExecutor.d.ts} +5 -5
  11. package/esm/typings/execution/assertsExecutionSuccessful.d.ts +2 -2
  12. package/esm/typings/execution/createPromptbookExecutor.d.ts +40 -0
  13. package/esm/typings/execution/plugins/natural-execution-tools/mocked/joker.test.d.ts +1 -1
  14. package/esm/typings/execution/plugins/natural-execution-tools/mocked/mocked-chat.test.d.ts +1 -1
  15. package/esm/typings/execution/plugins/natural-execution-tools/mocked/mocked-completion.test.d.ts +1 -1
  16. package/esm/typings/execution/plugins/natural-execution-tools/remote/RemoteNaturalExecutionToolsOptions.d.ts +1 -1
  17. package/esm/typings/execution/plugins/natural-execution-tools/remote/interfaces/{Ptps_Error.d.ts → Promptbook_Server_Error.d.ts} +1 -1
  18. package/esm/typings/execution/plugins/natural-execution-tools/remote/interfaces/{Ptps_Progress.d.ts → Promptbook_Server_Progress.d.ts} +1 -1
  19. package/esm/typings/execution/plugins/natural-execution-tools/remote/interfaces/{Ptps_Request.d.ts → Promptbook_Server_Request.d.ts} +2 -2
  20. package/esm/typings/execution/plugins/natural-execution-tools/remote/interfaces/{Ptps_Response.d.ts → Promptbook_Server_Response.d.ts} +2 -2
  21. package/esm/typings/execution/plugins/natural-execution-tools/remote/interfaces/RemoteServerOptions.d.ts +3 -3
  22. package/{umd/typings/execution/plugins/natural-execution-tools/remote/runRemoteServer.d.ts → esm/typings/execution/plugins/natural-execution-tools/remote/startRemoteServer.d.ts} +2 -2
  23. package/esm/typings/types/Command.d.ts +12 -12
  24. package/esm/typings/types/Parameters.d.ts +3 -3
  25. package/esm/typings/types/Prompt.d.ts +5 -5
  26. package/{umd/typings/types/PromptTemplatePipelineJson → esm/typings/types/PromptbookJson}/PromptTemplateJson.d.ts +4 -4
  27. package/esm/typings/types/{PromptTemplatePipelineJson → PromptbookJson}/PromptTemplateParameterJson.d.ts +2 -2
  28. package/{umd/typings/types/PromptTemplatePipelineJson/PromptTemplatePipelineJson.d.ts → esm/typings/types/PromptbookJson/PromptbookJson.d.ts} +11 -15
  29. package/esm/typings/types/PromptbookString.d.ts +12 -0
  30. package/esm/typings/types/TaskProgress.d.ts +1 -1
  31. package/esm/typings/types/execution-report/ExecutionReportJson.d.ts +10 -10
  32. package/esm/typings/types/typeAliases.d.ts +4 -4
  33. package/esm/typings/utils/expectation-counters/countCharacters.d.ts +1 -1
  34. package/esm/typings/utils/expectation-counters/countLines.d.ts +1 -1
  35. package/esm/typings/utils/expectation-counters/countPages.d.ts +1 -1
  36. package/esm/typings/utils/expectation-counters/countParagraphs.d.ts +1 -1
  37. package/esm/typings/utils/expectation-counters/countSentences.d.ts +1 -1
  38. package/esm/typings/utils/expectation-counters/countWords.d.ts +1 -1
  39. package/esm/typings/utils/expectation-counters/index.d.ts +1 -1
  40. package/esm/typings/utils/isRunningInWhatever.d.ts +12 -0
  41. package/esm/typings/version.d.ts +1 -1
  42. package/package.json +2 -2
  43. package/umd/index.umd.js +1 -1
  44. package/umd/typings/_packages/core.index.d.ts +8 -8
  45. package/umd/typings/_packages/remote-server.index.d.ts +2 -2
  46. package/umd/typings/_packages/types.index.d.ts +8 -8
  47. package/umd/typings/classes/PromptbookLibrary.d.ts +61 -0
  48. package/umd/typings/conversion/_importPromptbook.d.ts +12 -0
  49. package/umd/typings/conversion/promptbookStringToJson.d.ts +13 -0
  50. package/umd/typings/conversion/validatePromptbookJson.d.ts +26 -0
  51. package/{esm/typings/execution/PtpExecutor.d.ts → umd/typings/execution/PromptbookExecutor.d.ts} +5 -5
  52. package/umd/typings/execution/assertsExecutionSuccessful.d.ts +2 -2
  53. package/umd/typings/execution/createPromptbookExecutor.d.ts +40 -0
  54. package/umd/typings/execution/plugins/natural-execution-tools/mocked/joker.test.d.ts +1 -1
  55. package/umd/typings/execution/plugins/natural-execution-tools/mocked/mocked-chat.test.d.ts +1 -1
  56. package/umd/typings/execution/plugins/natural-execution-tools/mocked/mocked-completion.test.d.ts +1 -1
  57. package/umd/typings/execution/plugins/natural-execution-tools/remote/RemoteNaturalExecutionToolsOptions.d.ts +1 -1
  58. package/umd/typings/execution/plugins/natural-execution-tools/remote/interfaces/{Ptps_Error.d.ts → Promptbook_Server_Error.d.ts} +1 -1
  59. package/umd/typings/execution/plugins/natural-execution-tools/remote/interfaces/{Ptps_Progress.d.ts → Promptbook_Server_Progress.d.ts} +1 -1
  60. package/umd/typings/execution/plugins/natural-execution-tools/remote/interfaces/{Ptps_Request.d.ts → Promptbook_Server_Request.d.ts} +2 -2
  61. package/umd/typings/execution/plugins/natural-execution-tools/remote/interfaces/{Ptps_Response.d.ts → Promptbook_Server_Response.d.ts} +2 -2
  62. package/umd/typings/execution/plugins/natural-execution-tools/remote/interfaces/RemoteServerOptions.d.ts +3 -3
  63. package/{esm/typings/execution/plugins/natural-execution-tools/remote/runRemoteServer.d.ts → umd/typings/execution/plugins/natural-execution-tools/remote/startRemoteServer.d.ts} +2 -2
  64. package/umd/typings/types/Command.d.ts +12 -12
  65. package/umd/typings/types/Parameters.d.ts +3 -3
  66. package/umd/typings/types/Prompt.d.ts +5 -5
  67. package/{esm/typings/types/PromptTemplatePipelineJson → umd/typings/types/PromptbookJson}/PromptTemplateJson.d.ts +4 -4
  68. package/umd/typings/types/{PromptTemplatePipelineJson → PromptbookJson}/PromptTemplateParameterJson.d.ts +2 -2
  69. package/{esm/typings/types/PromptTemplatePipelineJson/PromptTemplatePipelineJson.d.ts → umd/typings/types/PromptbookJson/PromptbookJson.d.ts} +11 -15
  70. package/umd/typings/types/PromptbookString.d.ts +12 -0
  71. package/umd/typings/types/TaskProgress.d.ts +1 -1
  72. package/umd/typings/types/execution-report/ExecutionReportJson.d.ts +10 -10
  73. package/umd/typings/types/typeAliases.d.ts +4 -4
  74. package/umd/typings/utils/expectation-counters/countCharacters.d.ts +1 -1
  75. package/umd/typings/utils/expectation-counters/countLines.d.ts +1 -1
  76. package/umd/typings/utils/expectation-counters/countPages.d.ts +1 -1
  77. package/umd/typings/utils/expectation-counters/countParagraphs.d.ts +1 -1
  78. package/umd/typings/utils/expectation-counters/countSentences.d.ts +1 -1
  79. package/umd/typings/utils/expectation-counters/countWords.d.ts +1 -1
  80. package/umd/typings/utils/expectation-counters/index.d.ts +1 -1
  81. package/umd/typings/utils/isRunningInWhatever.d.ts +12 -0
  82. package/umd/typings/version.d.ts +1 -1
  83. package/esm/typings/classes/PromptTemplatePipelineLibrary.d.ts +0 -71
  84. package/esm/typings/config.d.ts +0 -12
  85. package/esm/typings/conversion/_importPtp.d.ts +0 -12
  86. package/esm/typings/conversion/promptTemplatePipelineStringToJson.d.ts +0 -13
  87. package/esm/typings/conversion/validatePromptTemplatePipelineJson.d.ts +0 -26
  88. package/esm/typings/execution/createPtpExecutor.d.ts +0 -40
  89. package/esm/typings/types/PromptTemplatePipelineString.d.ts +0 -16
  90. package/umd/typings/classes/PromptTemplatePipelineLibrary.d.ts +0 -71
  91. package/umd/typings/config.d.ts +0 -12
  92. package/umd/typings/conversion/_importPtp.d.ts +0 -12
  93. package/umd/typings/conversion/promptTemplatePipelineStringToJson.d.ts +0 -13
  94. package/umd/typings/conversion/validatePromptTemplatePipelineJson.d.ts +0 -26
  95. package/umd/typings/execution/createPtpExecutor.d.ts +0 -40
  96. package/umd/typings/types/PromptTemplatePipelineString.d.ts +0 -16
  97. /package/esm/typings/conversion/{promptTemplatePipelineStringToJson-syntaxErrors.test.d.ts → promptbookStringToJson-syntaxErrors.test.d.ts} +0 -0
  98. /package/esm/typings/conversion/{promptTemplatePipelineStringToJson.test.d.ts → promptbookStringToJson.test.d.ts} +0 -0
  99. /package/esm/typings/conversion/{validatePromptTemplatePipelineJson-logicErrors.test.d.ts → validatePromptbookJson-logicErrors.test.d.ts} +0 -0
  100. /package/esm/typings/conversion/{validatePromptTemplatePipelineJson.test.d.ts → validatePromptbookJson.test.d.ts} +0 -0
  101. /package/umd/typings/conversion/{promptTemplatePipelineStringToJson-syntaxErrors.test.d.ts → promptbookStringToJson-syntaxErrors.test.d.ts} +0 -0
  102. /package/umd/typings/conversion/{promptTemplatePipelineStringToJson.test.d.ts → promptbookStringToJson.test.d.ts} +0 -0
  103. /package/umd/typings/conversion/{validatePromptTemplatePipelineJson-logicErrors.test.d.ts → validatePromptbookJson-logicErrors.test.d.ts} +0 -0
  104. /package/umd/typings/conversion/{validatePromptTemplatePipelineJson.test.d.ts → validatePromptbookJson.test.d.ts} +0 -0
@@ -2,9 +2,9 @@
2
2
  * Parameters of the prompt template (pipeline)
3
3
  *
4
4
  * There are three types of parameters:
5
- * - **INPUT PARAMETERs** are required to execute the prompt template pipeline.
6
- * - **Intermediate parameters** are used internally in the prompt template pipeline.
7
- * - **OUTPUT PARAMETERs** are not used internally in the prompt template pipeline, but are returned as the result of the prompt template pipeline execution.
5
+ * - **INPUT PARAMETERs** are required to execute the pipeline.
6
+ * - **Intermediate parameters** are used internally in the pipeline.
7
+ * - **OUTPUT PARAMETERs** are not used internally in the pipeline, but are returned as the result of the pipeline execution.
8
8
  *
9
9
  * @see https://github.com/webgptorg/promptbook#parameters
10
10
  */
@@ -1,4 +1,4 @@
1
- import type { string_name, string_prompt, string_ptbk_url_with_hashtemplate, string_title } from '.././types/typeAliases';
1
+ import type { string_name, string_prompt, string_promptbook_url_with_hashtemplate, string_title } from '.././types/typeAliases';
2
2
  import type { ModelRequirements } from './ModelRequirements';
3
3
  /**
4
4
  * Prompt in a text along with model requirements, but without any execution or templating logic.
@@ -24,15 +24,15 @@ export interface Prompt {
24
24
  */
25
25
  readonly modelRequirements: ModelRequirements;
26
26
  /**
27
- * Unique identifier of the prompt template pipeline with specific template name as hash
27
+ * Unique identifier of the promptbook with specific template name as hash
28
28
  *
29
- * @example https://ptbk.webgpt.com/cs/write-website-content.ptbk.md@v2.4.15#keywords
29
+ * @example https://promptbook.webgpt.com/cs/write-website-content.ptbk.md@v2.4.15#keywords
30
30
  */
31
- readonly ptbkUrl: string_ptbk_url_with_hashtemplate;
31
+ readonly promptbookUrl: string_promptbook_url_with_hashtemplate;
32
32
  /**
33
33
  * Parameters used in the prompt
34
34
  *
35
- * Note: This is redundant (same information is in ptbkUrl+content) but useful for logging and debugging
35
+ * Note: This is redundant (same information is in promptbookUrl+content) but useful for logging and debugging
36
36
  */
37
37
  readonly parameters: Record<string_name, string>;
38
38
  }
@@ -1,10 +1,10 @@
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
1
  import { ExpectFormatCommand } from '../Command';
3
2
  import { ExecutionType } from '../ExecutionTypes';
4
3
  import { ModelRequirements } from '../ModelRequirements';
5
4
  import { ScriptLanguage } from '../ScriptLanguage';
5
+ import { number_integer, number_positive_or_zero, string_javascript, string_javascript_name, string_markdown, string_name, string_prompt, string_template } from '../typeAliases';
6
6
  /**
7
- * Describes one prompt template in the prompt template pipeline
7
+ * Describes one prompt template in the promptbook
8
8
  */
9
9
  export type PromptTemplateJson = NaturalTemplateJson | SimpleTemplateJson | ScriptTemplateJson | PromptDialogJson;
10
10
  /**
@@ -16,7 +16,7 @@ export interface NaturalTemplateJson extends PromptTemplateJsonCommon {
16
16
  * Requirements for the model
17
17
  * - This is required only for executionType PROMPT_TEMPLATE
18
18
  */
19
- readonly modelRequirements?: ModelRequirements;
19
+ readonly modelRequirements: ModelRequirements;
20
20
  }
21
21
  /**
22
22
  * Units of text measurement
@@ -62,7 +62,7 @@ interface PromptTemplateJsonCommon {
62
62
  * Name of the template
63
63
  * - It must be unique across the pipeline
64
64
  * - It should start uppercase and contain letters and numbers
65
- * - The ptbkUrl together with hash and name are used to identify the prompt template in the pipeline
65
+ * - The promptbookUrl together with hash and name are used to identify the prompt template in the pipeline
66
66
  */
67
67
  readonly name: string_name;
68
68
  /**
@@ -1,6 +1,6 @@
1
- import { string_name } from '../.././types/typeAliases';
1
+ import { string_name } from '../typeAliases';
2
2
  /**
3
- * Describes one parameter of the prompt template pipeline
3
+ * Describes one parameter of the promptbook
4
4
  */
5
5
  export interface PromptTemplateParameterJson {
6
6
  /**
@@ -1,38 +1,34 @@
1
- import { string_ptbk_url, string_version } from '../.././types/typeAliases';
1
+ import { string_promptbook_url, string_version } from '../typeAliases';
2
2
  import { PromptTemplateJson } from './PromptTemplateJson';
3
3
  import { PromptTemplateParameterJson } from './PromptTemplateParameterJson';
4
4
  /**
5
- * Prompt template pipeline is the **core concept of this library**.
5
+ * Promptbook is the **core concept of this library**.
6
6
  * It represents a series of prompt templates chained together to form a pipeline / one big prompt template with input and result parameters.
7
7
  *
8
- * It can have 3 formats:
9
- * - **.ptbk.md file** in custom markdown format described above
10
- * - _(this)_ **JSON** format, parsed from the .ptbk.md file
11
- *
12
- * @see https://github.com/webgptorg/promptbook#prompt-template-pipeline
8
+ * @see https://github.com/webgptorg/promptbook#promptbook
13
9
  */
14
- export interface PromptTemplatePipelineJson {
10
+ export interface PromptbookJson {
15
11
  /**
16
- * Unique identifier of the prompt template pipeline
12
+ * Unique identifier of the promptbook
17
13
  *
18
- * Note: It must be unique across all prompt template pipelines
14
+ * Note: It must be unique across all promptbooks libraries
19
15
  * Note: It must use HTTPs URL
20
16
  * Tip: You can do versioning in the URL
21
- * For example: https://ptbk.webgpt.com/cs/write-website-content.ptbk.md@1.0.0
17
+ * For example: https://promptbook.webgpt.com/cs/write-website-content.ptbk.md@1.0.0
22
18
  * Warning: Do not hash part of the URL, hash part is used for identification of the prompt template in the pipeline
23
19
  */
24
- readonly ptbkUrl?: string_ptbk_url;
20
+ readonly promptbookUrl?: string_promptbook_url;
25
21
  /**
26
- * Title of the prompt template pipeline
22
+ * Title of the promptbook
27
23
  * -It can use simple markdown formatting like **bold**, *italic*, [link](https://example.com), ... BUT not code blocks and structure
28
24
  */
29
25
  readonly title: string;
30
26
  /**
31
27
  * Version of the .ptbk.json file
32
28
  */
33
- readonly ptbkVersion: string_version;
29
+ readonly promptbookVersion: string_version;
34
30
  /**
35
- * Description of the prompt template pipeline
31
+ * Description of the promptbook
36
32
  * It can use multiple paragraphs of simple markdown formatting like **bold**, *italic*, [link](https://example.com), ... BUT not code blocks and structure
37
33
  */
38
34
  readonly description?: string;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Promptbook is the **core concept of this library**.
3
+ * It represents a series of prompt templates chained together to form a pipeline / one big prompt template with input and result parameters.
4
+ *
5
+ * @see https://github.com/webgptorg/promptbook#promptbook
6
+ */
7
+ export type PromptbookString = string & {
8
+ readonly _type: 'Promptbook';
9
+ };
10
+ /**
11
+ * TODO: !! Better validation (validatePromptbookString) or remove branded type and make it just string
12
+ */
@@ -1,7 +1,7 @@
1
1
  import { ExecutionType } from './ExecutionTypes';
2
2
  import { string_markdown_text, string_name } from './typeAliases';
3
3
  /**
4
- * TaskProgress represents the progress of a PromptTemplatePipeline execution.
4
+ * TaskProgress represents the progress of a Promptbook execution.
5
5
  */
6
6
  export interface TaskProgress {
7
7
  /**
@@ -1,6 +1,6 @@
1
1
  import type { PromptResult } from '../../execution/PromptResult';
2
2
  import type { Prompt } from '../Prompt';
3
- import type { string_ptbk_url, string_version } from '../typeAliases';
3
+ import type { string_promptbook_url, string_version } from '../typeAliases';
4
4
  /**
5
5
  * ExecutionReport is result of executing one promptbook
6
6
  * It is kind of a variant of the promptbook usefull for debugging, logging and transparency for users.
@@ -13,23 +13,23 @@ import type { string_ptbk_url, string_version } from '../typeAliases';
13
13
  */
14
14
  export type ExecutionReportJson = {
15
15
  /**
16
- * Unique identifier of the ptp from ptp which was executed
16
+ * Unique identifier of the promptbook from promptbook which was executed
17
17
  */
18
- readonly ptbkUrl?: string_ptbk_url;
18
+ readonly promptbookUrl?: string_promptbook_url;
19
19
  /**
20
- * Title of from ptp which was executed
20
+ * Title of from promptbook which was executed
21
21
  */
22
22
  readonly title?: string;
23
23
  /**
24
- * Version from ptp which was executed
24
+ * Version from promptbook which was executed
25
25
  */
26
- readonly ptbkUsedVersion: string_version;
26
+ readonly promptbookUsedVersion: string_version;
27
27
  /**
28
- * Version from ptp which was requested by promptbook
28
+ * Version from promptbook which was requested by promptbook
29
29
  */
30
- readonly ptbkRequestedVersion?: string_version;
30
+ readonly promptbookRequestedVersion?: string_version;
31
31
  /**
32
- * Description of the ptp which was executed
32
+ * Description of the promptbook which was executed
33
33
  */
34
34
  readonly description?: string;
35
35
  /**
@@ -39,7 +39,7 @@ export type ExecutionReportJson = {
39
39
  /**
40
40
  * The prompt wich was executed
41
41
  */
42
- prompt: Omit<Prompt, 'ptbkUrl' | 'parameters'>;
42
+ prompt: Omit<Prompt, 'promptbookUrl' | 'parameters'>;
43
43
  /**
44
44
  * Result of the prompt execution (if not failed during LLM execution)
45
45
  */
@@ -179,15 +179,15 @@ export type string_url = string;
179
179
  /**
180
180
  * Semantic helper
181
181
  *
182
- * For example `"https://ptbk.webgpt.com/cs/write-website-content.ptbk.md@v2.4.15"`
182
+ * For example `"https://promptbook.webgpt.com/cs/write-website-content.ptbk.md@v2.4.15"`
183
183
  */
184
- export type string_ptbk_url = string;
184
+ export type string_promptbook_url = string;
185
185
  /**
186
186
  * Semantic helper
187
187
  *
188
- * For example `"https://ptbk.webgpt.com/cs/write-website-content.ptbk.md@v2.4.15#keywords"`
188
+ * For example `"https://promptbook.webgpt.com/cs/write-website-content.ptbk.md@v2.4.15#keywords"`
189
189
  */
190
- export type string_ptbk_url_with_hashtemplate = string;
190
+ export type string_promptbook_url_with_hashtemplate = string;
191
191
  /**
192
192
  * Semantic helper
193
193
  *
@@ -1,4 +1,4 @@
1
- import type { ExpectationAmount } from '../../types/PromptTemplatePipelineJson/PromptTemplateJson';
1
+ import type { ExpectationAmount } from '../../types/PromptbookJson/PromptTemplateJson';
2
2
  /**
3
3
  * Counts number of characters in the text
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { ExpectationAmount } from '../../types/PromptTemplatePipelineJson/PromptTemplateJson';
1
+ import type { ExpectationAmount } from '../../types/PromptbookJson/PromptTemplateJson';
2
2
  /**
3
3
  * Counts number of lines in the text
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { ExpectationAmount } from '../../types/PromptTemplatePipelineJson/PromptTemplateJson';
1
+ import type { ExpectationAmount } from '../../types/PromptbookJson/PromptTemplateJson';
2
2
  /**
3
3
  * Counts number of pages in the text
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { ExpectationAmount } from '../../types/PromptTemplatePipelineJson/PromptTemplateJson';
1
+ import type { ExpectationAmount } from '../../types/PromptbookJson/PromptTemplateJson';
2
2
  /**
3
3
  * Counts number of paragraphs in the text
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { ExpectationAmount } from '../../types/PromptTemplatePipelineJson/PromptTemplateJson';
1
+ import type { ExpectationAmount } from '../../types/PromptbookJson/PromptTemplateJson';
2
2
  /**
3
3
  * Counts number of sentences in the text
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { ExpectationAmount } from '../../types/PromptTemplatePipelineJson/PromptTemplateJson';
1
+ import type { ExpectationAmount } from '../../types/PromptbookJson/PromptTemplateJson';
2
2
  /**
3
3
  * Counts number of words in the text
4
4
  */
@@ -1,4 +1,4 @@
1
- import type { ExpectationAmount, ExpectationUnit } from '../../types/PromptTemplatePipelineJson/PromptTemplateJson';
1
+ import type { ExpectationAmount, ExpectationUnit } from '../../types/PromptbookJson/PromptTemplateJson';
2
2
  /**
3
3
  * Index of all counter functions
4
4
  */
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Detects if the code is running in a browser environment in main thread (Not in a web worker)
3
+ */
4
+ export declare const isRunningInBrowser: Function;
5
+ /**
6
+ * Detects if the code is running in a Node.js environment
7
+ */
8
+ export declare const isRunningInNode: Function;
9
+ /**
10
+ * Detects if the code is running in a web worker
11
+ */
12
+ export declare const isRunningInWebWorker: Function;
@@ -2,4 +2,4 @@ import type { string_version } from './types/typeAliases';
2
2
  /**
3
3
  * The version of the Promptbook library
4
4
  */
5
- export declare const PTBK_VERSION: string_version;
5
+ export declare const PROMPTBOOK_VERSION: string_version;
@@ -1,71 +0,0 @@
1
- import { string_name } from '.././types/typeAliases';
2
- import { CreatePtpExecutorSettings } from '../execution/createPtpExecutor';
3
- import { ExecutionTools } from '../execution/ExecutionTools';
4
- import { PtpExecutor } from '../execution/PtpExecutor';
5
- import { Prompt } from '../types/Prompt';
6
- import { PromptTemplatePipelineJson } from '../types/PromptTemplatePipelineJson/PromptTemplatePipelineJson';
7
- import { PromptTemplatePipelineString } from '../types/PromptTemplatePipelineString';
8
- /**
9
- * Options for PromptTemplatePipelineLibrary
10
- */
11
- type PromptTemplatePipelineLibraryOptions = {
12
- /**
13
- * The library of prompt template pipelines
14
- */
15
- readonly library: Record<string_name, PromptTemplatePipelineJson>;
16
- /**
17
- * Optional settings for creating a PromptTemplatePipelineExecutor
18
- */
19
- readonly settings?: Partial<CreatePtpExecutorSettings>;
20
- };
21
- /**
22
- * Library of prompt template pipelines that groups together prompt template pipelines for an application. This is a very thin wrapper around the Array / Set of prompt template pipelines.
23
- *
24
- * Prompt Template Pipeline library is a useful helper in execution, it can be shared between execution and consumer parts of the app and make common knowledge about prompt template pipelines.
25
- *
26
- * It allows to create executor functions from prompt template pipelines in the library.
27
- *
28
- * @see https://github.com/webgptorg/promptbook#prompt-template-pipeline-library
29
- */
30
- export declare class PromptTemplatePipelineLibrary {
31
- readonly options: PromptTemplatePipelineLibraryOptions;
32
- /**
33
- * Constructs PromptTemplatePipeline from any sources
34
- *
35
- * Note: During the construction syntax and logic of all sources are validated
36
- * Note: You can combine .ptbk.md and .ptbk.json files BUT it is not recommended
37
- *
38
- * @param ptbkSources contents of .ptbk.md or .ptbk.json files
39
- * @param settings settings for creating executor functions
40
- * @returns PromptTemplatePipelineLibrary
41
- */
42
- static fromSources(ptbkSources: Record<string_name, PromptTemplatePipelineJson | PromptTemplatePipelineString>, settings?: Partial<CreatePtpExecutorSettings>): PromptTemplatePipelineLibrary;
43
- private constructor();
44
- /**
45
- * Gets prompt template pipeline by name
46
- */
47
- getPtp(name: string_name): PromptTemplatePipelineJson;
48
- /**
49
- * Checks whether prompt is in the library
50
- */
51
- isPromptInLibrary(prompt: Prompt): boolean;
52
- /**
53
- * Gets executor function for given prompt template pipeline
54
- */
55
- createExecutor(name: string_name, tools: ExecutionTools): PtpExecutor;
56
- }
57
- export {};
58
- /**
59
- * TODO: !!! This should be renamed to Promptbook
60
- * TODO: !! [👐][🧠] Split of PromptTemplatePipeline,PromptTemplatePipelineLibrary between interface and class
61
- * TODO: !! [👐] Make promptTemplatePipelines private WHEN split between interface and class
62
- * TODO: [🧠] Maybe isPromptInLibrary should be separate utility function
63
- * TODO: [🧠] Maybe createExecutor should be separate utility function
64
- * TODO: Static method fromDirectory
65
- * TODO: [🤜] Add generic type for entry and result parameters
66
- * TODO: [🧠] Is it better to ptbkLibrary.executePtp('writeXyz',{...}) OR ptbkLibrary.createExecutor('writeXyz')({...}) OR createExecutor(ptbkLibrary.getPtp('writeXyz'))
67
- * TODO: [🧠] Formarly (before commit 62229afce7668a5b85077cc18becf798b583bf8d) there were two classes PromptTemplatePipelineLibrary+PtpLibraryExecutor (maybe it was better?)
68
- * TODO: [🧠] Is it better to pass tools into getExecutor or into constructor
69
- * Maybe it is not a good idea to cache executors when they are can be created with different tools
70
- * TODO: [👧] Strongly type the executors to avoid need of remove nullables whtn noUncheckedIndexedAccess in tsconfig.json
71
- */
@@ -1,12 +0,0 @@
1
- import { ModelRequirements } from './types/ModelRequirements';
2
- /**
3
- * Default model requirements for the pipeline
4
- *
5
- * Note: As default, we use the chat model gpt-3.5-turbo. For most tasks, this is the best model with most intuitive usage.
6
- * GPT-4 is overkill for most tasks so keeping it as opt-in option.
7
- */
8
- export declare const DEFAULT_MODEL_REQUIREMENTS: ModelRequirements;
9
- /**
10
- * TODO: !!! Different default model for different model variant
11
- * TODO: [🧠] What should be the default model?
12
- */
@@ -1,12 +0,0 @@
1
- import { PromptTemplatePipelineJson } from '../types/PromptTemplatePipelineJson/PromptTemplatePipelineJson';
2
- import { PromptTemplatePipelineString } from '../types/PromptTemplatePipelineString';
3
- /**
4
- * Import the text file
5
- *
6
- * Note: Using here custom import to work in jest tests
7
- * Note: Using sync version is 💩 in the production code, but it's ok here in tests
8
- *
9
- * @private
10
- */
11
- export declare function importPtp(path: `${string}.ptbk.md`): PromptTemplatePipelineString;
12
- export declare function importPtp(path: `${string}.ptbk.json`): PromptTemplatePipelineJson;
@@ -1,13 +0,0 @@
1
- import { PromptTemplatePipelineJson } from '../types/PromptTemplatePipelineJson/PromptTemplatePipelineJson';
2
- import { PromptTemplatePipelineString } from '../types/PromptTemplatePipelineString';
3
- /**
4
- * Parse prompt template pipeline from string format to JSON format
5
- *
6
- * Note: This function does not validate logic of the pipeline only the syntax
7
- */
8
- export declare function promptTemplatePipelineStringToJson(promptTemplatePipelineString: PromptTemplatePipelineString): PromptTemplatePipelineJson;
9
- /**
10
- * TODO: Report here line/column of error
11
- * TODO: Use spaceTrim more effectively
12
- * TODO: [🧠] Parameter flags - isInput, isOutput, isInternal
13
- */
@@ -1,26 +0,0 @@
1
- import type { PromptTemplatePipelineJson } from '../types/PromptTemplatePipelineJson/PromptTemplatePipelineJson';
2
- /**
3
- * Validates PromptTemplatePipelineJson if it is logically valid.
4
- *
5
- * It checks:
6
- * - if it has correct parameters dependency
7
- *
8
- * It does NOT check:
9
- * - if it is valid json
10
- * - if it is meaningful
11
- *
12
- * @param ptp valid or invalid PromptTemplatePipelineJson
13
- * @throws {Error} if invalid
14
- */
15
- export declare function validatePromptTemplatePipelineJson(ptp: PromptTemplatePipelineJson): void;
16
- /**
17
- * TODO: [🧠] Work with ptbkVersion
18
- * TODO: Use here some json-schema, Zod or something similar and change it to:
19
- * > /**
20
- * > * Validates PromptTemplatePipelineJson if it is logically valid.
21
- * > *
22
- * > * It checks:
23
- * > * - it has a valid structure
24
- * > * - ...
25
- * > ex port function validatePromptTemplatePipelineJson(ptp: unknown): asserts ptp is PromptTemplatePipelineJson {
26
- */
@@ -1,40 +0,0 @@
1
- import { PromptTemplatePipelineJson } from '../_packages/types.index';
2
- import { ExecutionTools } from './ExecutionTools';
3
- import { PtpExecutor } from './PtpExecutor';
4
- export interface CreatePtpExecutorSettings {
5
- /**
6
- * When executor does not satisfy expectations it will be retried this amount of times
7
- *
8
- * @default 3
9
- */
10
- readonly maxExecutionAttempts: number;
11
- }
12
- /**
13
- * Options for creating a PTP (Prompt Template Pipeline) executor
14
- */
15
- interface CreatePtpExecutorOptions {
16
- /**
17
- * The Prompt Template Pipeline (PTP) to be executed
18
- */
19
- readonly ptp: PromptTemplatePipelineJson;
20
- /**
21
- * The execution tools to be used during the execution of the PTP
22
- */
23
- readonly tools: ExecutionTools;
24
- /**
25
- * Optional settings for the PTP executor
26
- */
27
- readonly settings?: Partial<CreatePtpExecutorSettings>;
28
- }
29
- /**
30
- * Creates executor function from prompt template pipeline and execution tools.
31
- *
32
- * Note: Consider using getExecutor method of the library instead of using this function
33
- */
34
- export declare function createPtpExecutor(options: CreatePtpExecutorOptions): PtpExecutor;
35
- export {};
36
- /**
37
- * TODO: [🧠] When not meet expectations in PROMPT_DIALOG, make some way to tell the user
38
- * TODO: [👧] Strongly type the executors to avoid need of remove nullables whtn noUncheckedIndexedAccess in tsconfig.json
39
- * Note: CreatePtpExecutorOptions are just connected to PtpExecutor so do not extract to types folder
40
- */
@@ -1,16 +0,0 @@
1
- /**
2
- * Prompt template pipeline is the **core concept of this library**.
3
- * It represents a series of prompt templates chained together to form a pipeline / one big prompt template with input and result parameters.
4
- *
5
- * It can have 3 formats:
6
- * - _(this)_ **.ptbk.md file** in custom markdown format described above
7
- * - **JSON** format, parsed from the .ptbk.md file
8
- *
9
- * @see https://github.com/webgptorg/promptbook#prompt-template-pipeline
10
- */
11
- export type PromptTemplatePipelineString = string & {
12
- readonly _type: 'PromptTemplatePipeline';
13
- };
14
- /**
15
- * TODO: !! Better validation (validatePromptTemplatePipelineString) or remove branded type and make it just string
16
- */
@@ -1,71 +0,0 @@
1
- import { string_name } from '.././types/typeAliases';
2
- import { CreatePtpExecutorSettings } from '../execution/createPtpExecutor';
3
- import { ExecutionTools } from '../execution/ExecutionTools';
4
- import { PtpExecutor } from '../execution/PtpExecutor';
5
- import { Prompt } from '../types/Prompt';
6
- import { PromptTemplatePipelineJson } from '../types/PromptTemplatePipelineJson/PromptTemplatePipelineJson';
7
- import { PromptTemplatePipelineString } from '../types/PromptTemplatePipelineString';
8
- /**
9
- * Options for PromptTemplatePipelineLibrary
10
- */
11
- type PromptTemplatePipelineLibraryOptions = {
12
- /**
13
- * The library of prompt template pipelines
14
- */
15
- readonly library: Record<string_name, PromptTemplatePipelineJson>;
16
- /**
17
- * Optional settings for creating a PromptTemplatePipelineExecutor
18
- */
19
- readonly settings?: Partial<CreatePtpExecutorSettings>;
20
- };
21
- /**
22
- * Library of prompt template pipelines that groups together prompt template pipelines for an application. This is a very thin wrapper around the Array / Set of prompt template pipelines.
23
- *
24
- * Prompt Template Pipeline library is a useful helper in execution, it can be shared between execution and consumer parts of the app and make common knowledge about prompt template pipelines.
25
- *
26
- * It allows to create executor functions from prompt template pipelines in the library.
27
- *
28
- * @see https://github.com/webgptorg/promptbook#prompt-template-pipeline-library
29
- */
30
- export declare class PromptTemplatePipelineLibrary {
31
- readonly options: PromptTemplatePipelineLibraryOptions;
32
- /**
33
- * Constructs PromptTemplatePipeline from any sources
34
- *
35
- * Note: During the construction syntax and logic of all sources are validated
36
- * Note: You can combine .ptbk.md and .ptbk.json files BUT it is not recommended
37
- *
38
- * @param ptbkSources contents of .ptbk.md or .ptbk.json files
39
- * @param settings settings for creating executor functions
40
- * @returns PromptTemplatePipelineLibrary
41
- */
42
- static fromSources(ptbkSources: Record<string_name, PromptTemplatePipelineJson | PromptTemplatePipelineString>, settings?: Partial<CreatePtpExecutorSettings>): PromptTemplatePipelineLibrary;
43
- private constructor();
44
- /**
45
- * Gets prompt template pipeline by name
46
- */
47
- getPtp(name: string_name): PromptTemplatePipelineJson;
48
- /**
49
- * Checks whether prompt is in the library
50
- */
51
- isPromptInLibrary(prompt: Prompt): boolean;
52
- /**
53
- * Gets executor function for given prompt template pipeline
54
- */
55
- createExecutor(name: string_name, tools: ExecutionTools): PtpExecutor;
56
- }
57
- export {};
58
- /**
59
- * TODO: !!! This should be renamed to Promptbook
60
- * TODO: !! [👐][🧠] Split of PromptTemplatePipeline,PromptTemplatePipelineLibrary between interface and class
61
- * TODO: !! [👐] Make promptTemplatePipelines private WHEN split between interface and class
62
- * TODO: [🧠] Maybe isPromptInLibrary should be separate utility function
63
- * TODO: [🧠] Maybe createExecutor should be separate utility function
64
- * TODO: Static method fromDirectory
65
- * TODO: [🤜] Add generic type for entry and result parameters
66
- * TODO: [🧠] Is it better to ptbkLibrary.executePtp('writeXyz',{...}) OR ptbkLibrary.createExecutor('writeXyz')({...}) OR createExecutor(ptbkLibrary.getPtp('writeXyz'))
67
- * TODO: [🧠] Formarly (before commit 62229afce7668a5b85077cc18becf798b583bf8d) there were two classes PromptTemplatePipelineLibrary+PtpLibraryExecutor (maybe it was better?)
68
- * TODO: [🧠] Is it better to pass tools into getExecutor or into constructor
69
- * Maybe it is not a good idea to cache executors when they are can be created with different tools
70
- * TODO: [👧] Strongly type the executors to avoid need of remove nullables whtn noUncheckedIndexedAccess in tsconfig.json
71
- */
@@ -1,12 +0,0 @@
1
- import { ModelRequirements } from './types/ModelRequirements';
2
- /**
3
- * Default model requirements for the pipeline
4
- *
5
- * Note: As default, we use the chat model gpt-3.5-turbo. For most tasks, this is the best model with most intuitive usage.
6
- * GPT-4 is overkill for most tasks so keeping it as opt-in option.
7
- */
8
- export declare const DEFAULT_MODEL_REQUIREMENTS: ModelRequirements;
9
- /**
10
- * TODO: !!! Different default model for different model variant
11
- * TODO: [🧠] What should be the default model?
12
- */
@@ -1,12 +0,0 @@
1
- import { PromptTemplatePipelineJson } from '../types/PromptTemplatePipelineJson/PromptTemplatePipelineJson';
2
- import { PromptTemplatePipelineString } from '../types/PromptTemplatePipelineString';
3
- /**
4
- * Import the text file
5
- *
6
- * Note: Using here custom import to work in jest tests
7
- * Note: Using sync version is 💩 in the production code, but it's ok here in tests
8
- *
9
- * @private
10
- */
11
- export declare function importPtp(path: `${string}.ptbk.md`): PromptTemplatePipelineString;
12
- export declare function importPtp(path: `${string}.ptbk.json`): PromptTemplatePipelineJson;
@@ -1,13 +0,0 @@
1
- import { PromptTemplatePipelineJson } from '../types/PromptTemplatePipelineJson/PromptTemplatePipelineJson';
2
- import { PromptTemplatePipelineString } from '../types/PromptTemplatePipelineString';
3
- /**
4
- * Parse prompt template pipeline from string format to JSON format
5
- *
6
- * Note: This function does not validate logic of the pipeline only the syntax
7
- */
8
- export declare function promptTemplatePipelineStringToJson(promptTemplatePipelineString: PromptTemplatePipelineString): PromptTemplatePipelineJson;
9
- /**
10
- * TODO: Report here line/column of error
11
- * TODO: Use spaceTrim more effectively
12
- * TODO: [🧠] Parameter flags - isInput, isOutput, isInternal
13
- */
@@ -1,26 +0,0 @@
1
- import type { PromptTemplatePipelineJson } from '../types/PromptTemplatePipelineJson/PromptTemplatePipelineJson';
2
- /**
3
- * Validates PromptTemplatePipelineJson if it is logically valid.
4
- *
5
- * It checks:
6
- * - if it has correct parameters dependency
7
- *
8
- * It does NOT check:
9
- * - if it is valid json
10
- * - if it is meaningful
11
- *
12
- * @param ptp valid or invalid PromptTemplatePipelineJson
13
- * @throws {Error} if invalid
14
- */
15
- export declare function validatePromptTemplatePipelineJson(ptp: PromptTemplatePipelineJson): void;
16
- /**
17
- * TODO: [🧠] Work with ptbkVersion
18
- * TODO: Use here some json-schema, Zod or something similar and change it to:
19
- * > /**
20
- * > * Validates PromptTemplatePipelineJson if it is logically valid.
21
- * > *
22
- * > * It checks:
23
- * > * - it has a valid structure
24
- * > * - ...
25
- * > ex port function validatePromptTemplatePipelineJson(ptp: unknown): asserts ptp is PromptTemplatePipelineJson {
26
- */