@promptbook/utils 0.61.0-8 → 0.61.0
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/README.md +3 -3
- package/esm/index.es.js +349 -189
- package/esm/index.es.js.map +1 -1
- package/esm/typings/promptbook-collection/index.d.ts +200 -30
- package/esm/typings/src/_packages/core.index.d.ts +7 -2
- package/esm/typings/src/_packages/execute-javascript.index.d.ts +1 -1
- package/esm/typings/src/_packages/node.index.d.ts +2 -1
- package/esm/typings/src/_packages/types.index.d.ts +12 -8
- package/esm/typings/src/_packages/utils.index.d.ts +11 -8
- package/esm/typings/src/cli/cli-commands/hello.d.ts +3 -0
- package/esm/typings/src/cli/cli-commands/make.d.ts +3 -0
- package/esm/typings/src/cli/cli-commands/prettify.d.ts +3 -0
- package/esm/typings/src/cli/promptbookCli.d.ts +1 -0
- package/esm/typings/src/collection/PipelineCollection.d.ts +1 -1
- package/esm/typings/src/collection/SimplePipelineCollection.d.ts +10 -10
- package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +7 -7
- package/esm/typings/src/collection/constructors/createCollectionFromUrl.d.ts +2 -2
- package/esm/typings/src/commands/KNOWLEDGE/KnowledgeCommand.d.ts +2 -3
- package/esm/typings/src/commands/MODEL/ModelCommand.d.ts +2 -2
- package/esm/typings/src/commands/PERSONA/PersonaCommand.d.ts +4 -2
- package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -0
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +42 -14
- package/esm/typings/src/config.d.ts +46 -1
- package/esm/typings/src/config.test.d.ts +4 -0
- package/esm/typings/src/conversion/pipelineJsonToString.d.ts +1 -1
- package/esm/typings/src/conversion/pipelineStringToJson.d.ts +9 -5
- package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +6 -3
- package/esm/typings/src/conversion/prettify/PrettifyOptions.d.ts +2 -2
- package/{umd/typings/src/conversion/utils/extractParametersFromPromptTemplate.d.ts → esm/typings/src/conversion/utils/extractParameterNamesFromPromptTemplate.d.ts} +2 -2
- package/esm/typings/src/conversion/utils/renameParameter.d.ts +3 -3
- package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +14 -0
- package/esm/typings/src/conversion/validation/_importPipeline.d.ts +12 -3
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +10 -1
- package/esm/typings/src/errors/EnvironmentMismatchError.d.ts +7 -0
- package/esm/typings/src/errors/LimitReachedError.d.ts +7 -0
- package/esm/typings/src/errors/VersionMismatchError.d.ts +8 -0
- package/esm/typings/src/execution/CommonExecutionToolsOptions.d.ts +1 -0
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +10 -8
- package/esm/typings/src/execution/PipelineExecutor.d.ts +48 -26
- package/esm/typings/src/execution/PromptResult.d.ts +39 -54
- package/esm/typings/src/execution/PromptResultUsage.d.ts +29 -0
- package/esm/typings/src/execution/ScriptExecutionTools.d.ts +5 -4
- package/esm/typings/src/execution/UncertainNumber.d.ts +18 -0
- package/esm/typings/src/execution/UserInterfaceTools.d.ts +5 -5
- package/esm/typings/src/execution/createPipelineExecutor.d.ts +30 -3
- package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +2 -2
- package/esm/typings/src/execution/utils/addUsage.d.ts +58 -2
- package/esm/typings/src/execution/utils/computeUsageCounts.d.ts +1 -1
- package/esm/typings/src/execution/utils/forEachAsync.d.ts +1 -1
- package/esm/typings/src/execution/utils/uncertainNumber.d.ts +1 -1
- package/esm/typings/src/execution/utils/usageToWorktime.d.ts +2 -2
- package/esm/typings/src/formats/_common/FormatDefinition.d.ts +1 -1
- package/esm/typings/src/formats/csv/ListFormatDefinition.d.ts +2 -1
- package/esm/typings/src/formats/json/JsonFormatDefinition.d.ts +2 -1
- package/esm/typings/src/formats/list/ListFormatDefinition.d.ts +2 -1
- package/esm/typings/src/formats/xml/XmlFormatDefinition.d.ts +1 -0
- package/esm/typings/src/knowledge/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +1 -1
- package/esm/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +3 -0
- package/esm/typings/src/knowledge/prepare-knowledge/_common/Scraper.d.ts +27 -0
- package/esm/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.d.ts +18 -0
- package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +9 -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 +8 -14
- package/esm/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +30 -0
- package/esm/typings/src/llm-providers/_common/getLlmToolsForCli.d.ts +10 -0
- package/esm/typings/src/llm-providers/_common/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +11 -0
- package/esm/typings/src/llm-providers/_common/utils/cache/CacheItem.d.ts +29 -0
- package/esm/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +10 -0
- package/esm/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +16 -0
- package/esm/typings/src/llm-providers/_common/utils/count-total-cost/LlmExecutionToolsWithTotalCost.d.ts +11 -0
- package/esm/typings/src/llm-providers/_common/utils/count-total-cost/countTotalCost.d.ts +14 -0
- package/esm/typings/src/llm-providers/_common/utils/count-total-cost/limitTotalCost.d.ts +32 -0
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +4 -3
- 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 +3 -3
- package/esm/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +3 -0
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +5 -4
- 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/langtail/LangtailExecutionTools.d.ts +3 -0
- package/esm/typings/src/llm-providers/langtail/LangtailExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +5 -5
- package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +7 -7
- package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +12 -8
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +7 -6
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/computeOpenaiUsage.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/computeUsage.d.ts +2 -2
- 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/RemoteLlmExecutionTools.d.ts +10 -8
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +2 -2
- package/esm/typings/src/personas/preparePersona.d.ts +15 -0
- package/esm/typings/src/prepare/PrepareOptions.d.ts +22 -0
- package/esm/typings/src/prepare/isPipelinePrepared.d.ts +14 -0
- package/esm/typings/src/prepare/preparePipeline.d.ts +17 -0
- package/esm/typings/src/prepare/prepareTemplates.d.ts +31 -0
- package/esm/typings/src/prepare/unpreparePipeline.d.ts +11 -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/scripting/javascript/utils/unknownToString.d.ts +2 -1
- package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +25 -0
- package/esm/typings/src/storage/_common/PromptbookStorage.test-type.d.ts +5 -0
- package/esm/typings/src/storage/files-storage/FilesStorage.d.ts +30 -0
- package/esm/typings/src/storage/files-storage/FilesStorageOptions.d.ts +13 -0
- package/esm/typings/src/storage/files-storage/utils/nameToSubfolderPath.d.ts +7 -0
- package/esm/typings/src/storage/local-storage/getLocalStorage.d.ts +9 -0
- package/esm/typings/src/storage/local-storage/getSessionStorage.d.ts +9 -0
- package/esm/typings/src/storage/memory/MemoryStorage.d.ts +34 -0
- package/esm/typings/src/storage/utils/PrefixStorage.d.ts +26 -0
- package/esm/typings/src/storage/utils/makePromptbookStorageFromWebStorage.d.ts +11 -0
- package/esm/typings/src/types/ModelRequirements.d.ts +71 -11
- package/esm/typings/src/types/ModelVariant.d.ts +14 -0
- package/esm/typings/src/types/PipelineJson/Expectations.d.ts +6 -2
- package/esm/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +70 -0
- package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +27 -0
- package/esm/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +10 -1
- package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +41 -0
- package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +31 -5
- package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +22 -0
- package/esm/typings/src/types/PipelineJson/PromptDialogJson.d.ts +8 -2
- package/esm/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +5 -1
- package/esm/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +23 -4
- package/esm/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +12 -2
- package/esm/typings/src/types/PipelineJson/ScriptJson.d.ts +7 -2
- package/esm/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +7 -2
- package/esm/typings/src/types/PipelineString.d.ts +1 -1
- package/esm/typings/src/types/Prompt.d.ts +54 -10
- 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/execution-report/countWorkingDuration.d.ts +1 -1
- package/esm/typings/src/types/typeAliases.d.ts +114 -15
- 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/deepClone.d.ts +9 -0
- package/esm/typings/src/utils/deepFreeze.d.ts +22 -0
- package/esm/typings/src/utils/emojis.d.ts +2 -2
- package/esm/typings/src/utils/{extractParameters.d.ts → extractParameterNames.d.ts} +2 -2
- package/esm/typings/src/utils/formatNumber.d.ts +1 -1
- package/esm/typings/src/utils/isRunningInWhatever.d.ts +3 -0
- package/esm/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +3 -3
- package/esm/typings/src/utils/markdown/createMarkdownChart.d.ts +7 -10
- package/esm/typings/src/utils/markdown/createMarkdownTable.d.ts +1 -1
- 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/normalization/parseKeywords.d.ts +2 -1
- package/esm/typings/src/utils/organization/TODO_USE.d.ts +12 -0
- package/esm/typings/src/utils/organization/TODO_any.d.ts +6 -0
- package/esm/typings/src/utils/organization/TODO_object.d.ts +6 -0
- package/esm/typings/src/utils/organization/TODO_unknown.d.ts +6 -0
- package/esm/typings/src/utils/organization/___.d.ts +6 -0
- package/{umd/typings/src/utils → esm/typings/src/utils/organization}/just.d.ts +5 -1
- package/esm/typings/src/utils/organization/keepUnused.d.ts +16 -0
- package/esm/typings/src/utils/organization/really_any.d.ts +6 -0
- package/esm/typings/src/utils/organization/really_unknown.d.ts +6 -0
- package/esm/typings/src/utils/random/randomSeed.d.ts +7 -0
- package/esm/typings/src/{execution/utils → utils}/replaceParameters.d.ts +2 -4
- package/esm/typings/src/utils/replaceParameters.test.d.ts +1 -0
- package/esm/typings/src/utils/sets/difference.d.ts +3 -0
- package/esm/typings/src/utils/validators/email/isValidEmail.d.ts +2 -1
- package/esm/typings/src/utils/validators/filePath/isValidFilePath.d.ts +2 -1
- package/esm/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +2 -1
- package/esm/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.d.ts +2 -1
- package/esm/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.d.ts +2 -1
- package/esm/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -1
- package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +2 -1
- package/esm/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -1
- package/package.json +1 -1
- package/umd/index.umd.js +367 -201
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/promptbook-collection/index.d.ts +200 -30
- package/umd/typings/src/_packages/core.index.d.ts +7 -2
- package/umd/typings/src/_packages/execute-javascript.index.d.ts +1 -1
- package/umd/typings/src/_packages/node.index.d.ts +2 -1
- package/umd/typings/src/_packages/types.index.d.ts +12 -8
- package/umd/typings/src/_packages/utils.index.d.ts +11 -8
- package/umd/typings/src/cli/cli-commands/hello.d.ts +3 -0
- package/umd/typings/src/cli/cli-commands/make.d.ts +3 -0
- package/umd/typings/src/cli/cli-commands/prettify.d.ts +3 -0
- package/umd/typings/src/cli/promptbookCli.d.ts +1 -0
- package/umd/typings/src/collection/PipelineCollection.d.ts +1 -1
- package/umd/typings/src/collection/SimplePipelineCollection.d.ts +10 -10
- package/umd/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +7 -7
- package/umd/typings/src/collection/constructors/createCollectionFromUrl.d.ts +2 -2
- package/umd/typings/src/commands/KNOWLEDGE/KnowledgeCommand.d.ts +2 -3
- package/umd/typings/src/commands/MODEL/ModelCommand.d.ts +2 -2
- package/umd/typings/src/commands/PERSONA/PersonaCommand.d.ts +4 -2
- package/umd/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -0
- package/umd/typings/src/commands/_common/types/CommandParser.d.ts +42 -14
- package/umd/typings/src/config.d.ts +46 -1
- package/umd/typings/src/config.test.d.ts +4 -0
- package/umd/typings/src/conversion/pipelineJsonToString.d.ts +1 -1
- package/umd/typings/src/conversion/pipelineStringToJson.d.ts +9 -5
- package/umd/typings/src/conversion/pipelineStringToJsonSync.d.ts +6 -3
- package/umd/typings/src/conversion/prettify/PrettifyOptions.d.ts +2 -2
- package/{esm/typings/src/conversion/utils/extractParametersFromPromptTemplate.d.ts → umd/typings/src/conversion/utils/extractParameterNamesFromPromptTemplate.d.ts} +2 -2
- package/umd/typings/src/conversion/utils/extractParameterNamesFromPromptTemplate.test.d.ts +1 -0
- package/umd/typings/src/conversion/utils/renameParameter.d.ts +3 -3
- package/umd/typings/src/conversion/utils/stringifyPipelineJson.d.ts +14 -0
- package/umd/typings/src/conversion/utils/stringifyPipelineJson.test.d.ts +1 -0
- package/umd/typings/src/conversion/validation/_importPipeline.d.ts +12 -3
- package/umd/typings/src/conversion/validation/validatePipeline.d.ts +10 -1
- package/umd/typings/src/errors/EnvironmentMismatchError.d.ts +7 -0
- package/umd/typings/src/errors/LimitReachedError.d.ts +7 -0
- package/umd/typings/src/errors/VersionMismatchError.d.ts +8 -0
- package/umd/typings/src/execution/CommonExecutionToolsOptions.d.ts +1 -0
- package/umd/typings/src/execution/LlmExecutionTools.d.ts +10 -8
- package/umd/typings/src/execution/PipelineExecutor.d.ts +48 -26
- package/umd/typings/src/execution/PromptResult.d.ts +39 -54
- package/umd/typings/src/execution/PromptResultUsage.d.ts +29 -0
- package/umd/typings/src/execution/ScriptExecutionTools.d.ts +5 -4
- package/umd/typings/src/execution/UncertainNumber.d.ts +18 -0
- package/umd/typings/src/execution/UserInterfaceTools.d.ts +5 -5
- package/umd/typings/src/execution/createPipelineExecutor.d.ts +30 -3
- package/umd/typings/src/execution/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +2 -2
- package/umd/typings/src/execution/utils/addUsage.d.ts +58 -2
- package/umd/typings/src/execution/utils/computeUsageCounts.d.ts +1 -1
- package/umd/typings/src/execution/utils/forEachAsync.d.ts +1 -1
- package/umd/typings/src/execution/utils/uncertainNumber.d.ts +1 -1
- package/umd/typings/src/execution/utils/usageToWorktime.d.ts +2 -2
- package/umd/typings/src/formats/_common/FormatDefinition.d.ts +1 -1
- package/umd/typings/src/formats/csv/ListFormatDefinition.d.ts +2 -1
- package/umd/typings/src/formats/json/JsonFormatDefinition.d.ts +2 -1
- package/umd/typings/src/formats/list/ListFormatDefinition.d.ts +2 -1
- package/umd/typings/src/formats/xml/XmlFormatDefinition.d.ts +1 -0
- package/umd/typings/src/knowledge/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +1 -1
- package/umd/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +3 -0
- package/umd/typings/src/knowledge/prepare-knowledge/_common/Scraper.d.ts +27 -0
- 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/markdown/prepareKnowledgeFromMarkdown.d.ts +9 -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 +8 -14
- package/umd/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +30 -0
- package/umd/typings/src/llm-providers/_common/getLlmToolsForCli.d.ts +10 -0
- package/umd/typings/src/llm-providers/_common/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +11 -0
- package/umd/typings/src/llm-providers/_common/utils/cache/CacheItem.d.ts +29 -0
- package/umd/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +10 -0
- package/umd/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +16 -0
- package/umd/typings/src/llm-providers/_common/utils/count-total-cost/LlmExecutionToolsWithTotalCost.d.ts +11 -0
- package/umd/typings/src/llm-providers/_common/utils/count-total-cost/countTotalCost.d.ts +14 -0
- package/umd/typings/src/llm-providers/_common/utils/count-total-cost/limitTotalCost.d.ts +32 -0
- package/umd/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +4 -3
- 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 +3 -3
- package/umd/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +3 -0
- package/umd/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +5 -4
- 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/langtail/LangtailExecutionTools.d.ts +3 -0
- package/umd/typings/src/llm-providers/langtail/LangtailExecutionToolsOptions.d.ts +1 -1
- package/umd/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +5 -5
- package/umd/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +7 -7
- package/umd/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +12 -8
- package/umd/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +7 -6
- package/umd/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +1 -1
- package/umd/typings/src/llm-providers/openai/computeOpenaiUsage.d.ts +1 -1
- package/umd/typings/src/llm-providers/openai/computeUsage.d.ts +2 -2
- 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/RemoteLlmExecutionTools.d.ts +10 -8
- package/umd/typings/src/llm-providers/remote/RemoteLlmExecutionToolsOptions.d.ts +1 -1
- package/umd/typings/src/llm-providers/remote/startRemoteServer.d.ts +2 -2
- package/umd/typings/src/personas/preparePersona.d.ts +15 -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/isPipelinePrepared.d.ts +14 -0
- package/umd/typings/src/prepare/isPipelinePrepared.test.d.ts +1 -0
- package/umd/typings/src/prepare/preparePipeline.d.ts +17 -0
- package/umd/typings/src/prepare/prepareTemplates.d.ts +31 -0
- package/umd/typings/src/prepare/unpreparePipeline.d.ts +11 -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/scripting/javascript/utils/unknownToString.d.ts +2 -1
- package/umd/typings/src/storage/_common/PromptbookStorage.d.ts +25 -0
- package/umd/typings/src/storage/_common/PromptbookStorage.test-type.d.ts +5 -0
- package/umd/typings/src/storage/files-storage/FilesStorage.d.ts +30 -0
- package/umd/typings/src/storage/files-storage/FilesStorageOptions.d.ts +13 -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 +9 -0
- package/umd/typings/src/storage/local-storage/getSessionStorage.d.ts +9 -0
- package/umd/typings/src/storage/memory/MemoryStorage.d.ts +34 -0
- package/umd/typings/src/storage/utils/PrefixStorage.d.ts +26 -0
- package/umd/typings/src/storage/utils/makePromptbookStorageFromWebStorage.d.ts +11 -0
- package/umd/typings/src/types/ModelRequirements.d.ts +71 -11
- package/umd/typings/src/types/ModelVariant.d.ts +14 -0
- package/umd/typings/src/types/PipelineJson/Expectations.d.ts +6 -2
- package/umd/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +70 -0
- package/umd/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +27 -0
- package/umd/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +10 -1
- package/umd/typings/src/types/PipelineJson/PersonaJson.d.ts +41 -0
- package/umd/typings/src/types/PipelineJson/PipelineJson.d.ts +31 -5
- package/umd/typings/src/types/PipelineJson/PreparationJson.d.ts +22 -0
- package/umd/typings/src/types/PipelineJson/PromptDialogJson.d.ts +8 -2
- package/umd/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +5 -1
- package/umd/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +23 -4
- package/umd/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +12 -2
- package/umd/typings/src/types/PipelineJson/ScriptJson.d.ts +7 -2
- package/umd/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +7 -2
- package/umd/typings/src/types/PipelineString.d.ts +1 -1
- package/umd/typings/src/types/Prompt.d.ts +54 -10
- 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/execution-report/countWorkingDuration.d.ts +1 -1
- package/umd/typings/src/types/typeAliases.d.ts +114 -15
- 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/deepClone.d.ts +9 -0
- package/umd/typings/src/utils/deepFreeze.d.ts +22 -0
- package/umd/typings/src/utils/emojis.d.ts +2 -2
- package/umd/typings/src/utils/{extractParameters.d.ts → extractParameterNames.d.ts} +2 -2
- package/umd/typings/src/utils/extractParameterNames.test.d.ts +1 -0
- package/umd/typings/src/utils/formatNumber.d.ts +1 -1
- package/umd/typings/src/utils/isRunningInWhatever.d.ts +3 -0
- package/umd/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +3 -3
- package/umd/typings/src/utils/markdown/createMarkdownChart.d.ts +7 -10
- package/umd/typings/src/utils/markdown/createMarkdownTable.d.ts +1 -1
- 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/normalization/parseKeywords.d.ts +2 -1
- package/umd/typings/src/utils/organization/TODO_USE.d.ts +12 -0
- package/umd/typings/src/utils/organization/TODO_any.d.ts +6 -0
- package/umd/typings/src/utils/organization/TODO_object.d.ts +6 -0
- package/umd/typings/src/utils/organization/TODO_unknown.d.ts +6 -0
- package/umd/typings/src/utils/organization/___.d.ts +6 -0
- package/{esm/typings/src/utils → umd/typings/src/utils/organization}/just.d.ts +5 -1
- package/umd/typings/src/utils/organization/keepUnused.d.ts +16 -0
- package/umd/typings/src/utils/organization/really_any.d.ts +6 -0
- package/umd/typings/src/utils/organization/really_unknown.d.ts +6 -0
- package/umd/typings/src/utils/random/randomSeed.d.ts +7 -0
- package/umd/typings/src/{execution/utils → utils}/replaceParameters.d.ts +2 -4
- package/umd/typings/src/utils/replaceParameters.test.d.ts +1 -0
- package/umd/typings/src/utils/sets/difference.d.ts +3 -0
- package/umd/typings/src/utils/validators/email/isValidEmail.d.ts +2 -1
- package/umd/typings/src/utils/validators/filePath/isValidFilePath.d.ts +2 -1
- package/umd/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +2 -1
- package/umd/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.d.ts +2 -1
- package/umd/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.d.ts +2 -1
- package/umd/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -1
- package/umd/typings/src/utils/validators/url/isValidUrl.d.ts +2 -1
- package/umd/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -1
- 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/Parameters.d.ts +0 -14
- 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/Parameters.d.ts +0 -14
- 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/conversion/utils/{extractParametersFromPromptTemplate.test.d.ts → extractParameterNamesFromPromptTemplate.test.d.ts} +0 -0
- /package/esm/typings/src/{execution/addPromptResultUsage.test.d.ts → conversion/utils/stringifyPipelineJson.test.d.ts} +0 -0
- /package/esm/typings/src/{execution/utils/replaceParameters.test.d.ts → knowledge/prepare-knowledge/_common/prepareKnowledgePieces.test.d.ts} +0 -0
- /package/esm/typings/src/{utils/extractParameters.test.d.ts → personas/preparePersona.test.d.ts} +0 -0
- /package/esm/typings/src/{utils/postprocessing → postprocessing/utils}/extractBlock.d.ts +0 -0
- /package/{umd/typings/src/conversion/utils/extractParametersFromPromptTemplate.test.d.ts → esm/typings/src/prepare/isPipelinePrepared.test.d.ts} +0 -0
- /package/{umd/typings/src/execution/addPromptResultUsage.test.d.ts → esm/typings/src/storage/files-storage/utils/nameToSubfolderPath.test.d.ts} +0 -0
- /package/{umd/typings/src/execution/utils/replaceParameters.test.d.ts → esm/typings/src/utils/extractParameterNames.test.d.ts} +0 -0
- /package/{umd/typings/src/utils/extractParameters.test.d.ts → esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown-real.test.d.ts} +0 -0
- /package/umd/typings/src/{utils/postprocessing → postprocessing/utils}/extractBlock.d.ts +0 -0
package/esm/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { spaceTrim } from 'spacetrim';
|
|
1
|
+
import spaceTrim$1, { spaceTrim } from 'spacetrim';
|
|
2
2
|
export { spaceTrim } from 'spacetrim';
|
|
3
3
|
|
|
4
4
|
/*! *****************************************************************************
|
|
@@ -513,6 +513,14 @@ function removeEmojis(text) {
|
|
|
513
513
|
* Function normalizes title to name which can be used as identifier
|
|
514
514
|
*/
|
|
515
515
|
function titleToName(value) {
|
|
516
|
+
if (value.startsWith('http://') || value.startsWith('https://')) {
|
|
517
|
+
// TODO: Maybe check against some list unallowed characters
|
|
518
|
+
return value;
|
|
519
|
+
}
|
|
520
|
+
if (value.startsWith('./') || value.startsWith('../')) {
|
|
521
|
+
// TODO: Maybe check against some list unallowed characters
|
|
522
|
+
return value;
|
|
523
|
+
}
|
|
516
524
|
value = removeEmojis(value);
|
|
517
525
|
value = normalizeToKebabCase(value);
|
|
518
526
|
// TODO: [🧠] Maybe warn or add some padding to short name which are not good identifiers
|
|
@@ -583,7 +591,7 @@ function renderPromptbookMermaid(pipelineJson, options) {
|
|
|
583
591
|
* @param template the template with parameters in {curly} braces
|
|
584
592
|
* @returns the list of parameter names
|
|
585
593
|
*/
|
|
586
|
-
function
|
|
594
|
+
function extractParameterNames(template) {
|
|
587
595
|
var e_1, _a;
|
|
588
596
|
var matches = template.matchAll(/{\w+}/g);
|
|
589
597
|
var parameterNames = new Set();
|
|
@@ -673,37 +681,53 @@ function extractVariables(script) {
|
|
|
673
681
|
* @returns the set of parameter names
|
|
674
682
|
* @throws {ParsingError} if the script is invalid
|
|
675
683
|
*/
|
|
676
|
-
function
|
|
677
|
-
var e_1, _a, e_2, _b;
|
|
684
|
+
function extractParameterNamesFromPromptTemplate(promptTemplate) {
|
|
685
|
+
var e_1, _a, e_2, _b, e_3, _c;
|
|
686
|
+
var title = promptTemplate.title, description = promptTemplate.description, blockType = promptTemplate.blockType, content = promptTemplate.content, preparedContent = promptTemplate.preparedContent, jokerParameterNames = promptTemplate.jokerParameterNames;
|
|
678
687
|
var parameterNames = new Set();
|
|
679
688
|
try {
|
|
680
|
-
for (var
|
|
681
|
-
var parameterName =
|
|
689
|
+
for (var _d = __values(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(extractParameterNames(title)), false), __read(extractParameterNames(description || '')), false), __read(extractParameterNames(content)), false), __read(extractParameterNames(preparedContent || '')), false)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
690
|
+
var parameterName = _e.value;
|
|
682
691
|
parameterNames.add(parameterName);
|
|
683
692
|
}
|
|
684
693
|
}
|
|
685
694
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
686
695
|
finally {
|
|
687
696
|
try {
|
|
688
|
-
if (
|
|
697
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
689
698
|
}
|
|
690
699
|
finally { if (e_1) throw e_1.error; }
|
|
691
700
|
}
|
|
692
|
-
if (
|
|
701
|
+
if (blockType === 'SCRIPT') {
|
|
693
702
|
try {
|
|
694
|
-
for (var
|
|
695
|
-
var parameterName =
|
|
703
|
+
for (var _f = __values(extractVariables(content)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
704
|
+
var parameterName = _g.value;
|
|
696
705
|
parameterNames.add(parameterName);
|
|
697
706
|
}
|
|
698
707
|
}
|
|
699
708
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
700
709
|
finally {
|
|
701
710
|
try {
|
|
702
|
-
if (
|
|
711
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
703
712
|
}
|
|
704
713
|
finally { if (e_2) throw e_2.error; }
|
|
705
714
|
}
|
|
706
715
|
}
|
|
716
|
+
try {
|
|
717
|
+
for (var _h = __values(jokerParameterNames || []), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
718
|
+
var jokerName = _j.value;
|
|
719
|
+
parameterNames.add(jokerName);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
723
|
+
finally {
|
|
724
|
+
try {
|
|
725
|
+
if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
|
|
726
|
+
}
|
|
727
|
+
finally { if (e_3) throw e_3.error; }
|
|
728
|
+
}
|
|
729
|
+
parameterNames.delete('content');
|
|
730
|
+
// <- Note {websiteContent} is used in `preparedContent`
|
|
707
731
|
return parameterNames;
|
|
708
732
|
}
|
|
709
733
|
/**
|
|
@@ -789,12 +813,12 @@ function renameParameter(options) {
|
|
|
789
813
|
*/
|
|
790
814
|
function forEachAsync(array, options, callbackfunction) {
|
|
791
815
|
return __awaiter(this, void 0, void 0, function () {
|
|
792
|
-
var _a,
|
|
816
|
+
var _a, maxParallelCount, index, runningTasks, tasks, _loop_1, _b, _c, item, e_1_1;
|
|
793
817
|
var e_1, _d;
|
|
794
818
|
return __generator(this, function (_e) {
|
|
795
819
|
switch (_e.label) {
|
|
796
820
|
case 0:
|
|
797
|
-
_a = options.
|
|
821
|
+
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? Infinity : _a;
|
|
798
822
|
index = 0;
|
|
799
823
|
runningTasks = [];
|
|
800
824
|
tasks = [];
|
|
@@ -810,7 +834,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
810
834
|
/* not await */ Promise.resolve(task).then(function () {
|
|
811
835
|
runningTasks = runningTasks.filter(function (t) { return t !== task; });
|
|
812
836
|
});
|
|
813
|
-
if (!(
|
|
837
|
+
if (!(maxParallelCount < runningTasks.length)) return [3 /*break*/, 2];
|
|
814
838
|
return [4 /*yield*/, Promise.race(runningTasks)];
|
|
815
839
|
case 1:
|
|
816
840
|
_f.sent();
|
|
@@ -855,101 +879,154 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
855
879
|
}
|
|
856
880
|
|
|
857
881
|
/**
|
|
858
|
-
*
|
|
882
|
+
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
859
883
|
*/
|
|
860
|
-
|
|
884
|
+
function isValidJsonString(value /* <- [👨⚖️] */) {
|
|
885
|
+
try {
|
|
886
|
+
JSON.parse(value);
|
|
887
|
+
return true;
|
|
888
|
+
}
|
|
889
|
+
catch (error) {
|
|
890
|
+
if (!(error instanceof Error)) {
|
|
891
|
+
throw error;
|
|
892
|
+
}
|
|
893
|
+
if (error.message.includes('Unexpected token')) {
|
|
894
|
+
return false;
|
|
895
|
+
}
|
|
896
|
+
return false;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
861
899
|
|
|
862
900
|
/**
|
|
863
|
-
*
|
|
901
|
+
* Makes first letter of a string uppercase
|
|
902
|
+
*
|
|
864
903
|
*/
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
var _this = _super.call(this, message) || this;
|
|
869
|
-
_this.name = 'PipelineExecutionError';
|
|
870
|
-
Object.setPrototypeOf(_this, PipelineExecutionError.prototype);
|
|
871
|
-
return _this;
|
|
872
|
-
}
|
|
873
|
-
return PipelineExecutionError;
|
|
874
|
-
}(Error));
|
|
904
|
+
function capitalize(word) {
|
|
905
|
+
return word.substring(0, 1).toUpperCase() + word.substring(1);
|
|
906
|
+
}
|
|
875
907
|
|
|
876
908
|
/**
|
|
877
|
-
*
|
|
909
|
+
* Extracts all code blocks from markdown.
|
|
878
910
|
*
|
|
879
|
-
*
|
|
880
|
-
*
|
|
881
|
-
*
|
|
882
|
-
*
|
|
911
|
+
* Note: There are 3 simmilar function:
|
|
912
|
+
* - `extractBlock` just extracts the content of the code block which is also used as build-in function for postprocessing
|
|
913
|
+
* - `extractOneBlockFromMarkdown` extracts exactly one code block with language of the code block
|
|
914
|
+
* - `extractAllBlocksFromMarkdown` extracts all code blocks with language of the code block
|
|
915
|
+
*
|
|
916
|
+
* @param markdown any valid markdown
|
|
917
|
+
* @returns code blocks with language and content
|
|
883
918
|
*
|
|
884
|
-
* @private within the createPipelineExecutor
|
|
885
919
|
*/
|
|
886
|
-
function
|
|
887
|
-
var
|
|
888
|
-
var
|
|
889
|
-
var
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
var
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
920
|
+
function extractAllBlocksFromMarkdown(markdown) {
|
|
921
|
+
var e_1, _a;
|
|
922
|
+
var codeBlocks = [];
|
|
923
|
+
var lines = markdown.split('\n');
|
|
924
|
+
// Note: [0] Ensure that the last block notated by gt > will be closed
|
|
925
|
+
lines.push('');
|
|
926
|
+
var currentCodeBlock = null;
|
|
927
|
+
try {
|
|
928
|
+
for (var lines_1 = __values(lines), lines_1_1 = lines_1.next(); !lines_1_1.done; lines_1_1 = lines_1.next()) {
|
|
929
|
+
var line = lines_1_1.value;
|
|
930
|
+
if (line.startsWith('> ') || line === '>') {
|
|
931
|
+
if (currentCodeBlock === null) {
|
|
932
|
+
currentCodeBlock = { blockNotation: '>', language: null, content: '' };
|
|
933
|
+
} /* not else */
|
|
934
|
+
if (currentCodeBlock.blockNotation === '>') {
|
|
935
|
+
if (currentCodeBlock.content !== '') {
|
|
936
|
+
currentCodeBlock.content += '\n';
|
|
937
|
+
}
|
|
938
|
+
currentCodeBlock.content += line.slice(2);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
else if (currentCodeBlock !== null && currentCodeBlock.blockNotation === '>' /* <- Note: [0] */) {
|
|
942
|
+
codeBlocks.push(currentCodeBlock);
|
|
943
|
+
currentCodeBlock = null;
|
|
944
|
+
}
|
|
945
|
+
/* not else */
|
|
946
|
+
if (line.startsWith('```')) {
|
|
947
|
+
var language = line.slice(3).trim() || null;
|
|
948
|
+
if (currentCodeBlock === null) {
|
|
949
|
+
currentCodeBlock = { blockNotation: '```', language: language, content: '' };
|
|
950
|
+
}
|
|
951
|
+
else {
|
|
952
|
+
if (language !== null) {
|
|
953
|
+
throw new ParsingError("".concat(capitalize(currentCodeBlock.language || 'the'), " code block was not closed and already opening new ").concat(language, " code block"));
|
|
954
|
+
}
|
|
955
|
+
codeBlocks.push(currentCodeBlock);
|
|
956
|
+
currentCodeBlock = null;
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
else if (currentCodeBlock !== null && currentCodeBlock.blockNotation === '```') {
|
|
960
|
+
if (currentCodeBlock.content !== '') {
|
|
961
|
+
currentCodeBlock.content += '\n';
|
|
962
|
+
}
|
|
963
|
+
currentCodeBlock.content += line.split('\\`\\`\\`').join('```') /* <- TODO: Maybe make propper unescape */;
|
|
964
|
+
}
|
|
915
965
|
}
|
|
916
|
-
replacedTemplate =
|
|
917
|
-
replacedTemplate.substring(0, match.index + precol.length) +
|
|
918
|
-
parameterValue +
|
|
919
|
-
replacedTemplate.substring(match.index + precol.length + parameterName.length + 2);
|
|
920
|
-
};
|
|
921
|
-
while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
|
|
922
|
-
.exec(replacedTemplate))) {
|
|
923
|
-
_loop_1();
|
|
924
966
|
}
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
967
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
968
|
+
finally {
|
|
969
|
+
try {
|
|
970
|
+
if (lines_1_1 && !lines_1_1.done && (_a = lines_1.return)) _a.call(lines_1);
|
|
971
|
+
}
|
|
972
|
+
finally { if (e_1) throw e_1.error; }
|
|
928
973
|
}
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
throw new PipelineExecutionError('Parameter is not opened');
|
|
974
|
+
if (currentCodeBlock !== null) {
|
|
975
|
+
throw new ParsingError("".concat(capitalize(currentCodeBlock.language || 'the'), " code block was not closed at the end of the markdown"));
|
|
932
976
|
}
|
|
933
|
-
return
|
|
977
|
+
return codeBlocks;
|
|
934
978
|
}
|
|
979
|
+
/**
|
|
980
|
+
* TODO: Maybe name for `blockNotation` instead of '```' and '>'
|
|
981
|
+
*/
|
|
935
982
|
|
|
936
983
|
/**
|
|
937
|
-
*
|
|
984
|
+
* Extracts exactly ONE code block from markdown.
|
|
985
|
+
*
|
|
986
|
+
* Note: If there are multiple or no code blocks the function throws an error
|
|
987
|
+
*
|
|
988
|
+
* Note: There are 3 simmilar function:
|
|
989
|
+
* - `extractBlock` just extracts the content of the code block which is also used as build-in function for postprocessing
|
|
990
|
+
* - `extractOneBlockFromMarkdown` extracts exactly one code block with language of the code block
|
|
991
|
+
* - `extractAllBlocksFromMarkdown` extracts all code blocks with language of the code block
|
|
992
|
+
*
|
|
993
|
+
* @param markdown any valid markdown
|
|
994
|
+
* @returns code block with language and content
|
|
938
995
|
*/
|
|
939
|
-
function
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
return
|
|
943
|
-
}
|
|
944
|
-
catch (error) {
|
|
945
|
-
if (!(error instanceof Error)) {
|
|
946
|
-
throw error;
|
|
947
|
-
}
|
|
948
|
-
if (error.message.includes('Unexpected token')) {
|
|
949
|
-
return false;
|
|
950
|
-
}
|
|
951
|
-
return false;
|
|
996
|
+
function extractOneBlockFromMarkdown(markdown) {
|
|
997
|
+
var codeBlocks = extractAllBlocksFromMarkdown(markdown);
|
|
998
|
+
if (codeBlocks.length !== 1) {
|
|
999
|
+
throw new ParsingError(spaceTrim$1(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 "); }));
|
|
952
1000
|
}
|
|
1001
|
+
return codeBlocks[0];
|
|
1002
|
+
}
|
|
1003
|
+
/***
|
|
1004
|
+
* TODO: [🍓][🌻] Decide of this is internal util, external util OR validator/postprocessor
|
|
1005
|
+
*/
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* Extracts code block from markdown.
|
|
1009
|
+
*
|
|
1010
|
+
* Note: If there are multiple or no code blocks the function throws an error
|
|
1011
|
+
*
|
|
1012
|
+
* Note: There are 3 simmilar function:
|
|
1013
|
+
* - `extractBlock` just extracts the content of the code block which is also used as build-in function for postprocessing
|
|
1014
|
+
* - `extractOneBlockFromMarkdown` extracts exactly one code block with language of the code block
|
|
1015
|
+
* - `extractAllBlocksFromMarkdown` extracts all code blocks with language of the code block
|
|
1016
|
+
*/
|
|
1017
|
+
function extractBlock(markdown) {
|
|
1018
|
+
var content = extractOneBlockFromMarkdown(markdown).content;
|
|
1019
|
+
return content;
|
|
1020
|
+
}
|
|
1021
|
+
//
|
|
1022
|
+
|
|
1023
|
+
/**
|
|
1024
|
+
* Simple wrapper `new Date().toISOString()`
|
|
1025
|
+
*
|
|
1026
|
+
* @returns string_date branded type
|
|
1027
|
+
*/
|
|
1028
|
+
function $currentDate() {
|
|
1029
|
+
return new Date().toISOString();
|
|
953
1030
|
}
|
|
954
1031
|
|
|
955
1032
|
/**
|
|
@@ -1026,14 +1103,6 @@ var CountUtils = {
|
|
|
1026
1103
|
PAGES: countPages,
|
|
1027
1104
|
};
|
|
1028
1105
|
|
|
1029
|
-
/**
|
|
1030
|
-
* Makes first letter of a string uppercase
|
|
1031
|
-
*
|
|
1032
|
-
*/
|
|
1033
|
-
function capitalize(word) {
|
|
1034
|
-
return word.substring(0, 1).toUpperCase() + word.substring(1);
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
1106
|
/**
|
|
1038
1107
|
* Makes first letter of a string uppercase
|
|
1039
1108
|
*
|
|
@@ -1292,122 +1361,210 @@ function parseNumber(value) {
|
|
|
1292
1361
|
*/
|
|
1293
1362
|
|
|
1294
1363
|
/**
|
|
1295
|
-
*
|
|
1364
|
+
* Generates random seed
|
|
1296
1365
|
*
|
|
1297
|
-
*
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1366
|
+
* Warning: This function is not cryptographically secure (it uses Math.random internally)
|
|
1367
|
+
*/
|
|
1368
|
+
function $randomSeed() {
|
|
1369
|
+
return Math.random();
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
/**
|
|
1373
|
+
* Removes quotes from a string
|
|
1301
1374
|
*
|
|
1302
|
-
*
|
|
1303
|
-
*
|
|
1375
|
+
* Tip: This is very usefull for post-processing of the result of the LLM model
|
|
1376
|
+
* Note: This function removes only the same quotes from the beginning and the end of the string
|
|
1377
|
+
* Note: There are two simmilar functions:
|
|
1378
|
+
* - `removeQuotes` which removes only bounding quotes
|
|
1379
|
+
* - `unwrapResult` which removes whole introduce sentence
|
|
1304
1380
|
*
|
|
1381
|
+
* @param text optionally quoted text
|
|
1382
|
+
* @returns text without quotes
|
|
1305
1383
|
*/
|
|
1306
|
-
function
|
|
1384
|
+
function removeQuotes(text) {
|
|
1385
|
+
if (text.startsWith('"') && text.endsWith('"')) {
|
|
1386
|
+
return text.slice(1, -1);
|
|
1387
|
+
}
|
|
1388
|
+
if (text.startsWith('\'') && text.endsWith('\'')) {
|
|
1389
|
+
return text.slice(1, -1);
|
|
1390
|
+
}
|
|
1391
|
+
return text;
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
/**
|
|
1395
|
+
* @@@
|
|
1396
|
+
*
|
|
1397
|
+
* @returns The same object as the input, but deeply frozen
|
|
1398
|
+
*
|
|
1399
|
+
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
1400
|
+
*/
|
|
1401
|
+
function deepFreeze(objectValue) {
|
|
1307
1402
|
var e_1, _a;
|
|
1308
|
-
var
|
|
1309
|
-
var lines = markdown.split('\n');
|
|
1310
|
-
var currentCodeBlock = null;
|
|
1403
|
+
var propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
1311
1404
|
try {
|
|
1312
|
-
for (var
|
|
1313
|
-
var
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
currentCodeBlock = { language: language, content: '' };
|
|
1318
|
-
}
|
|
1319
|
-
else {
|
|
1320
|
-
if (language !== null) {
|
|
1321
|
-
// [🌻]
|
|
1322
|
-
throw new Error("".concat(capitalize(currentCodeBlock.language || 'the'), " code block was not closed and already opening new ").concat(language, " code block"));
|
|
1323
|
-
}
|
|
1324
|
-
codeBlocks.push(currentCodeBlock);
|
|
1325
|
-
currentCodeBlock = null;
|
|
1326
|
-
}
|
|
1327
|
-
}
|
|
1328
|
-
else if (currentCodeBlock !== null) {
|
|
1329
|
-
if (currentCodeBlock.content !== '') {
|
|
1330
|
-
currentCodeBlock.content += '\n';
|
|
1331
|
-
}
|
|
1332
|
-
currentCodeBlock.content += line.split('\\`\\`\\`').join('```') /* <- TODO: Maybe make propper unescape */;
|
|
1405
|
+
for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
|
|
1406
|
+
var propertyName = propertyNames_1_1.value;
|
|
1407
|
+
var value = objectValue[propertyName];
|
|
1408
|
+
if (value && typeof value === 'object') {
|
|
1409
|
+
deepFreeze(value);
|
|
1333
1410
|
}
|
|
1334
1411
|
}
|
|
1335
1412
|
}
|
|
1336
1413
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1337
1414
|
finally {
|
|
1338
1415
|
try {
|
|
1339
|
-
if (
|
|
1416
|
+
if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
|
|
1340
1417
|
}
|
|
1341
1418
|
finally { if (e_1) throw e_1.error; }
|
|
1342
1419
|
}
|
|
1343
|
-
|
|
1344
|
-
// [🌻]
|
|
1345
|
-
throw new Error("".concat(capitalize(currentCodeBlock.language || 'the'), " code block was not closed at the end of the markdown"));
|
|
1346
|
-
}
|
|
1347
|
-
return codeBlocks;
|
|
1420
|
+
return Object.freeze(objectValue);
|
|
1348
1421
|
}
|
|
1422
|
+
/**
|
|
1423
|
+
* TODO: [🔼] Export from `@promptbook/utils`
|
|
1424
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
1425
|
+
*/
|
|
1349
1426
|
|
|
1350
1427
|
/**
|
|
1351
|
-
*
|
|
1352
|
-
*
|
|
1353
|
-
* Note: If there are multiple or no code blocks the function throws an error
|
|
1354
|
-
*
|
|
1355
|
-
* Note: There are 3 simmilar function:
|
|
1356
|
-
* - `extractBlock` just extracts the content of the code block which is also used as build-in function for postprocessing
|
|
1357
|
-
* - `extractOneBlockFromMarkdown` extracts exactly one code block with language of the code block
|
|
1358
|
-
* - `extractAllBlocksFromMarkdown` extracts all code blocks with language of the code block
|
|
1359
|
-
*
|
|
1360
|
-
* @param markdown any valid markdown
|
|
1361
|
-
* @returns code block with language and content
|
|
1428
|
+
* The maximum number of iterations for a loops
|
|
1362
1429
|
*/
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1430
|
+
var LOOP_LIMIT = 1000;
|
|
1431
|
+
/**
|
|
1432
|
+
* Nonce which is used for replacing things in strings
|
|
1433
|
+
*/
|
|
1434
|
+
var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
|
|
1435
|
+
/**
|
|
1436
|
+
* The names of the parameters that are reserved for special purposes
|
|
1437
|
+
*/
|
|
1438
|
+
deepFreeze([
|
|
1439
|
+
'content',
|
|
1440
|
+
'context',
|
|
1441
|
+
'knowledge',
|
|
1442
|
+
'samples',
|
|
1443
|
+
'modelName',
|
|
1444
|
+
'currentDate',
|
|
1445
|
+
// <- TODO: Add more like 'date', 'modelName',...
|
|
1446
|
+
// <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
|
|
1447
|
+
]);
|
|
1448
|
+
/**
|
|
1449
|
+
* @@@
|
|
1450
|
+
*/
|
|
1451
|
+
var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
|
|
1452
|
+
/**
|
|
1453
|
+
* @@@
|
|
1454
|
+
*/
|
|
1455
|
+
var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
|
|
1456
|
+
/*
|
|
1457
|
+
TODO: !!! Just testing false-negative detection of [🟡][🟢][🔵][⚪] leak
|
|
1458
|
+
*/
|
|
1459
|
+
// [🟡][🟢][🔵][⚪]
|
|
1460
|
+
/**
|
|
1461
|
+
* TODO: [🔼] Export all to core
|
|
1373
1462
|
*/
|
|
1374
1463
|
|
|
1375
1464
|
/**
|
|
1376
|
-
*
|
|
1377
|
-
*
|
|
1378
|
-
* Note: If there are multiple or no code blocks the function throws an error
|
|
1379
|
-
*
|
|
1380
|
-
* Note: There are 3 simmilar function:
|
|
1381
|
-
* - `extractBlock` just extracts the content of the code block which is also used as build-in function for postprocessing
|
|
1382
|
-
* - `extractOneBlockFromMarkdown` extracts exactly one code block with language of the code block
|
|
1383
|
-
* - `extractAllBlocksFromMarkdown` extracts all code blocks with language of the code block
|
|
1465
|
+
* This error type indicates that some limit was reached
|
|
1384
1466
|
*/
|
|
1385
|
-
function
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1467
|
+
var LimitReachedError = /** @class */ (function (_super) {
|
|
1468
|
+
__extends(LimitReachedError, _super);
|
|
1469
|
+
function LimitReachedError(message) {
|
|
1470
|
+
var _this = _super.call(this, message) || this;
|
|
1471
|
+
_this.name = 'LimitReachedError';
|
|
1472
|
+
Object.setPrototypeOf(_this, LimitReachedError.prototype);
|
|
1473
|
+
return _this;
|
|
1474
|
+
}
|
|
1475
|
+
return LimitReachedError;
|
|
1476
|
+
}(Error));
|
|
1390
1477
|
|
|
1391
1478
|
/**
|
|
1392
|
-
*
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1479
|
+
* This error indicates errors during the execution of the pipeline
|
|
1480
|
+
*/
|
|
1481
|
+
var PipelineExecutionError = /** @class */ (function (_super) {
|
|
1482
|
+
__extends(PipelineExecutionError, _super);
|
|
1483
|
+
function PipelineExecutionError(message) {
|
|
1484
|
+
var _this = _super.call(this, message) || this;
|
|
1485
|
+
_this.name = 'PipelineExecutionError';
|
|
1486
|
+
Object.setPrototypeOf(_this, PipelineExecutionError.prototype);
|
|
1487
|
+
return _this;
|
|
1488
|
+
}
|
|
1489
|
+
return PipelineExecutionError;
|
|
1490
|
+
}(Error));
|
|
1491
|
+
|
|
1492
|
+
/**
|
|
1493
|
+
* Replaces parameters in template with values from parameters object
|
|
1399
1494
|
*
|
|
1400
|
-
* @param
|
|
1401
|
-
* @
|
|
1495
|
+
* @param template the template with parameters in {curly} braces
|
|
1496
|
+
* @param parameters the object with parameters
|
|
1497
|
+
* @returns the template with replaced parameters
|
|
1498
|
+
* @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
|
|
1402
1499
|
*/
|
|
1403
|
-
function
|
|
1404
|
-
|
|
1405
|
-
|
|
1500
|
+
function replaceParameters(template, parameters) {
|
|
1501
|
+
var e_1, _a;
|
|
1502
|
+
try {
|
|
1503
|
+
for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1504
|
+
var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
|
|
1505
|
+
if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
|
|
1506
|
+
throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
|
|
1507
|
+
}
|
|
1508
|
+
else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
|
|
1509
|
+
// TODO: [🍵]
|
|
1510
|
+
throw new UnexpectedError("Parameter {".concat(parameterName, "} is restricted to use"));
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1406
1513
|
}
|
|
1407
|
-
|
|
1408
|
-
|
|
1514
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1515
|
+
finally {
|
|
1516
|
+
try {
|
|
1517
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1518
|
+
}
|
|
1519
|
+
finally { if (e_1) throw e_1.error; }
|
|
1409
1520
|
}
|
|
1410
|
-
|
|
1521
|
+
var replacedTemplate = template;
|
|
1522
|
+
var match;
|
|
1523
|
+
var loopLimit = LOOP_LIMIT;
|
|
1524
|
+
var _loop_1 = function () {
|
|
1525
|
+
if (loopLimit-- < 0) {
|
|
1526
|
+
throw new LimitReachedError('Loop limit reached during parameters replacement in `replaceParameters`');
|
|
1527
|
+
}
|
|
1528
|
+
var precol = match.groups.precol;
|
|
1529
|
+
var parameterName = match.groups.parameterName;
|
|
1530
|
+
if (parameterName === '') {
|
|
1531
|
+
return "continue";
|
|
1532
|
+
}
|
|
1533
|
+
if (parameterName.indexOf('{') !== -1 || parameterName.indexOf('}') !== -1) {
|
|
1534
|
+
throw new PipelineExecutionError('Parameter is already opened or not closed');
|
|
1535
|
+
}
|
|
1536
|
+
if (parameters[parameterName] === undefined) {
|
|
1537
|
+
throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
|
|
1538
|
+
}
|
|
1539
|
+
var parameterValue = parameters[parameterName];
|
|
1540
|
+
if (parameterValue === undefined) {
|
|
1541
|
+
throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
|
|
1542
|
+
}
|
|
1543
|
+
parameterValue = parameterValue.toString();
|
|
1544
|
+
if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
|
|
1545
|
+
parameterValue = parameterValue
|
|
1546
|
+
.split('\n')
|
|
1547
|
+
.map(function (line, index) { return (index === 0 ? line : "".concat(precol).concat(line)); })
|
|
1548
|
+
.join('\n');
|
|
1549
|
+
}
|
|
1550
|
+
replacedTemplate =
|
|
1551
|
+
replacedTemplate.substring(0, match.index + precol.length) +
|
|
1552
|
+
parameterValue +
|
|
1553
|
+
replacedTemplate.substring(match.index + precol.length + parameterName.length + 2);
|
|
1554
|
+
};
|
|
1555
|
+
while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
|
|
1556
|
+
.exec(replacedTemplate))) {
|
|
1557
|
+
_loop_1();
|
|
1558
|
+
}
|
|
1559
|
+
// [💫] Check if there are parameters that are not closed properly
|
|
1560
|
+
if (/{\w+$/.test(replacedTemplate)) {
|
|
1561
|
+
throw new PipelineExecutionError('Parameter is not closed');
|
|
1562
|
+
}
|
|
1563
|
+
// [💫] Check if there are parameters that are not opened properly
|
|
1564
|
+
if (/^\w+}/.test(replacedTemplate)) {
|
|
1565
|
+
throw new PipelineExecutionError('Parameter is not opened');
|
|
1566
|
+
}
|
|
1567
|
+
return replacedTemplate;
|
|
1411
1568
|
}
|
|
1412
1569
|
|
|
1413
1570
|
/**
|
|
@@ -1439,6 +1596,9 @@ function difference(a, b, isEqual) {
|
|
|
1439
1596
|
}
|
|
1440
1597
|
return diff;
|
|
1441
1598
|
}
|
|
1599
|
+
/**
|
|
1600
|
+
* TODO: [🧠][💯] Maybe also implement symmetricDifference
|
|
1601
|
+
*/
|
|
1442
1602
|
|
|
1443
1603
|
/**
|
|
1444
1604
|
* Creates a new set with all elements that are present in all sets
|
|
@@ -1687,7 +1847,7 @@ function isValidPromptbookVersion(version) {
|
|
|
1687
1847
|
if ( /* version === '1.0.0' || */version === '2.0.0' || version === '3.0.0') {
|
|
1688
1848
|
return false;
|
|
1689
1849
|
}
|
|
1690
|
-
// <- TODO:
|
|
1850
|
+
// <- TODO: !!! Check isValidPromptbookVersion against PROMPTBOOK_VERSIONS
|
|
1691
1851
|
return true;
|
|
1692
1852
|
}
|
|
1693
1853
|
|
|
@@ -1809,7 +1969,7 @@ function isValidUuid(value) {
|
|
|
1809
1969
|
/**
|
|
1810
1970
|
* The version of the Promptbook library
|
|
1811
1971
|
*/
|
|
1812
|
-
var PROMPTBOOK_VERSION = '0.61.0-
|
|
1972
|
+
var PROMPTBOOK_VERSION = '0.61.0-30';
|
|
1813
1973
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
1814
1974
|
|
|
1815
1975
|
// @promptbook/utils
|
|
@@ -1827,5 +1987,5 @@ var normalizeTo = {
|
|
|
1827
1987
|
* Note: [🕙] It does not make sence to have simple lower / UPPER case normalization
|
|
1828
1988
|
*/
|
|
1829
1989
|
|
|
1830
|
-
export { CountUtils, DIACRITIC_VARIANTS_LETTERS, PROMPTBOOK_VERSION, capitalize, countCharacters, countLines, countPages, countParagraphs, countSentences, countWords, decapitalize, difference, extractBlock,
|
|
1990
|
+
export { $currentDate, $randomSeed, CountUtils, DIACRITIC_VARIANTS_LETTERS, PROMPTBOOK_VERSION, capitalize, countCharacters, countLines, countPages, countParagraphs, countSentences, countWords, decapitalize, difference, extractBlock, extractParameterNames, extractParameterNamesFromPromptTemplate, extractVariables, forEachAsync, intersection, isHostnameOnPrivateNetwork, isUrlOnPrivateNetwork, isValidFilePath, isValidJavascriptName, isValidJsonString, isValidKeyword, isValidPipelineUrl, isValidPromptbookVersion, isValidSemanticVersion, isValidUrl, isValidUuid, nameToUriPart, nameToUriParts, normalizeTo, normalizeToKebabCase, normalizeTo_PascalCase, normalizeTo_SCREAMING_CASE, normalizeTo_camelCase, normalizeTo_snake_case, normalizeWhitespaces, parseKeywords, parseKeywordsFromString, parseNumber, removeDiacritics, removeEmojis, removeQuotes, renameParameter, renderPromptbookMermaid, replaceParameters, searchKeywords, splitIntoSentences, titleToName, trimCodeBlock, trimEndOfCodeBlock, union, unwrapResult };
|
|
1831
1991
|
//# sourceMappingURL=index.es.js.map
|