@promptbook/core 0.62.1 → 0.63.0-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 +1 -1
- package/esm/index.es.js +534 -38
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/anthropic-claude.index.d.ts +3 -2
- package/esm/typings/src/_packages/azure-openai.index.d.ts +4 -2
- package/esm/typings/src/_packages/browser.index.d.ts +6 -0
- package/esm/typings/src/_packages/cli.index.d.ts +1 -7
- package/esm/typings/src/_packages/core.index.d.ts +87 -13
- package/esm/typings/src/_packages/execute-javascript.index.d.ts +5 -45
- package/esm/typings/src/_packages/fake-llm.index.d.ts +4 -5
- package/esm/typings/src/_packages/langtail.index.d.ts +4 -2
- package/esm/typings/src/_packages/markdown-utils.index.d.ts +23 -4
- package/esm/typings/src/_packages/node.index.d.ts +5 -2
- package/esm/typings/src/_packages/openai.index.d.ts +5 -2
- package/esm/typings/src/_packages/remote-client.index.d.ts +5 -2
- package/esm/typings/src/_packages/remote-server.index.d.ts +4 -2
- package/esm/typings/src/_packages/types.index.d.ts +441 -21
- package/esm/typings/src/_packages/utils.index.d.ts +84 -31
- package/esm/typings/src/cli/main.d.ts +12 -0
- package/esm/typings/src/collection/collectionToJson.d.ts +2 -0
- package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +1 -0
- package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +1 -0
- package/esm/typings/src/collection/constructors/createCollectionFromPromise.d.ts +1 -0
- package/esm/typings/src/collection/constructors/createCollectionFromUrl.d.ts +1 -1
- package/esm/typings/src/collection/constructors/createSubcollection.d.ts +1 -0
- package/esm/typings/src/commands/BLOCK/BlockTypes.d.ts +2 -0
- package/esm/typings/src/config.d.ts +27 -1
- package/esm/typings/src/conversion/pipelineJsonToString.d.ts +1 -0
- package/esm/typings/src/conversion/pipelineStringToJson.d.ts +6 -3
- package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +4 -3
- package/esm/typings/src/conversion/prettify/prettifyPipelineString.d.ts +2 -0
- package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +2 -0
- package/esm/typings/src/conversion/utils/extractParameterNamesFromPromptTemplate.d.ts +1 -0
- package/esm/typings/src/conversion/utils/extractVariables.d.ts +1 -0
- package/esm/typings/src/conversion/utils/renameParameter.d.ts +1 -0
- package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +2 -0
- package/esm/typings/src/conversion/utils/titleToName.d.ts +6 -1
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +1 -0
- package/esm/typings/src/errors/CollectionError.d.ts +2 -0
- package/esm/typings/src/errors/EnvironmentMismatchError.d.ts +2 -0
- package/esm/typings/src/errors/LimitReachedError.d.ts +2 -0
- package/esm/typings/src/errors/NotFoundError.d.ts +2 -0
- package/esm/typings/src/errors/NotYetImplementedError.d.ts +2 -0
- package/esm/typings/src/errors/ParsingError.d.ts +2 -0
- package/esm/typings/src/errors/PipelineExecutionError.d.ts +2 -0
- package/esm/typings/src/errors/PipelineLogicError.d.ts +2 -0
- package/esm/typings/src/errors/ReferenceError.d.ts +2 -0
- package/esm/typings/src/errors/UnexpectedError.d.ts +2 -0
- package/esm/typings/src/errors/VersionMismatchError.d.ts +2 -0
- package/esm/typings/src/execution/assertsExecutionSuccessful.d.ts +1 -0
- package/esm/typings/src/execution/createPipelineExecutor.d.ts +1 -0
- package/esm/typings/src/execution/embeddingVectorToString.d.ts +2 -0
- package/esm/typings/src/execution/utils/addUsage.d.ts +3 -1
- package/esm/typings/src/execution/utils/checkExpectations.d.ts +2 -0
- package/esm/typings/src/execution/utils/forEachAsync.d.ts +1 -0
- package/esm/typings/src/execution/utils/usageToHuman.d.ts +2 -0
- package/esm/typings/src/execution/utils/usageToWorktime.d.ts +2 -0
- package/esm/typings/src/formats/_common/FormatDefinition.d.ts +2 -1
- package/esm/typings/src/formats/json/utils/isValidJsonString.d.ts +2 -0
- package/esm/typings/src/knowledge/dialogs/callback/CallbackInterfaceTools.d.ts +2 -0
- package/esm/typings/src/knowledge/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +2 -0
- package/esm/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +3 -1
- package/esm/typings/src/knowledge/prepare-knowledge/_common/Scraper.d.ts +10 -0
- package/esm/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.d.ts +1 -1
- package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +2 -0
- package/esm/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +4 -1
- package/esm/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/countTotalUsage.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +2 -1
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +2 -0
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +2 -1
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +2 -0
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +1 -0
- package/esm/typings/src/llm-providers/langtail/LangtailExecutionTools.d.ts +2 -0
- package/esm/typings/src/llm-providers/langtail/LangtailExecutionToolsOptions.d.ts +2 -0
- package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +2 -0
- package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +2 -0
- package/esm/typings/src/llm-providers/multiple/joinLlmExecutionTools.d.ts +2 -0
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +2 -0
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +2 -0
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -0
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionToolsOptions.d.ts +2 -0
- package/esm/typings/src/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +7 -1
- package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -0
- package/esm/typings/src/personas/preparePersona.d.ts +1 -1
- package/esm/typings/src/postprocessing/utils/extractBlock.d.ts +5 -0
- package/esm/typings/src/prepare/isPipelinePrepared.d.ts +2 -1
- package/esm/typings/src/prepare/preparePipeline.d.ts +1 -1
- package/esm/typings/src/prepare/prepareTemplates.d.ts +2 -1
- package/esm/typings/src/prepare/unpreparePipeline.d.ts +2 -1
- package/esm/typings/src/scripting/javascript/JavascriptEvalExecutionTools.d.ts +2 -0
- package/esm/typings/src/scripting/javascript/JavascriptExecutionTools.d.ts +1 -0
- package/esm/typings/src/scripting/javascript/postprocessing-functions.d.ts +51 -0
- package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +0 -1
- package/esm/typings/src/storage/files-storage/FilesStorage.d.ts +2 -1
- package/esm/typings/src/storage/files-storage/FilesStorageOptions.d.ts +0 -3
- package/esm/typings/src/storage/local-storage/getLocalStorage.d.ts +2 -1
- package/esm/typings/src/storage/local-storage/getSessionStorage.d.ts +2 -1
- package/esm/typings/src/storage/memory/MemoryStorage.d.ts +2 -3
- package/esm/typings/src/storage/utils/PrefixStorage.d.ts +2 -3
- package/esm/typings/src/types/ModelRequirements.d.ts +0 -1
- package/esm/typings/src/types/Prompt.d.ts +0 -1
- package/esm/typings/src/types/execution-report/ExecutionReportStringOptions.d.ts +4 -0
- package/esm/typings/src/types/execution-report/executionReportJsonToString.d.ts +2 -0
- package/esm/typings/src/types/typeAliases.d.ts +9 -2
- package/esm/typings/src/utils/currentDate.d.ts +1 -0
- package/esm/typings/src/utils/deepClone.d.ts +2 -1
- package/esm/typings/src/utils/deepFreeze.d.ts +1 -1
- package/esm/typings/src/utils/expectation-counters/countCharacters.d.ts +2 -0
- package/esm/typings/src/utils/expectation-counters/countLines.d.ts +2 -0
- package/esm/typings/src/utils/expectation-counters/countPages.d.ts +2 -0
- package/esm/typings/src/utils/expectation-counters/countParagraphs.d.ts +2 -0
- package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +4 -0
- package/esm/typings/src/utils/expectation-counters/countWords.d.ts +2 -0
- package/esm/typings/src/utils/expectation-counters/index.d.ts +2 -0
- package/esm/typings/src/utils/extractParameterNames.d.ts +1 -0
- package/esm/typings/src/utils/isRunningInWhatever.d.ts +6 -3
- package/esm/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +4 -1
- package/esm/typings/src/utils/markdown/createMarkdownChart.d.ts +1 -1
- package/esm/typings/src/utils/markdown/createMarkdownTable.d.ts +4 -1
- package/esm/typings/src/utils/markdown/escapeMarkdownBlock.d.ts +5 -0
- package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +1 -1
- package/esm/typings/src/utils/markdown/extractAllListItemsFromMarkdown.d.ts +2 -1
- package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +1 -0
- package/esm/typings/src/utils/markdown/flattenMarkdown.d.ts +3 -0
- package/esm/typings/src/utils/markdown/parseMarkdownSection.d.ts +4 -0
- package/esm/typings/src/utils/markdown/removeContentComments.d.ts +1 -0
- package/esm/typings/src/utils/markdown/removeMarkdownFormatting.d.ts +1 -0
- package/esm/typings/src/utils/markdown/splitMarkdownIntoSections.d.ts +3 -0
- package/esm/typings/src/utils/normalization/DIACRITIC_VARIANTS_LETTERS.d.ts +2 -0
- package/esm/typings/src/utils/normalization/IKeywords.d.ts +3 -0
- package/esm/typings/src/utils/normalization/capitalize.d.ts +1 -0
- package/esm/typings/src/utils/normalization/decapitalize.d.ts +1 -0
- package/esm/typings/src/utils/normalization/isValidKeyword.d.ts +2 -0
- package/esm/typings/src/utils/normalization/nameToUriPart.d.ts +8 -0
- package/esm/typings/src/utils/normalization/nameToUriParts.d.ts +8 -0
- package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +10 -0
- package/esm/typings/src/utils/normalization/normalizeTo_PascalCase.d.ts +9 -0
- package/esm/typings/src/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +10 -0
- package/esm/typings/src/utils/normalization/normalizeTo_camelCase.d.ts +11 -0
- package/esm/typings/src/utils/normalization/normalizeTo_snake_case.d.ts +9 -0
- package/esm/typings/src/utils/normalization/parseKeywords.d.ts +1 -0
- package/esm/typings/src/utils/normalization/parseKeywordsFromString.d.ts +1 -0
- package/esm/typings/src/utils/normalization/removeDiacritics.d.ts +7 -0
- package/esm/typings/src/utils/normalization/searchKeywords.d.ts +5 -0
- package/esm/typings/src/utils/parseNumber.d.ts +2 -1
- package/esm/typings/src/utils/random/randomSeed.d.ts +1 -0
- package/esm/typings/src/utils/removeEmojis.d.ts +1 -0
- package/esm/typings/src/utils/removeQuotes.d.ts +1 -0
- package/esm/typings/src/utils/replaceParameters.d.ts +1 -0
- package/esm/typings/src/utils/sets/difference.d.ts +1 -0
- package/esm/typings/src/utils/sets/intersection.d.ts +1 -0
- package/esm/typings/src/utils/sets/union.d.ts +1 -0
- package/esm/typings/src/utils/trimCodeBlock.d.ts +1 -0
- package/esm/typings/src/utils/trimEndOfCodeBlock.d.ts +2 -0
- package/esm/typings/src/utils/unwrapResult.d.ts +1 -0
- package/esm/typings/src/utils/validators/filePath/isValidFilePath.d.ts +1 -0
- package/esm/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +7 -0
- package/esm/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.d.ts +2 -0
- package/esm/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.d.ts +2 -0
- package/esm/typings/src/utils/validators/url/isHostnameOnPrivateNetwork.d.ts +2 -0
- package/esm/typings/src/utils/validators/url/isUrlOnPrivateNetwork.d.ts +1 -0
- package/esm/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -0
- package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +2 -0
- package/esm/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -0
- package/esm/typings/src/version.d.ts +2 -0
- package/package.json +1 -1
- package/umd/index.umd.js +557 -42
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/src/_packages/anthropic-claude.index.d.ts +3 -2
- package/umd/typings/src/_packages/azure-openai.index.d.ts +4 -2
- package/umd/typings/src/_packages/browser.index.d.ts +6 -0
- package/umd/typings/src/_packages/cli.index.d.ts +1 -7
- package/umd/typings/src/_packages/core.index.d.ts +87 -13
- package/umd/typings/src/_packages/execute-javascript.index.d.ts +5 -45
- package/umd/typings/src/_packages/fake-llm.index.d.ts +4 -5
- package/umd/typings/src/_packages/langtail.index.d.ts +4 -2
- package/umd/typings/src/_packages/markdown-utils.index.d.ts +23 -4
- package/umd/typings/src/_packages/node.index.d.ts +5 -2
- package/umd/typings/src/_packages/openai.index.d.ts +5 -2
- package/umd/typings/src/_packages/remote-client.index.d.ts +5 -2
- package/umd/typings/src/_packages/remote-server.index.d.ts +4 -2
- package/umd/typings/src/_packages/types.index.d.ts +441 -21
- package/umd/typings/src/_packages/utils.index.d.ts +84 -31
- package/umd/typings/src/cli/main.d.ts +12 -0
- package/umd/typings/src/collection/collectionToJson.d.ts +2 -0
- package/umd/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +1 -0
- package/umd/typings/src/collection/constructors/createCollectionFromJson.d.ts +1 -0
- package/umd/typings/src/collection/constructors/createCollectionFromPromise.d.ts +1 -0
- package/umd/typings/src/collection/constructors/createCollectionFromUrl.d.ts +1 -1
- package/umd/typings/src/collection/constructors/createSubcollection.d.ts +1 -0
- package/umd/typings/src/commands/BLOCK/BlockTypes.d.ts +2 -0
- package/umd/typings/src/config.d.ts +27 -1
- package/umd/typings/src/conversion/pipelineJsonToString.d.ts +1 -0
- package/umd/typings/src/conversion/pipelineStringToJson.d.ts +6 -3
- package/umd/typings/src/conversion/pipelineStringToJsonSync.d.ts +4 -3
- package/umd/typings/src/conversion/prettify/prettifyPipelineString.d.ts +2 -0
- package/umd/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +2 -0
- package/umd/typings/src/conversion/utils/extractParameterNamesFromPromptTemplate.d.ts +1 -0
- package/umd/typings/src/conversion/utils/extractVariables.d.ts +1 -0
- package/umd/typings/src/conversion/utils/renameParameter.d.ts +1 -0
- package/umd/typings/src/conversion/utils/stringifyPipelineJson.d.ts +2 -0
- package/umd/typings/src/conversion/utils/titleToName.d.ts +6 -1
- package/umd/typings/src/conversion/validation/validatePipeline.d.ts +1 -0
- package/umd/typings/src/errors/CollectionError.d.ts +2 -0
- package/umd/typings/src/errors/EnvironmentMismatchError.d.ts +2 -0
- package/umd/typings/src/errors/LimitReachedError.d.ts +2 -0
- package/umd/typings/src/errors/NotFoundError.d.ts +2 -0
- package/umd/typings/src/errors/NotYetImplementedError.d.ts +2 -0
- package/umd/typings/src/errors/ParsingError.d.ts +2 -0
- package/umd/typings/src/errors/PipelineExecutionError.d.ts +2 -0
- package/umd/typings/src/errors/PipelineLogicError.d.ts +2 -0
- package/umd/typings/src/errors/ReferenceError.d.ts +2 -0
- package/umd/typings/src/errors/UnexpectedError.d.ts +2 -0
- package/umd/typings/src/errors/VersionMismatchError.d.ts +2 -0
- package/umd/typings/src/execution/assertsExecutionSuccessful.d.ts +1 -0
- package/umd/typings/src/execution/createPipelineExecutor.d.ts +1 -0
- package/umd/typings/src/execution/embeddingVectorToString.d.ts +2 -0
- package/umd/typings/src/execution/utils/addUsage.d.ts +3 -1
- package/umd/typings/src/execution/utils/checkExpectations.d.ts +2 -0
- package/umd/typings/src/execution/utils/forEachAsync.d.ts +1 -0
- package/umd/typings/src/execution/utils/usageToHuman.d.ts +2 -0
- package/umd/typings/src/execution/utils/usageToWorktime.d.ts +2 -0
- package/umd/typings/src/formats/_common/FormatDefinition.d.ts +2 -1
- package/umd/typings/src/formats/json/utils/isValidJsonString.d.ts +2 -0
- package/umd/typings/src/knowledge/dialogs/callback/CallbackInterfaceTools.d.ts +2 -0
- package/umd/typings/src/knowledge/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +2 -0
- package/umd/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +3 -1
- package/umd/typings/src/knowledge/prepare-knowledge/_common/Scraper.d.ts +10 -0
- package/umd/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.d.ts +1 -1
- package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +2 -0
- package/umd/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +4 -1
- package/umd/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +1 -1
- package/umd/typings/src/llm-providers/_common/utils/count-total-usage/countTotalUsage.d.ts +1 -1
- package/umd/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +2 -1
- package/umd/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +2 -0
- package/umd/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +2 -1
- package/umd/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +2 -0
- package/umd/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +1 -0
- package/umd/typings/src/llm-providers/langtail/LangtailExecutionTools.d.ts +2 -0
- package/umd/typings/src/llm-providers/langtail/LangtailExecutionToolsOptions.d.ts +2 -0
- package/umd/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +2 -0
- package/umd/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +2 -0
- package/umd/typings/src/llm-providers/multiple/joinLlmExecutionTools.d.ts +2 -0
- package/umd/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +2 -0
- package/umd/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +2 -0
- package/umd/typings/src/llm-providers/openai/openai-models.d.ts +1 -0
- package/umd/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -0
- package/umd/typings/src/llm-providers/remote/RemoteLlmExecutionToolsOptions.d.ts +2 -0
- package/umd/typings/src/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +7 -1
- package/umd/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -0
- package/umd/typings/src/personas/preparePersona.d.ts +1 -1
- package/umd/typings/src/postprocessing/utils/extractBlock.d.ts +5 -0
- package/umd/typings/src/prepare/isPipelinePrepared.d.ts +2 -1
- package/umd/typings/src/prepare/preparePipeline.d.ts +1 -1
- package/umd/typings/src/prepare/prepareTemplates.d.ts +2 -1
- package/umd/typings/src/prepare/unpreparePipeline.d.ts +2 -1
- package/umd/typings/src/scripting/javascript/JavascriptEvalExecutionTools.d.ts +2 -0
- package/umd/typings/src/scripting/javascript/JavascriptExecutionTools.d.ts +1 -0
- package/umd/typings/src/scripting/javascript/postprocessing-functions.d.ts +51 -0
- package/umd/typings/src/storage/_common/PromptbookStorage.d.ts +0 -1
- package/umd/typings/src/storage/files-storage/FilesStorage.d.ts +2 -1
- package/umd/typings/src/storage/files-storage/FilesStorageOptions.d.ts +0 -3
- package/umd/typings/src/storage/local-storage/getLocalStorage.d.ts +2 -1
- package/umd/typings/src/storage/local-storage/getSessionStorage.d.ts +2 -1
- package/umd/typings/src/storage/memory/MemoryStorage.d.ts +2 -3
- package/umd/typings/src/storage/utils/PrefixStorage.d.ts +2 -3
- package/umd/typings/src/types/ModelRequirements.d.ts +0 -1
- package/umd/typings/src/types/Prompt.d.ts +0 -1
- package/umd/typings/src/types/execution-report/ExecutionReportStringOptions.d.ts +4 -0
- package/umd/typings/src/types/execution-report/executionReportJsonToString.d.ts +2 -0
- package/umd/typings/src/types/typeAliases.d.ts +9 -2
- package/umd/typings/src/utils/currentDate.d.ts +1 -0
- package/umd/typings/src/utils/deepClone.d.ts +2 -1
- package/umd/typings/src/utils/deepFreeze.d.ts +1 -1
- package/umd/typings/src/utils/expectation-counters/countCharacters.d.ts +2 -0
- package/umd/typings/src/utils/expectation-counters/countLines.d.ts +2 -0
- package/umd/typings/src/utils/expectation-counters/countPages.d.ts +2 -0
- package/umd/typings/src/utils/expectation-counters/countParagraphs.d.ts +2 -0
- package/umd/typings/src/utils/expectation-counters/countSentences.d.ts +4 -0
- package/umd/typings/src/utils/expectation-counters/countWords.d.ts +2 -0
- package/umd/typings/src/utils/expectation-counters/index.d.ts +2 -0
- package/umd/typings/src/utils/extractParameterNames.d.ts +1 -0
- package/umd/typings/src/utils/isRunningInWhatever.d.ts +6 -3
- package/umd/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +4 -1
- package/umd/typings/src/utils/markdown/createMarkdownChart.d.ts +1 -1
- package/umd/typings/src/utils/markdown/createMarkdownTable.d.ts +4 -1
- package/umd/typings/src/utils/markdown/escapeMarkdownBlock.d.ts +5 -0
- package/umd/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +1 -1
- package/umd/typings/src/utils/markdown/extractAllListItemsFromMarkdown.d.ts +2 -1
- package/umd/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +1 -0
- package/umd/typings/src/utils/markdown/flattenMarkdown.d.ts +3 -0
- package/umd/typings/src/utils/markdown/parseMarkdownSection.d.ts +4 -0
- package/umd/typings/src/utils/markdown/removeContentComments.d.ts +1 -0
- package/umd/typings/src/utils/markdown/removeMarkdownFormatting.d.ts +1 -0
- package/umd/typings/src/utils/markdown/splitMarkdownIntoSections.d.ts +3 -0
- package/umd/typings/src/utils/normalization/DIACRITIC_VARIANTS_LETTERS.d.ts +2 -0
- package/umd/typings/src/utils/normalization/IKeywords.d.ts +3 -0
- package/umd/typings/src/utils/normalization/capitalize.d.ts +1 -0
- package/umd/typings/src/utils/normalization/decapitalize.d.ts +1 -0
- package/umd/typings/src/utils/normalization/isValidKeyword.d.ts +2 -0
- package/umd/typings/src/utils/normalization/nameToUriPart.d.ts +8 -0
- package/umd/typings/src/utils/normalization/nameToUriParts.d.ts +8 -0
- package/umd/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +10 -0
- package/umd/typings/src/utils/normalization/normalizeTo_PascalCase.d.ts +9 -0
- package/umd/typings/src/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +10 -0
- package/umd/typings/src/utils/normalization/normalizeTo_camelCase.d.ts +11 -0
- package/umd/typings/src/utils/normalization/normalizeTo_snake_case.d.ts +9 -0
- package/umd/typings/src/utils/normalization/parseKeywords.d.ts +1 -0
- package/umd/typings/src/utils/normalization/parseKeywordsFromString.d.ts +1 -0
- package/umd/typings/src/utils/normalization/removeDiacritics.d.ts +7 -0
- package/umd/typings/src/utils/normalization/searchKeywords.d.ts +5 -0
- package/umd/typings/src/utils/parseNumber.d.ts +2 -1
- package/umd/typings/src/utils/random/randomSeed.d.ts +1 -0
- package/umd/typings/src/utils/removeEmojis.d.ts +1 -0
- package/umd/typings/src/utils/removeQuotes.d.ts +1 -0
- package/umd/typings/src/utils/replaceParameters.d.ts +1 -0
- package/umd/typings/src/utils/sets/difference.d.ts +1 -0
- package/umd/typings/src/utils/sets/intersection.d.ts +1 -0
- package/umd/typings/src/utils/sets/union.d.ts +1 -0
- package/umd/typings/src/utils/trimCodeBlock.d.ts +1 -0
- package/umd/typings/src/utils/trimEndOfCodeBlock.d.ts +2 -0
- package/umd/typings/src/utils/unwrapResult.d.ts +1 -0
- package/umd/typings/src/utils/validators/filePath/isValidFilePath.d.ts +1 -0
- package/umd/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +7 -0
- package/umd/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.d.ts +2 -0
- package/umd/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.d.ts +2 -0
- package/umd/typings/src/utils/validators/url/isHostnameOnPrivateNetwork.d.ts +2 -0
- package/umd/typings/src/utils/validators/url/isUrlOnPrivateNetwork.d.ts +1 -0
- package/umd/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -0
- package/umd/typings/src/utils/validators/url/isValidUrl.d.ts +2 -0
- package/umd/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -0
- package/umd/typings/src/version.d.ts +2 -0
package/umd/index.umd.js
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('prettier'), require('prettier/parser-html'), require('moment')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'prettier', 'prettier/parser-html', 'moment'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-core"] = {}, global.spaceTrim, global.prettier, global.parserHtml, global.moment));
|
|
5
|
-
})(this, (function (exports, spaceTrim, prettier, parserHtml, moment) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('prettier'), require('prettier/parser-html'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('moment')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'prettier', 'prettier/parser-html', 'crypto-js/enc-hex', 'crypto-js/sha256', 'moment'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-core"] = {}, global.spaceTrim, global.prettier, global.parserHtml, global.hexEncoder, global.sha256, global.moment));
|
|
5
|
+
})(this, (function (exports, spaceTrim, prettier, parserHtml, hexEncoder, sha256, moment) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
9
|
var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
|
|
10
10
|
var parserHtml__default = /*#__PURE__*/_interopDefaultLegacy(parserHtml);
|
|
11
|
+
var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
|
|
12
|
+
var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
|
|
11
13
|
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
|
12
14
|
|
|
15
|
+
/**
|
|
16
|
+
* The version of the Promptbook library
|
|
17
|
+
*
|
|
18
|
+
* @public exported from all packages
|
|
19
|
+
*/
|
|
20
|
+
var PROMPTBOOK_VERSION = '0.62.0';
|
|
21
|
+
// TODO: !!!! List here all the versions and annotate + put into script
|
|
22
|
+
|
|
13
23
|
/*! *****************************************************************************
|
|
14
24
|
Copyright (c) Microsoft Corporation.
|
|
15
25
|
|
|
@@ -133,6 +143,8 @@
|
|
|
133
143
|
* Converts PipelineCollection to serialized JSON
|
|
134
144
|
*
|
|
135
145
|
* Note: Functions `collectionToJson` and `createCollectionFromJson` are complementary
|
|
146
|
+
*
|
|
147
|
+
* @public exported from `@promptbook/core`
|
|
136
148
|
*/
|
|
137
149
|
function collectionToJson(collection) {
|
|
138
150
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -191,6 +203,7 @@
|
|
|
191
203
|
/**
|
|
192
204
|
* Makes first letter of a string uppercase
|
|
193
205
|
*
|
|
206
|
+
* @public exported from `@promptbook/utils`
|
|
194
207
|
*/
|
|
195
208
|
function capitalize(word) {
|
|
196
209
|
return word.substring(0, 1).toUpperCase() + word.substring(1);
|
|
@@ -201,6 +214,7 @@
|
|
|
201
214
|
*
|
|
202
215
|
* @param pipelineJson Promptbook in JSON format (.ptbk.json)
|
|
203
216
|
* @returns Promptbook in string format (.ptbk.md)
|
|
217
|
+
* @public exported from `@promptbook/core`
|
|
204
218
|
*/
|
|
205
219
|
function pipelineJsonToString(pipelineJson) {
|
|
206
220
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
|
|
@@ -431,6 +445,7 @@
|
|
|
431
445
|
* @@@
|
|
432
446
|
*
|
|
433
447
|
* @returns The same object as the input, but deeply frozen
|
|
448
|
+
* @public exported from `@promptbook/utils`
|
|
434
449
|
*
|
|
435
450
|
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
436
451
|
*/
|
|
@@ -438,7 +453,6 @@
|
|
|
438
453
|
return deepFreeze(objectValue);
|
|
439
454
|
}
|
|
440
455
|
/**
|
|
441
|
-
* TODO: [🔼] Export from `@promptbook/utils`
|
|
442
456
|
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
443
457
|
*/
|
|
444
458
|
|
|
@@ -464,22 +478,62 @@
|
|
|
464
478
|
|
|
465
479
|
/**
|
|
466
480
|
* The maximum number of iterations for a loops
|
|
481
|
+
*
|
|
482
|
+
* @private within the repository - too low-level in comparison to other `MAX_...`
|
|
467
483
|
*/
|
|
468
484
|
var LOOP_LIMIT = 1000;
|
|
469
485
|
/**
|
|
470
486
|
* The maximum number of (LLM) tasks running in parallel
|
|
487
|
+
*
|
|
488
|
+
* @public exported from `@promptbook/core`
|
|
471
489
|
*/
|
|
472
490
|
var MAX_PARALLEL_COUNT = 5;
|
|
473
491
|
/**
|
|
474
492
|
* The maximum number of attempts to execute LLM task before giving up
|
|
493
|
+
*
|
|
494
|
+
* @public exported from `@promptbook/core`
|
|
475
495
|
*/
|
|
476
496
|
var MAX_EXECUTION_ATTEMPTS = 3;
|
|
497
|
+
/**
|
|
498
|
+
* The maximum length of the (generated) filename
|
|
499
|
+
*
|
|
500
|
+
* @public exported from `@promptbook/core`
|
|
501
|
+
*/
|
|
502
|
+
var MAX_FILENAME_LENGTH = 30;
|
|
503
|
+
/**
|
|
504
|
+
* @@@
|
|
505
|
+
* TODO: [🐝] !!! Use
|
|
506
|
+
*
|
|
507
|
+
* @public exported from `@promptbook/core`
|
|
508
|
+
*/
|
|
509
|
+
var MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH = 3;
|
|
510
|
+
/**
|
|
511
|
+
* @@@
|
|
512
|
+
* TODO: [🐝] !!! Use
|
|
513
|
+
*
|
|
514
|
+
* @public exported from `@promptbook/core`
|
|
515
|
+
*/
|
|
516
|
+
var MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL = 200;
|
|
517
|
+
/**
|
|
518
|
+
* Where to store the cache of executions for promptbook CLI
|
|
519
|
+
*
|
|
520
|
+
* @public exported from `@promptbook/core`
|
|
521
|
+
*/
|
|
522
|
+
var EXECUTIONS_CACHE_DIRNAME = '/.promptbook/executions-cache';
|
|
523
|
+
/**
|
|
524
|
+
* The name of the builded pipeline collection made by CLI `ptbk make` and for lookup in `createCollectionFromDirectory`
|
|
525
|
+
*
|
|
526
|
+
* @public exported from `@promptbook/core`
|
|
527
|
+
*/
|
|
528
|
+
var PIPELINE_COLLECTION_BASE_FILENAME = "index";
|
|
477
529
|
/**
|
|
478
530
|
* Nonce which is used for replacing things in strings
|
|
479
531
|
*/
|
|
480
532
|
var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
|
|
481
533
|
/**
|
|
482
534
|
* The names of the parameters that are reserved for special purposes
|
|
535
|
+
*
|
|
536
|
+
* @public exported from `@promptbook/core`
|
|
483
537
|
*/
|
|
484
538
|
var RESERVED_PARAMETER_NAMES = deepFreeze([
|
|
485
539
|
'content',
|
|
@@ -493,10 +547,14 @@
|
|
|
493
547
|
]);
|
|
494
548
|
/**
|
|
495
549
|
* @@@
|
|
550
|
+
*
|
|
551
|
+
* @private within the repository
|
|
496
552
|
*/
|
|
497
553
|
var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
|
|
498
554
|
/**
|
|
499
555
|
* @@@
|
|
556
|
+
*
|
|
557
|
+
* @private within the repository
|
|
500
558
|
*/
|
|
501
559
|
var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
|
|
502
560
|
/*
|
|
@@ -504,11 +562,13 @@
|
|
|
504
562
|
*/
|
|
505
563
|
// [🟡][🟢][🔵][⚪]
|
|
506
564
|
/**
|
|
507
|
-
* TODO:
|
|
565
|
+
* TODO: !!!!!! Check that all @private contains some normalized explanation
|
|
508
566
|
*/
|
|
509
567
|
|
|
510
568
|
/**
|
|
511
569
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
570
|
+
*
|
|
571
|
+
* @public exported from `@promptbook/core`
|
|
512
572
|
*/
|
|
513
573
|
var ParsingError = /** @class */ (function (_super) {
|
|
514
574
|
__extends(ParsingError, _super);
|
|
@@ -523,6 +583,8 @@
|
|
|
523
583
|
|
|
524
584
|
/**
|
|
525
585
|
* This error indicates that the promptbook object has valid syntax but contains logical errors (like circular dependencies)
|
|
586
|
+
*
|
|
587
|
+
* @public exported from `@promptbook/core`
|
|
526
588
|
*/
|
|
527
589
|
var PipelineLogicError = /** @class */ (function (_super) {
|
|
528
590
|
__extends(PipelineLogicError, _super);
|
|
@@ -537,6 +599,8 @@
|
|
|
537
599
|
|
|
538
600
|
/**
|
|
539
601
|
* This error type indicates that the error should not happen and its last check before crashing with some other error
|
|
602
|
+
*
|
|
603
|
+
* @public exported from `@promptbook/core`
|
|
540
604
|
*/
|
|
541
605
|
var UnexpectedError = /** @class */ (function (_super) {
|
|
542
606
|
__extends(UnexpectedError, _super);
|
|
@@ -555,6 +619,8 @@
|
|
|
555
619
|
* Note: There are two simmilar functions:
|
|
556
620
|
* - `isValidSemanticVersion` which tests any semantic version
|
|
557
621
|
* - `isValidPromptbookVersion` *(this one)* which tests just Promptbook versions
|
|
622
|
+
*
|
|
623
|
+
* @public exported from `@promptbook/utils`
|
|
558
624
|
*/
|
|
559
625
|
function isValidSemanticVersion(version) {
|
|
560
626
|
if (typeof version !== 'string') {
|
|
@@ -575,6 +641,8 @@
|
|
|
575
641
|
* Note: There are two simmilar functions:
|
|
576
642
|
* - `isValidSemanticVersion` which tests any semantic version
|
|
577
643
|
* - `isValidPromptbookVersion` *(this one)* which tests just Promptbook versions
|
|
644
|
+
*
|
|
645
|
+
* @public exported from `@promptbook/utils`
|
|
578
646
|
*/
|
|
579
647
|
function isValidPromptbookVersion(version) {
|
|
580
648
|
if (!isValidSemanticVersion(version)) {
|
|
@@ -593,6 +661,8 @@
|
|
|
593
661
|
* Note: There are two simmilar functions:
|
|
594
662
|
* - `isUrlOnPrivateNetwork` which tests full URL
|
|
595
663
|
* - `isHostnameOnPrivateNetwork` *(this one)* which tests just hostname
|
|
664
|
+
*
|
|
665
|
+
* @public exported from `@promptbook/utils`
|
|
596
666
|
*/
|
|
597
667
|
function isHostnameOnPrivateNetwork(hostname) {
|
|
598
668
|
if (hostname === 'example.com' ||
|
|
@@ -627,6 +697,7 @@
|
|
|
627
697
|
*
|
|
628
698
|
* @param {string} ipAddress - The IP address to check.
|
|
629
699
|
* @returns {boolean} Returns true if the IP address is reserved for private networks or localhost, otherwise false.
|
|
700
|
+
* @public exported from `@promptbook/utils`
|
|
630
701
|
*/
|
|
631
702
|
function isUrlOnPrivateNetwork(url) {
|
|
632
703
|
if (typeof url === 'string') {
|
|
@@ -642,6 +713,8 @@
|
|
|
642
713
|
* Note: There are two simmilar functions:
|
|
643
714
|
* - `isValidUrl` which tests any URL
|
|
644
715
|
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
716
|
+
*
|
|
717
|
+
* @public exported from `@promptbook/utils`
|
|
645
718
|
*/
|
|
646
719
|
function isValidUrl(url) {
|
|
647
720
|
if (typeof url !== 'string') {
|
|
@@ -668,6 +741,8 @@
|
|
|
668
741
|
* Note: There are two simmilar functions:
|
|
669
742
|
* - `isValidUrl` which tests any URL
|
|
670
743
|
* - `isValidPipelineUrl` *(this one)* which tests just pipeline URL
|
|
744
|
+
*
|
|
745
|
+
* @public exported from `@promptbook/utils`
|
|
671
746
|
*/
|
|
672
747
|
function isValidPipelineUrl(url) {
|
|
673
748
|
if (!isValidUrl(url)) {
|
|
@@ -705,6 +780,7 @@
|
|
|
705
780
|
* @param pipeline valid or invalid PipelineJson
|
|
706
781
|
* @returns the same pipeline if it is logically valid
|
|
707
782
|
* @throws {PipelineLogicError} on logical error in the pipeline
|
|
783
|
+
* @public exported from `@promptbook/core`
|
|
708
784
|
*/
|
|
709
785
|
function validatePipeline(pipeline) {
|
|
710
786
|
// TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
|
|
@@ -934,6 +1010,8 @@
|
|
|
934
1010
|
|
|
935
1011
|
/**
|
|
936
1012
|
* This error indicates that promptbook not found in the collection
|
|
1013
|
+
*
|
|
1014
|
+
* @public exported from `@promptbook/core`
|
|
937
1015
|
*/
|
|
938
1016
|
var NotFoundError = /** @class */ (function (_super) {
|
|
939
1017
|
__extends(NotFoundError, _super);
|
|
@@ -948,6 +1026,8 @@
|
|
|
948
1026
|
|
|
949
1027
|
/**
|
|
950
1028
|
* This error indicates errors in referencing promptbooks between each other
|
|
1029
|
+
*
|
|
1030
|
+
* @public exported from `@promptbook/core`
|
|
951
1031
|
*/
|
|
952
1032
|
var ReferenceError$1 = /** @class */ (function (_super) {
|
|
953
1033
|
__extends(ReferenceError, _super);
|
|
@@ -965,6 +1045,7 @@
|
|
|
965
1045
|
*
|
|
966
1046
|
* @param template the template with parameters in {curly} braces
|
|
967
1047
|
* @returns the list of parameter names
|
|
1048
|
+
* @public exported from `@promptbook/utils`
|
|
968
1049
|
*/
|
|
969
1050
|
function extractParameterNames(template) {
|
|
970
1051
|
var e_1, _a;
|
|
@@ -989,6 +1070,8 @@
|
|
|
989
1070
|
|
|
990
1071
|
/**
|
|
991
1072
|
* Unprepare just strips the preparation data of the pipeline
|
|
1073
|
+
*
|
|
1074
|
+
* @public exported from `@promptbook/core`
|
|
992
1075
|
*/
|
|
993
1076
|
function unpreparePipeline(pipeline) {
|
|
994
1077
|
var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, promptTemplates = pipeline.promptTemplates;
|
|
@@ -1005,7 +1088,6 @@
|
|
|
1005
1088
|
return __assign(__assign({}, pipeline), { promptTemplates: promptTemplates, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] });
|
|
1006
1089
|
}
|
|
1007
1090
|
/**
|
|
1008
|
-
* TODO: [🔼] !!! Export via `@promptbook/core`
|
|
1009
1091
|
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
1010
1092
|
* TODO: Write tests for `preparePipeline`
|
|
1011
1093
|
* TODO: [🍙] Make some standart order of json properties
|
|
@@ -1107,6 +1189,7 @@
|
|
|
1107
1189
|
*
|
|
1108
1190
|
* @param promptbookSources
|
|
1109
1191
|
* @returns PipelineCollection
|
|
1192
|
+
* @public exported from `@promptbook/core`
|
|
1110
1193
|
*/
|
|
1111
1194
|
function createCollectionFromJson() {
|
|
1112
1195
|
var promptbooks = [];
|
|
@@ -1134,6 +1217,7 @@
|
|
|
1134
1217
|
* @param promptbookSourcesPromiseOrFactory
|
|
1135
1218
|
* @returns PipelineCollection
|
|
1136
1219
|
* @deprecated Do not use, it will became internal tool for other constructor functions
|
|
1220
|
+
* @public exported from `@promptbook/core`
|
|
1137
1221
|
*/
|
|
1138
1222
|
function createCollectionFromPromise(promptbookSourcesPromiseOrFactory) {
|
|
1139
1223
|
var collection = null;
|
|
@@ -1204,8 +1288,8 @@
|
|
|
1204
1288
|
|
|
1205
1289
|
/**
|
|
1206
1290
|
* Constructs Promptbook from remote Promptbase URL
|
|
1207
|
-
|
|
1208
1291
|
* @returns PipelineCollection
|
|
1292
|
+
* @public exported from `@promptbook/core`
|
|
1209
1293
|
*/
|
|
1210
1294
|
function createCollectionFromUrl(url, options) {
|
|
1211
1295
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1245,6 +1329,7 @@
|
|
|
1245
1329
|
*
|
|
1246
1330
|
* @param promptbookSources
|
|
1247
1331
|
* @returns PipelineCollection
|
|
1332
|
+
* @public exported from `@promptbook/core`
|
|
1248
1333
|
*/
|
|
1249
1334
|
function createSubcollection(collection, predicate) {
|
|
1250
1335
|
function listPipelines() {
|
|
@@ -1320,6 +1405,7 @@
|
|
|
1320
1405
|
* Block type describes the way how the block is blockd
|
|
1321
1406
|
*
|
|
1322
1407
|
* @see https://github.com/webgptorg/promptbook#block-type
|
|
1408
|
+
* @public exported from `@promptbook/core`
|
|
1323
1409
|
*/
|
|
1324
1410
|
var BlockTypes = [
|
|
1325
1411
|
'PROMPT_TEMPLATE',
|
|
@@ -1335,6 +1421,8 @@
|
|
|
1335
1421
|
|
|
1336
1422
|
/**
|
|
1337
1423
|
* @@@
|
|
1424
|
+
*
|
|
1425
|
+
* @public exported from `@promptbook/utils`
|
|
1338
1426
|
*/
|
|
1339
1427
|
function deepClone(objectValue) {
|
|
1340
1428
|
return JSON.parse(JSON.stringify(objectValue));
|
|
@@ -1351,14 +1439,13 @@
|
|
|
1351
1439
|
*/
|
|
1352
1440
|
}
|
|
1353
1441
|
/**
|
|
1354
|
-
* TODO: [🔼] Export from `@promptbook/utils`
|
|
1355
1442
|
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
1356
1443
|
*/
|
|
1357
1444
|
|
|
1358
1445
|
/**
|
|
1359
1446
|
* @@@
|
|
1360
1447
|
*
|
|
1361
|
-
*
|
|
1448
|
+
* @public exported from `@promptbook/core`
|
|
1362
1449
|
*/
|
|
1363
1450
|
var ZERO_USAGE = deepFreeze({
|
|
1364
1451
|
price: { value: 0 },
|
|
@@ -1385,6 +1472,8 @@
|
|
|
1385
1472
|
* Function `addUsage` will add multiple usages into one
|
|
1386
1473
|
*
|
|
1387
1474
|
* Note: If you provide 0 values, it returns ZERO_USAGE
|
|
1475
|
+
*
|
|
1476
|
+
* @public exported from `@promptbook/core`
|
|
1388
1477
|
*/
|
|
1389
1478
|
function addUsage() {
|
|
1390
1479
|
var usageItems = [];
|
|
@@ -1457,6 +1546,7 @@
|
|
|
1457
1546
|
* @param array - Array to iterate over
|
|
1458
1547
|
* @param options - Options for the function
|
|
1459
1548
|
* @param callbackfunction - Function to call for each item
|
|
1549
|
+
* @public exported from `@promptbook/utils`
|
|
1460
1550
|
*/
|
|
1461
1551
|
function forEachAsync(array, options, callbackfunction) {
|
|
1462
1552
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1743,6 +1833,8 @@
|
|
|
1743
1833
|
* > "ě" => "e"
|
|
1744
1834
|
* > "Ă" => "A"
|
|
1745
1835
|
* > ...
|
|
1836
|
+
*
|
|
1837
|
+
* @public exported from `@promptbook/utils`
|
|
1746
1838
|
*/
|
|
1747
1839
|
var DIACRITIC_VARIANTS_LETTERS = {};
|
|
1748
1840
|
// tslint:disable-next-line: prefer-for-of
|
|
@@ -1770,7 +1862,11 @@
|
|
|
1770
1862
|
*/
|
|
1771
1863
|
|
|
1772
1864
|
/**
|
|
1865
|
+
* @@@
|
|
1773
1866
|
*
|
|
1867
|
+
* @param input @@@
|
|
1868
|
+
* @returns @@@
|
|
1869
|
+
* @public exported from `@promptbook/utils`
|
|
1774
1870
|
*/
|
|
1775
1871
|
function removeDiacritics(input) {
|
|
1776
1872
|
/*eslint no-control-regex: "off"*/
|
|
@@ -1778,7 +1874,19 @@
|
|
|
1778
1874
|
return DIACRITIC_VARIANTS_LETTERS[a] || a;
|
|
1779
1875
|
});
|
|
1780
1876
|
}
|
|
1877
|
+
/**
|
|
1878
|
+
* TODO: [Ж] Variant for cyrillic (and in general non-latin) letters
|
|
1879
|
+
*/
|
|
1781
1880
|
|
|
1881
|
+
/**
|
|
1882
|
+
* @@@
|
|
1883
|
+
*
|
|
1884
|
+
* @param text @@@
|
|
1885
|
+
* @returns @@@
|
|
1886
|
+
* @example 'hello-world'
|
|
1887
|
+
* @example 'i-love-promptbook'
|
|
1888
|
+
* @public exported from `@promptbook/utils`
|
|
1889
|
+
*/
|
|
1782
1890
|
function normalizeToKebabCase(text) {
|
|
1783
1891
|
var e_1, _a;
|
|
1784
1892
|
text = removeDiacritics(text);
|
|
@@ -1838,6 +1946,7 @@
|
|
|
1838
1946
|
*
|
|
1839
1947
|
* @param text with emojis
|
|
1840
1948
|
* @returns text without emojis
|
|
1949
|
+
* @public exported from `@promptbook/utils`
|
|
1841
1950
|
*/
|
|
1842
1951
|
function removeEmojis(text) {
|
|
1843
1952
|
// Replace emojis (and also ZWJ sequence) with hyphens
|
|
@@ -1849,7 +1958,12 @@
|
|
|
1849
1958
|
}
|
|
1850
1959
|
|
|
1851
1960
|
/**
|
|
1852
|
-
*
|
|
1961
|
+
* @@@
|
|
1962
|
+
*
|
|
1963
|
+
* @param value @@@
|
|
1964
|
+
* @returns @@@
|
|
1965
|
+
* @example @@@
|
|
1966
|
+
* @public exported from `@promptbook/utils`
|
|
1853
1967
|
*/
|
|
1854
1968
|
function titleToName(value) {
|
|
1855
1969
|
if (value.startsWith('http://') || value.startsWith('https://')) {
|
|
@@ -1868,6 +1982,8 @@
|
|
|
1868
1982
|
|
|
1869
1983
|
/**
|
|
1870
1984
|
* This error indicates errors during the execution of the pipeline
|
|
1985
|
+
*
|
|
1986
|
+
* @public exported from `@promptbook/core`
|
|
1871
1987
|
*/
|
|
1872
1988
|
var PipelineExecutionError = /** @class */ (function (_super) {
|
|
1873
1989
|
__extends(PipelineExecutionError, _super);
|
|
@@ -1885,6 +2001,7 @@
|
|
|
1885
2001
|
*
|
|
1886
2002
|
* @param executionResult - The partial result of the promptnook execution
|
|
1887
2003
|
* @throws {PipelineExecutionError} If the execution is not successful or if multiple errors occurred
|
|
2004
|
+
* @public exported from `@promptbook/core`
|
|
1888
2005
|
*/
|
|
1889
2006
|
function assertsExecutionSuccessful(executionResult) {
|
|
1890
2007
|
var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors;
|
|
@@ -1915,6 +2032,7 @@
|
|
|
1915
2032
|
* @param script from which to extract the variables
|
|
1916
2033
|
* @returns the list of variable names
|
|
1917
2034
|
* @throws {ParsingError} if the script is invalid
|
|
2035
|
+
* @public exported from `@promptbook/utils`
|
|
1918
2036
|
*/
|
|
1919
2037
|
function extractVariables(script) {
|
|
1920
2038
|
var variables = new Set();
|
|
@@ -1963,6 +2081,7 @@
|
|
|
1963
2081
|
* @param promptTemplate the template with used parameters
|
|
1964
2082
|
* @returns the set of parameter names
|
|
1965
2083
|
* @throws {ParsingError} if the script is invalid
|
|
2084
|
+
* @public exported from `@promptbook/utils`
|
|
1966
2085
|
*/
|
|
1967
2086
|
function extractParameterNamesFromPromptTemplate(promptTemplate) {
|
|
1968
2087
|
var e_1, _a, e_2, _b, e_3, _c;
|
|
@@ -2036,6 +2155,8 @@
|
|
|
2036
2155
|
|
|
2037
2156
|
/**
|
|
2038
2157
|
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
2158
|
+
*
|
|
2159
|
+
* @public exported from `@promptbook/utils`
|
|
2039
2160
|
*/
|
|
2040
2161
|
function isValidJsonString(value /* <- [👨⚖️] */) {
|
|
2041
2162
|
try {
|
|
@@ -2262,6 +2383,8 @@
|
|
|
2262
2383
|
*
|
|
2263
2384
|
*
|
|
2264
2385
|
* Tip: You don't have to use this function directly, just pass an array of LlmExecutionTools to the `ExecutionTools`
|
|
2386
|
+
*
|
|
2387
|
+
* @public exported from `@promptbook/core`
|
|
2265
2388
|
*/
|
|
2266
2389
|
function joinLlmExecutionTools() {
|
|
2267
2390
|
var llmExecutionTools = [];
|
|
@@ -2301,6 +2424,8 @@
|
|
|
2301
2424
|
|
|
2302
2425
|
/**
|
|
2303
2426
|
* Determine if the pipeline is fully prepared
|
|
2427
|
+
*
|
|
2428
|
+
* @public exported from `@promptbook/core`
|
|
2304
2429
|
*/
|
|
2305
2430
|
function isPipelinePrepared(pipeline) {
|
|
2306
2431
|
// Note: Ignoring `pipeline.preparations` @@@
|
|
@@ -2321,7 +2446,6 @@
|
|
|
2321
2446
|
}
|
|
2322
2447
|
/**
|
|
2323
2448
|
* TODO: [🐠] Maybe base this on `makeValidator`
|
|
2324
|
-
* TODO: [🔼] Export via core or utils
|
|
2325
2449
|
* TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
|
|
2326
2450
|
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
2327
2451
|
* - [🏍] ? Is context in each template
|
|
@@ -2367,6 +2491,8 @@
|
|
|
2367
2491
|
|
|
2368
2492
|
/**
|
|
2369
2493
|
* This error type indicates that some limit was reached
|
|
2494
|
+
*
|
|
2495
|
+
* @public exported from `@promptbook/core`
|
|
2370
2496
|
*/
|
|
2371
2497
|
var LimitReachedError = /** @class */ (function (_super) {
|
|
2372
2498
|
__extends(LimitReachedError, _super);
|
|
@@ -2386,6 +2512,7 @@
|
|
|
2386
2512
|
* @param parameters the object with parameters
|
|
2387
2513
|
* @returns the template with replaced parameters
|
|
2388
2514
|
* @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
|
|
2515
|
+
* @public exported from `@promptbook/utils`
|
|
2389
2516
|
*/
|
|
2390
2517
|
function replaceParameters(template, parameters) {
|
|
2391
2518
|
var e_1, _a;
|
|
@@ -2461,6 +2588,7 @@
|
|
|
2461
2588
|
* Create difference set of two sets.
|
|
2462
2589
|
*
|
|
2463
2590
|
* @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
2591
|
+
* @public exported from `@promptbook/utils`
|
|
2464
2592
|
*/
|
|
2465
2593
|
function difference(a, b, isEqual) {
|
|
2466
2594
|
var e_1, _a;
|
|
@@ -2494,6 +2622,7 @@
|
|
|
2494
2622
|
* Creates a new set with all elements that are present in either set
|
|
2495
2623
|
*
|
|
2496
2624
|
* @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
2625
|
+
* @public exported from `@promptbook/utils`
|
|
2497
2626
|
*/
|
|
2498
2627
|
function union() {
|
|
2499
2628
|
var e_1, _a, e_2, _b;
|
|
@@ -2530,14 +2659,10 @@
|
|
|
2530
2659
|
return union;
|
|
2531
2660
|
}
|
|
2532
2661
|
|
|
2533
|
-
/**
|
|
2534
|
-
* The version of the Promptbook library
|
|
2535
|
-
*/
|
|
2536
|
-
var PROMPTBOOK_VERSION = '0.62.0';
|
|
2537
|
-
// TODO: !!!! List here all the versions and annotate + put into script
|
|
2538
|
-
|
|
2539
2662
|
/**
|
|
2540
2663
|
* Counts number of characters in the text
|
|
2664
|
+
*
|
|
2665
|
+
* @public exported from `@promptbook/utils`
|
|
2541
2666
|
*/
|
|
2542
2667
|
function countCharacters(text) {
|
|
2543
2668
|
// Remove null characters
|
|
@@ -2551,6 +2676,8 @@
|
|
|
2551
2676
|
|
|
2552
2677
|
/**
|
|
2553
2678
|
* Counts number of lines in the text
|
|
2679
|
+
*
|
|
2680
|
+
* @public exported from `@promptbook/utils`
|
|
2554
2681
|
*/
|
|
2555
2682
|
function countLines(text) {
|
|
2556
2683
|
if (text === '') {
|
|
@@ -2561,6 +2688,8 @@
|
|
|
2561
2688
|
|
|
2562
2689
|
/**
|
|
2563
2690
|
* Counts number of pages in the text
|
|
2691
|
+
*
|
|
2692
|
+
* @public exported from `@promptbook/utils`
|
|
2564
2693
|
*/
|
|
2565
2694
|
function countPages(text) {
|
|
2566
2695
|
var sentencesPerPage = 5; // Assuming each page has 5 sentences
|
|
@@ -2571,6 +2700,8 @@
|
|
|
2571
2700
|
|
|
2572
2701
|
/**
|
|
2573
2702
|
* Counts number of paragraphs in the text
|
|
2703
|
+
*
|
|
2704
|
+
* @public exported from `@promptbook/utils`
|
|
2574
2705
|
*/
|
|
2575
2706
|
function countParagraphs(text) {
|
|
2576
2707
|
return text.split(/\n\s*\n/).filter(function (paragraph) { return paragraph.trim() !== ''; }).length;
|
|
@@ -2578,12 +2709,16 @@
|
|
|
2578
2709
|
|
|
2579
2710
|
/**
|
|
2580
2711
|
* Split text into sentences
|
|
2712
|
+
*
|
|
2713
|
+
* @public exported from `@promptbook/utils`
|
|
2581
2714
|
*/
|
|
2582
2715
|
function splitIntoSentences(text) {
|
|
2583
2716
|
return text.split(/[.!?]+/).filter(function (sentence) { return sentence.trim() !== ''; });
|
|
2584
2717
|
}
|
|
2585
2718
|
/**
|
|
2586
2719
|
* Counts number of sentences in the text
|
|
2720
|
+
*
|
|
2721
|
+
* @public exported from `@promptbook/utils`
|
|
2587
2722
|
*/
|
|
2588
2723
|
function countSentences(text) {
|
|
2589
2724
|
return splitIntoSentences(text).length;
|
|
@@ -2591,6 +2726,8 @@
|
|
|
2591
2726
|
|
|
2592
2727
|
/**
|
|
2593
2728
|
* Counts number of words in the text
|
|
2729
|
+
*
|
|
2730
|
+
* @public exported from `@promptbook/utils`
|
|
2594
2731
|
*/
|
|
2595
2732
|
function countWords(text) {
|
|
2596
2733
|
text = text.replace(/[\p{Extended_Pictographic}]/gu, 'a');
|
|
@@ -2600,6 +2737,8 @@
|
|
|
2600
2737
|
|
|
2601
2738
|
/**
|
|
2602
2739
|
* Index of all counter functions
|
|
2740
|
+
*
|
|
2741
|
+
* @public exported from `@promptbook/utils`
|
|
2603
2742
|
*/
|
|
2604
2743
|
var CountUtils = {
|
|
2605
2744
|
CHARACTERS: countCharacters,
|
|
@@ -2619,6 +2758,7 @@
|
|
|
2619
2758
|
*
|
|
2620
2759
|
* @throws {ExpectError} if the expectations are not met
|
|
2621
2760
|
* @returns {void} Nothing
|
|
2761
|
+
* @public exported from `@promptbook/core`
|
|
2622
2762
|
*/
|
|
2623
2763
|
function checkExpectations(expectations, value) {
|
|
2624
2764
|
var e_1, _a;
|
|
@@ -2650,6 +2790,7 @@
|
|
|
2650
2790
|
* - `isPassingExpectations` which returns a boolean
|
|
2651
2791
|
*
|
|
2652
2792
|
* @returns {boolean} True if the expectations are met
|
|
2793
|
+
* @public exported from `@promptbook/core`
|
|
2653
2794
|
*/
|
|
2654
2795
|
function isPassingExpectations(expectations, value) {
|
|
2655
2796
|
try {
|
|
@@ -2672,6 +2813,7 @@
|
|
|
2672
2813
|
*
|
|
2673
2814
|
* @returns The executor function
|
|
2674
2815
|
* @throws {PipelineLogicError} on logical error in the pipeline
|
|
2816
|
+
* @public exported from `@promptbook/core`
|
|
2675
2817
|
*/
|
|
2676
2818
|
function createPipelineExecutor(options) {
|
|
2677
2819
|
var _this = this;
|
|
@@ -3460,6 +3602,8 @@
|
|
|
3460
3602
|
|
|
3461
3603
|
/**
|
|
3462
3604
|
* @@@
|
|
3605
|
+
*
|
|
3606
|
+
* @public exported from `@promptbook/core`
|
|
3463
3607
|
*/
|
|
3464
3608
|
function prepareKnowledgeFromMarkdown(knowledgeContent /* <- TODO: [🖖] (?maybe not) Always the file */, options) {
|
|
3465
3609
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -3595,6 +3739,7 @@
|
|
|
3595
3739
|
* Prepares the knowle
|
|
3596
3740
|
*
|
|
3597
3741
|
* @see https://github.com/webgptorg/promptbook/discussions/41
|
|
3742
|
+
* @public exported from `@promptbook/core`
|
|
3598
3743
|
*/
|
|
3599
3744
|
function prepareKnowledgePieces(knowledgeSources, options) {
|
|
3600
3745
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -3609,7 +3754,7 @@
|
|
|
3609
3754
|
var partialPieces, pieces;
|
|
3610
3755
|
return __generator(this, function (_a) {
|
|
3611
3756
|
switch (_a.label) {
|
|
3612
|
-
case 0: return [4 /*yield*/, prepareKnowledgeFromMarkdown(knowledgeSource.source, // <- TODO: [🐝] !!! Unhardcode markdown, detect which type it is
|
|
3757
|
+
case 0: return [4 /*yield*/, prepareKnowledgeFromMarkdown(knowledgeSource.source, // <- TODO: [🐝] !!! Unhardcode markdown, detect which type it is - BE AWARE of big package size
|
|
3613
3758
|
options)];
|
|
3614
3759
|
case 1:
|
|
3615
3760
|
partialPieces = _a.sent();
|
|
@@ -3647,7 +3792,6 @@
|
|
|
3647
3792
|
> ):
|
|
3648
3793
|
*/
|
|
3649
3794
|
/**
|
|
3650
|
-
* TODO: [🐝][🔼] !!! Export via `@promptbook/core`
|
|
3651
3795
|
* TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
|
|
3652
3796
|
* Put `knowledgePieces` into `PrepareKnowledgeOptions`
|
|
3653
3797
|
* TODO: [🪂] More than max things can run in parallel by acident [1,[2a,2b,_],[3a,3b,_]]
|
|
@@ -3661,6 +3805,7 @@
|
|
|
3661
3805
|
*
|
|
3662
3806
|
* @param llmTools LLM tools to be intercepted with usage counting
|
|
3663
3807
|
* @returns LLM tools with same functionality with added total cost counting
|
|
3808
|
+
* @public exported from `@promptbook/core`
|
|
3664
3809
|
*/
|
|
3665
3810
|
function countTotalUsage(llmTools) {
|
|
3666
3811
|
var _this = this;
|
|
@@ -3728,7 +3873,6 @@
|
|
|
3728
3873
|
return proxyTools;
|
|
3729
3874
|
}
|
|
3730
3875
|
/**
|
|
3731
|
-
* TODO: [🔼] !!! Export via `@promptbookcore/`
|
|
3732
3876
|
* TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
|
|
3733
3877
|
* TODO: [🧠] Is there some meaningfull way how to test this util
|
|
3734
3878
|
* TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
|
|
@@ -3740,6 +3884,7 @@
|
|
|
3740
3884
|
* Prepares the persona for the pipeline
|
|
3741
3885
|
*
|
|
3742
3886
|
* @see https://github.com/webgptorg/promptbook/discussions/22
|
|
3887
|
+
* @public exported from `@promptbook/core`
|
|
3743
3888
|
*/
|
|
3744
3889
|
function preparePersona(personaDescription, options) {
|
|
3745
3890
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -3794,7 +3939,6 @@
|
|
|
3794
3939
|
});
|
|
3795
3940
|
}
|
|
3796
3941
|
/**
|
|
3797
|
-
* TODO: [🔼] !!! Export via `@promptbook/core`
|
|
3798
3942
|
* TODO: [🏢] !! Check validity of `modelName` in pipeline
|
|
3799
3943
|
* TODO: [🏢] !! Check validity of `systemMessage` in pipeline
|
|
3800
3944
|
* TODO: [🏢] !! Check validity of `temperature` in pipeline
|
|
@@ -3802,6 +3946,8 @@
|
|
|
3802
3946
|
|
|
3803
3947
|
/**
|
|
3804
3948
|
* @@@
|
|
3949
|
+
*
|
|
3950
|
+
* @public exported from `@promptbook/core`
|
|
3805
3951
|
*/
|
|
3806
3952
|
function prepareTemplates(pipeline, options) {
|
|
3807
3953
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -3843,7 +3989,6 @@
|
|
|
3843
3989
|
* TODO: [🧠] Add context to each template (if missing)
|
|
3844
3990
|
* TODO: [🧠] What is better name `prepareTemplate` or `prepareTemplateAndParameters`
|
|
3845
3991
|
* TODO: [♨] !!! Prepare index the samples and maybe templates
|
|
3846
|
-
* TODO: [🔼] !!! Export via `@promptbook/core`
|
|
3847
3992
|
* TODO: Write tests for `preparePipeline`
|
|
3848
3993
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
3849
3994
|
* TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
|
|
@@ -3856,6 +4001,7 @@
|
|
|
3856
4001
|
*
|
|
3857
4002
|
* Note: This function does not validate logic of the pipeline
|
|
3858
4003
|
* Note: This function acts as part of compilation process
|
|
4004
|
+
* @public exported from `@promptbook/core`
|
|
3859
4005
|
*/
|
|
3860
4006
|
function preparePipeline(pipeline, options) {
|
|
3861
4007
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -3932,7 +4078,6 @@
|
|
|
3932
4078
|
});
|
|
3933
4079
|
}
|
|
3934
4080
|
/**
|
|
3935
|
-
* TODO: [🔼] !!! Export via `@promptbook/core`
|
|
3936
4081
|
* TODO: Write tests for `preparePipeline`
|
|
3937
4082
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
3938
4083
|
* TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
|
|
@@ -3943,6 +4088,7 @@
|
|
|
3943
4088
|
* Tests if given string is valid URL.
|
|
3944
4089
|
*
|
|
3945
4090
|
* Note: This does not check if the file exists only if the path is valid
|
|
4091
|
+
* @public exported from `@promptbook/utils`
|
|
3946
4092
|
*/
|
|
3947
4093
|
function isValidFilePath(filePath) {
|
|
3948
4094
|
if (typeof filePath !== 'string') {
|
|
@@ -4125,6 +4271,7 @@
|
|
|
4125
4271
|
*
|
|
4126
4272
|
* @param {string} str - The string to remove Markdown tags from.
|
|
4127
4273
|
* @returns {string} The input string with all Markdown tags removed.
|
|
4274
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
4128
4275
|
*/
|
|
4129
4276
|
function removeMarkdownFormatting(str) {
|
|
4130
4277
|
// Remove bold formatting
|
|
@@ -4136,6 +4283,15 @@
|
|
|
4136
4283
|
return str;
|
|
4137
4284
|
}
|
|
4138
4285
|
|
|
4286
|
+
/**
|
|
4287
|
+
* @@@
|
|
4288
|
+
*
|
|
4289
|
+
* @param text @@@
|
|
4290
|
+
* @returns @@@
|
|
4291
|
+
* @example 'HELLO_WORLD'
|
|
4292
|
+
* @example 'I_LOVE_PROMPTBOOK'
|
|
4293
|
+
* @public exported from `@promptbook/utils`
|
|
4294
|
+
*/
|
|
4139
4295
|
function normalizeTo_SCREAMING_CASE(text) {
|
|
4140
4296
|
var e_1, _a;
|
|
4141
4297
|
var charType;
|
|
@@ -4303,7 +4459,7 @@
|
|
|
4303
4459
|
* @returns parsed number
|
|
4304
4460
|
* @throws {ParsingError} if the value is not a number
|
|
4305
4461
|
*
|
|
4306
|
-
* @
|
|
4462
|
+
* @public exported from `@promptbook/utils`
|
|
4307
4463
|
*/
|
|
4308
4464
|
function parseNumber(value) {
|
|
4309
4465
|
var originalValue = value;
|
|
@@ -4359,6 +4515,7 @@
|
|
|
4359
4515
|
}
|
|
4360
4516
|
/**
|
|
4361
4517
|
* TODO: Maybe use sth. like safe-eval in fraction/calculation case @see https://www.npmjs.com/package/safe-eval
|
|
4518
|
+
* TODO: [🧠][🌻] Maybe export through `@promptbook/markdown-utils` not `@promptbook/utils`
|
|
4362
4519
|
*/
|
|
4363
4520
|
|
|
4364
4521
|
/**
|
|
@@ -4670,6 +4827,13 @@
|
|
|
4670
4827
|
},
|
|
4671
4828
|
};
|
|
4672
4829
|
|
|
4830
|
+
/**
|
|
4831
|
+
* @@@
|
|
4832
|
+
*
|
|
4833
|
+
* @param javascriptName @@@
|
|
4834
|
+
* @returns @@@
|
|
4835
|
+
* @public exported from `@promptbook/utils`
|
|
4836
|
+
*/
|
|
4673
4837
|
function isValidJavascriptName(javascriptName) {
|
|
4674
4838
|
if (typeof javascriptName !== 'string') {
|
|
4675
4839
|
return false;
|
|
@@ -5142,6 +5306,8 @@
|
|
|
5142
5306
|
|
|
5143
5307
|
/**
|
|
5144
5308
|
* This error type indicates that some part of the code is not implemented yet
|
|
5309
|
+
*
|
|
5310
|
+
* @public exported from `@promptbook/core`
|
|
5145
5311
|
*/
|
|
5146
5312
|
var NotYetImplementedError = /** @class */ (function (_super) {
|
|
5147
5313
|
__extends(NotYetImplementedError, _super);
|
|
@@ -5168,7 +5334,8 @@
|
|
|
5168
5334
|
* Note: It can not work with html syntax and comments
|
|
5169
5335
|
*
|
|
5170
5336
|
* @param markdown any valid markdown
|
|
5171
|
-
* @returns
|
|
5337
|
+
* @returns @@@
|
|
5338
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
5172
5339
|
*/
|
|
5173
5340
|
function extractAllListItemsFromMarkdown(markdown) {
|
|
5174
5341
|
var e_1, _a;
|
|
@@ -5208,7 +5375,7 @@
|
|
|
5208
5375
|
*
|
|
5209
5376
|
* @param markdown any valid markdown
|
|
5210
5377
|
* @returns code blocks with language and content
|
|
5211
|
-
*
|
|
5378
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
5212
5379
|
*/
|
|
5213
5380
|
function extractAllBlocksFromMarkdown(markdown) {
|
|
5214
5381
|
var e_1, _a;
|
|
@@ -5285,6 +5452,7 @@
|
|
|
5285
5452
|
*
|
|
5286
5453
|
* @param markdown any valid markdown
|
|
5287
5454
|
* @returns code block with language and content
|
|
5455
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
5288
5456
|
*/
|
|
5289
5457
|
function extractOneBlockFromMarkdown(markdown) {
|
|
5290
5458
|
var codeBlocks = extractAllBlocksFromMarkdown(markdown);
|
|
@@ -5299,6 +5467,8 @@
|
|
|
5299
5467
|
|
|
5300
5468
|
/**
|
|
5301
5469
|
* Parses markdown section to title its level and content
|
|
5470
|
+
*
|
|
5471
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
5302
5472
|
*/
|
|
5303
5473
|
function parseMarkdownSection(value) {
|
|
5304
5474
|
var _a, _b;
|
|
@@ -5323,6 +5493,8 @@
|
|
|
5323
5493
|
|
|
5324
5494
|
/**
|
|
5325
5495
|
* Splits the markdown into sections by headings
|
|
5496
|
+
*
|
|
5497
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
5326
5498
|
*/
|
|
5327
5499
|
function splitMarkdownIntoSections(markdown) {
|
|
5328
5500
|
var e_1, _a;
|
|
@@ -5384,6 +5556,7 @@
|
|
|
5384
5556
|
return sections;
|
|
5385
5557
|
}
|
|
5386
5558
|
/**
|
|
5559
|
+
* TODO: [🏛] This can be part of markdown builder
|
|
5387
5560
|
* Note: [🕞] In past (commit 42086e1603cbed506482997c00a8ee979af0a247) there was much more
|
|
5388
5561
|
* sophisticated implementation of this function through parsing markdown into JSON structure
|
|
5389
5562
|
* and flattening the actual structure
|
|
@@ -5395,6 +5568,8 @@
|
|
|
5395
5568
|
*
|
|
5396
5569
|
* - It always have h1 - if there is no h1 in the markdown, it will be added "# Untitled"
|
|
5397
5570
|
* - All other headings are normalized to h2
|
|
5571
|
+
*
|
|
5572
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
5398
5573
|
*/
|
|
5399
5574
|
function flattenMarkdown(markdown) {
|
|
5400
5575
|
var e_1, _a;
|
|
@@ -5430,6 +5605,7 @@
|
|
|
5430
5605
|
return spaceTrim__default["default"](flattenedMarkdown);
|
|
5431
5606
|
}
|
|
5432
5607
|
/**
|
|
5608
|
+
* TODO: [🏛] This can be part of markdown builder
|
|
5433
5609
|
* Note: [🕞] In past (commit 42086e1603cbed506482997c00a8ee979af0a247) there was much more
|
|
5434
5610
|
* sophisticated implementation of this function through parsing markdown into JSON structure
|
|
5435
5611
|
* and flattening the actual structure
|
|
@@ -5441,6 +5617,7 @@
|
|
|
5441
5617
|
*
|
|
5442
5618
|
* @param {string} content - The string to remove comments from.
|
|
5443
5619
|
* @returns {string} The input string with all comments removed.
|
|
5620
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
5444
5621
|
*/
|
|
5445
5622
|
function removeContentComments(content) {
|
|
5446
5623
|
return spaceTrim.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
|
|
@@ -5454,12 +5631,13 @@
|
|
|
5454
5631
|
* - `pipelineStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
|
|
5455
5632
|
* - `preparePipeline` - just one step in the compilation process
|
|
5456
5633
|
*
|
|
5634
|
+
* Note: This function does not validate logic of the pipeline only the syntax
|
|
5635
|
+
* Note: This function acts as compilation process
|
|
5636
|
+
*
|
|
5457
5637
|
* @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
|
|
5458
5638
|
* @returns {Promptbook} compiled in JSON format (.ptbk.json)
|
|
5459
5639
|
* @throws {ParsingError} if the promptbook string is not valid
|
|
5460
|
-
*
|
|
5461
|
-
* Note: This function does not validate logic of the pipeline only the syntax
|
|
5462
|
-
* Note: This function acts as compilation process
|
|
5640
|
+
* @public exported from `@promptbook/core`
|
|
5463
5641
|
*/
|
|
5464
5642
|
function pipelineStringToJsonSync(pipelineString) {
|
|
5465
5643
|
var e_1, _a, e_2, _b;
|
|
@@ -5852,13 +6030,14 @@
|
|
|
5852
6030
|
* - `pipelineStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
|
|
5853
6031
|
* - `preparePipeline` - just one step in the compilation process
|
|
5854
6032
|
*
|
|
6033
|
+
* Note: This function does not validate logic of the pipeline only the syntax
|
|
6034
|
+
* Note: This function acts as compilation process
|
|
6035
|
+
*
|
|
5855
6036
|
* @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
|
|
5856
6037
|
* @param options - Options and tools for the compilation
|
|
5857
6038
|
* @returns {Promptbook} compiled in JSON format (.ptbk.json)
|
|
5858
6039
|
* @throws {ParsingError} if the promptbook string is not valid
|
|
5859
|
-
*
|
|
5860
|
-
* Note: This function does not validate logic of the pipeline only the syntax
|
|
5861
|
-
* Note: This function acts as compilation process
|
|
6040
|
+
* @public exported from `@promptbook/core`
|
|
5862
6041
|
*/
|
|
5863
6042
|
function pipelineStringToJson(pipelineString, options) {
|
|
5864
6043
|
if (options === void 0) { options = { llmTools: null }; }
|
|
@@ -5887,7 +6066,7 @@
|
|
|
5887
6066
|
/**
|
|
5888
6067
|
* Add or modify an auto-generated section in a markdown file
|
|
5889
6068
|
*
|
|
5890
|
-
* @
|
|
6069
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
5891
6070
|
*/
|
|
5892
6071
|
function addAutoGeneratedSection(content, options) {
|
|
5893
6072
|
var sectionName = options.sectionName, sectionContent = options.sectionContent;
|
|
@@ -5907,7 +6086,20 @@
|
|
|
5907
6086
|
var _a = __read(placeForSection, 1), heading = _a[0];
|
|
5908
6087
|
return content.replace(heading, "<!--".concat(sectionName, "-->\n").concat(warningLine, "\n").concat(sectionContent, "\n<!--/").concat(sectionName, "-->\n\n").concat(heading));
|
|
5909
6088
|
}
|
|
6089
|
+
/**
|
|
6090
|
+
* TODO: [🏛] This can be part of markdown builder
|
|
6091
|
+
*/
|
|
5910
6092
|
|
|
6093
|
+
/**
|
|
6094
|
+
* @@@
|
|
6095
|
+
*
|
|
6096
|
+
* @param text @@@
|
|
6097
|
+
* @param _isFirstLetterCapital @@@
|
|
6098
|
+
* @returns @@@
|
|
6099
|
+
* @example 'helloWorld'
|
|
6100
|
+
* @example 'iLovePromptbook'
|
|
6101
|
+
* @public exported from `@promptbook/utils`
|
|
6102
|
+
*/
|
|
5911
6103
|
function normalizeTo_camelCase(text, _isFirstLetterCapital) {
|
|
5912
6104
|
var e_1, _a;
|
|
5913
6105
|
if (_isFirstLetterCapital === void 0) { _isFirstLetterCapital = false; }
|
|
@@ -5966,6 +6158,8 @@
|
|
|
5966
6158
|
* Creates a Mermaid graph based on the promptbook
|
|
5967
6159
|
*
|
|
5968
6160
|
* Note: The result is not wrapped in a Markdown code block
|
|
6161
|
+
*
|
|
6162
|
+
* @public exported from `@promptbook/utils`
|
|
5969
6163
|
*/
|
|
5970
6164
|
function renderPromptbookMermaid(pipelineJson, options) {
|
|
5971
6165
|
var _a = (options || {}).linkPromptTemplate, linkPromptTemplate = _a === void 0 ? function () { return null; } : _a;
|
|
@@ -6022,6 +6216,8 @@
|
|
|
6022
6216
|
|
|
6023
6217
|
/**
|
|
6024
6218
|
* Prettyfies Promptbook string and adds Mermaid graph
|
|
6219
|
+
*
|
|
6220
|
+
* @public exported from `@promptbook/core`
|
|
6025
6221
|
*/
|
|
6026
6222
|
function prettifyPipelineString(pipelineString, options) {
|
|
6027
6223
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -6064,6 +6260,8 @@
|
|
|
6064
6260
|
*
|
|
6065
6261
|
* Note: [0] It can be used for more JSON types like whole collection of pipelines, single knowledge piece, etc.
|
|
6066
6262
|
* Note: In contrast to JSON.stringify, this function ensures that **embedding index** is on single line
|
|
6263
|
+
*
|
|
6264
|
+
* @public exported from `@promptbook/core`
|
|
6067
6265
|
*/
|
|
6068
6266
|
function stringifyPipelineJson(pipeline) {
|
|
6069
6267
|
var pipelineJsonStringified = JSON.stringify(pipeline, null, 4);
|
|
@@ -6083,6 +6281,8 @@
|
|
|
6083
6281
|
|
|
6084
6282
|
/**
|
|
6085
6283
|
* This error indicates that the pipeline collection cannot be propperly loaded
|
|
6284
|
+
*
|
|
6285
|
+
* @public exported from `@promptbook/core`
|
|
6086
6286
|
*/
|
|
6087
6287
|
var CollectionError = /** @class */ (function (_super) {
|
|
6088
6288
|
__extends(CollectionError, _super);
|
|
@@ -6095,8 +6295,26 @@
|
|
|
6095
6295
|
return CollectionError;
|
|
6096
6296
|
}(Error));
|
|
6097
6297
|
|
|
6298
|
+
/**
|
|
6299
|
+
* This error type indicates that you try to use a feature that is not available in the current environment
|
|
6300
|
+
*
|
|
6301
|
+
* @public exported from `@promptbook/core`
|
|
6302
|
+
*/
|
|
6303
|
+
var EnvironmentMismatchError = /** @class */ (function (_super) {
|
|
6304
|
+
__extends(EnvironmentMismatchError, _super);
|
|
6305
|
+
function EnvironmentMismatchError(message) {
|
|
6306
|
+
var _this = _super.call(this, message) || this;
|
|
6307
|
+
_this.name = 'EnvironmentMismatchError';
|
|
6308
|
+
Object.setPrototypeOf(_this, EnvironmentMismatchError.prototype);
|
|
6309
|
+
return _this;
|
|
6310
|
+
}
|
|
6311
|
+
return EnvironmentMismatchError;
|
|
6312
|
+
}(Error));
|
|
6313
|
+
|
|
6098
6314
|
/**
|
|
6099
6315
|
* This error type indicates that the version of the pipeline is not matching the expected version
|
|
6316
|
+
*
|
|
6317
|
+
* @public exported from `@promptbook/core`
|
|
6100
6318
|
*/
|
|
6101
6319
|
var VersionMismatchError = /** @class */ (function (_super) {
|
|
6102
6320
|
__extends(VersionMismatchError, _super);
|
|
@@ -6111,6 +6329,8 @@
|
|
|
6111
6329
|
|
|
6112
6330
|
/**
|
|
6113
6331
|
* Pretty print an embedding vector for logging
|
|
6332
|
+
*
|
|
6333
|
+
* @public exported from `@promptbook/core`
|
|
6114
6334
|
*/
|
|
6115
6335
|
function embeddingVectorToString(embeddingVector) {
|
|
6116
6336
|
var vectorLength = Math.pow(embeddingVector.reduce(function (acc, val) { return acc + Math.pow(val, 2); }, 0), 0.5);
|
|
@@ -6123,6 +6343,8 @@
|
|
|
6123
6343
|
* Note: This is an estimate based of theese sources:
|
|
6124
6344
|
* - https://jecas.cz/doba-cteni
|
|
6125
6345
|
* - https://www.originalnitonery.cz/blog/psani-vsemi-deseti-se-muzete-naucit-i-sami-doma
|
|
6346
|
+
*
|
|
6347
|
+
* @public exported from `@promptbook/core`
|
|
6126
6348
|
*/
|
|
6127
6349
|
function usageToWorktime(usage) {
|
|
6128
6350
|
var value = usage.input.wordsCount.value / (200 /* words per minute */ * 60) +
|
|
@@ -6137,6 +6359,8 @@
|
|
|
6137
6359
|
|
|
6138
6360
|
/**
|
|
6139
6361
|
* Function `usageToHuman` will take usage and convert it to human readable report
|
|
6362
|
+
*
|
|
6363
|
+
* @public exported from `@promptbook/core`
|
|
6140
6364
|
*/
|
|
6141
6365
|
function usageToHuman(usage) {
|
|
6142
6366
|
var report = 'Usage:';
|
|
@@ -6161,6 +6385,8 @@
|
|
|
6161
6385
|
/**
|
|
6162
6386
|
* Delagates the user interaction to a async callback function
|
|
6163
6387
|
* You need to provide your own implementation of this callback function and its bind to UI.
|
|
6388
|
+
*
|
|
6389
|
+
* @public exported from `@promptbook/core`
|
|
6164
6390
|
*/
|
|
6165
6391
|
var CallbackInterfaceTools = /** @class */ (function () {
|
|
6166
6392
|
function CallbackInterfaceTools(options) {
|
|
@@ -6193,6 +6419,8 @@
|
|
|
6193
6419
|
*
|
|
6194
6420
|
* Warning: It is used for testing and mocking
|
|
6195
6421
|
* **NOT intended to use in the production** due to its synchronous nature.
|
|
6422
|
+
*
|
|
6423
|
+
* @public exported from `@promptbook/core`
|
|
6196
6424
|
*/
|
|
6197
6425
|
var SimplePromptInterfaceTools = /** @class */ (function () {
|
|
6198
6426
|
function SimplePromptInterfaceTools(options) {
|
|
@@ -6224,12 +6452,260 @@
|
|
|
6224
6452
|
*/
|
|
6225
6453
|
|
|
6226
6454
|
/**
|
|
6227
|
-
*
|
|
6455
|
+
* Stores
|
|
6456
|
+
*
|
|
6457
|
+
* @public exported from `@promptbook/core`
|
|
6228
6458
|
*/
|
|
6229
|
-
var
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6459
|
+
var MemoryStorage = /** @class */ (function () {
|
|
6460
|
+
function MemoryStorage() {
|
|
6461
|
+
this.storage = {};
|
|
6462
|
+
}
|
|
6463
|
+
Object.defineProperty(MemoryStorage.prototype, "length", {
|
|
6464
|
+
/**
|
|
6465
|
+
* Returns the number of key/value pairs currently present in the list associated with the object.
|
|
6466
|
+
*/
|
|
6467
|
+
get: function () {
|
|
6468
|
+
return Object.keys(this.storage).length;
|
|
6469
|
+
},
|
|
6470
|
+
enumerable: false,
|
|
6471
|
+
configurable: true
|
|
6472
|
+
});
|
|
6473
|
+
/**
|
|
6474
|
+
* Empties the list associated with the object of all key/value pairs, if there are any.
|
|
6475
|
+
*/
|
|
6476
|
+
MemoryStorage.prototype.clear = function () {
|
|
6477
|
+
this.storage = {};
|
|
6478
|
+
};
|
|
6479
|
+
/**
|
|
6480
|
+
* Returns the current value associated with the given key, or null if the given key does not exist in the list associated with the object.
|
|
6481
|
+
*/
|
|
6482
|
+
MemoryStorage.prototype.getItem = function (key) {
|
|
6483
|
+
return this.storage[key] || null;
|
|
6484
|
+
};
|
|
6485
|
+
/**
|
|
6486
|
+
* Returns the name of the nth key in the list, or null if n is greater than or equal to the number of key/value pairs in the object.
|
|
6487
|
+
*/
|
|
6488
|
+
MemoryStorage.prototype.key = function (index) {
|
|
6489
|
+
return Object.keys(this.storage)[index] || null;
|
|
6490
|
+
};
|
|
6491
|
+
/**
|
|
6492
|
+
* Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
|
|
6493
|
+
*/
|
|
6494
|
+
MemoryStorage.prototype.setItem = function (key, value) {
|
|
6495
|
+
this.storage[key] = value;
|
|
6496
|
+
};
|
|
6497
|
+
/**
|
|
6498
|
+
* Removes the key/value pair with the given key from the list associated with the object, if a key/value pair with the given key exists.
|
|
6499
|
+
*/
|
|
6500
|
+
MemoryStorage.prototype.removeItem = function (key) {
|
|
6501
|
+
delete this.storage[key];
|
|
6502
|
+
};
|
|
6503
|
+
return MemoryStorage;
|
|
6504
|
+
}());
|
|
6505
|
+
|
|
6506
|
+
/**
|
|
6507
|
+
* Simple wrapper `new Date().toISOString()`
|
|
6508
|
+
*
|
|
6509
|
+
* @returns string_date branded type
|
|
6510
|
+
* @public exported from `@promptbook/utils`
|
|
6511
|
+
*/
|
|
6512
|
+
function $currentDate() {
|
|
6513
|
+
return new Date().toISOString();
|
|
6514
|
+
}
|
|
6515
|
+
|
|
6516
|
+
/**
|
|
6517
|
+
* Intercepts LLM tools and counts total usage of the tools
|
|
6518
|
+
*
|
|
6519
|
+
* Note: It can take extended `LlmExecutionTools` and cache the
|
|
6520
|
+
*
|
|
6521
|
+
* @param llmTools LLM tools to be intercepted with usage counting, it can contain extra methods like `totalUsage`
|
|
6522
|
+
* @returns LLM tools with same functionality with added total cost counting
|
|
6523
|
+
* @public exported from `@promptbook/core`
|
|
6524
|
+
*/
|
|
6525
|
+
function cacheLlmTools(llmTools, options) {
|
|
6526
|
+
var _this = this;
|
|
6527
|
+
if (options === void 0) { options = {}; }
|
|
6528
|
+
var _a = options.storage, storage = _a === void 0 ? new MemoryStorage() : _a, _b = options.isReloaded, isReloaded = _b === void 0 ? false : _b;
|
|
6529
|
+
var proxyTools = __assign(__assign({}, llmTools), {
|
|
6530
|
+
// <- Note: [🥫]
|
|
6531
|
+
get title() {
|
|
6532
|
+
// TODO: [🧠] Maybe put here some suffix
|
|
6533
|
+
return llmTools.title;
|
|
6534
|
+
},
|
|
6535
|
+
get description() {
|
|
6536
|
+
// TODO: [🧠] Maybe put here some suffix
|
|
6537
|
+
return llmTools.description;
|
|
6538
|
+
}, listModels: function () {
|
|
6539
|
+
// TODO: [🧠] Should be model listing also cached?
|
|
6540
|
+
return /* not await */ llmTools.listModels();
|
|
6541
|
+
} });
|
|
6542
|
+
var callCommonModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
6543
|
+
var key, cacheItem, _a, promptResult, _b;
|
|
6544
|
+
return __generator(this, function (_c) {
|
|
6545
|
+
switch (_c.label) {
|
|
6546
|
+
case 0:
|
|
6547
|
+
key = titleToName(prompt.title.substring(0, MAX_FILENAME_LENGTH - 10) +
|
|
6548
|
+
'-' +
|
|
6549
|
+
sha256__default["default"](hexEncoder__default["default"].parse(JSON.stringify(prompt.parameters))).toString( /* hex */));
|
|
6550
|
+
if (!!isReloaded) return [3 /*break*/, 2];
|
|
6551
|
+
return [4 /*yield*/, storage.getItem(key)];
|
|
6552
|
+
case 1:
|
|
6553
|
+
_a = _c.sent();
|
|
6554
|
+
return [3 /*break*/, 3];
|
|
6555
|
+
case 2:
|
|
6556
|
+
_a = null;
|
|
6557
|
+
_c.label = 3;
|
|
6558
|
+
case 3:
|
|
6559
|
+
cacheItem = _a;
|
|
6560
|
+
if (cacheItem) {
|
|
6561
|
+
return [2 /*return*/, cacheItem.promptResult];
|
|
6562
|
+
}
|
|
6563
|
+
_b = prompt.modelRequirements.modelVariant;
|
|
6564
|
+
switch (_b) {
|
|
6565
|
+
case 'CHAT': return [3 /*break*/, 4];
|
|
6566
|
+
case 'COMPLETION': return [3 /*break*/, 6];
|
|
6567
|
+
case 'EMBEDDING': return [3 /*break*/, 8];
|
|
6568
|
+
}
|
|
6569
|
+
return [3 /*break*/, 10];
|
|
6570
|
+
case 4: return [4 /*yield*/, llmTools.callChatModel(prompt)];
|
|
6571
|
+
case 5:
|
|
6572
|
+
promptResult = _c.sent();
|
|
6573
|
+
return [3 /*break*/, 11];
|
|
6574
|
+
case 6: return [4 /*yield*/, llmTools.callCompletionModel(prompt)];
|
|
6575
|
+
case 7:
|
|
6576
|
+
promptResult = _c.sent();
|
|
6577
|
+
return [3 /*break*/, 11];
|
|
6578
|
+
case 8: return [4 /*yield*/, llmTools.callEmbeddingModel(prompt)];
|
|
6579
|
+
case 9:
|
|
6580
|
+
promptResult = _c.sent();
|
|
6581
|
+
return [3 /*break*/, 11];
|
|
6582
|
+
case 10: throw new PipelineExecutionError("Unknown model variant \"".concat(prompt.modelRequirements.modelVariant, "\""));
|
|
6583
|
+
case 11: return [4 /*yield*/, storage.setItem(key, {
|
|
6584
|
+
date: $currentDate(),
|
|
6585
|
+
promptbookVersion: PROMPTBOOK_VERSION,
|
|
6586
|
+
prompt: prompt,
|
|
6587
|
+
promptResult: promptResult,
|
|
6588
|
+
})];
|
|
6589
|
+
case 12:
|
|
6590
|
+
_c.sent();
|
|
6591
|
+
return [2 /*return*/, promptResult];
|
|
6592
|
+
}
|
|
6593
|
+
});
|
|
6594
|
+
}); };
|
|
6595
|
+
if (llmTools.callChatModel !== undefined) {
|
|
6596
|
+
proxyTools.callChatModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
6597
|
+
return __generator(this, function (_a) {
|
|
6598
|
+
return [2 /*return*/, /* not await */ callCommonModel(prompt)];
|
|
6599
|
+
});
|
|
6600
|
+
}); };
|
|
6601
|
+
}
|
|
6602
|
+
if (llmTools.callCompletionModel !== undefined) {
|
|
6603
|
+
proxyTools.callCompletionModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
6604
|
+
return __generator(this, function (_a) {
|
|
6605
|
+
return [2 /*return*/, /* not await */ callCommonModel(prompt)];
|
|
6606
|
+
});
|
|
6607
|
+
}); };
|
|
6608
|
+
}
|
|
6609
|
+
if (llmTools.callEmbeddingModel !== undefined) {
|
|
6610
|
+
proxyTools.callEmbeddingModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
6611
|
+
return __generator(this, function (_a) {
|
|
6612
|
+
return [2 /*return*/, /* not await */ callCommonModel(prompt)];
|
|
6613
|
+
});
|
|
6614
|
+
}); };
|
|
6615
|
+
}
|
|
6616
|
+
// <- Note: [🤖]
|
|
6617
|
+
return proxyTools;
|
|
6618
|
+
}
|
|
6619
|
+
/**
|
|
6620
|
+
* TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
|
|
6621
|
+
* TODO: [🧠] Is there some meaningfull way how to test this util
|
|
6622
|
+
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
6623
|
+
* @@@ write discussion about this and storages
|
|
6624
|
+
* @@@ write how to combine multiple interceptors
|
|
6625
|
+
*/
|
|
6626
|
+
|
|
6627
|
+
/**
|
|
6628
|
+
* @@@
|
|
6629
|
+
*
|
|
6630
|
+
* @public exported from `@promptbook/core`
|
|
6631
|
+
*/
|
|
6632
|
+
function limitTotalUsage(llmTools, options) {
|
|
6633
|
+
var _this = this;
|
|
6634
|
+
if (options === void 0) { options = {}; }
|
|
6635
|
+
var _a = options.maxTotalUsage, maxTotalUsage = _a === void 0 ? ZERO_USAGE : _a, _b = options.storage, storage = _b === void 0 ? new MemoryStorage() : _b;
|
|
6636
|
+
TODO_USE(storage);
|
|
6637
|
+
var proxyTools = countTotalUsage(llmTools);
|
|
6638
|
+
if (maxTotalUsage.price.value !== 0) {
|
|
6639
|
+
throw new NotYetImplementedError('`limitTotalUsage` is not yet implemented for non-zero price');
|
|
6640
|
+
// TODO: "Cannot call `callChatModel` because the total cost limit is reached"
|
|
6641
|
+
}
|
|
6642
|
+
if (proxyTools.callChatModel !== undefined) {
|
|
6643
|
+
proxyTools.callChatModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
6644
|
+
return __generator(this, function (_a) {
|
|
6645
|
+
TODO_USE(prompt);
|
|
6646
|
+
throw new LimitReachedError('Cannot call `callChatModel` because you are not allowed to spend any cost');
|
|
6647
|
+
});
|
|
6648
|
+
}); };
|
|
6649
|
+
}
|
|
6650
|
+
if (proxyTools.callCompletionModel !== undefined) {
|
|
6651
|
+
proxyTools.callCompletionModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
6652
|
+
return __generator(this, function (_a) {
|
|
6653
|
+
TODO_USE(prompt);
|
|
6654
|
+
throw new LimitReachedError('Cannot call `callCompletionModel` because you are not allowed to spend any cost');
|
|
6655
|
+
});
|
|
6656
|
+
}); };
|
|
6657
|
+
}
|
|
6658
|
+
if (proxyTools.callEmbeddingModel !== undefined) {
|
|
6659
|
+
proxyTools.callEmbeddingModel = function (prompt) { return __awaiter(_this, void 0, void 0, function () {
|
|
6660
|
+
return __generator(this, function (_a) {
|
|
6661
|
+
TODO_USE(prompt);
|
|
6662
|
+
throw new LimitReachedError('Cannot call `callEmbeddingModel` because you are not allowed to spend any cost');
|
|
6663
|
+
});
|
|
6664
|
+
}); };
|
|
6665
|
+
}
|
|
6666
|
+
// <- Note: [🤖]
|
|
6667
|
+
return proxyTools;
|
|
6668
|
+
}
|
|
6669
|
+
/**
|
|
6670
|
+
* TODO: Maybe internally use `countTotalUsage`
|
|
6671
|
+
* TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
|
|
6672
|
+
* TODO: [🧠] Is there some meaningfull way how to test this util
|
|
6673
|
+
* TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
|
|
6674
|
+
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
6675
|
+
*/
|
|
6676
|
+
|
|
6677
|
+
/**
|
|
6678
|
+
* This class behaves like LocalStorage but separates keys by prefix
|
|
6679
|
+
*
|
|
6680
|
+
* @public exported from `@promptbook/core`
|
|
6681
|
+
*/
|
|
6682
|
+
var PrefixStorage = /** @class */ (function () {
|
|
6683
|
+
function PrefixStorage(baseStorage, keyPrefix, separator) {
|
|
6684
|
+
if (separator === void 0) { separator = '_'; }
|
|
6685
|
+
this.baseStorage = baseStorage;
|
|
6686
|
+
this.keyPrefix = keyPrefix;
|
|
6687
|
+
this.separator = separator;
|
|
6688
|
+
}
|
|
6689
|
+
/**
|
|
6690
|
+
* Returns the current value associated with the given key, or null if the given key does not exist in the list associated with the object.
|
|
6691
|
+
*/
|
|
6692
|
+
PrefixStorage.prototype.getItem = function (key) {
|
|
6693
|
+
return this.baseStorage.getItem(this.keyPrefix + this.separator + key);
|
|
6694
|
+
};
|
|
6695
|
+
/**
|
|
6696
|
+
* Sets the value of the pair identified by key to value, creating a new key/value pair if none existed for key previously.
|
|
6697
|
+
*/
|
|
6698
|
+
PrefixStorage.prototype.setItem = function (key, value) {
|
|
6699
|
+
return this.baseStorage.setItem(this.keyPrefix + this.separator + key, value);
|
|
6700
|
+
};
|
|
6701
|
+
/**
|
|
6702
|
+
* Removes the key/value pair with the given key from the list associated with the object, if a key/value pair with the given key exists.
|
|
6703
|
+
*/
|
|
6704
|
+
PrefixStorage.prototype.removeItem = function (key) {
|
|
6705
|
+
this.baseStorage.removeItem(this.keyPrefix + this.separator + key);
|
|
6706
|
+
};
|
|
6707
|
+
return PrefixStorage;
|
|
6708
|
+
}());
|
|
6233
6709
|
|
|
6234
6710
|
/**
|
|
6235
6711
|
* Format either small or big number
|
|
@@ -6254,7 +6730,7 @@
|
|
|
6254
6730
|
/**
|
|
6255
6731
|
* Create a markdown table from a 2D array of strings
|
|
6256
6732
|
*
|
|
6257
|
-
* @
|
|
6733
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
6258
6734
|
*/
|
|
6259
6735
|
function createMarkdownTable(table) {
|
|
6260
6736
|
var columnWidths = table.reduce(function (widths, row) {
|
|
@@ -6278,11 +6754,14 @@
|
|
|
6278
6754
|
});
|
|
6279
6755
|
return __spreadArray([header, separator], __read(rows), false).join('\n');
|
|
6280
6756
|
}
|
|
6757
|
+
/**
|
|
6758
|
+
* TODO: [🏛] This can be part of markdown builder
|
|
6759
|
+
*/
|
|
6281
6760
|
|
|
6282
6761
|
/**
|
|
6283
6762
|
* Function createMarkdownChart will draw a chart in markdown from ⬛+🟦 tiles
|
|
6284
6763
|
*
|
|
6285
|
-
* @
|
|
6764
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
6286
6765
|
*/
|
|
6287
6766
|
function createMarkdownChart(options) {
|
|
6288
6767
|
var e_1, _a;
|
|
@@ -6318,10 +6797,25 @@
|
|
|
6318
6797
|
/**
|
|
6319
6798
|
* Function escapeMarkdownBlock will escape markdown block if needed
|
|
6320
6799
|
* It is useful when you want have block in block
|
|
6800
|
+
*
|
|
6801
|
+
* @public exported from `@promptbook/markdown-utils`
|
|
6321
6802
|
*/
|
|
6322
6803
|
function escapeMarkdownBlock(value) {
|
|
6323
6804
|
return value.replace(/```/g, '\\`\\`\\`');
|
|
6324
6805
|
}
|
|
6806
|
+
/**
|
|
6807
|
+
* TODO: [🏛] This can be part of markdown builder
|
|
6808
|
+
*/
|
|
6809
|
+
|
|
6810
|
+
/**
|
|
6811
|
+
* Default options for generating an execution report string
|
|
6812
|
+
*
|
|
6813
|
+
* @public exported from `@promptbook/core`
|
|
6814
|
+
*/
|
|
6815
|
+
var ExecutionReportStringOptionsDefaults = {
|
|
6816
|
+
taxRate: 0,
|
|
6817
|
+
chartsWidth: 36,
|
|
6818
|
+
};
|
|
6325
6819
|
|
|
6326
6820
|
/**
|
|
6327
6821
|
* The thresholds for the relative time in the `moment` NPM package.
|
|
@@ -6367,6 +6861,8 @@
|
|
|
6367
6861
|
|
|
6368
6862
|
/**
|
|
6369
6863
|
* Converts execution report from JSON to string format
|
|
6864
|
+
*
|
|
6865
|
+
* @public exported from `@promptbook/core`
|
|
6370
6866
|
*/
|
|
6371
6867
|
function executionReportJsonToString(executionReportJson, options) {
|
|
6372
6868
|
var e_1, _a;
|
|
@@ -6539,22 +7035,36 @@
|
|
|
6539
7035
|
exports.BlockTypes = BlockTypes;
|
|
6540
7036
|
exports.CallbackInterfaceTools = CallbackInterfaceTools;
|
|
6541
7037
|
exports.CollectionError = CollectionError;
|
|
7038
|
+
exports.EXECUTIONS_CACHE_DIRNAME = EXECUTIONS_CACHE_DIRNAME;
|
|
7039
|
+
exports.EnvironmentMismatchError = EnvironmentMismatchError;
|
|
6542
7040
|
exports.ExecutionReportStringOptionsDefaults = ExecutionReportStringOptionsDefaults;
|
|
6543
|
-
exports.
|
|
7041
|
+
exports.LimitReachedError = LimitReachedError;
|
|
7042
|
+
exports.MAX_EXECUTION_ATTEMPTS = MAX_EXECUTION_ATTEMPTS;
|
|
7043
|
+
exports.MAX_FILENAME_LENGTH = MAX_FILENAME_LENGTH;
|
|
7044
|
+
exports.MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH = MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH;
|
|
7045
|
+
exports.MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL = MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL;
|
|
7046
|
+
exports.MAX_PARALLEL_COUNT = MAX_PARALLEL_COUNT;
|
|
7047
|
+
exports.MemoryStorage = MemoryStorage;
|
|
6544
7048
|
exports.NotFoundError = NotFoundError;
|
|
7049
|
+
exports.NotYetImplementedError = NotYetImplementedError;
|
|
7050
|
+
exports.PIPELINE_COLLECTION_BASE_FILENAME = PIPELINE_COLLECTION_BASE_FILENAME;
|
|
6545
7051
|
exports.PROMPTBOOK_VERSION = PROMPTBOOK_VERSION;
|
|
6546
7052
|
exports.ParsingError = ParsingError;
|
|
6547
7053
|
exports.PipelineExecutionError = PipelineExecutionError;
|
|
6548
7054
|
exports.PipelineLogicError = PipelineLogicError;
|
|
7055
|
+
exports.PrefixStorage = PrefixStorage;
|
|
6549
7056
|
exports.RESERVED_PARAMETER_NAMES = RESERVED_PARAMETER_NAMES;
|
|
6550
7057
|
exports.ReferenceError = ReferenceError$1;
|
|
6551
7058
|
exports.SimplePromptInterfaceTools = SimplePromptInterfaceTools;
|
|
6552
7059
|
exports.UnexpectedError = UnexpectedError;
|
|
6553
7060
|
exports.VersionMismatchError = VersionMismatchError;
|
|
7061
|
+
exports.ZERO_USAGE = ZERO_USAGE;
|
|
6554
7062
|
exports.addUsage = addUsage;
|
|
6555
7063
|
exports.assertsExecutionSuccessful = assertsExecutionSuccessful;
|
|
7064
|
+
exports.cacheLlmTools = cacheLlmTools;
|
|
6556
7065
|
exports.checkExpectations = checkExpectations;
|
|
6557
7066
|
exports.collectionToJson = collectionToJson;
|
|
7067
|
+
exports.countTotalUsage = countTotalUsage;
|
|
6558
7068
|
exports.createCollectionFromJson = createCollectionFromJson;
|
|
6559
7069
|
exports.createCollectionFromPromise = createCollectionFromPromise;
|
|
6560
7070
|
exports.createCollectionFromUrl = createCollectionFromUrl;
|
|
@@ -6563,12 +7073,17 @@
|
|
|
6563
7073
|
exports.embeddingVectorToString = embeddingVectorToString;
|
|
6564
7074
|
exports.executionReportJsonToString = executionReportJsonToString;
|
|
6565
7075
|
exports.isPassingExpectations = isPassingExpectations;
|
|
7076
|
+
exports.isPipelinePrepared = isPipelinePrepared;
|
|
6566
7077
|
exports.joinLlmExecutionTools = joinLlmExecutionTools;
|
|
7078
|
+
exports.limitTotalUsage = limitTotalUsage;
|
|
6567
7079
|
exports.pipelineJsonToString = pipelineJsonToString;
|
|
6568
7080
|
exports.pipelineStringToJson = pipelineStringToJson;
|
|
6569
7081
|
exports.pipelineStringToJsonSync = pipelineStringToJsonSync;
|
|
6570
7082
|
exports.prepareKnowledgeFromMarkdown = prepareKnowledgeFromMarkdown;
|
|
7083
|
+
exports.prepareKnowledgePieces = prepareKnowledgePieces;
|
|
7084
|
+
exports.preparePersona = preparePersona;
|
|
6571
7085
|
exports.preparePipeline = preparePipeline;
|
|
7086
|
+
exports.prepareTemplates = prepareTemplates;
|
|
6572
7087
|
exports.prettifyPipelineString = prettifyPipelineString;
|
|
6573
7088
|
exports.stringifyPipelineJson = stringifyPipelineJson;
|
|
6574
7089
|
exports.unpreparePipeline = unpreparePipeline;
|