@promptbook/core 0.61.0-1 → 0.61.0-11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.es.js +766 -346
- package/esm/index.es.js.map +1 -1
- package/esm/typings/promptbook-collection/index.d.ts +196 -23
- package/esm/typings/src/_packages/core.index.d.ts +5 -1
- package/esm/typings/src/_packages/types.index.d.ts +6 -4
- package/esm/typings/src/_packages/utils.index.d.ts +4 -3
- package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +1 -1
- package/esm/typings/src/collection/constructors/createCollectionFromUrl.d.ts +2 -2
- package/esm/typings/src/commands/MODEL/ModelCommand.d.ts +1 -1
- package/esm/typings/src/commands/PERSONA/PersonaCommand.d.ts +4 -2
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +15 -12
- package/esm/typings/src/config.d.ts +8 -0
- package/esm/typings/src/conversion/pipelineStringToJson.d.ts +9 -5
- package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +5 -3
- package/esm/typings/src/conversion/prettify/PrettifyOptions.d.ts +2 -2
- package/esm/typings/src/conversion/utils/renameParameter.d.ts +3 -3
- package/esm/typings/src/conversion/validation/_importPipeline.d.ts +2 -2
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +4 -0
- package/esm/typings/src/errors/EnvironmentMismatchError.d.ts +7 -0
- package/esm/typings/src/errors/VersionMismatchError.d.ts +8 -0
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +3 -1
- package/esm/typings/src/execution/PipelineExecutor.d.ts +8 -7
- package/esm/typings/src/execution/PromptResult.d.ts +17 -5
- package/esm/typings/src/execution/ScriptExecutionTools.d.ts +6 -4
- package/esm/typings/src/execution/UserInterfaceTools.d.ts +5 -5
- package/esm/typings/src/execution/createPipelineExecutor.d.ts +4 -1
- package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +2 -2
- package/esm/typings/src/execution/utils/forEachAsync.d.ts +1 -1
- package/esm/typings/src/formats/csv/ListFormatDefinition.d.ts +1 -1
- package/esm/typings/src/formats/json/JsonFormatDefinition.d.ts +1 -1
- package/esm/typings/src/formats/list/ListFormatDefinition.d.ts +1 -1
- package/esm/typings/src/knowledge/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +1 -1
- package/esm/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.d.ts +18 -0
- package/esm/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.test.d.ts +1 -0
- package/esm/typings/src/knowledge/prepare-knowledge/_common/utils/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +10 -0
- package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +8 -23
- package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +3 -0
- package/esm/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +7 -14
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +2 -2
- package/esm/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +3 -0
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +5 -5
- package/esm/typings/src/llm-providers/azure-openai/playground/playground.d.ts +3 -0
- package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +3 -1
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +3 -2
- package/esm/typings/src/llm-providers/openai/playground/playground.d.ts +3 -0
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/utils/cache/CacheItem.d.ts +29 -0
- package/esm/typings/src/llm-providers/utils/cache/CacheLlmToolsOptions.d.ts +10 -0
- package/esm/typings/src/llm-providers/utils/cache/cacheLlmTools.d.ts +17 -0
- package/esm/typings/src/llm-providers/utils/count-total-cost/LlmExecutionToolsWithTotalCost.d.ts +11 -0
- package/esm/typings/src/llm-providers/utils/count-total-cost/countTotalCost.d.ts +14 -0
- package/esm/typings/src/llm-providers/utils/createLlmToolsFromEnv.d.ts +21 -0
- package/esm/typings/src/personas/preparePersona.d.ts +10 -0
- package/esm/typings/src/personas/preparePersona.test.d.ts +1 -0
- package/esm/typings/src/prepare/PrepareOptions.d.ts +22 -0
- package/esm/typings/src/prepare/preparePipeline.d.ts +16 -0
- package/esm/typings/src/prepare/unpreparePipeline.d.ts +8 -0
- package/esm/typings/src/scripting/javascript/JavascriptExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
- package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +24 -0
- package/esm/typings/src/storage/_common/PromptbookStorage.test-type.d.ts +5 -0
- package/esm/typings/src/storage/files-storage/FilesStorage.d.ts +28 -0
- package/esm/typings/src/storage/files-storage/FilesStorageOptions.d.ts +10 -0
- package/esm/typings/src/storage/files-storage/utils/nameToSubfolderPath.d.ts +7 -0
- package/esm/typings/src/storage/files-storage/utils/nameToSubfolderPath.test.d.ts +1 -0
- package/esm/typings/src/storage/local-storage/getLocalStorage.d.ts +8 -0
- package/esm/typings/src/storage/local-storage/getSessionStorage.d.ts +8 -0
- package/esm/typings/src/storage/memory/MemoryStorage.d.ts +31 -0
- package/esm/typings/src/storage/utils/PrefixStorage.d.ts +23 -0
- package/esm/typings/src/storage/utils/makePromptbookStorageFromWebStorage.d.ts +12 -0
- package/esm/typings/src/types/ModelRequirements.d.ts +22 -1
- package/esm/typings/src/types/PipelineJson/Expectations.d.ts +6 -2
- package/esm/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +67 -0
- package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +24 -0
- package/esm/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +8 -1
- package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +40 -0
- package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +27 -3
- package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +21 -0
- package/esm/typings/src/types/PipelineJson/PromptDialogJson.d.ts +2 -0
- package/esm/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +8 -1
- package/esm/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +11 -2
- package/esm/typings/src/types/PipelineJson/ScriptJson.d.ts +2 -0
- package/esm/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +2 -0
- package/esm/typings/src/types/Prompt.d.ts +5 -2
- package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +4 -4
- package/esm/typings/src/types/execution-report/ExecutionReportStringOptions.d.ts +3 -3
- package/esm/typings/src/types/typeAliases.d.ts +62 -14
- package/esm/typings/src/utils/FromtoItems.d.ts +3 -3
- package/esm/typings/src/utils/currentDate.d.ts +7 -0
- package/esm/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +2 -2
- package/esm/typings/src/utils/markdown/createMarkdownChart.d.ts +6 -9
- package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown-real.test.d.ts +1 -0
- package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +9 -2
- package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +1 -1
- package/esm/typings/src/utils/markdown/parseMarkdownSection.d.ts +3 -3
- package/esm/typings/src/utils/organization/TODO.d.ts +4 -0
- package/esm/typings/src/utils/organization/TODO_USE.d.ts +11 -0
- package/esm/typings/src/utils/organization/___.d.ts +4 -0
- package/esm/typings/src/utils/organization/notUsing.d.ts +11 -0
- package/esm/typings/src/utils/organization/really_any.d.ts +4 -0
- package/esm/typings/src/utils/random/randomSeed.d.ts +7 -0
- package/package.json +1 -1
- package/umd/index.umd.js +768 -345
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/promptbook-collection/index.d.ts +196 -23
- package/umd/typings/src/_packages/core.index.d.ts +5 -1
- package/umd/typings/src/_packages/types.index.d.ts +6 -4
- package/umd/typings/src/_packages/utils.index.d.ts +4 -3
- package/umd/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +1 -1
- package/umd/typings/src/collection/constructors/createCollectionFromUrl.d.ts +2 -2
- package/umd/typings/src/commands/MODEL/ModelCommand.d.ts +1 -1
- package/umd/typings/src/commands/PERSONA/PersonaCommand.d.ts +4 -2
- package/umd/typings/src/commands/_common/types/CommandParser.d.ts +15 -12
- package/umd/typings/src/config.d.ts +8 -0
- package/umd/typings/src/conversion/pipelineStringToJson.d.ts +9 -5
- package/umd/typings/src/conversion/pipelineStringToJsonSync.d.ts +5 -3
- package/umd/typings/src/conversion/prettify/PrettifyOptions.d.ts +2 -2
- package/umd/typings/src/conversion/utils/renameParameter.d.ts +3 -3
- package/umd/typings/src/conversion/validation/_importPipeline.d.ts +2 -2
- package/umd/typings/src/conversion/validation/validatePipeline.d.ts +4 -0
- package/umd/typings/src/errors/EnvironmentMismatchError.d.ts +7 -0
- package/umd/typings/src/errors/VersionMismatchError.d.ts +8 -0
- package/umd/typings/src/execution/LlmExecutionTools.d.ts +3 -1
- package/umd/typings/src/execution/PipelineExecutor.d.ts +8 -7
- package/umd/typings/src/execution/PromptResult.d.ts +17 -5
- package/umd/typings/src/execution/ScriptExecutionTools.d.ts +6 -4
- package/umd/typings/src/execution/UserInterfaceTools.d.ts +5 -5
- package/umd/typings/src/execution/createPipelineExecutor.d.ts +4 -1
- package/umd/typings/src/execution/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +2 -2
- package/umd/typings/src/execution/utils/forEachAsync.d.ts +1 -1
- package/umd/typings/src/formats/csv/ListFormatDefinition.d.ts +1 -1
- package/umd/typings/src/formats/json/JsonFormatDefinition.d.ts +1 -1
- package/umd/typings/src/formats/list/ListFormatDefinition.d.ts +1 -1
- package/umd/typings/src/knowledge/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +1 -1
- package/umd/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.d.ts +18 -0
- package/umd/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.test.d.ts +1 -0
- package/umd/typings/src/knowledge/prepare-knowledge/_common/utils/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +10 -0
- package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +8 -23
- package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +3 -0
- package/umd/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +7 -14
- package/umd/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
- package/umd/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +2 -2
- package/umd/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +3 -0
- package/umd/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +5 -5
- package/umd/typings/src/llm-providers/azure-openai/playground/playground.d.ts +3 -0
- package/umd/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
- package/umd/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
- package/umd/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +3 -1
- package/umd/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +1 -1
- package/umd/typings/src/llm-providers/openai/openai-models.d.ts +3 -2
- package/umd/typings/src/llm-providers/openai/playground/playground.d.ts +3 -0
- package/umd/typings/src/llm-providers/remote/RemoteLlmExecutionToolsOptions.d.ts +1 -1
- package/umd/typings/src/llm-providers/utils/cache/CacheItem.d.ts +29 -0
- package/umd/typings/src/llm-providers/utils/cache/CacheLlmToolsOptions.d.ts +10 -0
- package/umd/typings/src/llm-providers/utils/cache/cacheLlmTools.d.ts +17 -0
- package/umd/typings/src/llm-providers/utils/count-total-cost/LlmExecutionToolsWithTotalCost.d.ts +11 -0
- package/umd/typings/src/llm-providers/utils/count-total-cost/countTotalCost.d.ts +14 -0
- package/umd/typings/src/llm-providers/utils/createLlmToolsFromEnv.d.ts +21 -0
- package/umd/typings/src/personas/preparePersona.d.ts +10 -0
- package/umd/typings/src/personas/preparePersona.test.d.ts +1 -0
- package/umd/typings/src/prepare/PrepareOptions.d.ts +22 -0
- package/umd/typings/src/prepare/preparePipeline.d.ts +16 -0
- package/umd/typings/src/prepare/unpreparePipeline.d.ts +8 -0
- package/umd/typings/src/scripting/javascript/JavascriptExecutionToolsOptions.d.ts +1 -1
- package/umd/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
- package/umd/typings/src/storage/_common/PromptbookStorage.d.ts +24 -0
- package/umd/typings/src/storage/_common/PromptbookStorage.test-type.d.ts +5 -0
- package/umd/typings/src/storage/files-storage/FilesStorage.d.ts +28 -0
- package/umd/typings/src/storage/files-storage/FilesStorageOptions.d.ts +10 -0
- package/umd/typings/src/storage/files-storage/utils/nameToSubfolderPath.d.ts +7 -0
- package/umd/typings/src/storage/files-storage/utils/nameToSubfolderPath.test.d.ts +1 -0
- package/umd/typings/src/storage/local-storage/getLocalStorage.d.ts +8 -0
- package/umd/typings/src/storage/local-storage/getSessionStorage.d.ts +8 -0
- package/umd/typings/src/storage/memory/MemoryStorage.d.ts +31 -0
- package/umd/typings/src/storage/utils/PrefixStorage.d.ts +23 -0
- package/umd/typings/src/storage/utils/makePromptbookStorageFromWebStorage.d.ts +12 -0
- package/umd/typings/src/types/ModelRequirements.d.ts +22 -1
- package/umd/typings/src/types/PipelineJson/Expectations.d.ts +6 -2
- package/umd/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +67 -0
- package/umd/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +24 -0
- package/umd/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +8 -1
- package/umd/typings/src/types/PipelineJson/PersonaJson.d.ts +40 -0
- package/umd/typings/src/types/PipelineJson/PipelineJson.d.ts +27 -3
- package/umd/typings/src/types/PipelineJson/PreparationJson.d.ts +21 -0
- package/umd/typings/src/types/PipelineJson/PromptDialogJson.d.ts +2 -0
- package/umd/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +1 -1
- package/umd/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +8 -1
- package/umd/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +11 -2
- package/umd/typings/src/types/PipelineJson/ScriptJson.d.ts +2 -0
- package/umd/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +2 -0
- package/umd/typings/src/types/Prompt.d.ts +5 -2
- package/umd/typings/src/types/execution-report/ExecutionReportJson.d.ts +4 -4
- package/umd/typings/src/types/execution-report/ExecutionReportStringOptions.d.ts +3 -3
- package/umd/typings/src/types/typeAliases.d.ts +62 -14
- package/umd/typings/src/utils/FromtoItems.d.ts +3 -3
- package/umd/typings/src/utils/currentDate.d.ts +7 -0
- package/umd/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +2 -2
- package/umd/typings/src/utils/markdown/createMarkdownChart.d.ts +6 -9
- package/umd/typings/src/utils/markdown/extractAllBlocksFromMarkdown-real.test.d.ts +1 -0
- package/umd/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +9 -2
- package/umd/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +1 -1
- package/umd/typings/src/utils/markdown/parseMarkdownSection.d.ts +3 -3
- package/umd/typings/src/utils/organization/TODO.d.ts +4 -0
- package/umd/typings/src/utils/organization/TODO_USE.d.ts +11 -0
- package/umd/typings/src/utils/organization/___.d.ts +4 -0
- package/umd/typings/src/utils/organization/notUsing.d.ts +11 -0
- package/umd/typings/src/utils/organization/really_any.d.ts +4 -0
- package/umd/typings/src/utils/random/randomSeed.d.ts +7 -0
- package/esm/typings/src/collection/constructors/justTestFsImport.d.ts +0 -7
- package/esm/typings/src/personas/personaToModelRequirements.d.ts +0 -6
- package/esm/typings/src/types/PipelineJson/KnowledgeJson.d.ts +0 -6
- package/esm/typings/src/types/PipelineJson/MaterialKnowledgePieceJson.d.ts +0 -28
- package/umd/typings/src/collection/constructors/justTestFsImport.d.ts +0 -7
- package/umd/typings/src/personas/personaToModelRequirements.d.ts +0 -6
- package/umd/typings/src/types/PipelineJson/KnowledgeJson.d.ts +0 -6
- package/umd/typings/src/types/PipelineJson/MaterialKnowledgePieceJson.d.ts +0 -28
- /package/esm/typings/src/_packages/{markdown-utils.d.ts → markdown-utils.index.d.ts} +0 -0
- /package/esm/typings/src/utils/{just.d.ts → organization/just.d.ts} +0 -0
- /package/umd/typings/src/_packages/{markdown-utils.d.ts → markdown-utils.index.d.ts} +0 -0
- /package/umd/typings/src/utils/{just.d.ts → organization/just.d.ts} +0 -0
package/umd/index.umd.js
CHANGED
|
@@ -401,6 +401,10 @@
|
|
|
401
401
|
* The maximum number of iterations for a loops
|
|
402
402
|
*/
|
|
403
403
|
var LOOP_LIMIT = 1000;
|
|
404
|
+
/**
|
|
405
|
+
* The maximum number of (LLM) tasks running in parallel
|
|
406
|
+
*/
|
|
407
|
+
var MAX_PARALLEL_COUNT = 5;
|
|
404
408
|
/**
|
|
405
409
|
* The names of the parameters that are reserved for special purposes
|
|
406
410
|
*/
|
|
@@ -782,6 +786,10 @@
|
|
|
782
786
|
* > * - ...
|
|
783
787
|
* > ex port function validatePipeline(promptbook: unknown): asserts promptbook is PipelineJson {
|
|
784
788
|
*/
|
|
789
|
+
/**
|
|
790
|
+
* TODO: [🧠] !!!!! Validate new things
|
|
791
|
+
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
792
|
+
*/
|
|
785
793
|
|
|
786
794
|
/**
|
|
787
795
|
* This error indicates that promptbook not found in the collection
|
|
@@ -1126,7 +1134,172 @@
|
|
|
1126
1134
|
// <- [🩻]
|
|
1127
1135
|
];
|
|
1128
1136
|
|
|
1129
|
-
|
|
1137
|
+
/**
|
|
1138
|
+
* Function `addUsage` will add multiple usages into one
|
|
1139
|
+
*
|
|
1140
|
+
* Note: If you provide 0 values, it returns void usage
|
|
1141
|
+
*/
|
|
1142
|
+
function addUsage() {
|
|
1143
|
+
var usageItems = [];
|
|
1144
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1145
|
+
usageItems[_i] = arguments[_i];
|
|
1146
|
+
}
|
|
1147
|
+
var initialStructure = {
|
|
1148
|
+
price: { value: 0 },
|
|
1149
|
+
input: {
|
|
1150
|
+
tokensCount: { value: 0 },
|
|
1151
|
+
charactersCount: { value: 0 },
|
|
1152
|
+
wordsCount: { value: 0 },
|
|
1153
|
+
sentencesCount: { value: 0 },
|
|
1154
|
+
linesCount: { value: 0 },
|
|
1155
|
+
paragraphsCount: { value: 0 },
|
|
1156
|
+
pagesCount: { value: 0 },
|
|
1157
|
+
},
|
|
1158
|
+
output: {
|
|
1159
|
+
tokensCount: { value: 0 },
|
|
1160
|
+
charactersCount: { value: 0 },
|
|
1161
|
+
wordsCount: { value: 0 },
|
|
1162
|
+
sentencesCount: { value: 0 },
|
|
1163
|
+
linesCount: { value: 0 },
|
|
1164
|
+
paragraphsCount: { value: 0 },
|
|
1165
|
+
pagesCount: { value: 0 },
|
|
1166
|
+
},
|
|
1167
|
+
};
|
|
1168
|
+
return usageItems.reduce(function (acc, item) {
|
|
1169
|
+
var e_1, _a, e_2, _b;
|
|
1170
|
+
var _c;
|
|
1171
|
+
acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
|
|
1172
|
+
try {
|
|
1173
|
+
for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
1174
|
+
var key = _e.value;
|
|
1175
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1176
|
+
//@ts-ignore
|
|
1177
|
+
if (item.input[key]) {
|
|
1178
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1179
|
+
//@ts-ignore
|
|
1180
|
+
acc.input[key].value += item.input[key].value || 0;
|
|
1181
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1182
|
+
//@ts-ignore
|
|
1183
|
+
if (item.input[key].isUncertain) {
|
|
1184
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1185
|
+
//@ts-ignore
|
|
1186
|
+
acc.input[key].isUncertain = true;
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1192
|
+
finally {
|
|
1193
|
+
try {
|
|
1194
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
1195
|
+
}
|
|
1196
|
+
finally { if (e_1) throw e_1.error; }
|
|
1197
|
+
}
|
|
1198
|
+
try {
|
|
1199
|
+
for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
1200
|
+
var key = _g.value;
|
|
1201
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1202
|
+
//@ts-ignore
|
|
1203
|
+
if (item.output[key]) {
|
|
1204
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1205
|
+
//@ts-ignore
|
|
1206
|
+
acc.output[key].value += item.output[key].value || 0;
|
|
1207
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1208
|
+
//@ts-ignore
|
|
1209
|
+
if (item.output[key].isUncertain) {
|
|
1210
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1211
|
+
//@ts-ignore
|
|
1212
|
+
acc.output[key].isUncertain = true;
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1218
|
+
finally {
|
|
1219
|
+
try {
|
|
1220
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
1221
|
+
}
|
|
1222
|
+
finally { if (e_2) throw e_2.error; }
|
|
1223
|
+
}
|
|
1224
|
+
return acc;
|
|
1225
|
+
}, initialStructure);
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
/**
|
|
1229
|
+
* Async version of Array.forEach
|
|
1230
|
+
*
|
|
1231
|
+
* @param array - Array to iterate over
|
|
1232
|
+
* @param options - Options for the function
|
|
1233
|
+
* @param callbackfunction - Function to call for each item
|
|
1234
|
+
*/
|
|
1235
|
+
function forEachAsync(array, options, callbackfunction) {
|
|
1236
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1237
|
+
var _a, maxParallelCount, index, runningTasks, tasks, _loop_1, _b, _c, item, e_1_1;
|
|
1238
|
+
var e_1, _d;
|
|
1239
|
+
return __generator(this, function (_e) {
|
|
1240
|
+
switch (_e.label) {
|
|
1241
|
+
case 0:
|
|
1242
|
+
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? Infinity : _a;
|
|
1243
|
+
index = 0;
|
|
1244
|
+
runningTasks = [];
|
|
1245
|
+
tasks = [];
|
|
1246
|
+
_loop_1 = function (item) {
|
|
1247
|
+
var currentIndex, task;
|
|
1248
|
+
return __generator(this, function (_f) {
|
|
1249
|
+
switch (_f.label) {
|
|
1250
|
+
case 0:
|
|
1251
|
+
currentIndex = index++;
|
|
1252
|
+
task = callbackfunction(item, currentIndex, array);
|
|
1253
|
+
tasks.push(task);
|
|
1254
|
+
runningTasks.push(task);
|
|
1255
|
+
/* not await */ Promise.resolve(task).then(function () {
|
|
1256
|
+
runningTasks = runningTasks.filter(function (t) { return t !== task; });
|
|
1257
|
+
});
|
|
1258
|
+
if (!(maxParallelCount < runningTasks.length)) return [3 /*break*/, 2];
|
|
1259
|
+
return [4 /*yield*/, Promise.race(runningTasks)];
|
|
1260
|
+
case 1:
|
|
1261
|
+
_f.sent();
|
|
1262
|
+
_f.label = 2;
|
|
1263
|
+
case 2: return [2 /*return*/];
|
|
1264
|
+
}
|
|
1265
|
+
});
|
|
1266
|
+
};
|
|
1267
|
+
_e.label = 1;
|
|
1268
|
+
case 1:
|
|
1269
|
+
_e.trys.push([1, 6, 7, 8]);
|
|
1270
|
+
_b = __values(array), _c = _b.next();
|
|
1271
|
+
_e.label = 2;
|
|
1272
|
+
case 2:
|
|
1273
|
+
if (!!_c.done) return [3 /*break*/, 5];
|
|
1274
|
+
item = _c.value;
|
|
1275
|
+
return [5 /*yield**/, _loop_1(item)];
|
|
1276
|
+
case 3:
|
|
1277
|
+
_e.sent();
|
|
1278
|
+
_e.label = 4;
|
|
1279
|
+
case 4:
|
|
1280
|
+
_c = _b.next();
|
|
1281
|
+
return [3 /*break*/, 2];
|
|
1282
|
+
case 5: return [3 /*break*/, 8];
|
|
1283
|
+
case 6:
|
|
1284
|
+
e_1_1 = _e.sent();
|
|
1285
|
+
e_1 = { error: e_1_1 };
|
|
1286
|
+
return [3 /*break*/, 8];
|
|
1287
|
+
case 7:
|
|
1288
|
+
try {
|
|
1289
|
+
if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
|
|
1290
|
+
}
|
|
1291
|
+
finally { if (e_1) throw e_1.error; }
|
|
1292
|
+
return [7 /*endfinally*/];
|
|
1293
|
+
case 8: return [4 /*yield*/, Promise.all(tasks)];
|
|
1294
|
+
case 9:
|
|
1295
|
+
_e.sent();
|
|
1296
|
+
return [2 /*return*/];
|
|
1297
|
+
}
|
|
1298
|
+
});
|
|
1299
|
+
});
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-10",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledge",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],blockType:"PROMPT_TEMPLATE",personaName:null,modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {content}",resultingParameterName:"knowledge"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-10",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.61.0-10",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],blockType:"PROMPT_TEMPLATE",personaName:null,modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {content}",resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-10",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.61.0-10",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],blockType:"PROMPT_TEMPLATE",expectations:{words:{min:1,max:8}},personaName:null,modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {content}",resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-10",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.61.0-10",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],promptTemplates:[{name:"make-model-requirements",title:"Make modelRequirements",dependentParameterNames:["availableModelNames","personaDescription"],blockType:"PROMPT_TEMPLATE",expectFormat:"JSON",personaName:null,modelRequirements:{modelVariant:"CHAT",modelName:"gpt-4-turbo"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n### Option `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Option `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Option `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-10",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
|
|
1130
1303
|
|
|
1131
1304
|
var defaultDiacriticsRemovalMap = [
|
|
1132
1305
|
{
|
|
@@ -1453,6 +1626,14 @@
|
|
|
1453
1626
|
* Function normalizes title to name which can be used as identifier
|
|
1454
1627
|
*/
|
|
1455
1628
|
function titleToName(value) {
|
|
1629
|
+
if (value.startsWith('http://') || value.startsWith('https://')) {
|
|
1630
|
+
// TODO: Maybe check against some list unallowed characters
|
|
1631
|
+
return value;
|
|
1632
|
+
}
|
|
1633
|
+
if (value.startsWith('./') || value.startsWith('../')) {
|
|
1634
|
+
// TODO: Maybe check against some list unallowed characters
|
|
1635
|
+
return value;
|
|
1636
|
+
}
|
|
1456
1637
|
value = removeEmojis(value);
|
|
1457
1638
|
value = normalizeToKebabCase(value);
|
|
1458
1639
|
// TODO: [🧠] Maybe warn or add some padding to short name which are not good identifiers
|
|
@@ -1674,7 +1855,7 @@
|
|
|
1674
1855
|
};
|
|
1675
1856
|
/**
|
|
1676
1857
|
* List all available models that can be used
|
|
1677
|
-
* This
|
|
1858
|
+
* This lists is a combination of all available models from all execution tools
|
|
1678
1859
|
*/
|
|
1679
1860
|
MultipleLlmExecutionTools.prototype.listModels = function () {
|
|
1680
1861
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1720,6 +1901,8 @@
|
|
|
1720
1901
|
}());
|
|
1721
1902
|
/**
|
|
1722
1903
|
* TODO: [🧠][🎛] Aggregating multiple models - have result not only from one first aviable model BUT all of them
|
|
1904
|
+
* TODO: [🏖] If no llmTools have for example not defined `callCompletionModel` this will still return object with defined `callCompletionModel` which just throws `PipelineExecutionError`, make it undefined instead
|
|
1905
|
+
* Look how `countTotalUsage` (and `cacheLlmTools`) implements it
|
|
1723
1906
|
*/
|
|
1724
1907
|
|
|
1725
1908
|
/**
|
|
@@ -1790,100 +1973,9 @@
|
|
|
1790
1973
|
/**
|
|
1791
1974
|
* The version of the Promptbook library
|
|
1792
1975
|
*/
|
|
1793
|
-
var PROMPTBOOK_VERSION = '0.61.0-
|
|
1976
|
+
var PROMPTBOOK_VERSION = '0.61.0-10';
|
|
1794
1977
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
1795
1978
|
|
|
1796
|
-
/**
|
|
1797
|
-
* Function `addUsage` will add multiple usages into one
|
|
1798
|
-
*
|
|
1799
|
-
* Note: If you provide 0 values, it returns void usage
|
|
1800
|
-
*/
|
|
1801
|
-
function addUsage() {
|
|
1802
|
-
var usageItems = [];
|
|
1803
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1804
|
-
usageItems[_i] = arguments[_i];
|
|
1805
|
-
}
|
|
1806
|
-
var initialStructure = {
|
|
1807
|
-
price: { value: 0 },
|
|
1808
|
-
input: {
|
|
1809
|
-
tokensCount: { value: 0 },
|
|
1810
|
-
charactersCount: { value: 0 },
|
|
1811
|
-
wordsCount: { value: 0 },
|
|
1812
|
-
sentencesCount: { value: 0 },
|
|
1813
|
-
linesCount: { value: 0 },
|
|
1814
|
-
paragraphsCount: { value: 0 },
|
|
1815
|
-
pagesCount: { value: 0 },
|
|
1816
|
-
},
|
|
1817
|
-
output: {
|
|
1818
|
-
tokensCount: { value: 0 },
|
|
1819
|
-
charactersCount: { value: 0 },
|
|
1820
|
-
wordsCount: { value: 0 },
|
|
1821
|
-
sentencesCount: { value: 0 },
|
|
1822
|
-
linesCount: { value: 0 },
|
|
1823
|
-
paragraphsCount: { value: 0 },
|
|
1824
|
-
pagesCount: { value: 0 },
|
|
1825
|
-
},
|
|
1826
|
-
};
|
|
1827
|
-
return usageItems.reduce(function (acc, item) {
|
|
1828
|
-
var e_1, _a, e_2, _b;
|
|
1829
|
-
var _c;
|
|
1830
|
-
acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
|
|
1831
|
-
try {
|
|
1832
|
-
for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
1833
|
-
var key = _e.value;
|
|
1834
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1835
|
-
//@ts-ignore
|
|
1836
|
-
if (item.input[key]) {
|
|
1837
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1838
|
-
//@ts-ignore
|
|
1839
|
-
acc.input[key].value += item.input[key].value || 0;
|
|
1840
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1841
|
-
//@ts-ignore
|
|
1842
|
-
if (item.input[key].isUncertain) {
|
|
1843
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1844
|
-
//@ts-ignore
|
|
1845
|
-
acc.input[key].isUncertain = true;
|
|
1846
|
-
}
|
|
1847
|
-
}
|
|
1848
|
-
}
|
|
1849
|
-
}
|
|
1850
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1851
|
-
finally {
|
|
1852
|
-
try {
|
|
1853
|
-
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
1854
|
-
}
|
|
1855
|
-
finally { if (e_1) throw e_1.error; }
|
|
1856
|
-
}
|
|
1857
|
-
try {
|
|
1858
|
-
for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
1859
|
-
var key = _g.value;
|
|
1860
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1861
|
-
//@ts-ignore
|
|
1862
|
-
if (item.output[key]) {
|
|
1863
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1864
|
-
//@ts-ignore
|
|
1865
|
-
acc.output[key].value += item.output[key].value || 0;
|
|
1866
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1867
|
-
//@ts-ignore
|
|
1868
|
-
if (item.output[key].isUncertain) {
|
|
1869
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1870
|
-
//@ts-ignore
|
|
1871
|
-
acc.output[key].isUncertain = true;
|
|
1872
|
-
}
|
|
1873
|
-
}
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1877
|
-
finally {
|
|
1878
|
-
try {
|
|
1879
|
-
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
1880
|
-
}
|
|
1881
|
-
finally { if (e_2) throw e_2.error; }
|
|
1882
|
-
}
|
|
1883
|
-
return acc;
|
|
1884
|
-
}, initialStructure);
|
|
1885
|
-
}
|
|
1886
|
-
|
|
1887
1979
|
/**
|
|
1888
1980
|
* Counts number of characters in the text
|
|
1889
1981
|
*/
|
|
@@ -2085,10 +2177,7 @@
|
|
|
2085
2177
|
var _this = this;
|
|
2086
2178
|
var pipeline = options.pipeline, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
|
|
2087
2179
|
var _b = settings.maxExecutionAttempts, maxExecutionAttempts = _b === void 0 ? 3 : _b;
|
|
2088
|
-
// TODO: !!!!! Implement new commands
|
|
2089
2180
|
validatePipeline(pipeline);
|
|
2090
|
-
// TODO: !!!!! Do here materialization of still unmaterialized or dynamic knowledge
|
|
2091
|
-
// TODO: !!!!! Do here personaToModelRequirements
|
|
2092
2181
|
var llmTools = joinLlmExecutionTools.apply(void 0, __spreadArray([], __read(arrayableToArray(tools.llm)), false));
|
|
2093
2182
|
var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
2094
2183
|
function executeSingleTemplate(currentTemplate) {
|
|
@@ -2163,7 +2252,10 @@
|
|
|
2163
2252
|
: 'anonymous' /* <- TODO: [🧠] How to deal with anonymous pipelines, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(currentTemplate.name),
|
|
2164
2253
|
parameters: parametersToPass,
|
|
2165
2254
|
content: replaceParameters(currentTemplate.content, parametersToPass) /* <- [2] */,
|
|
2255
|
+
// <- TODO: !!!!! Apply {context} and knowledges
|
|
2256
|
+
// <- TODO: !!!!! Apply samples
|
|
2166
2257
|
modelRequirements: currentTemplate.modelRequirements,
|
|
2258
|
+
// <- TODO: !!!!! Apply persona
|
|
2167
2259
|
expectations: currentTemplate.expectations,
|
|
2168
2260
|
expectFormat: currentTemplate.expectFormat,
|
|
2169
2261
|
postprocessing: (currentTemplate.postprocessing || []).map(function (functionName) { return function (result) { return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -2609,53 +2701,75 @@
|
|
|
2609
2701
|
return pipelineExecutor;
|
|
2610
2702
|
}
|
|
2611
2703
|
/**
|
|
2704
|
+
* TODO: [🪂] Pass maxParallelCount here
|
|
2705
|
+
* TODO: [♈] Probbably move expectations from templates to parameters
|
|
2612
2706
|
* TODO: [🧠] When not meet expectations in PROMPT_DIALOG, make some way to tell the user
|
|
2613
2707
|
* TODO: [👧] Strongly type the executors to avoid need of remove nullables whtn noUncheckedIndexedAccess in tsconfig.json
|
|
2614
2708
|
* Note: CreatePipelineExecutorOptions are just connected to PipelineExecutor so do not extract to types folder
|
|
2615
2709
|
* TODO: [🧠][3] transparent = (report intermediate parameters) / opaque execution = (report only output parameters) progress reporting mode
|
|
2710
|
+
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
2711
|
+
*/
|
|
2712
|
+
|
|
2713
|
+
/**
|
|
2714
|
+
* Just marks a place of place where should be something implemented
|
|
2715
|
+
* No side effects.
|
|
2716
|
+
*
|
|
2717
|
+
* Note: It can be usefull suppressing eslint errors of unused variables
|
|
2718
|
+
*
|
|
2719
|
+
* @param value any values
|
|
2720
|
+
* @returns void
|
|
2616
2721
|
*/
|
|
2722
|
+
function TODO_USE() {
|
|
2723
|
+
var value = [];
|
|
2724
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2725
|
+
value[_i] = arguments[_i];
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2617
2728
|
|
|
2618
|
-
|
|
2729
|
+
/**
|
|
2730
|
+
* @@@
|
|
2731
|
+
*/
|
|
2732
|
+
function prepareKnowledgeFromMarkdown(content /* <- TODO: [🖖] (?maybe not) Always the file */, options) {
|
|
2619
2733
|
return __awaiter(this, void 0, void 0, function () {
|
|
2620
|
-
var
|
|
2621
|
-
var
|
|
2734
|
+
var llmTools, _a, maxParallelCount, _b, isVerbose, collection, prepareKnowledgeFromMarkdownExecutor, _c, prepareTitleExecutor, _d, prepareKeywordsExecutor, _e, result, outputParameters, knowledgeRaw, knowledgeTextPieces, knowledge;
|
|
2735
|
+
var _f, _g, _h;
|
|
2622
2736
|
var _this = this;
|
|
2623
|
-
return __generator(this, function (
|
|
2624
|
-
switch (
|
|
2737
|
+
return __generator(this, function (_j) {
|
|
2738
|
+
switch (_j.label) {
|
|
2625
2739
|
case 0:
|
|
2626
|
-
|
|
2740
|
+
llmTools = options.llmTools, _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a, _b = options.isVerbose, isVerbose = _b === void 0 ? false : _b;
|
|
2741
|
+
TODO_USE(maxParallelCount); // <- [🪂]
|
|
2627
2742
|
collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
|
|
2628
|
-
_b = createPipelineExecutor;
|
|
2629
|
-
_e = {};
|
|
2630
|
-
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md')];
|
|
2631
|
-
case 1:
|
|
2632
|
-
prepareKnowledgeFromMarkdownExecutor = _b.apply(void 0, [(_e.pipeline = _h.sent(),
|
|
2633
|
-
_e.tools = {
|
|
2634
|
-
llm: llmTools,
|
|
2635
|
-
},
|
|
2636
|
-
_e)]);
|
|
2637
2743
|
_c = createPipelineExecutor;
|
|
2638
2744
|
_f = {};
|
|
2639
|
-
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-
|
|
2640
|
-
case
|
|
2641
|
-
|
|
2745
|
+
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md')];
|
|
2746
|
+
case 1:
|
|
2747
|
+
prepareKnowledgeFromMarkdownExecutor = _c.apply(void 0, [(_f.pipeline = _j.sent(),
|
|
2642
2748
|
_f.tools = {
|
|
2643
2749
|
llm: llmTools,
|
|
2644
2750
|
},
|
|
2645
2751
|
_f)]);
|
|
2646
2752
|
_d = createPipelineExecutor;
|
|
2647
2753
|
_g = {};
|
|
2648
|
-
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-
|
|
2649
|
-
case
|
|
2650
|
-
|
|
2754
|
+
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md')];
|
|
2755
|
+
case 2:
|
|
2756
|
+
prepareTitleExecutor = _d.apply(void 0, [(_g.pipeline = _j.sent(),
|
|
2651
2757
|
_g.tools = {
|
|
2652
2758
|
llm: llmTools,
|
|
2653
2759
|
},
|
|
2654
2760
|
_g)]);
|
|
2761
|
+
_e = createPipelineExecutor;
|
|
2762
|
+
_h = {};
|
|
2763
|
+
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md')];
|
|
2764
|
+
case 3:
|
|
2765
|
+
prepareKeywordsExecutor = _e.apply(void 0, [(_h.pipeline = _j.sent(),
|
|
2766
|
+
_h.tools = {
|
|
2767
|
+
llm: llmTools,
|
|
2768
|
+
},
|
|
2769
|
+
_h)]);
|
|
2655
2770
|
return [4 /*yield*/, prepareKnowledgeFromMarkdownExecutor({ content: content })];
|
|
2656
2771
|
case 4:
|
|
2657
|
-
result =
|
|
2658
|
-
// TODO: [0] !!! Aggeregate usage
|
|
2772
|
+
result = _j.sent();
|
|
2659
2773
|
assertsExecutionSuccessful(result);
|
|
2660
2774
|
outputParameters = result.outputParameters;
|
|
2661
2775
|
knowledgeRaw = outputParameters.knowledge;
|
|
@@ -2664,9 +2778,9 @@
|
|
|
2664
2778
|
console.info('knowledgeTextPieces:', knowledgeTextPieces);
|
|
2665
2779
|
}
|
|
2666
2780
|
return [4 /*yield*/, Promise.all(
|
|
2667
|
-
// TODO:
|
|
2781
|
+
// TODO: [🪂] !! Do not send all at once but in chunks
|
|
2668
2782
|
knowledgeTextPieces.map(function (knowledgeTextPiece, i) { return __awaiter(_this, void 0, void 0, function () {
|
|
2669
|
-
var name, title, content, keywords, index,
|
|
2783
|
+
var name, title, content, keywords, index, titleResult, _a, titleRaw, keywordsResult, _b, keywordsRaw, embeddingResult, error_1;
|
|
2670
2784
|
return __generator(this, function (_c) {
|
|
2671
2785
|
switch (_c.label) {
|
|
2672
2786
|
case 0:
|
|
@@ -2675,12 +2789,6 @@
|
|
|
2675
2789
|
content = spaceTrim__default["default"](knowledgeTextPiece);
|
|
2676
2790
|
keywords = [];
|
|
2677
2791
|
index = [];
|
|
2678
|
-
sources = [
|
|
2679
|
-
{
|
|
2680
|
-
title: 'Markdown document' /* <- TODO: !!! Unhardcode */,
|
|
2681
|
-
href: '#' /* <- TODO: !!! Unhardcode */,
|
|
2682
|
-
},
|
|
2683
|
-
];
|
|
2684
2792
|
_c.label = 1;
|
|
2685
2793
|
case 1:
|
|
2686
2794
|
_c.trys.push([1, 7, , 8]);
|
|
@@ -2715,7 +2823,6 @@
|
|
|
2715
2823
|
})];
|
|
2716
2824
|
case 5:
|
|
2717
2825
|
embeddingResult = _c.sent();
|
|
2718
|
-
// TODO: [0] !!! Aggeregate usage embeddingResult.usage
|
|
2719
2826
|
index.push({
|
|
2720
2827
|
modelName: embeddingResult.modelName,
|
|
2721
2828
|
position: embeddingResult.content,
|
|
@@ -2733,21 +2840,388 @@
|
|
|
2733
2840
|
content: content,
|
|
2734
2841
|
keywords: keywords,
|
|
2735
2842
|
index: index,
|
|
2736
|
-
|
|
2843
|
+
// <- TODO: [☀] sources,
|
|
2737
2844
|
}];
|
|
2738
2845
|
}
|
|
2739
2846
|
});
|
|
2740
2847
|
}); }))];
|
|
2741
2848
|
case 5:
|
|
2742
|
-
knowledge =
|
|
2849
|
+
knowledge = _j.sent();
|
|
2743
2850
|
return [2 /*return*/, knowledge];
|
|
2744
2851
|
}
|
|
2745
2852
|
});
|
|
2746
2853
|
});
|
|
2747
2854
|
}
|
|
2748
2855
|
/**
|
|
2749
|
-
* 11:11
|
|
2856
|
+
* TODO: [🪂] Do it in parallel 11:11
|
|
2857
|
+
* Note: No need to aggregate usage here, it is done by intercepting the llmTools
|
|
2858
|
+
*/
|
|
2859
|
+
|
|
2860
|
+
/**
|
|
2861
|
+
* Prepares the knowle
|
|
2862
|
+
*
|
|
2863
|
+
* @see https://github.com/webgptorg/promptbook/discussions/41
|
|
2864
|
+
* @private within the package
|
|
2865
|
+
*/
|
|
2866
|
+
function prepareKnowledgePieces(knowledgeSources, options) {
|
|
2867
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2868
|
+
var _a, maxParallelCount, knowledgePrepared;
|
|
2869
|
+
var _this = this;
|
|
2870
|
+
return __generator(this, function (_b) {
|
|
2871
|
+
switch (_b.label) {
|
|
2872
|
+
case 0:
|
|
2873
|
+
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a;
|
|
2874
|
+
knowledgePrepared = [];
|
|
2875
|
+
return [4 /*yield*/, forEachAsync(knowledgeSources, { maxParallelCount: maxParallelCount }, function (knowledgeSource) { return __awaiter(_this, void 0, void 0, function () {
|
|
2876
|
+
var partialPieces, pieces;
|
|
2877
|
+
return __generator(this, function (_a) {
|
|
2878
|
+
switch (_a.label) {
|
|
2879
|
+
case 0: return [4 /*yield*/, prepareKnowledgeFromMarkdown(knowledgeSource.source, // <- TODO: !!!!! Unhardcode markdown, detect which type it is
|
|
2880
|
+
options)];
|
|
2881
|
+
case 1:
|
|
2882
|
+
partialPieces = _a.sent();
|
|
2883
|
+
pieces = partialPieces.map(function (partialPiece) { return (__assign(__assign({}, partialPiece), { sources: [
|
|
2884
|
+
{
|
|
2885
|
+
name: knowledgeSource.name,
|
|
2886
|
+
// line, column <- TODO: [☀]
|
|
2887
|
+
// <- TODO: [❎]
|
|
2888
|
+
},
|
|
2889
|
+
] })); });
|
|
2890
|
+
knowledgePrepared.push.apply(knowledgePrepared, __spreadArray([], __read(pieces), false));
|
|
2891
|
+
return [2 /*return*/];
|
|
2892
|
+
}
|
|
2893
|
+
});
|
|
2894
|
+
}); })];
|
|
2895
|
+
case 1:
|
|
2896
|
+
_b.sent();
|
|
2897
|
+
return [2 /*return*/, knowledgePrepared];
|
|
2898
|
+
}
|
|
2899
|
+
});
|
|
2900
|
+
});
|
|
2901
|
+
}
|
|
2902
|
+
/*
|
|
2903
|
+
TODO: [🧊] This is how it can look in future
|
|
2904
|
+
> type PrepareKnowledgeKnowledge = {
|
|
2905
|
+
> /**
|
|
2906
|
+
> * Unprepared knowledge
|
|
2907
|
+
> * /
|
|
2908
|
+
> readonly knowledgeSources: Array<KnowledgeSourceJson>;
|
|
2909
|
+
> };
|
|
2910
|
+
>
|
|
2911
|
+
> export async function prepareKnowledgePieces(
|
|
2912
|
+
> knowledge: PrepareKnowledgeKnowledge,
|
|
2913
|
+
> options: PrepareOptions,
|
|
2914
|
+
> ):
|
|
2915
|
+
*/
|
|
2916
|
+
/**
|
|
2917
|
+
* TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
|
|
2918
|
+
* Put `knowledgePieces` into `PrepareKnowledgeOptions`
|
|
2919
|
+
* TODO: [🪂] More than max things can run in parallel by acident [1,[2a,2b,_],[3a,3b,_]]
|
|
2920
|
+
* TODO: [🧠][❎] Do here propper M:N mapping
|
|
2921
|
+
* [x] One source can make multiple pieces
|
|
2922
|
+
* [ ] One piece can have multiple sources
|
|
2923
|
+
*/
|
|
2924
|
+
|
|
2925
|
+
/**
|
|
2926
|
+
* Prepares the persona for the pipeline
|
|
2927
|
+
*
|
|
2928
|
+
* @see https://github.com/webgptorg/promptbook/discussions/22
|
|
2929
|
+
* @private within the package
|
|
2930
|
+
*/
|
|
2931
|
+
function preparePersona(personaDescription, options) {
|
|
2932
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2933
|
+
var llmTools, _a, isVerbose, collection, preparePersonaExecutor, _b, availableModels, availableModelNames, result, outputParameters, modelRequirementsRaw, modelRequirements, modelName, systemMessage, temperature;
|
|
2934
|
+
var _c;
|
|
2935
|
+
return __generator(this, function (_d) {
|
|
2936
|
+
switch (_d.label) {
|
|
2937
|
+
case 0:
|
|
2938
|
+
llmTools = options.llmTools, _a = options.isVerbose, isVerbose = _a === void 0 ? false : _a;
|
|
2939
|
+
collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
|
|
2940
|
+
_b = createPipelineExecutor;
|
|
2941
|
+
_c = {};
|
|
2942
|
+
return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.ptbk.md')];
|
|
2943
|
+
case 1:
|
|
2944
|
+
preparePersonaExecutor = _b.apply(void 0, [(_c.pipeline = _d.sent(),
|
|
2945
|
+
_c.tools = {
|
|
2946
|
+
llm: llmTools,
|
|
2947
|
+
},
|
|
2948
|
+
_c)]);
|
|
2949
|
+
return [4 /*yield*/, llmTools.listModels()];
|
|
2950
|
+
case 2:
|
|
2951
|
+
availableModels = _d.sent();
|
|
2952
|
+
availableModelNames = availableModels
|
|
2953
|
+
.filter(function (_a) {
|
|
2954
|
+
var modelVariant = _a.modelVariant;
|
|
2955
|
+
return modelVariant === 'CHAT';
|
|
2956
|
+
})
|
|
2957
|
+
.map(function (_a) {
|
|
2958
|
+
var modelName = _a.modelName;
|
|
2959
|
+
return modelName;
|
|
2960
|
+
})
|
|
2961
|
+
.join(',');
|
|
2962
|
+
return [4 /*yield*/, preparePersonaExecutor({ availableModelNames: availableModelNames, personaDescription: personaDescription })];
|
|
2963
|
+
case 3:
|
|
2964
|
+
result = _d.sent();
|
|
2965
|
+
assertsExecutionSuccessful(result);
|
|
2966
|
+
outputParameters = result.outputParameters;
|
|
2967
|
+
modelRequirementsRaw = outputParameters.modelRequirements;
|
|
2968
|
+
modelRequirements = JSON.parse(modelRequirementsRaw);
|
|
2969
|
+
if (isVerbose) {
|
|
2970
|
+
console.info("PERSONA ".concat(personaDescription), modelRequirements);
|
|
2971
|
+
}
|
|
2972
|
+
modelName = modelRequirements.modelName, systemMessage = modelRequirements.systemMessage, temperature = modelRequirements.temperature;
|
|
2973
|
+
// TODO: !!! Check validity of `modelName`
|
|
2974
|
+
// TODO: !!! Check validity of `systemMessage`
|
|
2975
|
+
// TODO: !!! Check validity of `temperature`
|
|
2976
|
+
return [2 /*return*/, {
|
|
2977
|
+
modelVariant: 'CHAT',
|
|
2978
|
+
modelName: modelName,
|
|
2979
|
+
systemMessage: systemMessage,
|
|
2980
|
+
temperature: temperature,
|
|
2981
|
+
}];
|
|
2982
|
+
}
|
|
2983
|
+
});
|
|
2984
|
+
});
|
|
2985
|
+
}
|
|
2986
|
+
|
|
2987
|
+
/**
|
|
2988
|
+
* Prepare pipeline from string (markdown) format to JSON format
|
|
2989
|
+
*
|
|
2990
|
+
* Note: This function does not validate logic of the pipeline
|
|
2991
|
+
* Note: This function acts as part of compilation process
|
|
2992
|
+
*/
|
|
2993
|
+
function preparePipeline(pipeline, options) {
|
|
2994
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2995
|
+
var _a, maxParallelCount,
|
|
2996
|
+
/*
|
|
2997
|
+
<- TODO: [🧠][0] `promptbookVersion` */
|
|
2998
|
+
knowledgeSources /*
|
|
2999
|
+
<- TODO: [🧊] `knowledgePieces` */, personas /*
|
|
3000
|
+
<- TODO: [🧊] `preparations` */, currentPreparation, preparations, preparedPersonas, knowledgeSourcesPrepared, partialknowledgePiecesPrepared, knowledgePiecesPrepared;
|
|
3001
|
+
var _this = this;
|
|
3002
|
+
return __generator(this, function (_b) {
|
|
3003
|
+
switch (_b.label) {
|
|
3004
|
+
case 0:
|
|
3005
|
+
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a;
|
|
3006
|
+
knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
|
|
3007
|
+
currentPreparation = {
|
|
3008
|
+
id: 1,
|
|
3009
|
+
// TODO: [🍥]> date: $currentDate(),
|
|
3010
|
+
promptbookVersion: PROMPTBOOK_VERSION,
|
|
3011
|
+
modelUsage: addUsage(),
|
|
3012
|
+
};
|
|
3013
|
+
preparations = [
|
|
3014
|
+
// ...preparations
|
|
3015
|
+
// <- TODO: [🧊]
|
|
3016
|
+
currentPreparation,
|
|
3017
|
+
];
|
|
3018
|
+
preparedPersonas = new Array(personas.length);
|
|
3019
|
+
return [4 /*yield*/, forEachAsync(personas, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (persona, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
3020
|
+
var modelRequirements, preparedPersona;
|
|
3021
|
+
return __generator(this, function (_a) {
|
|
3022
|
+
switch (_a.label) {
|
|
3023
|
+
case 0: return [4 /*yield*/, preparePersona(persona.description, options)];
|
|
3024
|
+
case 1:
|
|
3025
|
+
modelRequirements = _a.sent();
|
|
3026
|
+
preparedPersona = __assign(__assign({}, persona), { modelRequirements: modelRequirements, preparationIds: [/* TODO: [🧊] -> */ currentPreparation.id] });
|
|
3027
|
+
preparedPersonas[index] = preparedPersona;
|
|
3028
|
+
return [2 /*return*/];
|
|
3029
|
+
}
|
|
3030
|
+
});
|
|
3031
|
+
}); })];
|
|
3032
|
+
case 1:
|
|
3033
|
+
_b.sent();
|
|
3034
|
+
knowledgeSourcesPrepared = knowledgeSources.map(function (source) { return (__assign(__assign({}, source), { preparationIds: [/* TODO: [🧊] -> */ currentPreparation.id] })); });
|
|
3035
|
+
return [4 /*yield*/, prepareKnowledgePieces(knowledgeSources /* <- TODO: [🧊] {knowledgeSources, knowledgePieces} */, options)];
|
|
3036
|
+
case 2:
|
|
3037
|
+
partialknowledgePiecesPrepared = _b.sent();
|
|
3038
|
+
knowledgePiecesPrepared = partialknowledgePiecesPrepared.map(function (piece) { return (__assign(__assign({}, piece), { preparationIds: [/* TODO: [🧊] -> */ currentPreparation.id] })); });
|
|
3039
|
+
// ----- /Knowledge preparation -----
|
|
3040
|
+
return [2 /*return*/, __assign(__assign({}, pipeline), { knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: preparations })];
|
|
3041
|
+
}
|
|
3042
|
+
});
|
|
3043
|
+
});
|
|
3044
|
+
}
|
|
3045
|
+
/**
|
|
3046
|
+
* TODO: Write tests for `preparePipeline`
|
|
3047
|
+
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
3048
|
+
* TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
|
|
3049
|
+
* TODO: !!!!! Use here countTotalUsage
|
|
3050
|
+
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
3051
|
+
*/
|
|
3052
|
+
|
|
3053
|
+
/**
|
|
3054
|
+
* Tests if given string is valid URL.
|
|
3055
|
+
*
|
|
3056
|
+
* Note: This does not check if the file exists only if the path is valid
|
|
3057
|
+
*/
|
|
3058
|
+
function isValidFilePath(filePath) {
|
|
3059
|
+
if (typeof filePath !== 'string') {
|
|
3060
|
+
return false;
|
|
3061
|
+
}
|
|
3062
|
+
var filePathSlashes = filePath.split('\\').join('/');
|
|
3063
|
+
// Absolute Unix path: /hello.txt
|
|
3064
|
+
if (/^(\/)/i.test(filePathSlashes)) {
|
|
3065
|
+
return true;
|
|
3066
|
+
}
|
|
3067
|
+
// Absolute Windows path: /hello.txt
|
|
3068
|
+
if (/^([A-Z]{1,2}:\/?)\//i.test(filePathSlashes)) {
|
|
3069
|
+
return true;
|
|
3070
|
+
}
|
|
3071
|
+
// Relative path: ./hello.txt
|
|
3072
|
+
if (/^(\.\.?\/)+/i.test(filePathSlashes)) {
|
|
3073
|
+
return true;
|
|
3074
|
+
}
|
|
3075
|
+
return false;
|
|
3076
|
+
}
|
|
3077
|
+
|
|
3078
|
+
/**
|
|
3079
|
+
* Parses the knowledge command
|
|
3080
|
+
*
|
|
3081
|
+
* @see ./KNOWLEDGE-README.md for more details
|
|
3082
|
+
* @private within the commands folder
|
|
2750
3083
|
*/
|
|
3084
|
+
var knowledgeCommandParser = {
|
|
3085
|
+
/**
|
|
3086
|
+
* Name of the command
|
|
3087
|
+
*/
|
|
3088
|
+
name: 'KNOWLEDGE',
|
|
3089
|
+
/**
|
|
3090
|
+
* BOILERPLATE command can be used in:
|
|
3091
|
+
*/
|
|
3092
|
+
usagePlaces: ['PIPELINE_HEAD'],
|
|
3093
|
+
/**
|
|
3094
|
+
* Description of the KNOWLEDGE command
|
|
3095
|
+
*/
|
|
3096
|
+
description: "Tells promptbook which external knowledge to use",
|
|
3097
|
+
/**
|
|
3098
|
+
* Link to discussion
|
|
3099
|
+
*/
|
|
3100
|
+
discussionUrl: 'https://github.com/webgptorg/promptbook/discussions/41',
|
|
3101
|
+
/**
|
|
3102
|
+
* Example usages of the KNOWLEDGE command
|
|
3103
|
+
*/
|
|
3104
|
+
examples: [
|
|
3105
|
+
'KNOWLEDGE https://www.pavolhejny.com/',
|
|
3106
|
+
'KNOWLEDGE ./hejny-cv.txt',
|
|
3107
|
+
'KNOWLEDGE ./hejny-cv.md',
|
|
3108
|
+
'KNOWLEDGE ./hejny-cv.pdf',
|
|
3109
|
+
'KNOWLEDGE ./hejny-cv.docx',
|
|
3110
|
+
],
|
|
3111
|
+
/**
|
|
3112
|
+
* Parses the KNOWLEDGE command
|
|
3113
|
+
*/
|
|
3114
|
+
parse: function (input) {
|
|
3115
|
+
var args = input.args;
|
|
3116
|
+
var source = args[0];
|
|
3117
|
+
if (source === undefined) {
|
|
3118
|
+
throw new ParsingError("Source is not defined");
|
|
3119
|
+
}
|
|
3120
|
+
if (source.startsWith('http://')) {
|
|
3121
|
+
throw new ParsingError("Source is not secure");
|
|
3122
|
+
}
|
|
3123
|
+
if (!(isValidFilePath(source) || isValidUrl(source))) {
|
|
3124
|
+
throw new ParsingError("Source not valid");
|
|
3125
|
+
}
|
|
3126
|
+
if (source.startsWith('../') || source.startsWith('/') || /^[A-Z]:[\\/]+/i.test(source)) {
|
|
3127
|
+
throw new ParsingError("Source cannot be outside of the .ptbk.md folder");
|
|
3128
|
+
}
|
|
3129
|
+
return {
|
|
3130
|
+
type: 'KNOWLEDGE',
|
|
3131
|
+
source: source,
|
|
3132
|
+
};
|
|
3133
|
+
},
|
|
3134
|
+
/**
|
|
3135
|
+
* Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
3136
|
+
*/
|
|
3137
|
+
applyToPipelineJson: function (pipelineJson, personaCommand) {
|
|
3138
|
+
var source = personaCommand.source;
|
|
3139
|
+
var name = titleToName(source);
|
|
3140
|
+
pipelineJson.knowledgeSources.push({
|
|
3141
|
+
name: name,
|
|
3142
|
+
source: source,
|
|
3143
|
+
});
|
|
3144
|
+
},
|
|
3145
|
+
};
|
|
3146
|
+
|
|
3147
|
+
/**
|
|
3148
|
+
* Parses the persona command
|
|
3149
|
+
*
|
|
3150
|
+
* @see ./PERSONA-README.md for more details
|
|
3151
|
+
* @private within the commands folder
|
|
3152
|
+
*/
|
|
3153
|
+
var personaCommandParser = {
|
|
3154
|
+
/**
|
|
3155
|
+
* Name of the command
|
|
3156
|
+
*/
|
|
3157
|
+
name: 'PERSONA',
|
|
3158
|
+
/**
|
|
3159
|
+
* Aliases for the PERSONA command
|
|
3160
|
+
*/
|
|
3161
|
+
aliasNames: ['PERSON'],
|
|
3162
|
+
/**
|
|
3163
|
+
* PERSONA command can be used in:
|
|
3164
|
+
*/
|
|
3165
|
+
usagePlaces: ['PIPELINE_HEAD', 'PIPELINE_TEMPLATE'],
|
|
3166
|
+
/**
|
|
3167
|
+
* Description of the PERSONA command
|
|
3168
|
+
*/
|
|
3169
|
+
description: "Persona command is used to specify who the system is, it will be transformed into system message, top_t,...",
|
|
3170
|
+
/**
|
|
3171
|
+
* Link to discussion
|
|
3172
|
+
*/
|
|
3173
|
+
discussionUrl: 'https://github.com/webgptorg/promptbook/discussions/22',
|
|
3174
|
+
/**
|
|
3175
|
+
* Example usages of the PERSONA command
|
|
3176
|
+
*/
|
|
3177
|
+
examples: ['PERSONA Jane, skilled copywriter', 'PERSONA Joe, male 28 years old, programmer'],
|
|
3178
|
+
/**
|
|
3179
|
+
* Parses the PERSONA command
|
|
3180
|
+
*/
|
|
3181
|
+
parse: function (input) {
|
|
3182
|
+
var rawArgs = input.rawArgs;
|
|
3183
|
+
var _a = __read(rawArgs.split(/[,;:]/, 2), 2), personaNameRaw = _a[0], personaDescriptionRaw = _a[1];
|
|
3184
|
+
var personaName = (personaNameRaw || '').trim();
|
|
3185
|
+
if (personaName === '') {
|
|
3186
|
+
throw new ParsingError("You must set name for the persona");
|
|
3187
|
+
}
|
|
3188
|
+
var personaDescription = (personaDescriptionRaw || '').trim();
|
|
3189
|
+
if (personaDescription === '') {
|
|
3190
|
+
personaDescription = null;
|
|
3191
|
+
}
|
|
3192
|
+
return {
|
|
3193
|
+
type: 'PERSONA',
|
|
3194
|
+
personaName: personaName,
|
|
3195
|
+
personaDescription: personaDescription,
|
|
3196
|
+
};
|
|
3197
|
+
},
|
|
3198
|
+
/**
|
|
3199
|
+
* Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
3200
|
+
*/
|
|
3201
|
+
applyToPipelineJson: function (pipelineJson, personaCommand) {
|
|
3202
|
+
var personaName = personaCommand.personaName, personaDescription = personaCommand.personaDescription;
|
|
3203
|
+
var persona = pipelineJson.personas.find(function (persona) { return persona.name === personaName; });
|
|
3204
|
+
if (persona === undefined) {
|
|
3205
|
+
pipelineJson.personas.push({
|
|
3206
|
+
name: personaName,
|
|
3207
|
+
description: personaDescription || '',
|
|
3208
|
+
});
|
|
3209
|
+
return;
|
|
3210
|
+
}
|
|
3211
|
+
if (persona.description === personaDescription) {
|
|
3212
|
+
return;
|
|
3213
|
+
}
|
|
3214
|
+
if (personaDescription === null) {
|
|
3215
|
+
return;
|
|
3216
|
+
}
|
|
3217
|
+
if (persona.description === '') {
|
|
3218
|
+
persona.description = personaDescription;
|
|
3219
|
+
return;
|
|
3220
|
+
}
|
|
3221
|
+
console.warn(spaceTrim__default["default"]("\n\n Persona \"".concat(personaName, "\" is defined multiple times with different description:\n\n First definition:\n ").concat(persona.description, "\n\n Second definition:\n ").concat(personaDescription, "\n\n ")));
|
|
3222
|
+
persona.description += spaceTrim__default["default"]('\n\n' + personaDescription);
|
|
3223
|
+
},
|
|
3224
|
+
};
|
|
2751
3225
|
|
|
2752
3226
|
/**
|
|
2753
3227
|
* Removes Markdown formatting tags from a string.
|
|
@@ -2903,7 +3377,6 @@
|
|
|
2903
3377
|
normalized = normalized.split('EXAMPLE').join('SAMPLE');
|
|
2904
3378
|
var blockTypes = BlockTypes.filter(function (blockType) { return normalized.includes(blockType); });
|
|
2905
3379
|
if (blockTypes.length !== 1) {
|
|
2906
|
-
// console.log('!!!', { blockType });
|
|
2907
3380
|
throw new ParsingError(spaceTrim__default["default"](function (block) { return "\n Unknown block type in BLOCK command\n\n Supported block types are:\n ".concat(block(BlockTypes.join(', ')), "\n "); }));
|
|
2908
3381
|
}
|
|
2909
3382
|
// TODO: !!!! Not supported yet
|
|
@@ -2916,6 +3389,7 @@
|
|
|
2916
3389
|
|
|
2917
3390
|
/**
|
|
2918
3391
|
* Units of text measurement
|
|
3392
|
+
* @see https://github.com/webgptorg/promptbook/discussions/30
|
|
2919
3393
|
*/
|
|
2920
3394
|
var EXPECTATION_UNITS = ['CHARACTERS', 'WORDS', 'SENTENCES', 'LINES', 'PARAGRAPHS', 'PAGES'];
|
|
2921
3395
|
/**
|
|
@@ -3151,94 +3625,15 @@
|
|
|
3151
3625
|
},
|
|
3152
3626
|
};
|
|
3153
3627
|
|
|
3154
|
-
/**
|
|
3155
|
-
* Tests if given string is valid URL.
|
|
3156
|
-
*
|
|
3157
|
-
* Note: This does not check if the file exists only if the path is valid
|
|
3158
|
-
*/
|
|
3159
|
-
function isValidFilePath(filePath) {
|
|
3160
|
-
if (typeof filePath !== 'string') {
|
|
3161
|
-
return false;
|
|
3162
|
-
}
|
|
3163
|
-
var filePathSlashes = filePath.split('\\').join('/');
|
|
3164
|
-
// Absolute Unix path: /hello.txt
|
|
3165
|
-
if (/^(\/)/i.test(filePathSlashes)) {
|
|
3166
|
-
return true;
|
|
3167
|
-
}
|
|
3168
|
-
// Absolute Windows path: /hello.txt
|
|
3169
|
-
if (/^([A-Z]{1,2}:\/?)\//i.test(filePathSlashes)) {
|
|
3170
|
-
return true;
|
|
3171
|
-
}
|
|
3172
|
-
// Relative path: ./hello.txt
|
|
3173
|
-
if (/^(\.\.?\/)+/i.test(filePathSlashes)) {
|
|
3174
|
-
return true;
|
|
3175
|
-
}
|
|
3176
|
-
return false;
|
|
3177
|
-
}
|
|
3178
|
-
|
|
3179
|
-
/**
|
|
3180
|
-
* Parses the knowledge command
|
|
3181
|
-
*
|
|
3182
|
-
* @see ./KNOWLEDGE-README.md for more details
|
|
3183
|
-
* @private within the commands folder
|
|
3184
|
-
*/
|
|
3185
|
-
var knowledgeCommandParser = {
|
|
3186
|
-
/**
|
|
3187
|
-
* Name of the command
|
|
3188
|
-
*/
|
|
3189
|
-
name: 'KNOWLEDGE',
|
|
3190
|
-
/**
|
|
3191
|
-
* BOILERPLATE command can be used in:
|
|
3192
|
-
*/
|
|
3193
|
-
usagePlaces: ['PIPELINE_HEAD'],
|
|
3194
|
-
/**
|
|
3195
|
-
* Description of the KNOWLEDGE command
|
|
3196
|
-
*/
|
|
3197
|
-
description: "Tells promptbook which external knowledge to use",
|
|
3198
|
-
/**
|
|
3199
|
-
* Link to discussion
|
|
3200
|
-
*/
|
|
3201
|
-
discussionUrl: 'https://github.com/webgptorg/promptbook/discussions/41',
|
|
3202
|
-
/**
|
|
3203
|
-
* Example usages of the KNOWLEDGE command
|
|
3204
|
-
*/
|
|
3205
|
-
examples: [
|
|
3206
|
-
'KNOWLEDGE https://www.pavolhejny.com/',
|
|
3207
|
-
'KNOWLEDGE ./hejny-cv.txt',
|
|
3208
|
-
'KNOWLEDGE ./hejny-cv.md',
|
|
3209
|
-
'KNOWLEDGE ./hejny-cv.pdf',
|
|
3210
|
-
'KNOWLEDGE ./hejny-cv.docx',
|
|
3211
|
-
],
|
|
3212
|
-
/**
|
|
3213
|
-
* Parses the KNOWLEDGE command
|
|
3214
|
-
*/
|
|
3215
|
-
parse: function (input) {
|
|
3216
|
-
var args = input.args;
|
|
3217
|
-
var source = args[0];
|
|
3218
|
-
if (source === undefined) {
|
|
3219
|
-
throw new ParsingError("Source is not defined");
|
|
3220
|
-
}
|
|
3221
|
-
if (source.startsWith('http://')) {
|
|
3222
|
-
throw new ParsingError("Source is not secure");
|
|
3223
|
-
}
|
|
3224
|
-
if (!(isValidFilePath(source) || isValidUrl(source))) {
|
|
3225
|
-
throw new ParsingError("Source not valid");
|
|
3226
|
-
}
|
|
3227
|
-
if (source.startsWith('../') || source.startsWith('/') || /^[A-Z]:[\\/]+/i.test(source)) {
|
|
3228
|
-
throw new ParsingError("Source cannot be outside of the .ptbk.md folder");
|
|
3229
|
-
}
|
|
3230
|
-
return {
|
|
3231
|
-
type: 'KNOWLEDGE',
|
|
3232
|
-
source: source,
|
|
3233
|
-
};
|
|
3234
|
-
},
|
|
3235
|
-
};
|
|
3236
|
-
|
|
3237
3628
|
var MODEL_VARIANTS = ['COMPLETION', 'CHAT', 'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */];
|
|
3238
3629
|
/**
|
|
3630
|
+
* TODO: [🈁] `seed` should maybe be somewhere else (not in `ModelRequirements`) (simmilar that `user` identification is not here)
|
|
3631
|
+
* TODO: [🧠][💱] Add more model options: `stop_token`, `logit_bias`, `logprobs` (`top_logprobs`), `top_k`, `top_p`, `presence_penalty`, `frequency_penalty`, `bestOf`, `logitBias`, `logitBiasType`,...
|
|
3632
|
+
* [💱] Probbably keep using just `temperature` in Promptbook (not `top_k` and `top_p`)
|
|
3633
|
+
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
3239
3634
|
* TODO: Maybe figure out better word than "variant"
|
|
3240
3635
|
* TODO: Add here more requirement options like max context size, max tokens, etc.
|
|
3241
|
-
* TODO: [
|
|
3636
|
+
* TODO: [💕][🧠] Just selecting gpt3 or gpt4 level of model
|
|
3242
3637
|
*/
|
|
3243
3638
|
|
|
3244
3639
|
/**
|
|
@@ -3377,59 +3772,6 @@
|
|
|
3377
3772
|
},
|
|
3378
3773
|
};
|
|
3379
3774
|
|
|
3380
|
-
/**
|
|
3381
|
-
* Parses the persona command
|
|
3382
|
-
*
|
|
3383
|
-
* @see ./PERSONA-README.md for more details
|
|
3384
|
-
* @private within the commands folder
|
|
3385
|
-
*/
|
|
3386
|
-
var personaCommandParser = {
|
|
3387
|
-
/**
|
|
3388
|
-
* Name of the command
|
|
3389
|
-
*/
|
|
3390
|
-
name: 'PERSONA',
|
|
3391
|
-
/**
|
|
3392
|
-
* Aliases for the PERSONA command
|
|
3393
|
-
*/
|
|
3394
|
-
aliasNames: ['PERSON'],
|
|
3395
|
-
/**
|
|
3396
|
-
* PERSONA command can be used in:
|
|
3397
|
-
*/
|
|
3398
|
-
usagePlaces: ['PIPELINE_HEAD', 'PIPELINE_TEMPLATE'],
|
|
3399
|
-
/**
|
|
3400
|
-
* Description of the PERSONA command
|
|
3401
|
-
*/
|
|
3402
|
-
description: "Persona command is used to specify who the system is, it will be transformed into system message, top_t,...",
|
|
3403
|
-
/**
|
|
3404
|
-
* Link to discussion
|
|
3405
|
-
*/
|
|
3406
|
-
discussionUrl: 'https://github.com/webgptorg/promptbook/discussions/22',
|
|
3407
|
-
/**
|
|
3408
|
-
* Example usages of the PERSONA command
|
|
3409
|
-
*/
|
|
3410
|
-
examples: ['PERSONA Jane, skilled copywriter', 'PERSONA Joe, male 28 years old, programmer'],
|
|
3411
|
-
/**
|
|
3412
|
-
* Parses the PERSONA command
|
|
3413
|
-
*/
|
|
3414
|
-
parse: function (input) {
|
|
3415
|
-
var rawArgs = input.rawArgs;
|
|
3416
|
-
var _a = __read(rawArgs.split(/[,;:]/, 2), 2), personaNameRaw = _a[0], personaDescriptionRaw = _a[1];
|
|
3417
|
-
var personaName = (personaNameRaw || '').trim();
|
|
3418
|
-
if (personaName === '') {
|
|
3419
|
-
throw new ParsingError("You must set name for the persona");
|
|
3420
|
-
}
|
|
3421
|
-
var personaDescription = (personaDescriptionRaw || '').trim();
|
|
3422
|
-
if (personaDescription === '') {
|
|
3423
|
-
personaDescription = null;
|
|
3424
|
-
}
|
|
3425
|
-
return {
|
|
3426
|
-
type: 'PERSONA',
|
|
3427
|
-
personaName: personaName,
|
|
3428
|
-
personaDescription: personaDescription,
|
|
3429
|
-
};
|
|
3430
|
-
},
|
|
3431
|
-
};
|
|
3432
|
-
|
|
3433
3775
|
function isValidJavascriptName(javascriptName) {
|
|
3434
3776
|
if (typeof javascriptName !== 'string') {
|
|
3435
3777
|
return false;
|
|
@@ -3616,22 +3958,6 @@
|
|
|
3616
3958
|
},
|
|
3617
3959
|
};
|
|
3618
3960
|
|
|
3619
|
-
/**
|
|
3620
|
-
* Returns the same value that is passed as argument.
|
|
3621
|
-
* No side effects.
|
|
3622
|
-
*
|
|
3623
|
-
* Note: It can be usefull for leveling indentation
|
|
3624
|
-
*
|
|
3625
|
-
* @param value any values
|
|
3626
|
-
* @returns the same values
|
|
3627
|
-
*/
|
|
3628
|
-
function just(value) {
|
|
3629
|
-
if (value === undefined) {
|
|
3630
|
-
return undefined;
|
|
3631
|
-
}
|
|
3632
|
-
return value;
|
|
3633
|
-
}
|
|
3634
|
-
|
|
3635
3961
|
/**
|
|
3636
3962
|
* Parses the action command
|
|
3637
3963
|
*
|
|
@@ -3663,7 +3989,8 @@
|
|
|
3663
3989
|
* Parses the ACTION command
|
|
3664
3990
|
*/
|
|
3665
3991
|
parse: function (input) {
|
|
3666
|
-
input.args;
|
|
3992
|
+
var args = input.args;
|
|
3993
|
+
TODO_USE(args);
|
|
3667
3994
|
return {
|
|
3668
3995
|
type: 'ACTION',
|
|
3669
3996
|
};
|
|
@@ -3701,7 +4028,8 @@
|
|
|
3701
4028
|
* Parses the INSTRUMENT command
|
|
3702
4029
|
*/
|
|
3703
4030
|
parse: function (input) {
|
|
3704
|
-
input.args;
|
|
4031
|
+
var args = input.args;
|
|
4032
|
+
TODO_USE(args);
|
|
3705
4033
|
return {
|
|
3706
4034
|
type: 'INSTRUMENT',
|
|
3707
4035
|
};
|
|
@@ -3883,7 +4211,6 @@
|
|
|
3883
4211
|
var _loop_1 = function (commandParser) {
|
|
3884
4212
|
var name_1 = commandParser.name, aliasNames = commandParser.aliasNames, deprecatedNames = commandParser.deprecatedNames, parse = commandParser.parse;
|
|
3885
4213
|
var names = __spreadArray(__spreadArray([name_1], __read((aliasNames || [])), false), __read((deprecatedNames || [])), false);
|
|
3886
|
-
// console.log('!!!', { commandName, names });
|
|
3887
4214
|
if (names.includes(commandName)) {
|
|
3888
4215
|
try {
|
|
3889
4216
|
return { value: parse({ usagePlace: usagePlace, raw: raw, rawArgs: rawArgs, normalized: normalized, args: args }) };
|
|
@@ -3993,25 +4320,42 @@
|
|
|
3993
4320
|
var e_1, _a;
|
|
3994
4321
|
var codeBlocks = [];
|
|
3995
4322
|
var lines = markdown.split('\n');
|
|
4323
|
+
// Note: [0] Ensure that the last block notated by gt > will be closed
|
|
4324
|
+
lines.push('');
|
|
3996
4325
|
var currentCodeBlock = null;
|
|
3997
4326
|
try {
|
|
3998
4327
|
for (var lines_1 = __values(lines), lines_1_1 = lines_1.next(); !lines_1_1.done; lines_1_1 = lines_1.next()) {
|
|
3999
4328
|
var line = lines_1_1.value;
|
|
4329
|
+
if (line.startsWith('> ') || line === '>') {
|
|
4330
|
+
if (currentCodeBlock === null) {
|
|
4331
|
+
currentCodeBlock = { blockNotation: '>', language: null, content: '' };
|
|
4332
|
+
} /* not else */
|
|
4333
|
+
if (currentCodeBlock.blockNotation === '>') {
|
|
4334
|
+
if (currentCodeBlock.content !== '') {
|
|
4335
|
+
currentCodeBlock.content += '\n';
|
|
4336
|
+
}
|
|
4337
|
+
currentCodeBlock.content += line.slice(2);
|
|
4338
|
+
}
|
|
4339
|
+
}
|
|
4340
|
+
else if (currentCodeBlock !== null && currentCodeBlock.blockNotation === '>' /* <- Note: [0] */) {
|
|
4341
|
+
codeBlocks.push(currentCodeBlock);
|
|
4342
|
+
currentCodeBlock = null;
|
|
4343
|
+
}
|
|
4344
|
+
/* not else */
|
|
4000
4345
|
if (line.startsWith('```')) {
|
|
4001
4346
|
var language = line.slice(3).trim() || null;
|
|
4002
4347
|
if (currentCodeBlock === null) {
|
|
4003
|
-
currentCodeBlock = { language: language, content: '' };
|
|
4348
|
+
currentCodeBlock = { blockNotation: '```', language: language, content: '' };
|
|
4004
4349
|
}
|
|
4005
4350
|
else {
|
|
4006
4351
|
if (language !== null) {
|
|
4007
|
-
|
|
4008
|
-
throw new Error("".concat(capitalize(currentCodeBlock.language || 'the'), " code block was not closed and already opening new ").concat(language, " code block"));
|
|
4352
|
+
throw new ParsingError("".concat(capitalize(currentCodeBlock.language || 'the'), " code block was not closed and already opening new ").concat(language, " code block"));
|
|
4009
4353
|
}
|
|
4010
4354
|
codeBlocks.push(currentCodeBlock);
|
|
4011
4355
|
currentCodeBlock = null;
|
|
4012
4356
|
}
|
|
4013
4357
|
}
|
|
4014
|
-
else if (currentCodeBlock !== null) {
|
|
4358
|
+
else if (currentCodeBlock !== null && currentCodeBlock.blockNotation === '```') {
|
|
4015
4359
|
if (currentCodeBlock.content !== '') {
|
|
4016
4360
|
currentCodeBlock.content += '\n';
|
|
4017
4361
|
}
|
|
@@ -4027,11 +4371,13 @@
|
|
|
4027
4371
|
finally { if (e_1) throw e_1.error; }
|
|
4028
4372
|
}
|
|
4029
4373
|
if (currentCodeBlock !== null) {
|
|
4030
|
-
|
|
4031
|
-
throw new Error("".concat(capitalize(currentCodeBlock.language || 'the'), " code block was not closed at the end of the markdown"));
|
|
4374
|
+
throw new ParsingError("".concat(capitalize(currentCodeBlock.language || 'the'), " code block was not closed at the end of the markdown"));
|
|
4032
4375
|
}
|
|
4033
4376
|
return codeBlocks;
|
|
4034
4377
|
}
|
|
4378
|
+
/**
|
|
4379
|
+
* TODO: Maybe name for `blockNotation` instead of '```' and '>'
|
|
4380
|
+
*/
|
|
4035
4381
|
|
|
4036
4382
|
/**
|
|
4037
4383
|
* Extracts exactly ONE code block from markdown.
|
|
@@ -4049,13 +4395,12 @@
|
|
|
4049
4395
|
function extractOneBlockFromMarkdown(markdown) {
|
|
4050
4396
|
var codeBlocks = extractAllBlocksFromMarkdown(markdown);
|
|
4051
4397
|
if (codeBlocks.length !== 1) {
|
|
4052
|
-
|
|
4053
|
-
throw new Error(/* <- [🌻] */ 'There should be exactly one code block in the markdown');
|
|
4398
|
+
throw new ParsingError(spaceTrim__default["default"](function (block) { return "\n There should be exactly 1 code block, found ".concat(codeBlocks.length, " code blocks\n\n ").concat(block(codeBlocks.map(function (block, i) { return "Block ".concat(i + 1, ":\n").concat(block.content); }).join('\n\n\n')), "\n "); }));
|
|
4054
4399
|
}
|
|
4055
4400
|
return codeBlocks[0];
|
|
4056
4401
|
}
|
|
4057
4402
|
/***
|
|
4058
|
-
* TODO: [🍓][🌻]
|
|
4403
|
+
* TODO: [🍓][🌻] Decide of this is internal util, external util OR validator/postprocessor
|
|
4059
4404
|
*/
|
|
4060
4405
|
|
|
4061
4406
|
/**
|
|
@@ -4065,13 +4410,13 @@
|
|
|
4065
4410
|
var _a, _b;
|
|
4066
4411
|
var lines = value.split('\n');
|
|
4067
4412
|
if (!lines[0].startsWith('#')) {
|
|
4068
|
-
throw new
|
|
4413
|
+
throw new ParsingError('Markdown section must start with heading');
|
|
4069
4414
|
}
|
|
4070
4415
|
var title = lines[0].replace(/^#+\s*/, '');
|
|
4071
4416
|
var level = (_b = (_a = lines[0].match(/^#+/)) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
|
|
4072
4417
|
var content = spaceTrim__default["default"](lines.slice(1).join('\n'));
|
|
4073
4418
|
if (level < 1 || level > 6) {
|
|
4074
|
-
throw new
|
|
4419
|
+
throw new ParsingError('Markdown section must have heading level between 1 and 6');
|
|
4075
4420
|
}
|
|
4076
4421
|
return { title: title, level: level, content: content };
|
|
4077
4422
|
}
|
|
@@ -4397,14 +4742,14 @@
|
|
|
4397
4742
|
*/
|
|
4398
4743
|
|
|
4399
4744
|
/**
|
|
4400
|
-
* Compile
|
|
4745
|
+
* Compile pipeline from string (markdown) format to JSON format synchronously
|
|
4401
4746
|
*
|
|
4402
|
-
* Note: There are
|
|
4747
|
+
* Note: There are 3 similar functions:
|
|
4403
4748
|
* - `pipelineStringToJson` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
|
|
4404
4749
|
* - `pipelineStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
|
|
4750
|
+
* - `preparePipeline` - just one step in the compilation process
|
|
4405
4751
|
*
|
|
4406
4752
|
* @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
|
|
4407
|
-
* @param options - Options and tools for the compilation
|
|
4408
4753
|
* @returns {Promptbook} compiled in JSON format (.ptbk.json)
|
|
4409
4754
|
* @throws {ParsingError} if the promptbook string is not valid
|
|
4410
4755
|
*
|
|
@@ -4420,7 +4765,10 @@
|
|
|
4420
4765
|
description: undefined /* <- Note: Putting here placeholder to keep `description` on top at final JSON */,
|
|
4421
4766
|
parameters: [],
|
|
4422
4767
|
promptTemplates: [],
|
|
4423
|
-
|
|
4768
|
+
knowledgeSources: [],
|
|
4769
|
+
knowledgePieces: [],
|
|
4770
|
+
personas: [],
|
|
4771
|
+
preparations: [],
|
|
4424
4772
|
};
|
|
4425
4773
|
// =============================================================
|
|
4426
4774
|
// Note: 1️⃣ Parsing of the markdown into object
|
|
@@ -4450,7 +4798,7 @@
|
|
|
4450
4798
|
existingParameter.description &&
|
|
4451
4799
|
existingParameter.description !== parameterDescription &&
|
|
4452
4800
|
parameterDescription) {
|
|
4453
|
-
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description
|
|
4801
|
+
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description:\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
|
|
4454
4802
|
}
|
|
4455
4803
|
if (existingParameter) {
|
|
4456
4804
|
if (parameterDescription) {
|
|
@@ -4469,11 +4817,12 @@
|
|
|
4469
4817
|
// =============================================================
|
|
4470
4818
|
// Note: 3️⃣ Process pipeline head
|
|
4471
4819
|
pipelineJson.title = pipelineHead.title;
|
|
4472
|
-
// TODO: [1] DRY description
|
|
4820
|
+
// TODO: [🎾][1] DRY description
|
|
4473
4821
|
var description = pipelineHead.content;
|
|
4474
|
-
// Note: Remove codeblocks - TODO:
|
|
4822
|
+
// Note: Remove codeblocks - TODO: [🎾] Make util removeAllBlocksFromMarkdown (exported from `@promptbool/utils`)
|
|
4475
4823
|
description = description.split(/^```.*^```/gms).join('');
|
|
4476
|
-
|
|
4824
|
+
description = description.split(/^>.*$/gm).join('');
|
|
4825
|
+
//Note: Remove lists and return statement - TODO: [🎾] Make util (exported from `@promptbool/utils`)
|
|
4477
4826
|
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
4478
4827
|
description = spaceTrim.spaceTrim(description);
|
|
4479
4828
|
if (description === '') {
|
|
@@ -4501,7 +4850,7 @@
|
|
|
4501
4850
|
pipelineJson.pipelineUrl = command.pipelineUrl.href;
|
|
4502
4851
|
break;
|
|
4503
4852
|
case 'KNOWLEDGE':
|
|
4504
|
-
|
|
4853
|
+
knowledgeCommandParser.applyToPipelineJson(pipelineJson, command);
|
|
4505
4854
|
break;
|
|
4506
4855
|
case 'ACTION':
|
|
4507
4856
|
console.error(new NotYetImplementedError('Actions are not implemented yet'));
|
|
@@ -4510,7 +4859,8 @@
|
|
|
4510
4859
|
console.error(new NotYetImplementedError('Instruments are not implemented yet'));
|
|
4511
4860
|
break;
|
|
4512
4861
|
case 'PERSONA':
|
|
4513
|
-
|
|
4862
|
+
personaCommandParser.applyToPipelineJson(pipelineJson, command);
|
|
4863
|
+
// <- Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
4514
4864
|
break;
|
|
4515
4865
|
case 'BOILERPLATE':
|
|
4516
4866
|
throw new ParsingError('BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file'); // <- TODO: [🚞]
|
|
@@ -4539,7 +4889,27 @@
|
|
|
4539
4889
|
var postprocessing = [];
|
|
4540
4890
|
var expectAmount = {};
|
|
4541
4891
|
var expectFormat = undefined;
|
|
4542
|
-
var
|
|
4892
|
+
var isBlockTypeSet = false;
|
|
4893
|
+
var lastLine = section.content.split('\n').pop();
|
|
4894
|
+
var resultingParameterNameMatch = /^->\s*\{(?<resultingParamName>[a-z0-9_]+)\}/im.exec(lastLine);
|
|
4895
|
+
var resultingParameterName = null;
|
|
4896
|
+
if (resultingParameterNameMatch &&
|
|
4897
|
+
resultingParameterNameMatch.groups !== undefined &&
|
|
4898
|
+
resultingParameterNameMatch.groups.resultingParamName !== undefined) {
|
|
4899
|
+
resultingParameterName = resultingParameterNameMatch.groups.resultingParamName;
|
|
4900
|
+
}
|
|
4901
|
+
var expectResultingParameterName = function () {
|
|
4902
|
+
if (resultingParameterName !== null) {
|
|
4903
|
+
return resultingParameterName;
|
|
4904
|
+
}
|
|
4905
|
+
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Template section must end with -> {parameterName}\n\n Invalid section:\n ".concat(block(
|
|
4906
|
+
// TODO: Show code of invalid sections each time + DRY
|
|
4907
|
+
section.content
|
|
4908
|
+
.split('\n')
|
|
4909
|
+
.map(function (line) { return " | ".concat(line); } /* <- TODO: [🚞] */)
|
|
4910
|
+
.join('\n')), "\n "); }));
|
|
4911
|
+
};
|
|
4912
|
+
var _e = extractOneBlockFromMarkdown(section.content), language = _e.language, content = _e.content;
|
|
4543
4913
|
try {
|
|
4544
4914
|
for (var listItems_2 = (e_3 = void 0, __values(listItems_3)), listItems_2_1 = listItems_2.next(); !listItems_2_1.done; listItems_2_1 = listItems_2.next()) {
|
|
4545
4915
|
var listItem = listItems_2_1.value;
|
|
@@ -4547,15 +4917,24 @@
|
|
|
4547
4917
|
switch (command.type) {
|
|
4548
4918
|
// TODO: [🍧] Use here applyToPipelineJson and remove switch statement
|
|
4549
4919
|
case 'BLOCK':
|
|
4550
|
-
if (
|
|
4920
|
+
if (isBlockTypeSet) {
|
|
4551
4921
|
throw new ParsingError('Block type is already defined in the prompt template. It can be defined only once.');
|
|
4552
4922
|
}
|
|
4553
4923
|
if (command.blockType === 'SAMPLE') {
|
|
4554
|
-
|
|
4924
|
+
expectResultingParameterName();
|
|
4925
|
+
var parameter = pipelineJson.parameters.find(function (param) { return param.name === resultingParameterName; });
|
|
4926
|
+
if (parameter === undefined) {
|
|
4927
|
+
throw new UnexpectedError("Can not find parameter {".concat(resultingParameterName, "} to assign sample value"));
|
|
4928
|
+
}
|
|
4929
|
+
parameter.sampleValues = parameter.sampleValues || [];
|
|
4930
|
+
parameter.sampleValues.push(content);
|
|
4555
4931
|
return "continue-templates";
|
|
4556
4932
|
}
|
|
4557
4933
|
if (command.blockType === 'KNOWLEDGE') {
|
|
4558
|
-
|
|
4934
|
+
knowledgeCommandParser.applyToPipelineJson(pipelineJson, {
|
|
4935
|
+
type: 'KNOWLEDGE',
|
|
4936
|
+
source: content, // <- TODO: !!!! Working KNOWLEDGE which not referring to the source file/wweb, but its content itseld
|
|
4937
|
+
});
|
|
4559
4938
|
return "continue-templates";
|
|
4560
4939
|
}
|
|
4561
4940
|
if (command.blockType === 'ACTION') {
|
|
@@ -4566,8 +4945,9 @@
|
|
|
4566
4945
|
console.error(new NotYetImplementedError('Instruments are not implemented yet'));
|
|
4567
4946
|
return "continue-templates";
|
|
4568
4947
|
}
|
|
4948
|
+
expectResultingParameterName();
|
|
4569
4949
|
blockType = command.blockType;
|
|
4570
|
-
|
|
4950
|
+
isBlockTypeSet = true;
|
|
4571
4951
|
break;
|
|
4572
4952
|
case 'EXPECT_AMOUNT':
|
|
4573
4953
|
// eslint-disable-next-line no-case-declarations
|
|
@@ -4607,16 +4987,20 @@
|
|
|
4607
4987
|
postprocessing.push(command.functionName);
|
|
4608
4988
|
break;
|
|
4609
4989
|
case 'KNOWLEDGE':
|
|
4610
|
-
|
|
4990
|
+
// TODO: [👙] The knowledge is maybe relevant for just this template
|
|
4991
|
+
knowledgeCommandParser.applyToPipelineJson(pipelineJson, command);
|
|
4611
4992
|
break;
|
|
4612
4993
|
case 'ACTION':
|
|
4994
|
+
// TODO: [👙] The action is maybe relevant for just this template
|
|
4613
4995
|
console.error(new NotYetImplementedError('Actions are not implemented yet'));
|
|
4614
4996
|
break;
|
|
4615
4997
|
case 'INSTRUMENT':
|
|
4998
|
+
// TODO: [👙] The instrument is maybe relevant for just this template
|
|
4616
4999
|
console.error(new NotYetImplementedError('Instruments are not implemented yet'));
|
|
4617
5000
|
break;
|
|
4618
5001
|
case 'PERSONA':
|
|
4619
|
-
|
|
5002
|
+
personaCommandParser.applyToPipelineJson(pipelineJson, command);
|
|
5003
|
+
// <- Note: Prototype of [🍧] (remove this comment after full implementation)
|
|
4620
5004
|
break;
|
|
4621
5005
|
case 'BOILERPLATE':
|
|
4622
5006
|
console.error(new ParsingError('BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file'));
|
|
@@ -4634,7 +5018,6 @@
|
|
|
4634
5018
|
}
|
|
4635
5019
|
finally { if (e_3) throw e_3.error; }
|
|
4636
5020
|
}
|
|
4637
|
-
var _e = extractOneBlockFromMarkdown(section.content), language = _e.language, content = _e.content;
|
|
4638
5021
|
if (blockType === 'SCRIPT') {
|
|
4639
5022
|
if (!language) {
|
|
4640
5023
|
throw new ParsingError('You must specify the language of the script in the prompt template');
|
|
@@ -4643,22 +5026,12 @@
|
|
|
4643
5026
|
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Script language ".concat(language, " is not supported.\n\n Supported languages are:\n ").concat(block(SUPPORTED_SCRIPT_LANGUAGES.join(', ')), "\n\n "); }));
|
|
4644
5027
|
}
|
|
4645
5028
|
}
|
|
4646
|
-
|
|
4647
|
-
var match = /^->\s*\{(?<resultingParamName>[a-z0-9_]+)\}/im.exec(lastLine);
|
|
4648
|
-
if (!match || match.groups === undefined || match.groups.resultingParamName === undefined) {
|
|
4649
|
-
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Each section must end with -> {parameterName}\n\n Invalid section:\n ".concat(block(
|
|
4650
|
-
// TODO: Show code of invalid sections each time + DRY
|
|
4651
|
-
section.content
|
|
4652
|
-
.split('\n')
|
|
4653
|
-
.map(function (line) { return " | ".concat(line); } /* <- TODO: [🚞] */)
|
|
4654
|
-
.join('\n')), "\n "); }));
|
|
4655
|
-
}
|
|
4656
|
-
var resultingParameterName = match.groups.resultingParamName;
|
|
4657
|
-
// TODO: [1] DRY description
|
|
5029
|
+
// TODO: [🎾][1] DRY description
|
|
4658
5030
|
var description_1 = section.content;
|
|
4659
|
-
// Note: Remove codeblocks
|
|
5031
|
+
// Note: Remove codeblocks - TODO: [🎾]
|
|
4660
5032
|
description_1 = description_1.split(/^```.*^```/gms).join('');
|
|
4661
|
-
|
|
5033
|
+
description_1 = description_1.split(/^>.*$/gm).join('');
|
|
5034
|
+
//Note: Remove lists and return statement - TODO: [🎾]
|
|
4662
5035
|
description_1 = description_1.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
4663
5036
|
description_1 = spaceTrim.spaceTrim(description_1);
|
|
4664
5037
|
if (description_1 === '') {
|
|
@@ -4688,10 +5061,11 @@
|
|
|
4688
5061
|
postprocessing: postprocessing,
|
|
4689
5062
|
expectations: expectAmount,
|
|
4690
5063
|
expectFormat: expectFormat,
|
|
5064
|
+
personaName: null,
|
|
4691
5065
|
modelRequirements: templateModelRequirements,
|
|
4692
5066
|
contentLanguage: blockType === 'SCRIPT' ? language : undefined,
|
|
4693
5067
|
content: content,
|
|
4694
|
-
resultingParameterName:
|
|
5068
|
+
resultingParameterName: expectResultingParameterName( /* <- Note: This is once more redundant */),
|
|
4695
5069
|
};
|
|
4696
5070
|
if (blockType !== 'PROMPT_TEMPLATE') {
|
|
4697
5071
|
delete template.modelRequirements;
|
|
@@ -4764,14 +5138,17 @@
|
|
|
4764
5138
|
* TODO: Use spaceTrim more effectively
|
|
4765
5139
|
* TODO: [🧠] Parameter flags - isInput, isOutput, isInternal
|
|
4766
5140
|
* TODO: [🥞] Not optimal parsing because `splitMarkdownIntoSections` is executed twice with same string, once through `flattenMarkdown` and second directly here
|
|
5141
|
+
* TODO: [♈] Probbably move expectations from templates to parameters
|
|
5142
|
+
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
4767
5143
|
*/
|
|
4768
5144
|
|
|
4769
5145
|
/**
|
|
4770
|
-
* Compile
|
|
5146
|
+
* Compile pipeline from string (markdown) format to JSON format
|
|
4771
5147
|
*
|
|
4772
|
-
* Note: There are
|
|
5148
|
+
* Note: There are 3 similar functions:
|
|
4773
5149
|
* - `pipelineStringToJson` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
|
|
4774
5150
|
* - `pipelineStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
|
|
5151
|
+
* - `preparePipeline` - just one step in the compilation process
|
|
4775
5152
|
*
|
|
4776
5153
|
* @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
|
|
4777
5154
|
* @param options - Options and tools for the compilation
|
|
@@ -4782,22 +5159,18 @@
|
|
|
4782
5159
|
* Note: This function acts as compilation process
|
|
4783
5160
|
*/
|
|
4784
5161
|
function pipelineStringToJson(pipelineString, options) {
|
|
4785
|
-
if (options === void 0) { options = {}; }
|
|
5162
|
+
if (options === void 0) { options = { llmTools: null }; }
|
|
4786
5163
|
return __awaiter(this, void 0, void 0, function () {
|
|
4787
|
-
var llmTools, pipelineJson
|
|
5164
|
+
var llmTools, pipelineJson;
|
|
4788
5165
|
return __generator(this, function (_a) {
|
|
4789
5166
|
switch (_a.label) {
|
|
4790
5167
|
case 0:
|
|
4791
5168
|
llmTools = options.llmTools;
|
|
4792
5169
|
pipelineJson = pipelineStringToJsonSync(pipelineString);
|
|
4793
|
-
if (!llmTools) return [3 /*break*/, 2];
|
|
4794
|
-
return [4 /*yield*/,
|
|
4795
|
-
content: 'Roses are red, violets are blue, programmers use Promptbook, users too',
|
|
4796
|
-
llmTools: llmTools,
|
|
4797
|
-
})];
|
|
5170
|
+
if (!(llmTools !== null)) return [3 /*break*/, 2];
|
|
5171
|
+
return [4 /*yield*/, preparePipeline(pipelineJson, { llmTools: llmTools })];
|
|
4798
5172
|
case 1:
|
|
4799
|
-
|
|
4800
|
-
pipelineJson = __assign(__assign({}, pipelineJson), { knowledge: __spreadArray(__spreadArray([], __read((pipelineJson.knowledge || [])), false), __read(knowledge), false) });
|
|
5173
|
+
pipelineJson = _a.sent();
|
|
4801
5174
|
_a.label = 2;
|
|
4802
5175
|
case 2: return [2 /*return*/, pipelineJson];
|
|
4803
5176
|
}
|
|
@@ -4806,6 +5179,7 @@
|
|
|
4806
5179
|
}
|
|
4807
5180
|
/**
|
|
4808
5181
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
5182
|
+
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
4809
5183
|
*/
|
|
4810
5184
|
|
|
4811
5185
|
/**
|
|
@@ -4823,7 +5197,10 @@
|
|
|
4823
5197
|
}
|
|
4824
5198
|
var placeForSection = removeContentComments(content).match(/^##.*$/im);
|
|
4825
5199
|
if (!placeForSection) {
|
|
4826
|
-
throw new
|
|
5200
|
+
throw new ParsingError(
|
|
5201
|
+
// <- [🧠] Maybe something better than `ParsingError`
|
|
5202
|
+
"No place where to put the section <!--".concat(sectionName, "-->"));
|
|
5203
|
+
// <- [🚞]
|
|
4827
5204
|
}
|
|
4828
5205
|
var _a = __read(placeForSection, 1), heading = _a[0];
|
|
4829
5206
|
return content.replace(heading, "<!--".concat(sectionName, "-->\n").concat(warningLine, "\n").concat(sectionContent, "\n<!--/").concat(sectionName, "-->\n\n").concat(heading));
|
|
@@ -4994,6 +5371,20 @@
|
|
|
4994
5371
|
return CollectionError;
|
|
4995
5372
|
}(Error));
|
|
4996
5373
|
|
|
5374
|
+
/**
|
|
5375
|
+
* This error type indicates that the version of the pipeline is not matching the expected version
|
|
5376
|
+
*/
|
|
5377
|
+
var VersionMismatchError = /** @class */ (function (_super) {
|
|
5378
|
+
__extends(VersionMismatchError, _super);
|
|
5379
|
+
function VersionMismatchError(message, expectedVersion) {
|
|
5380
|
+
var _this = _super.call(this, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n This error indicates that there is error with compatibility\n\n Expected version:\n ").concat(expectedVersion, "\n\n Current version:\n ").concat(PROMPTBOOK_VERSION, "\n\n "); })) || this;
|
|
5381
|
+
_this.name = 'UnexpectedError';
|
|
5382
|
+
Object.setPrototypeOf(_this, VersionMismatchError.prototype);
|
|
5383
|
+
return _this;
|
|
5384
|
+
}
|
|
5385
|
+
return VersionMismatchError;
|
|
5386
|
+
}(Error));
|
|
5387
|
+
|
|
4997
5388
|
/**
|
|
4998
5389
|
* Pretty print an embedding vector for logging
|
|
4999
5390
|
*/
|
|
@@ -5082,6 +5473,19 @@
|
|
|
5082
5473
|
return SimplePromptInterfaceTools;
|
|
5083
5474
|
}());
|
|
5084
5475
|
|
|
5476
|
+
/**
|
|
5477
|
+
* Unprepare just strips the preparation data of the pipeline
|
|
5478
|
+
*/
|
|
5479
|
+
function unpreparePipeline(pipeline) {
|
|
5480
|
+
var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources;
|
|
5481
|
+
personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
|
|
5482
|
+
knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
|
|
5483
|
+
return __assign(__assign({}, pipeline), { knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] });
|
|
5484
|
+
}
|
|
5485
|
+
/**
|
|
5486
|
+
* TODO: Write tests for `preparePipeline`
|
|
5487
|
+
*/
|
|
5488
|
+
|
|
5085
5489
|
/**
|
|
5086
5490
|
* Default options for generating an execution report string
|
|
5087
5491
|
*/
|
|
@@ -5182,6 +5586,22 @@
|
|
|
5182
5586
|
return value.replace(/```/g, '\\`\\`\\`');
|
|
5183
5587
|
}
|
|
5184
5588
|
|
|
5589
|
+
/**
|
|
5590
|
+
* Returns the same value that is passed as argument.
|
|
5591
|
+
* No side effects.
|
|
5592
|
+
*
|
|
5593
|
+
* Note: It can be usefull for leveling indentation
|
|
5594
|
+
*
|
|
5595
|
+
* @param value any values
|
|
5596
|
+
* @returns the same values
|
|
5597
|
+
*/
|
|
5598
|
+
function just(value) {
|
|
5599
|
+
if (value === undefined) {
|
|
5600
|
+
return undefined;
|
|
5601
|
+
}
|
|
5602
|
+
return value;
|
|
5603
|
+
}
|
|
5604
|
+
|
|
5185
5605
|
/**
|
|
5186
5606
|
* The thresholds for the relative time in the `moment` NPM package.
|
|
5187
5607
|
*
|
|
@@ -5406,6 +5826,7 @@
|
|
|
5406
5826
|
exports.ReferenceError = ReferenceError$1;
|
|
5407
5827
|
exports.SimplePromptInterfaceTools = SimplePromptInterfaceTools;
|
|
5408
5828
|
exports.UnexpectedError = UnexpectedError;
|
|
5829
|
+
exports.VersionMismatchError = VersionMismatchError;
|
|
5409
5830
|
exports.addUsage = addUsage;
|
|
5410
5831
|
exports.assertsExecutionSuccessful = assertsExecutionSuccessful;
|
|
5411
5832
|
exports.checkExpectations = checkExpectations;
|
|
@@ -5423,7 +5844,9 @@
|
|
|
5423
5844
|
exports.pipelineStringToJson = pipelineStringToJson;
|
|
5424
5845
|
exports.pipelineStringToJsonSync = pipelineStringToJsonSync;
|
|
5425
5846
|
exports.prepareKnowledgeFromMarkdown = prepareKnowledgeFromMarkdown;
|
|
5847
|
+
exports.preparePipeline = preparePipeline;
|
|
5426
5848
|
exports.prettifyPipelineString = prettifyPipelineString;
|
|
5849
|
+
exports.unpreparePipeline = unpreparePipeline;
|
|
5427
5850
|
exports.usageToWorktime = usageToWorktime;
|
|
5428
5851
|
exports.validatePipeline = validatePipeline;
|
|
5429
5852
|
|