@promptbook/openai 0.61.0-1 → 0.61.0-10

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 (159) hide show
  1. package/esm/index.es.js +1 -1
  2. package/esm/typings/promptbook-collection/index.d.ts +118 -26
  3. package/esm/typings/src/_packages/core.index.d.ts +5 -1
  4. package/esm/typings/src/_packages/types.index.d.ts +5 -3
  5. package/esm/typings/src/_packages/utils.index.d.ts +1 -2
  6. package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +1 -1
  7. package/esm/typings/src/collection/constructors/createCollectionFromUrl.d.ts +2 -2
  8. package/esm/typings/src/collection/constructors/justTestFsImport.d.ts +1 -1
  9. package/esm/typings/src/commands/MODEL/ModelCommand.d.ts +1 -1
  10. package/esm/typings/src/commands/PERSONA/PersonaCommand.d.ts +4 -2
  11. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +12 -12
  12. package/esm/typings/src/config.d.ts +4 -0
  13. package/esm/typings/src/conversion/pipelineStringToJson.d.ts +8 -5
  14. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +3 -3
  15. package/esm/typings/src/conversion/prettify/PrettifyOptions.d.ts +2 -2
  16. package/esm/typings/src/conversion/utils/renameParameter.d.ts +3 -3
  17. package/esm/typings/src/conversion/validation/_importPipeline.d.ts +2 -2
  18. package/esm/typings/src/errors/VersionMismatch.d.ts +8 -0
  19. package/esm/typings/src/execution/PipelineExecutor.d.ts +5 -5
  20. package/esm/typings/src/execution/PromptResult.d.ts +5 -5
  21. package/esm/typings/src/execution/ScriptExecutionTools.d.ts +3 -3
  22. package/esm/typings/src/execution/UserInterfaceTools.d.ts +5 -5
  23. package/esm/typings/src/execution/createPipelineExecutor.d.ts +2 -1
  24. package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +2 -2
  25. package/esm/typings/src/execution/utils/forEachAsync.d.ts +1 -1
  26. package/esm/typings/src/formats/csv/ListFormatDefinition.d.ts +1 -1
  27. package/esm/typings/src/formats/json/JsonFormatDefinition.d.ts +1 -1
  28. package/esm/typings/src/formats/list/ListFormatDefinition.d.ts +1 -1
  29. package/esm/typings/src/knowledge/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +1 -1
  30. package/esm/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.d.ts +18 -0
  31. package/esm/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.test.d.ts +1 -0
  32. package/esm/typings/src/knowledge/prepare-knowledge/_common/utils/getLlmToolsForTests.d.ts +7 -0
  33. package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +8 -23
  34. package/esm/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +7 -14
  35. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
  36. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +2 -2
  37. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +5 -5
  38. package/esm/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +1 -1
  39. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +2 -2
  40. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionToolsOptions.d.ts +1 -1
  41. package/esm/typings/src/personas/preparePersona.d.ts +13 -0
  42. package/esm/typings/src/personas/preparePersona.test.d.ts +1 -0
  43. package/esm/typings/src/prepare/PrepareOptions.d.ts +22 -0
  44. package/esm/typings/src/prepare/preparePipeline.d.ts +15 -0
  45. package/esm/typings/src/prepare/unpreparePipeline.d.ts +8 -0
  46. package/esm/typings/src/scripting/javascript/JavascriptExecutionToolsOptions.d.ts +1 -1
  47. package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
  48. package/esm/typings/src/types/ModelRequirements.d.ts +2 -1
  49. package/esm/typings/src/types/Parameters.d.ts +1 -0
  50. package/esm/typings/src/types/PipelineJson/Expectations.d.ts +6 -2
  51. package/esm/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +67 -0
  52. package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +24 -0
  53. package/esm/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +8 -1
  54. package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +40 -0
  55. package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +27 -2
  56. package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +25 -0
  57. package/esm/typings/src/types/PipelineJson/PromptDialogJson.d.ts +2 -0
  58. package/esm/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +1 -1
  59. package/esm/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +7 -1
  60. package/esm/typings/src/types/PipelineJson/ScriptJson.d.ts +2 -0
  61. package/esm/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +2 -0
  62. package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +4 -4
  63. package/esm/typings/src/types/execution-report/ExecutionReportStringOptions.d.ts +3 -3
  64. package/esm/typings/src/types/typeAliases.d.ts +27 -13
  65. package/esm/typings/src/utils/FromtoItems.d.ts +3 -3
  66. package/esm/typings/src/utils/currentDate.d.ts +7 -0
  67. package/esm/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +2 -2
  68. package/esm/typings/src/utils/markdown/createMarkdownChart.d.ts +6 -9
  69. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +2 -2
  70. package/esm/typings/src/utils/markdown/parseMarkdownSection.d.ts +3 -3
  71. package/esm/typings/src/utils/organization/TODO.d.ts +4 -0
  72. package/esm/typings/src/utils/organization/TODO_USE.d.ts +11 -0
  73. package/esm/typings/src/utils/organization/___.d.ts +4 -0
  74. package/esm/typings/src/utils/organization/really_any.d.ts +4 -0
  75. package/package.json +2 -2
  76. package/umd/index.umd.js +1 -1
  77. package/umd/typings/promptbook-collection/index.d.ts +118 -26
  78. package/umd/typings/src/_packages/core.index.d.ts +5 -1
  79. package/umd/typings/src/_packages/types.index.d.ts +5 -3
  80. package/umd/typings/src/_packages/utils.index.d.ts +1 -2
  81. package/umd/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +1 -1
  82. package/umd/typings/src/collection/constructors/createCollectionFromUrl.d.ts +2 -2
  83. package/umd/typings/src/collection/constructors/justTestFsImport.d.ts +1 -1
  84. package/umd/typings/src/commands/MODEL/ModelCommand.d.ts +1 -1
  85. package/umd/typings/src/commands/PERSONA/PersonaCommand.d.ts +4 -2
  86. package/umd/typings/src/commands/_common/types/CommandParser.d.ts +12 -12
  87. package/umd/typings/src/config.d.ts +4 -0
  88. package/umd/typings/src/conversion/pipelineStringToJson.d.ts +8 -5
  89. package/umd/typings/src/conversion/pipelineStringToJsonSync.d.ts +3 -3
  90. package/umd/typings/src/conversion/prettify/PrettifyOptions.d.ts +2 -2
  91. package/umd/typings/src/conversion/utils/renameParameter.d.ts +3 -3
  92. package/umd/typings/src/conversion/validation/_importPipeline.d.ts +2 -2
  93. package/umd/typings/src/errors/VersionMismatch.d.ts +8 -0
  94. package/umd/typings/src/execution/PipelineExecutor.d.ts +5 -5
  95. package/umd/typings/src/execution/PromptResult.d.ts +5 -5
  96. package/umd/typings/src/execution/ScriptExecutionTools.d.ts +3 -3
  97. package/umd/typings/src/execution/UserInterfaceTools.d.ts +5 -5
  98. package/umd/typings/src/execution/createPipelineExecutor.d.ts +2 -1
  99. package/umd/typings/src/execution/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +2 -2
  100. package/umd/typings/src/execution/utils/forEachAsync.d.ts +1 -1
  101. package/umd/typings/src/formats/csv/ListFormatDefinition.d.ts +1 -1
  102. package/umd/typings/src/formats/json/JsonFormatDefinition.d.ts +1 -1
  103. package/umd/typings/src/formats/list/ListFormatDefinition.d.ts +1 -1
  104. package/umd/typings/src/knowledge/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +1 -1
  105. package/umd/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.d.ts +18 -0
  106. package/umd/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.test.d.ts +1 -0
  107. package/umd/typings/src/knowledge/prepare-knowledge/_common/utils/getLlmToolsForTests.d.ts +7 -0
  108. package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +8 -23
  109. package/umd/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +7 -14
  110. package/umd/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
  111. package/umd/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +2 -2
  112. package/umd/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +5 -5
  113. package/umd/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +1 -1
  114. package/umd/typings/src/llm-providers/openai/openai-models.d.ts +2 -2
  115. package/umd/typings/src/llm-providers/remote/RemoteLlmExecutionToolsOptions.d.ts +1 -1
  116. package/umd/typings/src/personas/preparePersona.d.ts +13 -0
  117. package/umd/typings/src/personas/preparePersona.test.d.ts +1 -0
  118. package/umd/typings/src/prepare/PrepareOptions.d.ts +22 -0
  119. package/umd/typings/src/prepare/preparePipeline.d.ts +15 -0
  120. package/umd/typings/src/prepare/unpreparePipeline.d.ts +8 -0
  121. package/umd/typings/src/scripting/javascript/JavascriptExecutionToolsOptions.d.ts +1 -1
  122. package/umd/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
  123. package/umd/typings/src/types/ModelRequirements.d.ts +2 -1
  124. package/umd/typings/src/types/Parameters.d.ts +1 -0
  125. package/umd/typings/src/types/PipelineJson/Expectations.d.ts +6 -2
  126. package/umd/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +67 -0
  127. package/umd/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +24 -0
  128. package/umd/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +8 -1
  129. package/umd/typings/src/types/PipelineJson/PersonaJson.d.ts +40 -0
  130. package/umd/typings/src/types/PipelineJson/PipelineJson.d.ts +27 -2
  131. package/umd/typings/src/types/PipelineJson/PreparationJson.d.ts +25 -0
  132. package/umd/typings/src/types/PipelineJson/PromptDialogJson.d.ts +2 -0
  133. package/umd/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +1 -1
  134. package/umd/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +7 -1
  135. package/umd/typings/src/types/PipelineJson/ScriptJson.d.ts +2 -0
  136. package/umd/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +2 -0
  137. package/umd/typings/src/types/execution-report/ExecutionReportJson.d.ts +4 -4
  138. package/umd/typings/src/types/execution-report/ExecutionReportStringOptions.d.ts +3 -3
  139. package/umd/typings/src/types/typeAliases.d.ts +27 -13
  140. package/umd/typings/src/utils/FromtoItems.d.ts +3 -3
  141. package/umd/typings/src/utils/currentDate.d.ts +7 -0
  142. package/umd/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +2 -2
  143. package/umd/typings/src/utils/markdown/createMarkdownChart.d.ts +6 -9
  144. package/umd/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +2 -2
  145. package/umd/typings/src/utils/markdown/parseMarkdownSection.d.ts +3 -3
  146. package/umd/typings/src/utils/organization/TODO.d.ts +4 -0
  147. package/umd/typings/src/utils/organization/TODO_USE.d.ts +11 -0
  148. package/umd/typings/src/utils/organization/___.d.ts +4 -0
  149. package/umd/typings/src/utils/organization/really_any.d.ts +4 -0
  150. package/esm/typings/src/personas/personaToModelRequirements.d.ts +0 -6
  151. package/esm/typings/src/types/PipelineJson/KnowledgeJson.d.ts +0 -6
  152. package/esm/typings/src/types/PipelineJson/MaterialKnowledgePieceJson.d.ts +0 -28
  153. package/umd/typings/src/personas/personaToModelRequirements.d.ts +0 -6
  154. package/umd/typings/src/types/PipelineJson/KnowledgeJson.d.ts +0 -6
  155. package/umd/typings/src/types/PipelineJson/MaterialKnowledgePieceJson.d.ts +0 -28
  156. /package/esm/typings/src/_packages/{markdown-utils.d.ts → markdown-utils.index.d.ts} +0 -0
  157. /package/esm/typings/src/utils/{just.d.ts → organization/just.d.ts} +0 -0
  158. /package/umd/typings/src/_packages/{markdown-utils.d.ts → markdown-utils.index.d.ts} +0 -0
  159. /package/umd/typings/src/utils/{just.d.ts → organization/just.d.ts} +0 -0
@@ -2,7 +2,7 @@ import type { Promisable } from 'type-fest';
2
2
  import type { CommonExecutionToolsOptions } from '../../../execution/CommonExecutionToolsOptions';
3
3
  import type { UserInterfaceToolsPromptDialogOptions } from '../../../execution/UserInterfaceTools';
4
4
  /**
5
- * Options for CallbackInterfaceTools
5
+ * Options for `CallbackInterfaceTools`
6
6
  */
7
7
  export type CallbackInterfaceToolsOptions = CommonExecutionToolsOptions & {
8
8
  /**
@@ -0,0 +1,18 @@
1
+ import type { PrepareOptions } from '../../../prepare/PrepareOptions';
2
+ import type { KnowledgePiecePreparedJson } from '../../../types/PipelineJson/KnowledgePieceJson';
3
+ import type { KnowledgeSourceJson } from '../../../types/PipelineJson/KnowledgeSourceJson';
4
+ /**
5
+ * Prepares the knowle
6
+ *
7
+ * @see https://github.com/webgptorg/promptbook/discussions/41
8
+ * @private within the package
9
+ */
10
+ export declare function prepareKnowledgePieces(knowledgeSources: Array<KnowledgeSourceJson>, options: PrepareOptions): Promise<Array<Omit<KnowledgePiecePreparedJson, 'preparationIds'>>>;
11
+ /**
12
+ * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
13
+ * Put `knowledgePieces` into `PrepareKnowledgeOptions`
14
+ * TODO: [🪂] More than max things can run in parallel by acident [1,[2a,2b,_],[3a,3b,_]]
15
+ * TODO: [🧠][❎] Do here propper M:N mapping
16
+ * [x] One source can make multiple pieces
17
+ * [ ] One piece can have multiple sources
18
+ */
@@ -0,0 +1,7 @@
1
+ import type { LlmExecutionTools } from '../../../../execution/LlmExecutionTools';
2
+ /**
3
+ * Returns LLM tools for testing purposes
4
+ *
5
+ * @private within the package - JUST FOR TESTS
6
+ */
7
+ export declare function getLlmToolsForTests(): LlmExecutionTools;
@@ -1,26 +1,11 @@
1
- import type { LlmExecutionTools } from '../../../execution/LlmExecutionTools';
2
- import type { KnowledgeJson } from '../../../types/PipelineJson/KnowledgeJson';
1
+ import type { PrepareOptions } from '../../../prepare/PrepareOptions';
2
+ import type { KnowledgePiecePreparedJson } from '../../../types/PipelineJson/KnowledgePieceJson';
3
3
  import type { string_markdown } from '../../../types/typeAliases';
4
- type PrepareKnowledgeFromMarkdownOptions = {
5
- /**
6
- * The source of the knowledge in markdown format
7
- */
8
- content: string_markdown;
9
- /**
10
- * The LLM tools to use for the conversion and extraction of knowledge
11
- *
12
- * Note: If you want to use multiple LLMs, you can use `joinLlmExecutionTools` to join them first
13
- */
14
- llmTools: LlmExecutionTools;
15
- /**
16
- * If true, the preaparation of knowledge logs additional information
17
- *
18
- * @default false
19
- */
20
- isVerbose?: boolean;
21
- };
22
- export declare function prepareKnowledgeFromMarkdown(options: PrepareKnowledgeFromMarkdownOptions): Promise<KnowledgeJson>;
23
- export {};
24
4
  /**
25
- * 11:11
5
+ * @@@
6
+ */
7
+ export declare function prepareKnowledgeFromMarkdown(content: string_markdown, options: PrepareOptions): Promise<Array<Omit<KnowledgePiecePreparedJson, 'sources' | 'preparationIds'>>>;
8
+ /**
9
+ * TODO: [🪂] Do it in parallel 11:11
10
+ * Note: No need to aggregate usage here, it is done by intercepting the llmTools
26
11
  */
@@ -1,19 +1,12 @@
1
- import type { LlmExecutionTools } from '../../../execution/LlmExecutionTools';
2
- import type { KnowledgeJson } from '../../../types/PipelineJson/KnowledgeJson';
1
+ import type { PrepareOptions } from '../../../prepare/PrepareOptions';
2
+ import type { KnowledgePiecePreparedJson } from '../../../types/PipelineJson/KnowledgePieceJson';
3
3
  import type { string_base64 } from '../../../types/typeAliases';
4
- type PrepareKnowledgeFromPdfOptions = {
5
- /**
6
- * The source of the knowledge in PDF format
7
- */
8
- content: string_base64;
9
- /**
10
- * The LLM tools to use for the conversion and extraction of knowledge
11
- */
12
- llmTools: LlmExecutionTools;
13
- };
14
- export declare function prepareKnowledgeFromPdf(options: PrepareKnowledgeFromPdfOptions): Promise<KnowledgeJson>;
15
- export {};
4
+ /**
5
+ * @@@
6
+ */
7
+ export declare function prepareKnowledgeFromPdf(content: string_base64, options: PrepareOptions): Promise<Array<Omit<KnowledgePiecePreparedJson, 'sources' | 'preparationIds'>>>;
16
8
  /**
17
9
  * TODO: [🧺] In future, content can be alse File or Blob BUT for now for wider compatibility its only base64
18
10
  * @see https://stackoverflow.com/questions/14653349/node-js-cant-create-blobs
11
+ * TODO: [🪂] Do it in parallel
19
12
  */
@@ -1,7 +1,7 @@
1
1
  import type { ClientOptions } from '@anthropic-ai/sdk';
2
2
  import type { CommonExecutionToolsOptions } from '../../execution/CommonExecutionToolsOptions';
3
3
  /**
4
- * Options for AnthropicClaudeExecutionTools
4
+ * Options for `AnthropicClaudeExecutionTools`
5
5
  *
6
6
  * This extends Anthropic's `ClientOptions` with are directly passed to the Anthropic client.
7
7
  */
@@ -9,8 +9,8 @@ import type { number_usd } from '../../types/typeAliases';
9
9
  */
10
10
  export declare const ANTHROPIC_CLAUDE_MODELS: Array<AvailableModel & {
11
11
  pricing?: {
12
- prompt: number_usd;
13
- output: number_usd;
12
+ readonly prompt: number_usd;
13
+ readonly output: number_usd;
14
14
  };
15
15
  }>;
16
16
  /**
@@ -2,7 +2,7 @@ import type { CommonExecutionToolsOptions } from '../../execution/CommonExecutio
2
2
  import type { string_name } from '../../types/typeAliases';
3
3
  import type { string_token } from '../../types/typeAliases';
4
4
  /**
5
- * Options for AzureOpenAiExecutionTools
5
+ * Options for `AzureOpenAiExecutionTools`
6
6
  *
7
7
  * @see https://oai.azure.com/portal/
8
8
  */
@@ -12,7 +12,7 @@ export type AzureOpenAiExecutionToolsOptions = CommonExecutionToolsOptions & {
12
12
  *
13
13
  * Note: Typically you have one resource and multiple deployments.
14
14
  */
15
- resourceName: string_name;
15
+ readonly resourceName: string_name;
16
16
  /**
17
17
  * The deployment name
18
18
  *
@@ -20,16 +20,16 @@ export type AzureOpenAiExecutionToolsOptions = CommonExecutionToolsOptions & {
20
20
  * Note: This is kind of a modelName in OpenAI terms
21
21
  * Note: Typically you have one resource and multiple deployments.
22
22
  */
23
- deploymentName: string_name;
23
+ readonly deploymentName: string_name;
24
24
  /**
25
25
  * The API key of the Azure OpenAI resource
26
26
  */
27
- apiKey: string_token;
27
+ readonly apiKey: string_token;
28
28
  /**
29
29
  * A unique identifier representing your end-user, which can help Azure OpenAI to monitor
30
30
  * and detect abuse.
31
31
  *
32
32
  * @see https://platform.openai.com/docs/guides/safety-best-practices/end-user-ids (document from OpenAI not Azure, but same concept)
33
33
  */
34
- user?: string_token;
34
+ readonly user?: string_token;
35
35
  };
@@ -2,7 +2,7 @@ import type { ClientOptions } from 'openai';
2
2
  import type { CommonExecutionToolsOptions } from '../../execution/CommonExecutionToolsOptions';
3
3
  import type { string_token } from '../../types/typeAliases';
4
4
  /**
5
- * Options for OpenAiExecutionTools
5
+ * Options for `OpenAiExecutionTools`
6
6
  *
7
7
  * This extends OpenAI's `ClientOptions` with are directly passed to the OpenAI client.
8
8
  * Rest is used by the `OpenAiExecutionTools`.
@@ -10,8 +10,8 @@ import type { number_usd } from '../../types/typeAliases';
10
10
  */
11
11
  export declare const OPENAI_MODELS: Array<AvailableModel & {
12
12
  pricing?: {
13
- prompt: number_usd;
14
- output: number_usd;
13
+ readonly prompt: number_usd;
14
+ readonly output: number_usd;
15
15
  };
16
16
  }>;
17
17
  /**
@@ -2,7 +2,7 @@ import type { CommonExecutionToolsOptions } from '../../execution/CommonExecutio
2
2
  import type { client_id } from '../../types/typeAliases';
3
3
  import type { string_uri } from '../../types/typeAliases';
4
4
  /**
5
- * Options for RemoteLlmExecutionTools
5
+ * Options for `RemoteLlmExecutionTools`
6
6
  */
7
7
  export type RemoteLlmExecutionToolsOptions = CommonExecutionToolsOptions & {
8
8
  /**
@@ -0,0 +1,13 @@
1
+ import type { PrepareOptions } from '../prepare/PrepareOptions';
2
+ import type { PersonaPreparedJson } from '../types/PipelineJson/PersonaJson';
3
+ import type { string_persona_description } from '../types/typeAliases';
4
+ /**
5
+ * Prepares the persona for the pipeline
6
+ *
7
+ * @see https://github.com/webgptorg/promptbook/discussions/22
8
+ * @private within the package
9
+ */
10
+ export declare function preparePersona(personaDescription: string_persona_description, options: PrepareOptions): Promise<PersonaPreparedJson['modelRequirements']>;
11
+ /**
12
+ * TODO: [🪂] Do it in parallel
13
+ */
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ import type { LlmExecutionTools } from '../execution/LlmExecutionTools';
2
+ /**
3
+ * Options for preparation of the pipeline
4
+ */
5
+ export type PrepareOptions = {
6
+ /**
7
+ * LLM tools
8
+ */
9
+ readonly llmTools: LlmExecutionTools;
10
+ /**
11
+ * Maximum number of tasks running in parallel
12
+ *
13
+ * @default MAX_PARALLEL_COUNT
14
+ */
15
+ readonly maxParallelCount?: number;
16
+ /**
17
+ * If true, the preparation logs additional information
18
+ *
19
+ * @default false
20
+ */
21
+ readonly isVerbose?: boolean;
22
+ };
@@ -0,0 +1,15 @@
1
+ import type { PipelineJson } from '../types/PipelineJson/PipelineJson';
2
+ import type { PrepareOptions } from './PrepareOptions';
3
+ /**
4
+ * Prepare pipeline from string (markdown) format to JSON format
5
+ *
6
+ * Note: This function does not validate logic of the pipeline
7
+ * Note: This function acts as part of compilation process
8
+ */
9
+ export declare function preparePipeline(pipeline: PipelineJson, options: PrepareOptions): Promise<PipelineJson>;
10
+ /**
11
+ * TODO: Write tests for `preparePipeline`
12
+ * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
13
+ * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
14
+ * TODO: [💸] Make utilities `interceptLlmTools` and `costLlmTools` to compute cost and DO put this counting logic in `prepareKnowledge` or `preparePersona`
15
+ */
@@ -0,0 +1,8 @@
1
+ import type { PipelineJson } from '../types/PipelineJson/PipelineJson';
2
+ /**
3
+ * Unprepare just strips the preparation data of the pipeline
4
+ */
5
+ export declare function unpreparePipeline(pipeline: PipelineJson): PipelineJson;
6
+ /**
7
+ * TODO: Write tests for `preparePipeline`
8
+ */
@@ -2,7 +2,7 @@ import type { Promisable } from 'type-fest';
2
2
  import type { CommonExecutionToolsOptions } from '../../execution/CommonExecutionToolsOptions';
3
3
  import type { string_javascript_name } from '../../types/typeAliases';
4
4
  /**
5
- * Options for javascript execution
5
+ * Options for `JavascriptExecutionTools`
6
6
  */
7
7
  export type JavascriptExecutionToolsOptions = CommonExecutionToolsOptions & {
8
8
  /**
@@ -1,4 +1,4 @@
1
- import type { really_any } from '../../../types/typeAliases';
1
+ import type { really_any } from '../../../utils/organization/really_any';
2
2
  /**
3
3
  * Does nothing, but preserves the function in the bundle
4
4
  * Compiler is tricked into thinking the function is used
@@ -37,7 +37,8 @@ export type ModelRequirements = {
37
37
  readonly maxTokens?: number;
38
38
  };
39
39
  /**
40
+ * TODO: !!!!! Add and use systemMessage, temprerature, top_k, top_p, presencePenalty, frequencyPenalty, bestOf, n, logitBias, logitBiasType, stop, ... to ModelRequirements
40
41
  * TODO: Maybe figure out better word than "variant"
41
42
  * TODO: Add here more requirement options like max context size, max tokens, etc.
42
- * TODO: [👙][🧠] Just selecting gpt3 or gpt4 level of model
43
+ * TODO: [💕][🧠] Just selecting gpt3 or gpt4 level of model
43
44
  */
@@ -10,5 +10,6 @@
10
10
  */
11
11
  export type Parameters = object;
12
12
  /**
13
+ * TODO: !!!!! Implement samples into parameters
13
14
  * TODO: Constrain type to Simple key-value object, only string keys and string values and no index signature + only camelCase keys and spaceTrimmed values
14
15
  */
@@ -6,21 +6,25 @@ import type { number_positive } from '../typeAliases';
6
6
  * For example 5 words, 3 sentences, 2 paragraphs, ...
7
7
  *
8
8
  * Note: Expectations are performed after all postprocessing steps
9
+ * @see https://github.com/webgptorg/promptbook/discussions/30
9
10
  */
10
11
  export type Expectations = Partial<Record<Lowercase<ExpectationUnit>, {
11
- min?: ExpectationAmount;
12
- max?: ExpectationAmount;
12
+ readonly min?: ExpectationAmount;
13
+ readonly max?: ExpectationAmount;
13
14
  }>>;
14
15
  /**
15
16
  * Units of text measurement
17
+ * @see https://github.com/webgptorg/promptbook/discussions/30
16
18
  */
17
19
  export declare const EXPECTATION_UNITS: readonly ["CHARACTERS", "WORDS", "SENTENCES", "LINES", "PARAGRAPHS", "PAGES"];
18
20
  /**
19
21
  * Unit of text measurement
22
+ * @see https://github.com/webgptorg/promptbook/discussions/30
20
23
  */
21
24
  export type ExpectationUnit = typeof EXPECTATION_UNITS[number];
22
25
  /**
23
26
  * Amount of text measurement
27
+ * @see https://github.com/webgptorg/promptbook/discussions/30
24
28
  */
25
29
  export type ExpectationAmount = number_integer & (number_positive | 0);
26
30
  /**
@@ -0,0 +1,67 @@
1
+ import type { EmbeddingVector } from '../../execution/EmbeddingVector';
2
+ import type { string_keyword } from '../../utils/normalization/IKeywords';
3
+ import type { number_id } from '../typeAliases';
4
+ import type { number_linecol_number } from '../typeAliases';
5
+ import type { string_markdown } from '../typeAliases';
6
+ import type { string_markdown_text } from '../typeAliases';
7
+ import type { string_model_name } from '../typeAliases';
8
+ import type { string_name } from '../typeAliases';
9
+ /**
10
+ * Defines one piece of knowledge in the pipeline
11
+ *
12
+ * Note: Knowledge piece is by definition prepared
13
+ *
14
+ * @see https://github.com/webgptorg/promptbook/discussions/41
15
+ */
16
+ export type KnowledgePiecePreparedJson = {
17
+ /**
18
+ * Unique name of the knowledge piece based on the title
19
+ */
20
+ readonly name?: string_name;
21
+ /**
22
+ * Short title for the information
23
+ */
24
+ readonly title?: string_markdown_text;
25
+ /**
26
+ * The information in markdown format
27
+ */
28
+ readonly content?: string_markdown;
29
+ /**
30
+ * List of sources where the information comes from
31
+ */
32
+ readonly sources: Array<{
33
+ /**
34
+ * Identifier of the source
35
+ */
36
+ readonly name: string_name;
37
+ /**
38
+ * Line number
39
+ */
40
+ readonly line?: number_linecol_number;
41
+ /**
42
+ * Column number
43
+ */
44
+ readonly column?: number_linecol_number;
45
+ }>;
46
+ /**
47
+ * List of keywords that are associated with the knowledge piece
48
+ */
49
+ readonly keywords: Array<string_keyword>;
50
+ /**
51
+ * List of models embeddings that are associated with the knowledge piece
52
+ */
53
+ readonly index: Array<{
54
+ /**
55
+ * Model name which generated the embedding
56
+ */
57
+ readonly modelName: string_model_name;
58
+ /**
59
+ * Embedding vector of the knowledge piece
60
+ */
61
+ readonly position: EmbeddingVector;
62
+ }>;
63
+ /**
64
+ * List of preparation ids that were used to prepare this knowledge piece
65
+ */
66
+ readonly preparationIds: Array<number_id>;
67
+ };
@@ -0,0 +1,24 @@
1
+ import type { number_id } from '../typeAliases';
2
+ import type { string_knowledge_source } from '../typeAliases';
3
+ import type { string_name } from '../typeAliases';
4
+ /**
5
+ * Defines one source of knowledge in the pipeline
6
+ * For example, a source of information, a fact, a quote, a definition, website, etc.
7
+ *
8
+ * @see https://github.com/webgptorg/promptbook/discussions/41
9
+ */
10
+ export type KnowledgeSourceJson = {
11
+ readonly name: string_name;
12
+ readonly source: string_knowledge_source;
13
+ };
14
+ /**
15
+ * Defines one source of knowledge in the pipeline after it has been prepared
16
+ *
17
+ * @see https://github.com/webgptorg/promptbook/discussions/41
18
+ */
19
+ export type KnowledgeSourcePreparedJson = KnowledgeSourceJson & {
20
+ /**
21
+ * List of preparation ids that were used to prepare this knowledge source to knowledge pieces
22
+ */
23
+ readonly preparationIds: Array<number_id>;
24
+ };
@@ -1,10 +1,15 @@
1
1
  import type { ModelRequirements } from '../ModelRequirements';
2
+ import type { string_name } from '../typeAliases';
2
3
  import type { PromptTemplateJsonCommon } from './PromptTemplateJsonCommon';
3
4
  /**
4
5
  * Template for prompt to LLM
5
6
  */
6
7
  export type LlmTemplateJson = PromptTemplateJsonCommon & {
7
8
  readonly blockType: 'PROMPT_TEMPLATE';
9
+ /**
10
+ * Name of the persona who will be responding to this prompt
11
+ */
12
+ readonly personaName: string_name | null;
8
13
  /**
9
14
  * Requirements for the model
10
15
  * - This is required only for blockType PROMPT_TEMPLATE
@@ -12,5 +17,7 @@ export type LlmTemplateJson = PromptTemplateJsonCommon & {
12
17
  readonly modelRequirements: ModelRequirements;
13
18
  };
14
19
  /**
15
- * TODO: [👙][🧠] Just selecting gpt3 or gpt4 level of modelT
20
+ * TODO: [👙][🧠] Maybe add `knowledge`, `actions` and `instruments` to be available granularly for each template
21
+ * @see https://github.com/webgptorg/promptbook/discussions/79
22
+ * TODO: [💕][🧠] Just selecting gpt3 or gpt4 level of model
16
23
  */
@@ -0,0 +1,40 @@
1
+ import type { ModelRequirements } from '../ModelRequirements';
2
+ import type { number_id } from '../typeAliases';
3
+ import type { string_name } from '../typeAliases';
4
+ import type { string_persona_description } from '../typeAliases';
5
+ /**
6
+ * Defines a persona in the pipeline
7
+ *
8
+ * @see https://github.com/webgptorg/promptbook/discussions/22
9
+ */
10
+ export type PersonaJson = {
11
+ /**
12
+ * Name of the template
13
+ * - It must be unique across the pipeline
14
+ * - It should start uppercase and can contain letters and numbers
15
+ */
16
+ readonly name: string_name;
17
+ /**
18
+ * Description of persona
19
+ */
20
+ readonly description: string_persona_description;
21
+ };
22
+ /**
23
+ * Defines a persona in the pipeline after it has been prepared
24
+ *
25
+ * @see https://github.com/webgptorg/promptbook/discussions/22
26
+ */
27
+ export type PersonaPreparedJson = PersonaJson & {
28
+ /**
29
+ * Model requirements for the persona
30
+ *
31
+ * Note: The model must be CHAT variant to be usable through persona
32
+ */
33
+ readonly modelRequirements: ModelRequirements & {
34
+ readonly modelVariant: 'CHAT';
35
+ };
36
+ /**
37
+ * List of preparation ids that were used to prepare this persona
38
+ */
39
+ readonly preparationIds: Array<number_id>;
40
+ };
@@ -2,7 +2,12 @@ import type { string_file_path } from '../typeAliases';
2
2
  import type { string_markdown_text } from '../typeAliases';
3
3
  import type { string_pipeline_url } from '../typeAliases';
4
4
  import type { string_semantic_version } from '../typeAliases';
5
- import type { KnowledgeJson } from './KnowledgeJson';
5
+ import type { KnowledgePiecePreparedJson } from './KnowledgePieceJson';
6
+ import type { KnowledgeSourceJson } from './KnowledgeSourceJson';
7
+ import type { KnowledgeSourcePreparedJson } from './KnowledgeSourceJson';
8
+ import type { PersonaJson } from './PersonaJson';
9
+ import type { PersonaPreparedJson } from './PersonaJson';
10
+ import type { PreparationJson } from './PreparationJson';
6
11
  import type { PromptTemplateJson } from './PromptTemplateJson';
7
12
  import type { PromptTemplateParameterJson } from './PromptTemplateParameterJson';
8
13
  /**
@@ -50,8 +55,28 @@ export type PipelineJson = {
50
55
  readonly promptTemplates: Array<PromptTemplateJson>;
51
56
  /**
52
57
  * Set of information that are used as external knowledge in the pipeline
58
+ *
59
+ * @see https://github.com/webgptorg/promptbook/discussions/41
60
+ */
61
+ readonly knowledgeSources: Array<KnowledgeSourceJson | KnowledgeSourcePreparedJson>;
62
+ /**
63
+ * Set of information that are used as external knowledge in the pipeline
64
+ *
65
+ * @see https://github.com/webgptorg/promptbook/discussions/41
66
+ */
67
+ readonly knowledgePieces: Array<KnowledgePiecePreparedJson>;
68
+ /**
69
+ * List of prepared virtual personas that are used in the pipeline
70
+ *
71
+ * @see https://github.com/webgptorg/promptbook/discussions/22
72
+ */
73
+ readonly personas: Array<PersonaJson | PersonaPreparedJson>;
74
+ /**
75
+ * List of prepared virtual personas that are used in the pipeline
76
+ *
77
+ * @see https://github.com/webgptorg/promptbook/discussions/78
53
78
  */
54
- readonly knowledge: KnowledgeJson;
79
+ readonly preparations: Array<PreparationJson>;
55
80
  };
56
81
  /**
57
82
  * TODO: !!!!! Implement new commands
@@ -0,0 +1,25 @@
1
+ import type { PromptResultUsage } from '../../execution/PromptResult';
2
+ import type { string_promptbook_version } from '../../version';
3
+ import type { number_id } from '../typeAliases';
4
+ import type { string_date_iso8601 } from '../typeAliases';
5
+ export type PreparationJson = {
6
+ /**
7
+ * Incremental ID of the preparation
8
+ */
9
+ readonly id: number_id;
10
+ /**
11
+ * Date and time of the preparation
12
+ */
13
+ readonly date: string_date_iso8601;
14
+ /**
15
+ * Version of the promptbook used for the preparation
16
+ */
17
+ readonly promptbookVersion: string_promptbook_version;
18
+ /**
19
+ * Usage of the prompt execution
20
+ */
21
+ readonly modelUsage: PromptResultUsage;
22
+ };
23
+ /**
24
+ * TODO: Maybe put here used `modelName`
25
+ */
@@ -1,6 +1,8 @@
1
1
  import type { PromptTemplateJsonCommon } from './PromptTemplateJsonCommon';
2
2
  /**
3
3
  * Template for prompt to user
4
+ *
5
+ * @see https://github.com/webgptorg/promptbook/discussions/76
4
6
  */
5
7
  export interface PromptDialogJson extends PromptTemplateJsonCommon {
6
8
  readonly blockType: 'PROMPT_DIALOG';
@@ -1,4 +1,4 @@
1
- import type { ___ } from '../typeAliases';
1
+ import type { ___ } from '../../utils/organization/___';
2
2
  import type { LlmTemplateJson } from './LlmTemplateJson';
3
3
  import type { PromptDialogJson } from './PromptDialogJson';
4
4
  import type { ScriptJson } from './ScriptJson';
@@ -15,7 +15,7 @@ export interface PromptTemplateJsonCommon {
15
15
  /**
16
16
  * Name of the template
17
17
  * - It must be unique across the pipeline
18
- * - It should start uppercase and contain letters and numbers
18
+ * - It should start uppercase and can contain letters and numbers
19
19
  * - The pipelineUrl together with hash and name are used to identify the prompt template in the pipeline
20
20
  */
21
21
  readonly name: string_name;
@@ -37,6 +37,8 @@ export interface PromptTemplateJsonCommon {
37
37
  readonly dependentParameterNames: Array<string_name>;
38
38
  /**
39
39
  * If theese parameters meet the expectations requirements, they are used instead of executing this prompt template
40
+ *
41
+ * @see https://github.com/webgptorg/promptbook/discussions/66
40
42
  */
41
43
  readonly jokers?: Array<string>;
42
44
  /**
@@ -50,6 +52,8 @@ export interface PromptTemplateJsonCommon {
50
52
  readonly content: (string_prompt | string_javascript | string_markdown) & string_template;
51
53
  /**
52
54
  * List of postprocessing steps that are executed after the prompt template
55
+ *
56
+ * @see https://github.com/webgptorg/promptbook/discussions/31
53
57
  */
54
58
  readonly postprocessing?: Array<string_javascript_name>;
55
59
  /**
@@ -58,12 +62,14 @@ export interface PromptTemplateJsonCommon {
58
62
  * For example 5 words, 3 sentences, 2 paragraphs, ...
59
63
  *
60
64
  * Note: Expectations are performed after all postprocessing steps
65
+ * @see https://github.com/webgptorg/promptbook/discussions/30
61
66
  */
62
67
  readonly expectations?: Expectations;
63
68
  /**
64
69
  * Expect this format of the answer
65
70
  *
66
71
  * Note: Expectations are performed after all postprocessing steps
72
+ * @see https://github.com/webgptorg/promptbook/discussions/30
67
73
  * @deprecated [💝]
68
74
  */
69
75
  readonly expectFormat?: ExpectFormatCommand['format'];
@@ -2,6 +2,8 @@ import type { ScriptLanguage } from '../ScriptLanguage';
2
2
  import type { PromptTemplateJsonCommon } from './PromptTemplateJsonCommon';
3
3
  /**
4
4
  * Template for script execution
5
+ *
6
+ * @see https://github.com/webgptorg/promptbook/discussions/77
5
7
  */
6
8
  export interface ScriptJson extends PromptTemplateJsonCommon {
7
9
  readonly blockType: 'SCRIPT';
@@ -1,6 +1,8 @@
1
1
  import type { PromptTemplateJsonCommon } from './PromptTemplateJsonCommon';
2
2
  /**
3
3
  * Template for simple concatenation of strings
4
+ *
5
+ * @see https://github.com/webgptorg/promptbook/discussions/17
4
6
  */
5
7
  export interface SimpleTemplateJson extends PromptTemplateJsonCommon {
6
8
  readonly blockType: 'SIMPLE_TEMPLATE';