@promptbook/openai 0.35.0 → 0.36.1

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 (112) hide show
  1. package/README.md +1 -1
  2. package/esm/index.es.js +10 -10
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/_packages/core.index.d.ts +8 -8
  5. package/esm/typings/_packages/remote-server.index.d.ts +2 -2
  6. package/esm/typings/_packages/types.index.d.ts +8 -8
  7. package/esm/typings/classes/PromptbookLibrary.d.ts +61 -0
  8. package/esm/typings/conversion/_importPromptbook.d.ts +12 -0
  9. package/esm/typings/conversion/promptbookStringToJson.d.ts +13 -0
  10. package/esm/typings/conversion/validatePromptbookJson.d.ts +26 -0
  11. package/{umd/typings/execution/PtpExecutor.d.ts → esm/typings/execution/PromptbookExecutor.d.ts} +5 -5
  12. package/esm/typings/execution/assertsExecutionSuccessful.d.ts +2 -2
  13. package/esm/typings/execution/createPromptbookExecutor.d.ts +40 -0
  14. package/esm/typings/execution/plugins/natural-execution-tools/mocked/joker.test.d.ts +1 -1
  15. package/esm/typings/execution/plugins/natural-execution-tools/mocked/mocked-chat.test.d.ts +1 -1
  16. package/esm/typings/execution/plugins/natural-execution-tools/mocked/mocked-completion.test.d.ts +1 -1
  17. package/esm/typings/execution/plugins/natural-execution-tools/remote/RemoteNaturalExecutionToolsOptions.d.ts +1 -1
  18. package/esm/typings/execution/plugins/natural-execution-tools/remote/interfaces/{Ptps_Error.d.ts → Promptbook_Server_Error.d.ts} +1 -1
  19. package/esm/typings/execution/plugins/natural-execution-tools/remote/interfaces/{Ptps_Progress.d.ts → Promptbook_Server_Progress.d.ts} +1 -1
  20. package/esm/typings/execution/plugins/natural-execution-tools/remote/interfaces/{Ptps_Request.d.ts → Promptbook_Server_Request.d.ts} +2 -2
  21. package/esm/typings/execution/plugins/natural-execution-tools/remote/interfaces/{Ptps_Response.d.ts → Promptbook_Server_Response.d.ts} +2 -2
  22. package/esm/typings/execution/plugins/natural-execution-tools/remote/interfaces/RemoteServerOptions.d.ts +3 -3
  23. 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
  24. package/esm/typings/types/Command.d.ts +12 -12
  25. package/esm/typings/types/Parameters.d.ts +3 -3
  26. package/esm/typings/types/Prompt.d.ts +5 -5
  27. package/{umd/typings/types/PromptTemplatePipelineJson → esm/typings/types/PromptbookJson}/PromptTemplateJson.d.ts +4 -4
  28. package/esm/typings/types/{PromptTemplatePipelineJson → PromptbookJson}/PromptTemplateParameterJson.d.ts +2 -2
  29. package/{umd/typings/types/PromptTemplatePipelineJson/PromptTemplatePipelineJson.d.ts → esm/typings/types/PromptbookJson/PromptbookJson.d.ts} +11 -15
  30. package/esm/typings/types/PromptbookString.d.ts +12 -0
  31. package/esm/typings/types/TaskProgress.d.ts +1 -1
  32. package/esm/typings/types/execution-report/ExecutionReportJson.d.ts +10 -10
  33. package/esm/typings/types/typeAliases.d.ts +4 -4
  34. package/esm/typings/utils/expectation-counters/countCharacters.d.ts +1 -1
  35. package/esm/typings/utils/expectation-counters/countLines.d.ts +1 -1
  36. package/esm/typings/utils/expectation-counters/countPages.d.ts +1 -1
  37. package/esm/typings/utils/expectation-counters/countParagraphs.d.ts +1 -1
  38. package/esm/typings/utils/expectation-counters/countSentences.d.ts +1 -1
  39. package/esm/typings/utils/expectation-counters/countWords.d.ts +1 -1
  40. package/esm/typings/utils/expectation-counters/index.d.ts +1 -1
  41. package/esm/typings/utils/isRunningInWhatever.d.ts +12 -0
  42. package/esm/typings/utils/markdown/addAutoGeneratedSection.d.ts +10 -0
  43. package/esm/typings/utils/markdown/createMarkdownChart.d.ts +4 -0
  44. package/esm/typings/version.d.ts +1 -1
  45. package/package.json +2 -2
  46. package/umd/index.umd.js +10 -10
  47. package/umd/index.umd.js.map +1 -1
  48. package/umd/typings/_packages/core.index.d.ts +8 -8
  49. package/umd/typings/_packages/remote-server.index.d.ts +2 -2
  50. package/umd/typings/_packages/types.index.d.ts +8 -8
  51. package/umd/typings/classes/PromptbookLibrary.d.ts +61 -0
  52. package/umd/typings/conversion/_importPromptbook.d.ts +12 -0
  53. package/umd/typings/conversion/promptbookStringToJson.d.ts +13 -0
  54. package/umd/typings/conversion/validatePromptbookJson.d.ts +26 -0
  55. package/umd/typings/conversion/validatePromptbookJson.test.d.ts +1 -0
  56. package/{esm/typings/execution/PtpExecutor.d.ts → umd/typings/execution/PromptbookExecutor.d.ts} +5 -5
  57. package/umd/typings/execution/assertsExecutionSuccessful.d.ts +2 -2
  58. package/umd/typings/execution/createPromptbookExecutor.d.ts +40 -0
  59. package/umd/typings/execution/plugins/natural-execution-tools/mocked/joker.test.d.ts +1 -1
  60. package/umd/typings/execution/plugins/natural-execution-tools/mocked/mocked-chat.test.d.ts +1 -1
  61. package/umd/typings/execution/plugins/natural-execution-tools/mocked/mocked-completion.test.d.ts +1 -1
  62. package/umd/typings/execution/plugins/natural-execution-tools/remote/RemoteNaturalExecutionToolsOptions.d.ts +1 -1
  63. package/umd/typings/execution/plugins/natural-execution-tools/remote/interfaces/{Ptps_Error.d.ts → Promptbook_Server_Error.d.ts} +1 -1
  64. package/umd/typings/execution/plugins/natural-execution-tools/remote/interfaces/{Ptps_Progress.d.ts → Promptbook_Server_Progress.d.ts} +1 -1
  65. package/umd/typings/execution/plugins/natural-execution-tools/remote/interfaces/{Ptps_Request.d.ts → Promptbook_Server_Request.d.ts} +2 -2
  66. package/umd/typings/execution/plugins/natural-execution-tools/remote/interfaces/{Ptps_Response.d.ts → Promptbook_Server_Response.d.ts} +2 -2
  67. package/umd/typings/execution/plugins/natural-execution-tools/remote/interfaces/RemoteServerOptions.d.ts +3 -3
  68. 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
  69. package/umd/typings/types/Command.d.ts +12 -12
  70. package/umd/typings/types/Parameters.d.ts +3 -3
  71. package/umd/typings/types/Prompt.d.ts +5 -5
  72. package/{esm/typings/types/PromptTemplatePipelineJson → umd/typings/types/PromptbookJson}/PromptTemplateJson.d.ts +4 -4
  73. package/umd/typings/types/{PromptTemplatePipelineJson → PromptbookJson}/PromptTemplateParameterJson.d.ts +2 -2
  74. package/{esm/typings/types/PromptTemplatePipelineJson/PromptTemplatePipelineJson.d.ts → umd/typings/types/PromptbookJson/PromptbookJson.d.ts} +11 -15
  75. package/umd/typings/types/PromptbookString.d.ts +12 -0
  76. package/umd/typings/types/TaskProgress.d.ts +1 -1
  77. package/umd/typings/types/execution-report/ExecutionReportJson.d.ts +10 -10
  78. package/umd/typings/types/typeAliases.d.ts +4 -4
  79. package/umd/typings/utils/expectation-counters/countCharacters.d.ts +1 -1
  80. package/umd/typings/utils/expectation-counters/countLines.d.ts +1 -1
  81. package/umd/typings/utils/expectation-counters/countPages.d.ts +1 -1
  82. package/umd/typings/utils/expectation-counters/countParagraphs.d.ts +1 -1
  83. package/umd/typings/utils/expectation-counters/countSentences.d.ts +1 -1
  84. package/umd/typings/utils/expectation-counters/countWords.d.ts +1 -1
  85. package/umd/typings/utils/expectation-counters/index.d.ts +1 -1
  86. package/umd/typings/utils/isRunningInWhatever.d.ts +12 -0
  87. package/umd/typings/utils/markdown/addAutoGeneratedSection.d.ts +10 -0
  88. package/umd/typings/utils/markdown/addAutoGeneratedSection.test.d.ts +1 -0
  89. package/umd/typings/utils/markdown/createMarkdownChart.d.ts +4 -0
  90. package/umd/typings/version.d.ts +1 -1
  91. package/esm/typings/classes/PromptTemplatePipelineLibrary.d.ts +0 -71
  92. package/esm/typings/config.d.ts +0 -12
  93. package/esm/typings/conversion/_importPtp.d.ts +0 -12
  94. package/esm/typings/conversion/promptTemplatePipelineStringToJson.d.ts +0 -13
  95. package/esm/typings/conversion/validatePromptTemplatePipelineJson.d.ts +0 -26
  96. package/esm/typings/execution/createPtpExecutor.d.ts +0 -40
  97. package/esm/typings/types/PromptTemplatePipelineString.d.ts +0 -16
  98. package/umd/typings/classes/PromptTemplatePipelineLibrary.d.ts +0 -71
  99. package/umd/typings/config.d.ts +0 -12
  100. package/umd/typings/conversion/_importPtp.d.ts +0 -12
  101. package/umd/typings/conversion/promptTemplatePipelineStringToJson.d.ts +0 -13
  102. package/umd/typings/conversion/validatePromptTemplatePipelineJson.d.ts +0 -26
  103. package/umd/typings/execution/createPtpExecutor.d.ts +0 -40
  104. package/umd/typings/types/PromptTemplatePipelineString.d.ts +0 -16
  105. /package/esm/typings/conversion/{promptTemplatePipelineStringToJson-syntaxErrors.test.d.ts → promptbookStringToJson-syntaxErrors.test.d.ts} +0 -0
  106. /package/esm/typings/conversion/{promptTemplatePipelineStringToJson.test.d.ts → promptbookStringToJson.test.d.ts} +0 -0
  107. /package/esm/typings/conversion/{validatePromptTemplatePipelineJson-logicErrors.test.d.ts → validatePromptbookJson-logicErrors.test.d.ts} +0 -0
  108. /package/esm/typings/conversion/{validatePromptTemplatePipelineJson.test.d.ts → validatePromptbookJson.test.d.ts} +0 -0
  109. /package/{umd/typings/conversion/promptTemplatePipelineStringToJson-syntaxErrors.test.d.ts → esm/typings/utils/markdown/addAutoGeneratedSection.test.d.ts} +0 -0
  110. /package/umd/typings/conversion/{promptTemplatePipelineStringToJson.test.d.ts → promptbookStringToJson-syntaxErrors.test.d.ts} +0 -0
  111. /package/umd/typings/conversion/{validatePromptTemplatePipelineJson-logicErrors.test.d.ts → promptbookStringToJson.test.d.ts} +0 -0
  112. /package/umd/typings/conversion/{validatePromptTemplatePipelineJson.test.d.ts → validatePromptbookJson-logicErrors.test.d.ts} +0 -0
@@ -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;
@@ -0,0 +1,10 @@
1
+ import type { string_markdown, string_name } from '../../types/typeAliases';
2
+ /**
3
+ * Add or modify an auto-generated section in a markdown file
4
+ *
5
+ * @private within the library
6
+ */
7
+ export declare function addAutoGeneratedSection(content: string_markdown, options: {
8
+ sectionName: string_name;
9
+ sectionContent: string_markdown;
10
+ }): string_markdown;
@@ -35,3 +35,7 @@ type CreateMarkdownChartOptions = {
35
35
  */
36
36
  export declare function createMarkdownChart(options: CreateMarkdownChartOptions): string_markdown;
37
37
  export {};
38
+ /**
39
+ * TODO: Maybe use Mermain Gant Diagrams
40
+ * @see https://jojozhuang.github.io/tutorial/mermaid-cheat-sheet/
41
+ */
@@ -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
- */
@@ -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
- */