@promptbook/utils 0.61.0-9 → 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/umd/index.umd.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-utils"] = {}, global.
|
|
5
|
-
})(this, (function (exports,
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-utils"] = {}, global.spaceTrim));
|
|
5
|
+
})(this, (function (exports, spaceTrim) { 'use strict';
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
|
|
6
10
|
|
|
7
11
|
/*! *****************************************************************************
|
|
8
12
|
Copyright (c) Microsoft Corporation.
|
|
@@ -129,7 +133,7 @@
|
|
|
129
133
|
var UnexpectedError = /** @class */ (function (_super) {
|
|
130
134
|
__extends(UnexpectedError, _super);
|
|
131
135
|
function UnexpectedError(message) {
|
|
132
|
-
var _this = _super.call(this,
|
|
136
|
+
var _this = _super.call(this, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
|
|
133
137
|
_this.name = 'UnexpectedError';
|
|
134
138
|
Object.setPrototypeOf(_this, UnexpectedError.prototype);
|
|
135
139
|
return _this;
|
|
@@ -516,6 +520,14 @@
|
|
|
516
520
|
* Function normalizes title to name which can be used as identifier
|
|
517
521
|
*/
|
|
518
522
|
function titleToName(value) {
|
|
523
|
+
if (value.startsWith('http://') || value.startsWith('https://')) {
|
|
524
|
+
// TODO: Maybe check against some list unallowed characters
|
|
525
|
+
return value;
|
|
526
|
+
}
|
|
527
|
+
if (value.startsWith('./') || value.startsWith('../')) {
|
|
528
|
+
// TODO: Maybe check against some list unallowed characters
|
|
529
|
+
return value;
|
|
530
|
+
}
|
|
519
531
|
value = removeEmojis(value);
|
|
520
532
|
value = normalizeToKebabCase(value);
|
|
521
533
|
// TODO: [🧠] Maybe warn or add some padding to short name which are not good identifiers
|
|
@@ -543,7 +555,7 @@
|
|
|
543
555
|
}
|
|
544
556
|
return normalizeTo_camelCase('template-' + titleToName(template.title));
|
|
545
557
|
};
|
|
546
|
-
var promptbookMermaid =
|
|
558
|
+
var promptbookMermaid = spaceTrim.spaceTrim(function (block) { return "\n\n %% \uD83D\uDD2E Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually\n\n flowchart LR\n subgraph \"".concat(pipelineJson.title, "\"\n\n direction TB\n\n input((Input)):::input\n ").concat(block(pipelineJson.promptTemplates
|
|
547
559
|
.flatMap(function (_a) {
|
|
548
560
|
var title = _a.title, dependentParameterNames = _a.dependentParameterNames, resultingParameterName = _a.resultingParameterName;
|
|
549
561
|
return __spreadArray([
|
|
@@ -586,7 +598,7 @@
|
|
|
586
598
|
* @param template the template with parameters in {curly} braces
|
|
587
599
|
* @returns the list of parameter names
|
|
588
600
|
*/
|
|
589
|
-
function
|
|
601
|
+
function extractParameterNames(template) {
|
|
590
602
|
var e_1, _a;
|
|
591
603
|
var matches = template.matchAll(/{\w+}/g);
|
|
592
604
|
var parameterNames = new Set();
|
|
@@ -661,7 +673,7 @@
|
|
|
661
673
|
if (!(error instanceof Error)) {
|
|
662
674
|
throw error;
|
|
663
675
|
}
|
|
664
|
-
throw new ParsingError(
|
|
676
|
+
throw new ParsingError(spaceTrim.spaceTrim(function (block) { return "\n Can not extract variables from the script\n\n ".concat(block(error.name), ": ").concat(block(error.message), "\n "); }));
|
|
665
677
|
}
|
|
666
678
|
return variables;
|
|
667
679
|
}
|
|
@@ -676,37 +688,53 @@
|
|
|
676
688
|
* @returns the set of parameter names
|
|
677
689
|
* @throws {ParsingError} if the script is invalid
|
|
678
690
|
*/
|
|
679
|
-
function
|
|
680
|
-
var e_1, _a, e_2, _b;
|
|
691
|
+
function extractParameterNamesFromPromptTemplate(promptTemplate) {
|
|
692
|
+
var e_1, _a, e_2, _b, e_3, _c;
|
|
693
|
+
var title = promptTemplate.title, description = promptTemplate.description, blockType = promptTemplate.blockType, content = promptTemplate.content, preparedContent = promptTemplate.preparedContent, jokerParameterNames = promptTemplate.jokerParameterNames;
|
|
681
694
|
var parameterNames = new Set();
|
|
682
695
|
try {
|
|
683
|
-
for (var
|
|
684
|
-
var parameterName =
|
|
696
|
+
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()) {
|
|
697
|
+
var parameterName = _e.value;
|
|
685
698
|
parameterNames.add(parameterName);
|
|
686
699
|
}
|
|
687
700
|
}
|
|
688
701
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
689
702
|
finally {
|
|
690
703
|
try {
|
|
691
|
-
if (
|
|
704
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
692
705
|
}
|
|
693
706
|
finally { if (e_1) throw e_1.error; }
|
|
694
707
|
}
|
|
695
|
-
if (
|
|
708
|
+
if (blockType === 'SCRIPT') {
|
|
696
709
|
try {
|
|
697
|
-
for (var
|
|
698
|
-
var parameterName =
|
|
710
|
+
for (var _f = __values(extractVariables(content)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
711
|
+
var parameterName = _g.value;
|
|
699
712
|
parameterNames.add(parameterName);
|
|
700
713
|
}
|
|
701
714
|
}
|
|
702
715
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
703
716
|
finally {
|
|
704
717
|
try {
|
|
705
|
-
if (
|
|
718
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
706
719
|
}
|
|
707
720
|
finally { if (e_2) throw e_2.error; }
|
|
708
721
|
}
|
|
709
722
|
}
|
|
723
|
+
try {
|
|
724
|
+
for (var _h = __values(jokerParameterNames || []), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
725
|
+
var jokerName = _j.value;
|
|
726
|
+
parameterNames.add(jokerName);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
730
|
+
finally {
|
|
731
|
+
try {
|
|
732
|
+
if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
|
|
733
|
+
}
|
|
734
|
+
finally { if (e_3) throw e_3.error; }
|
|
735
|
+
}
|
|
736
|
+
parameterNames.delete('content');
|
|
737
|
+
// <- Note {websiteContent} is used in `preparedContent`
|
|
710
738
|
return parameterNames;
|
|
711
739
|
}
|
|
712
740
|
/**
|
|
@@ -792,12 +820,12 @@
|
|
|
792
820
|
*/
|
|
793
821
|
function forEachAsync(array, options, callbackfunction) {
|
|
794
822
|
return __awaiter(this, void 0, void 0, function () {
|
|
795
|
-
var _a,
|
|
823
|
+
var _a, maxParallelCount, index, runningTasks, tasks, _loop_1, _b, _c, item, e_1_1;
|
|
796
824
|
var e_1, _d;
|
|
797
825
|
return __generator(this, function (_e) {
|
|
798
826
|
switch (_e.label) {
|
|
799
827
|
case 0:
|
|
800
|
-
_a = options.
|
|
828
|
+
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? Infinity : _a;
|
|
801
829
|
index = 0;
|
|
802
830
|
runningTasks = [];
|
|
803
831
|
tasks = [];
|
|
@@ -813,7 +841,7 @@
|
|
|
813
841
|
/* not await */ Promise.resolve(task).then(function () {
|
|
814
842
|
runningTasks = runningTasks.filter(function (t) { return t !== task; });
|
|
815
843
|
});
|
|
816
|
-
if (!(
|
|
844
|
+
if (!(maxParallelCount < runningTasks.length)) return [3 /*break*/, 2];
|
|
817
845
|
return [4 /*yield*/, Promise.race(runningTasks)];
|
|
818
846
|
case 1:
|
|
819
847
|
_f.sent();
|
|
@@ -858,101 +886,154 @@
|
|
|
858
886
|
}
|
|
859
887
|
|
|
860
888
|
/**
|
|
861
|
-
*
|
|
889
|
+
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
862
890
|
*/
|
|
863
|
-
|
|
891
|
+
function isValidJsonString(value /* <- [👨⚖️] */) {
|
|
892
|
+
try {
|
|
893
|
+
JSON.parse(value);
|
|
894
|
+
return true;
|
|
895
|
+
}
|
|
896
|
+
catch (error) {
|
|
897
|
+
if (!(error instanceof Error)) {
|
|
898
|
+
throw error;
|
|
899
|
+
}
|
|
900
|
+
if (error.message.includes('Unexpected token')) {
|
|
901
|
+
return false;
|
|
902
|
+
}
|
|
903
|
+
return false;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
864
906
|
|
|
865
907
|
/**
|
|
866
|
-
*
|
|
908
|
+
* Makes first letter of a string uppercase
|
|
909
|
+
*
|
|
867
910
|
*/
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
var _this = _super.call(this, message) || this;
|
|
872
|
-
_this.name = 'PipelineExecutionError';
|
|
873
|
-
Object.setPrototypeOf(_this, PipelineExecutionError.prototype);
|
|
874
|
-
return _this;
|
|
875
|
-
}
|
|
876
|
-
return PipelineExecutionError;
|
|
877
|
-
}(Error));
|
|
911
|
+
function capitalize(word) {
|
|
912
|
+
return word.substring(0, 1).toUpperCase() + word.substring(1);
|
|
913
|
+
}
|
|
878
914
|
|
|
879
915
|
/**
|
|
880
|
-
*
|
|
916
|
+
* Extracts all code blocks from markdown.
|
|
881
917
|
*
|
|
882
|
-
*
|
|
883
|
-
*
|
|
884
|
-
*
|
|
885
|
-
*
|
|
918
|
+
* Note: There are 3 simmilar function:
|
|
919
|
+
* - `extractBlock` just extracts the content of the code block which is also used as build-in function for postprocessing
|
|
920
|
+
* - `extractOneBlockFromMarkdown` extracts exactly one code block with language of the code block
|
|
921
|
+
* - `extractAllBlocksFromMarkdown` extracts all code blocks with language of the code block
|
|
922
|
+
*
|
|
923
|
+
* @param markdown any valid markdown
|
|
924
|
+
* @returns code blocks with language and content
|
|
886
925
|
*
|
|
887
|
-
* @private within the createPipelineExecutor
|
|
888
926
|
*/
|
|
889
|
-
function
|
|
890
|
-
var
|
|
891
|
-
var
|
|
892
|
-
var
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
var
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
927
|
+
function extractAllBlocksFromMarkdown(markdown) {
|
|
928
|
+
var e_1, _a;
|
|
929
|
+
var codeBlocks = [];
|
|
930
|
+
var lines = markdown.split('\n');
|
|
931
|
+
// Note: [0] Ensure that the last block notated by gt > will be closed
|
|
932
|
+
lines.push('');
|
|
933
|
+
var currentCodeBlock = null;
|
|
934
|
+
try {
|
|
935
|
+
for (var lines_1 = __values(lines), lines_1_1 = lines_1.next(); !lines_1_1.done; lines_1_1 = lines_1.next()) {
|
|
936
|
+
var line = lines_1_1.value;
|
|
937
|
+
if (line.startsWith('> ') || line === '>') {
|
|
938
|
+
if (currentCodeBlock === null) {
|
|
939
|
+
currentCodeBlock = { blockNotation: '>', language: null, content: '' };
|
|
940
|
+
} /* not else */
|
|
941
|
+
if (currentCodeBlock.blockNotation === '>') {
|
|
942
|
+
if (currentCodeBlock.content !== '') {
|
|
943
|
+
currentCodeBlock.content += '\n';
|
|
944
|
+
}
|
|
945
|
+
currentCodeBlock.content += line.slice(2);
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
else if (currentCodeBlock !== null && currentCodeBlock.blockNotation === '>' /* <- Note: [0] */) {
|
|
949
|
+
codeBlocks.push(currentCodeBlock);
|
|
950
|
+
currentCodeBlock = null;
|
|
951
|
+
}
|
|
952
|
+
/* not else */
|
|
953
|
+
if (line.startsWith('```')) {
|
|
954
|
+
var language = line.slice(3).trim() || null;
|
|
955
|
+
if (currentCodeBlock === null) {
|
|
956
|
+
currentCodeBlock = { blockNotation: '```', language: language, content: '' };
|
|
957
|
+
}
|
|
958
|
+
else {
|
|
959
|
+
if (language !== null) {
|
|
960
|
+
throw new ParsingError("".concat(capitalize(currentCodeBlock.language || 'the'), " code block was not closed and already opening new ").concat(language, " code block"));
|
|
961
|
+
}
|
|
962
|
+
codeBlocks.push(currentCodeBlock);
|
|
963
|
+
currentCodeBlock = null;
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
else if (currentCodeBlock !== null && currentCodeBlock.blockNotation === '```') {
|
|
967
|
+
if (currentCodeBlock.content !== '') {
|
|
968
|
+
currentCodeBlock.content += '\n';
|
|
969
|
+
}
|
|
970
|
+
currentCodeBlock.content += line.split('\\`\\`\\`').join('```') /* <- TODO: Maybe make propper unescape */;
|
|
971
|
+
}
|
|
918
972
|
}
|
|
919
|
-
replacedTemplate =
|
|
920
|
-
replacedTemplate.substring(0, match.index + precol.length) +
|
|
921
|
-
parameterValue +
|
|
922
|
-
replacedTemplate.substring(match.index + precol.length + parameterName.length + 2);
|
|
923
|
-
};
|
|
924
|
-
while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
|
|
925
|
-
.exec(replacedTemplate))) {
|
|
926
|
-
_loop_1();
|
|
927
973
|
}
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
974
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
975
|
+
finally {
|
|
976
|
+
try {
|
|
977
|
+
if (lines_1_1 && !lines_1_1.done && (_a = lines_1.return)) _a.call(lines_1);
|
|
978
|
+
}
|
|
979
|
+
finally { if (e_1) throw e_1.error; }
|
|
931
980
|
}
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
throw new PipelineExecutionError('Parameter is not opened');
|
|
981
|
+
if (currentCodeBlock !== null) {
|
|
982
|
+
throw new ParsingError("".concat(capitalize(currentCodeBlock.language || 'the'), " code block was not closed at the end of the markdown"));
|
|
935
983
|
}
|
|
936
|
-
return
|
|
984
|
+
return codeBlocks;
|
|
937
985
|
}
|
|
986
|
+
/**
|
|
987
|
+
* TODO: Maybe name for `blockNotation` instead of '```' and '>'
|
|
988
|
+
*/
|
|
938
989
|
|
|
939
990
|
/**
|
|
940
|
-
*
|
|
991
|
+
* Extracts exactly ONE code block from markdown.
|
|
992
|
+
*
|
|
993
|
+
* Note: If there are multiple or no code blocks the function throws an error
|
|
994
|
+
*
|
|
995
|
+
* Note: There are 3 simmilar function:
|
|
996
|
+
* - `extractBlock` just extracts the content of the code block which is also used as build-in function for postprocessing
|
|
997
|
+
* - `extractOneBlockFromMarkdown` extracts exactly one code block with language of the code block
|
|
998
|
+
* - `extractAllBlocksFromMarkdown` extracts all code blocks with language of the code block
|
|
999
|
+
*
|
|
1000
|
+
* @param markdown any valid markdown
|
|
1001
|
+
* @returns code block with language and content
|
|
941
1002
|
*/
|
|
942
|
-
function
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
return
|
|
946
|
-
}
|
|
947
|
-
catch (error) {
|
|
948
|
-
if (!(error instanceof Error)) {
|
|
949
|
-
throw error;
|
|
950
|
-
}
|
|
951
|
-
if (error.message.includes('Unexpected token')) {
|
|
952
|
-
return false;
|
|
953
|
-
}
|
|
954
|
-
return false;
|
|
1003
|
+
function extractOneBlockFromMarkdown(markdown) {
|
|
1004
|
+
var codeBlocks = extractAllBlocksFromMarkdown(markdown);
|
|
1005
|
+
if (codeBlocks.length !== 1) {
|
|
1006
|
+
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 "); }));
|
|
955
1007
|
}
|
|
1008
|
+
return codeBlocks[0];
|
|
1009
|
+
}
|
|
1010
|
+
/***
|
|
1011
|
+
* TODO: [🍓][🌻] Decide of this is internal util, external util OR validator/postprocessor
|
|
1012
|
+
*/
|
|
1013
|
+
|
|
1014
|
+
/**
|
|
1015
|
+
* Extracts code block from markdown.
|
|
1016
|
+
*
|
|
1017
|
+
* Note: If there are multiple or no code blocks the function throws an error
|
|
1018
|
+
*
|
|
1019
|
+
* Note: There are 3 simmilar function:
|
|
1020
|
+
* - `extractBlock` just extracts the content of the code block which is also used as build-in function for postprocessing
|
|
1021
|
+
* - `extractOneBlockFromMarkdown` extracts exactly one code block with language of the code block
|
|
1022
|
+
* - `extractAllBlocksFromMarkdown` extracts all code blocks with language of the code block
|
|
1023
|
+
*/
|
|
1024
|
+
function extractBlock(markdown) {
|
|
1025
|
+
var content = extractOneBlockFromMarkdown(markdown).content;
|
|
1026
|
+
return content;
|
|
1027
|
+
}
|
|
1028
|
+
//
|
|
1029
|
+
|
|
1030
|
+
/**
|
|
1031
|
+
* Simple wrapper `new Date().toISOString()`
|
|
1032
|
+
*
|
|
1033
|
+
* @returns string_date branded type
|
|
1034
|
+
*/
|
|
1035
|
+
function $currentDate() {
|
|
1036
|
+
return new Date().toISOString();
|
|
956
1037
|
}
|
|
957
1038
|
|
|
958
1039
|
/**
|
|
@@ -1029,14 +1110,6 @@
|
|
|
1029
1110
|
PAGES: countPages,
|
|
1030
1111
|
};
|
|
1031
1112
|
|
|
1032
|
-
/**
|
|
1033
|
-
* Makes first letter of a string uppercase
|
|
1034
|
-
*
|
|
1035
|
-
*/
|
|
1036
|
-
function capitalize(word) {
|
|
1037
|
-
return word.substring(0, 1).toUpperCase() + word.substring(1);
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
1113
|
/**
|
|
1041
1114
|
* Makes first letter of a string uppercase
|
|
1042
1115
|
*
|
|
@@ -1295,122 +1368,210 @@
|
|
|
1295
1368
|
*/
|
|
1296
1369
|
|
|
1297
1370
|
/**
|
|
1298
|
-
*
|
|
1371
|
+
* Generates random seed
|
|
1299
1372
|
*
|
|
1300
|
-
*
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1373
|
+
* Warning: This function is not cryptographically secure (it uses Math.random internally)
|
|
1374
|
+
*/
|
|
1375
|
+
function $randomSeed() {
|
|
1376
|
+
return Math.random();
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
/**
|
|
1380
|
+
* Removes quotes from a string
|
|
1304
1381
|
*
|
|
1305
|
-
*
|
|
1306
|
-
*
|
|
1382
|
+
* Tip: This is very usefull for post-processing of the result of the LLM model
|
|
1383
|
+
* Note: This function removes only the same quotes from the beginning and the end of the string
|
|
1384
|
+
* Note: There are two simmilar functions:
|
|
1385
|
+
* - `removeQuotes` which removes only bounding quotes
|
|
1386
|
+
* - `unwrapResult` which removes whole introduce sentence
|
|
1307
1387
|
*
|
|
1388
|
+
* @param text optionally quoted text
|
|
1389
|
+
* @returns text without quotes
|
|
1308
1390
|
*/
|
|
1309
|
-
function
|
|
1391
|
+
function removeQuotes(text) {
|
|
1392
|
+
if (text.startsWith('"') && text.endsWith('"')) {
|
|
1393
|
+
return text.slice(1, -1);
|
|
1394
|
+
}
|
|
1395
|
+
if (text.startsWith('\'') && text.endsWith('\'')) {
|
|
1396
|
+
return text.slice(1, -1);
|
|
1397
|
+
}
|
|
1398
|
+
return text;
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
/**
|
|
1402
|
+
* @@@
|
|
1403
|
+
*
|
|
1404
|
+
* @returns The same object as the input, but deeply frozen
|
|
1405
|
+
*
|
|
1406
|
+
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
1407
|
+
*/
|
|
1408
|
+
function deepFreeze(objectValue) {
|
|
1310
1409
|
var e_1, _a;
|
|
1311
|
-
var
|
|
1312
|
-
var lines = markdown.split('\n');
|
|
1313
|
-
var currentCodeBlock = null;
|
|
1410
|
+
var propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
1314
1411
|
try {
|
|
1315
|
-
for (var
|
|
1316
|
-
var
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
currentCodeBlock = { language: language, content: '' };
|
|
1321
|
-
}
|
|
1322
|
-
else {
|
|
1323
|
-
if (language !== null) {
|
|
1324
|
-
// [🌻]
|
|
1325
|
-
throw new Error("".concat(capitalize(currentCodeBlock.language || 'the'), " code block was not closed and already opening new ").concat(language, " code block"));
|
|
1326
|
-
}
|
|
1327
|
-
codeBlocks.push(currentCodeBlock);
|
|
1328
|
-
currentCodeBlock = null;
|
|
1329
|
-
}
|
|
1330
|
-
}
|
|
1331
|
-
else if (currentCodeBlock !== null) {
|
|
1332
|
-
if (currentCodeBlock.content !== '') {
|
|
1333
|
-
currentCodeBlock.content += '\n';
|
|
1334
|
-
}
|
|
1335
|
-
currentCodeBlock.content += line.split('\\`\\`\\`').join('```') /* <- TODO: Maybe make propper unescape */;
|
|
1412
|
+
for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
|
|
1413
|
+
var propertyName = propertyNames_1_1.value;
|
|
1414
|
+
var value = objectValue[propertyName];
|
|
1415
|
+
if (value && typeof value === 'object') {
|
|
1416
|
+
deepFreeze(value);
|
|
1336
1417
|
}
|
|
1337
1418
|
}
|
|
1338
1419
|
}
|
|
1339
1420
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1340
1421
|
finally {
|
|
1341
1422
|
try {
|
|
1342
|
-
if (
|
|
1423
|
+
if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
|
|
1343
1424
|
}
|
|
1344
1425
|
finally { if (e_1) throw e_1.error; }
|
|
1345
1426
|
}
|
|
1346
|
-
|
|
1347
|
-
// [🌻]
|
|
1348
|
-
throw new Error("".concat(capitalize(currentCodeBlock.language || 'the'), " code block was not closed at the end of the markdown"));
|
|
1349
|
-
}
|
|
1350
|
-
return codeBlocks;
|
|
1427
|
+
return Object.freeze(objectValue);
|
|
1351
1428
|
}
|
|
1429
|
+
/**
|
|
1430
|
+
* TODO: [🔼] Export from `@promptbook/utils`
|
|
1431
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
1432
|
+
*/
|
|
1352
1433
|
|
|
1353
1434
|
/**
|
|
1354
|
-
*
|
|
1355
|
-
*
|
|
1356
|
-
* Note: If there are multiple or no code blocks the function throws an error
|
|
1357
|
-
*
|
|
1358
|
-
* Note: There are 3 simmilar function:
|
|
1359
|
-
* - `extractBlock` just extracts the content of the code block which is also used as build-in function for postprocessing
|
|
1360
|
-
* - `extractOneBlockFromMarkdown` extracts exactly one code block with language of the code block
|
|
1361
|
-
* - `extractAllBlocksFromMarkdown` extracts all code blocks with language of the code block
|
|
1362
|
-
*
|
|
1363
|
-
* @param markdown any valid markdown
|
|
1364
|
-
* @returns code block with language and content
|
|
1435
|
+
* The maximum number of iterations for a loops
|
|
1365
1436
|
*/
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1437
|
+
var LOOP_LIMIT = 1000;
|
|
1438
|
+
/**
|
|
1439
|
+
* Nonce which is used for replacing things in strings
|
|
1440
|
+
*/
|
|
1441
|
+
var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
|
|
1442
|
+
/**
|
|
1443
|
+
* The names of the parameters that are reserved for special purposes
|
|
1444
|
+
*/
|
|
1445
|
+
deepFreeze([
|
|
1446
|
+
'content',
|
|
1447
|
+
'context',
|
|
1448
|
+
'knowledge',
|
|
1449
|
+
'samples',
|
|
1450
|
+
'modelName',
|
|
1451
|
+
'currentDate',
|
|
1452
|
+
// <- TODO: Add more like 'date', 'modelName',...
|
|
1453
|
+
// <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
|
|
1454
|
+
]);
|
|
1455
|
+
/**
|
|
1456
|
+
* @@@
|
|
1457
|
+
*/
|
|
1458
|
+
var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
|
|
1459
|
+
/**
|
|
1460
|
+
* @@@
|
|
1461
|
+
*/
|
|
1462
|
+
var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
|
|
1463
|
+
/*
|
|
1464
|
+
TODO: !!! Just testing false-negative detection of [🟡][🟢][🔵][⚪] leak
|
|
1465
|
+
*/
|
|
1466
|
+
// [🟡][🟢][🔵][⚪]
|
|
1467
|
+
/**
|
|
1468
|
+
* TODO: [🔼] Export all to core
|
|
1376
1469
|
*/
|
|
1377
1470
|
|
|
1378
1471
|
/**
|
|
1379
|
-
*
|
|
1380
|
-
*
|
|
1381
|
-
* Note: If there are multiple or no code blocks the function throws an error
|
|
1382
|
-
*
|
|
1383
|
-
* Note: There are 3 simmilar function:
|
|
1384
|
-
* - `extractBlock` just extracts the content of the code block which is also used as build-in function for postprocessing
|
|
1385
|
-
* - `extractOneBlockFromMarkdown` extracts exactly one code block with language of the code block
|
|
1386
|
-
* - `extractAllBlocksFromMarkdown` extracts all code blocks with language of the code block
|
|
1472
|
+
* This error type indicates that some limit was reached
|
|
1387
1473
|
*/
|
|
1388
|
-
function
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1474
|
+
var LimitReachedError = /** @class */ (function (_super) {
|
|
1475
|
+
__extends(LimitReachedError, _super);
|
|
1476
|
+
function LimitReachedError(message) {
|
|
1477
|
+
var _this = _super.call(this, message) || this;
|
|
1478
|
+
_this.name = 'LimitReachedError';
|
|
1479
|
+
Object.setPrototypeOf(_this, LimitReachedError.prototype);
|
|
1480
|
+
return _this;
|
|
1481
|
+
}
|
|
1482
|
+
return LimitReachedError;
|
|
1483
|
+
}(Error));
|
|
1393
1484
|
|
|
1394
1485
|
/**
|
|
1395
|
-
*
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1486
|
+
* This error indicates errors during the execution of the pipeline
|
|
1487
|
+
*/
|
|
1488
|
+
var PipelineExecutionError = /** @class */ (function (_super) {
|
|
1489
|
+
__extends(PipelineExecutionError, _super);
|
|
1490
|
+
function PipelineExecutionError(message) {
|
|
1491
|
+
var _this = _super.call(this, message) || this;
|
|
1492
|
+
_this.name = 'PipelineExecutionError';
|
|
1493
|
+
Object.setPrototypeOf(_this, PipelineExecutionError.prototype);
|
|
1494
|
+
return _this;
|
|
1495
|
+
}
|
|
1496
|
+
return PipelineExecutionError;
|
|
1497
|
+
}(Error));
|
|
1498
|
+
|
|
1499
|
+
/**
|
|
1500
|
+
* Replaces parameters in template with values from parameters object
|
|
1402
1501
|
*
|
|
1403
|
-
* @param
|
|
1404
|
-
* @
|
|
1502
|
+
* @param template the template with parameters in {curly} braces
|
|
1503
|
+
* @param parameters the object with parameters
|
|
1504
|
+
* @returns the template with replaced parameters
|
|
1505
|
+
* @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
|
|
1405
1506
|
*/
|
|
1406
|
-
function
|
|
1407
|
-
|
|
1408
|
-
|
|
1507
|
+
function replaceParameters(template, parameters) {
|
|
1508
|
+
var e_1, _a;
|
|
1509
|
+
try {
|
|
1510
|
+
for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1511
|
+
var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
|
|
1512
|
+
if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
|
|
1513
|
+
throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
|
|
1514
|
+
}
|
|
1515
|
+
else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
|
|
1516
|
+
// TODO: [🍵]
|
|
1517
|
+
throw new UnexpectedError("Parameter {".concat(parameterName, "} is restricted to use"));
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1409
1520
|
}
|
|
1410
|
-
|
|
1411
|
-
|
|
1521
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1522
|
+
finally {
|
|
1523
|
+
try {
|
|
1524
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1525
|
+
}
|
|
1526
|
+
finally { if (e_1) throw e_1.error; }
|
|
1412
1527
|
}
|
|
1413
|
-
|
|
1528
|
+
var replacedTemplate = template;
|
|
1529
|
+
var match;
|
|
1530
|
+
var loopLimit = LOOP_LIMIT;
|
|
1531
|
+
var _loop_1 = function () {
|
|
1532
|
+
if (loopLimit-- < 0) {
|
|
1533
|
+
throw new LimitReachedError('Loop limit reached during parameters replacement in `replaceParameters`');
|
|
1534
|
+
}
|
|
1535
|
+
var precol = match.groups.precol;
|
|
1536
|
+
var parameterName = match.groups.parameterName;
|
|
1537
|
+
if (parameterName === '') {
|
|
1538
|
+
return "continue";
|
|
1539
|
+
}
|
|
1540
|
+
if (parameterName.indexOf('{') !== -1 || parameterName.indexOf('}') !== -1) {
|
|
1541
|
+
throw new PipelineExecutionError('Parameter is already opened or not closed');
|
|
1542
|
+
}
|
|
1543
|
+
if (parameters[parameterName] === undefined) {
|
|
1544
|
+
throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
|
|
1545
|
+
}
|
|
1546
|
+
var parameterValue = parameters[parameterName];
|
|
1547
|
+
if (parameterValue === undefined) {
|
|
1548
|
+
throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
|
|
1549
|
+
}
|
|
1550
|
+
parameterValue = parameterValue.toString();
|
|
1551
|
+
if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
|
|
1552
|
+
parameterValue = parameterValue
|
|
1553
|
+
.split('\n')
|
|
1554
|
+
.map(function (line, index) { return (index === 0 ? line : "".concat(precol).concat(line)); })
|
|
1555
|
+
.join('\n');
|
|
1556
|
+
}
|
|
1557
|
+
replacedTemplate =
|
|
1558
|
+
replacedTemplate.substring(0, match.index + precol.length) +
|
|
1559
|
+
parameterValue +
|
|
1560
|
+
replacedTemplate.substring(match.index + precol.length + parameterName.length + 2);
|
|
1561
|
+
};
|
|
1562
|
+
while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
|
|
1563
|
+
.exec(replacedTemplate))) {
|
|
1564
|
+
_loop_1();
|
|
1565
|
+
}
|
|
1566
|
+
// [💫] Check if there are parameters that are not closed properly
|
|
1567
|
+
if (/{\w+$/.test(replacedTemplate)) {
|
|
1568
|
+
throw new PipelineExecutionError('Parameter is not closed');
|
|
1569
|
+
}
|
|
1570
|
+
// [💫] Check if there are parameters that are not opened properly
|
|
1571
|
+
if (/^\w+}/.test(replacedTemplate)) {
|
|
1572
|
+
throw new PipelineExecutionError('Parameter is not opened');
|
|
1573
|
+
}
|
|
1574
|
+
return replacedTemplate;
|
|
1414
1575
|
}
|
|
1415
1576
|
|
|
1416
1577
|
/**
|
|
@@ -1442,6 +1603,9 @@
|
|
|
1442
1603
|
}
|
|
1443
1604
|
return diff;
|
|
1444
1605
|
}
|
|
1606
|
+
/**
|
|
1607
|
+
* TODO: [🧠][💯] Maybe also implement symmetricDifference
|
|
1608
|
+
*/
|
|
1445
1609
|
|
|
1446
1610
|
/**
|
|
1447
1611
|
* Creates a new set with all elements that are present in all sets
|
|
@@ -1530,13 +1694,13 @@
|
|
|
1530
1694
|
*
|
|
1531
1695
|
*/
|
|
1532
1696
|
function trimCodeBlock(value) {
|
|
1533
|
-
value =
|
|
1697
|
+
value = spaceTrim.spaceTrim(value);
|
|
1534
1698
|
if (!/^```[a-z]*(.*)```$/is.test(value)) {
|
|
1535
1699
|
return value;
|
|
1536
1700
|
}
|
|
1537
1701
|
value = value.replace(/^```[a-z]*/i, '');
|
|
1538
1702
|
value = value.replace(/```$/i, '');
|
|
1539
|
-
value =
|
|
1703
|
+
value = spaceTrim.spaceTrim(value);
|
|
1540
1704
|
return value;
|
|
1541
1705
|
}
|
|
1542
1706
|
|
|
@@ -1547,9 +1711,9 @@
|
|
|
1547
1711
|
* if you want to start code block in the prompt but you don't want to end it in the result.
|
|
1548
1712
|
*/
|
|
1549
1713
|
function trimEndOfCodeBlock(value) {
|
|
1550
|
-
value =
|
|
1714
|
+
value = spaceTrim.spaceTrim(value);
|
|
1551
1715
|
value = value.replace(/```$/g, '');
|
|
1552
|
-
value =
|
|
1716
|
+
value = spaceTrim.spaceTrim(value);
|
|
1553
1717
|
return value;
|
|
1554
1718
|
}
|
|
1555
1719
|
|
|
@@ -1570,7 +1734,7 @@
|
|
|
1570
1734
|
var trimmedText = text;
|
|
1571
1735
|
// Remove leading and trailing spaces and newlines
|
|
1572
1736
|
if (isTrimmed) {
|
|
1573
|
-
trimmedText =
|
|
1737
|
+
trimmedText = spaceTrim.spaceTrim(trimmedText);
|
|
1574
1738
|
}
|
|
1575
1739
|
var processedText = trimmedText;
|
|
1576
1740
|
if (isIntroduceSentenceRemoved) {
|
|
@@ -1579,7 +1743,7 @@
|
|
|
1579
1743
|
// Remove the introduce sentence and quotes by replacing it with an empty string
|
|
1580
1744
|
processedText = processedText.replace(introduceSentenceRegex, '');
|
|
1581
1745
|
}
|
|
1582
|
-
processedText =
|
|
1746
|
+
processedText = spaceTrim.spaceTrim(processedText);
|
|
1583
1747
|
}
|
|
1584
1748
|
if (processedText.length < 3) {
|
|
1585
1749
|
return trimmedText;
|
|
@@ -1690,7 +1854,7 @@
|
|
|
1690
1854
|
if ( /* version === '1.0.0' || */version === '2.0.0' || version === '3.0.0') {
|
|
1691
1855
|
return false;
|
|
1692
1856
|
}
|
|
1693
|
-
// <- TODO:
|
|
1857
|
+
// <- TODO: !!! Check isValidPromptbookVersion against PROMPTBOOK_VERSIONS
|
|
1694
1858
|
return true;
|
|
1695
1859
|
}
|
|
1696
1860
|
|
|
@@ -1812,7 +1976,7 @@
|
|
|
1812
1976
|
/**
|
|
1813
1977
|
* The version of the Promptbook library
|
|
1814
1978
|
*/
|
|
1815
|
-
var PROMPTBOOK_VERSION = '0.61.0-
|
|
1979
|
+
var PROMPTBOOK_VERSION = '0.61.0-30';
|
|
1816
1980
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
1817
1981
|
|
|
1818
1982
|
// @promptbook/utils
|
|
@@ -1832,8 +1996,10 @@
|
|
|
1832
1996
|
|
|
1833
1997
|
Object.defineProperty(exports, 'spaceTrim', {
|
|
1834
1998
|
enumerable: true,
|
|
1835
|
-
get: function () { return
|
|
1999
|
+
get: function () { return spaceTrim.spaceTrim; }
|
|
1836
2000
|
});
|
|
2001
|
+
exports.$currentDate = $currentDate;
|
|
2002
|
+
exports.$randomSeed = $randomSeed;
|
|
1837
2003
|
exports.CountUtils = CountUtils;
|
|
1838
2004
|
exports.DIACRITIC_VARIANTS_LETTERS = DIACRITIC_VARIANTS_LETTERS;
|
|
1839
2005
|
exports.PROMPTBOOK_VERSION = PROMPTBOOK_VERSION;
|
|
@@ -1847,8 +2013,8 @@
|
|
|
1847
2013
|
exports.decapitalize = decapitalize;
|
|
1848
2014
|
exports.difference = difference;
|
|
1849
2015
|
exports.extractBlock = extractBlock;
|
|
1850
|
-
exports.
|
|
1851
|
-
exports.
|
|
2016
|
+
exports.extractParameterNames = extractParameterNames;
|
|
2017
|
+
exports.extractParameterNamesFromPromptTemplate = extractParameterNamesFromPromptTemplate;
|
|
1852
2018
|
exports.extractVariables = extractVariables;
|
|
1853
2019
|
exports.forEachAsync = forEachAsync;
|
|
1854
2020
|
exports.intersection = intersection;
|