@promptbook/fake-llm 0.56.0-3
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 +705 -0
- package/esm/index.es.js +843 -0
- package/esm/index.es.js.map +1 -0
- package/esm/typings/_packages/anthropic-claude.index.d.ts +5 -0
- package/esm/typings/_packages/azure-openai.index.d.ts +5 -0
- package/esm/typings/_packages/cli.index.d.ts +10 -0
- package/esm/typings/_packages/core.index.d.ts +41 -0
- package/esm/typings/_packages/execute-javascript.index.d.ts +48 -0
- package/esm/typings/_packages/fake-llm.index.d.ts +7 -0
- package/esm/typings/_packages/langtail.index.d.ts +5 -0
- package/esm/typings/_packages/node.index.d.ts +4 -0
- package/esm/typings/_packages/openai.index.d.ts +6 -0
- package/esm/typings/_packages/remote-client.index.d.ts +6 -0
- package/esm/typings/_packages/remote-server.index.d.ts +5 -0
- package/esm/typings/_packages/types.index.d.ts +28 -0
- package/esm/typings/_packages/utils.index.d.ts +71 -0
- package/esm/typings/config.d.ts +8 -0
- package/esm/typings/conversion/prettify/PrettifyOptions.d.ts +13 -0
- package/esm/typings/conversion/prettify/prettifyPromptbookString.d.ts +10 -0
- package/esm/typings/conversion/prettify/prettifyPromptbookStringCli.d.ts +9 -0
- package/esm/typings/conversion/prettify/renderPromptbookMermaid.d.ts +25 -0
- package/esm/typings/conversion/promptbookJsonToString.d.ts +12 -0
- package/esm/typings/conversion/promptbookStringToJson.d.ts +15 -0
- package/esm/typings/conversion/promptbookStringToJson.test.d.ts +1 -0
- package/esm/typings/conversion/utils/extractParametersFromPromptTemplate.d.ts +13 -0
- package/esm/typings/conversion/utils/extractParametersFromPromptTemplate.test.d.ts +1 -0
- package/esm/typings/conversion/utils/extractVariables.d.ts +13 -0
- package/esm/typings/conversion/utils/extractVariables.test.d.ts +1 -0
- package/esm/typings/conversion/utils/parseCommand.d.ts +11 -0
- package/esm/typings/conversion/utils/parseCommand.test.d.ts +4 -0
- package/esm/typings/conversion/utils/parseNumber.d.ts +15 -0
- package/esm/typings/conversion/utils/parseNumber.test.d.ts +1 -0
- package/esm/typings/conversion/utils/renameParameter.d.ts +25 -0
- package/esm/typings/conversion/utils/renameParameter.test.d.ts +1 -0
- package/esm/typings/conversion/utils/titleToName.d.ts +4 -0
- package/esm/typings/conversion/utils/titleToName.test.d.ts +1 -0
- package/esm/typings/conversion/validation/_importPromptbook.d.ts +13 -0
- package/esm/typings/conversion/validation/promptbookStringToJson-syntaxErrors.test.d.ts +1 -0
- package/esm/typings/conversion/validation/validatePromptbookJson-logicErrors.test.d.ts +1 -0
- package/esm/typings/conversion/validation/validatePromptbookJson.d.ts +27 -0
- package/esm/typings/conversion/validation/validatePromptbookJson.test.d.ts +1 -0
- package/esm/typings/errors/PromptbookExecutionError.d.ts +7 -0
- package/esm/typings/errors/PromptbookLibraryError.d.ts +7 -0
- package/esm/typings/errors/PromptbookLogicError.d.ts +7 -0
- package/esm/typings/errors/PromptbookNotFoundError.d.ts +7 -0
- package/esm/typings/errors/PromptbookReferenceError.d.ts +7 -0
- package/esm/typings/errors/PromptbookSyntaxError.d.ts +7 -0
- package/esm/typings/errors/TemplateError.d.ts +9 -0
- package/esm/typings/errors/UnexpectedError.d.ts +7 -0
- package/esm/typings/errors/_ExpectError.d.ts +10 -0
- package/esm/typings/execution/CommonExecutionToolsOptions.d.ts +9 -0
- package/esm/typings/execution/ExecutionTools.d.ts +32 -0
- package/esm/typings/execution/LlmExecutionTools.d.ts +50 -0
- package/esm/typings/execution/PromptResult.d.ts +103 -0
- package/esm/typings/execution/PromptbookExecutor.d.ts +42 -0
- package/esm/typings/execution/ScriptExecutionTools.d.ts +38 -0
- package/esm/typings/execution/UserInterfaceTools.d.ts +46 -0
- package/esm/typings/execution/addPromptResultUsage.test.d.ts +1 -0
- package/esm/typings/execution/assertsExecutionSuccessful.d.ts +11 -0
- package/esm/typings/execution/createPromptbookExecutor.d.ts +42 -0
- package/esm/typings/execution/plugins/llm-execution-tools/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +43 -0
- package/esm/typings/execution/plugins/llm-execution-tools/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +8 -0
- package/esm/typings/execution/plugins/llm-execution-tools/anthropic-claude/anthropic-claude-models.d.ts +20 -0
- package/esm/typings/execution/plugins/llm-execution-tools/anthropic-claude/playground/playground.d.ts +2 -0
- package/esm/typings/execution/plugins/llm-execution-tools/azure-openai/AzureOpenAiExecutionTools.d.ts +42 -0
- package/esm/typings/execution/plugins/llm-execution-tools/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +35 -0
- package/esm/typings/execution/plugins/llm-execution-tools/azure-openai/playground/playground.d.ts +2 -0
- package/esm/typings/execution/plugins/llm-execution-tools/langtail/LangtailExecutionTools.d.ts +7 -0
- package/esm/typings/execution/plugins/llm-execution-tools/langtail/LangtailExecutionToolsOptions.d.ts +11 -0
- package/esm/typings/execution/plugins/llm-execution-tools/langtail/playground/playground.d.ts +2 -0
- package/esm/typings/execution/plugins/llm-execution-tools/mocked/MockedEchoLlmExecutionTools.d.ts +28 -0
- package/esm/typings/execution/plugins/llm-execution-tools/mocked/MockedFackedLlmExecutionTools.d.ts +25 -0
- package/esm/typings/execution/plugins/llm-execution-tools/mocked/fakeTextToExpectations.d.ts +14 -0
- package/esm/typings/execution/plugins/llm-execution-tools/mocked/fakeTextToExpectations.test.d.ts +1 -0
- package/esm/typings/execution/plugins/llm-execution-tools/mocked/faked-completion.test.d.ts +1 -0
- package/esm/typings/execution/plugins/llm-execution-tools/mocked/joker.test.d.ts +4 -0
- package/esm/typings/execution/plugins/llm-execution-tools/mocked/mocked-chat.test.d.ts +4 -0
- package/esm/typings/execution/plugins/llm-execution-tools/mocked/mocked-completion.test.d.ts +4 -0
- package/esm/typings/execution/plugins/llm-execution-tools/multiple/MultipleLlmExecutionTools.d.ts +37 -0
- package/esm/typings/execution/plugins/llm-execution-tools/multiple/MultipleLlmExecutionToolsOptions.d.ts +24 -0
- package/esm/typings/execution/plugins/llm-execution-tools/multiple/playground/playground.d.ts +2 -0
- package/esm/typings/execution/plugins/llm-execution-tools/openai/OpenAiExecutionTools.d.ts +47 -0
- package/esm/typings/execution/plugins/llm-execution-tools/openai/OpenAiExecutionToolsOptions.d.ts +18 -0
- package/esm/typings/execution/plugins/llm-execution-tools/openai/computeOpenaiUsage.d.ts +12 -0
- package/esm/typings/execution/plugins/llm-execution-tools/openai/computeUsage.d.ts +16 -0
- package/esm/typings/execution/plugins/llm-execution-tools/openai/computeUsage.test.d.ts +1 -0
- package/esm/typings/execution/plugins/llm-execution-tools/openai/openai-models.d.ts +26 -0
- package/esm/typings/execution/plugins/llm-execution-tools/openai/playground/playground.d.ts +2 -0
- package/esm/typings/execution/plugins/llm-execution-tools/remote/RemoteLlmExecutionTools.d.ts +42 -0
- package/esm/typings/execution/plugins/llm-execution-tools/remote/RemoteLlmExecutionToolsOptions.d.ts +24 -0
- package/esm/typings/execution/plugins/llm-execution-tools/remote/interfaces/Promptbook_Server_Error.d.ts +11 -0
- package/esm/typings/execution/plugins/llm-execution-tools/remote/interfaces/Promptbook_Server_Progress.d.ts +12 -0
- package/esm/typings/execution/plugins/llm-execution-tools/remote/interfaces/Promptbook_Server_Request.d.ts +17 -0
- package/esm/typings/execution/plugins/llm-execution-tools/remote/interfaces/Promptbook_Server_Response.d.ts +12 -0
- package/esm/typings/execution/plugins/llm-execution-tools/remote/interfaces/RemoteServerOptions.d.ts +28 -0
- package/esm/typings/execution/plugins/llm-execution-tools/remote/startRemoteServer.d.ts +18 -0
- package/esm/typings/execution/plugins/script-execution-tools/custom-function-async.test.ts.test.d.ts +1 -0
- package/esm/typings/execution/plugins/script-execution-tools/custom-function-missing.test.d.ts +1 -0
- package/esm/typings/execution/plugins/script-execution-tools/custom-function-with-dependencies.test.d.ts +1 -0
- package/esm/typings/execution/plugins/script-execution-tools/custom-function.test.d.ts +1 -0
- package/esm/typings/execution/plugins/script-execution-tools/javascript/JavascriptEvalExecutionTools.d.ts +20 -0
- package/esm/typings/execution/plugins/script-execution-tools/javascript/JavascriptEvalExecutionTools.test.d.ts +4 -0
- package/esm/typings/execution/plugins/script-execution-tools/javascript/JavascriptExecutionTools.d.ts +7 -0
- package/esm/typings/execution/plugins/script-execution-tools/javascript/JavascriptExecutionToolsOptions.d.ts +26 -0
- package/esm/typings/execution/plugins/script-execution-tools/javascript/utils/preserve.d.ts +11 -0
- package/esm/typings/execution/plugins/script-execution-tools/javascript/utils/unknownToString.d.ts +7 -0
- package/esm/typings/execution/plugins/script-execution-tools/postprocessing.test.d.ts +1 -0
- package/esm/typings/execution/plugins/script-execution-tools/python/PythonExecutionTools.d.ts +16 -0
- package/esm/typings/execution/plugins/script-execution-tools/script-execution-errors.test.d.ts +1 -0
- package/esm/typings/execution/plugins/script-execution-tools/script-execution-tools.test.d.ts +1 -0
- package/esm/typings/execution/plugins/script-execution-tools/typescript/TypescriptExecutionTools.d.ts +16 -0
- package/esm/typings/execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceTools.d.ts +15 -0
- package/esm/typings/execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceToolsOptions.d.ts +12 -0
- package/esm/typings/execution/plugins/user-interface-execution-tools/simple-prompt/SimplePromptInterfaceTools.d.ts +17 -0
- package/esm/typings/execution/plugins/user-interface-execution-tools/user-interface-execution-tools.test.d.ts +1 -0
- package/esm/typings/execution/translation/automatic-translate/automatic-translators/AutomaticTranslator.d.ts +4 -0
- package/esm/typings/execution/translation/automatic-translate/automatic-translators/DebugAutomaticTranslator.d.ts +9 -0
- package/esm/typings/execution/translation/automatic-translate/automatic-translators/FakeAutomaticTranslator.d.ts +5 -0
- package/esm/typings/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +11 -0
- package/esm/typings/execution/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +4 -0
- package/esm/typings/execution/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.d.ts +7 -0
- package/esm/typings/execution/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.test.d.ts +1 -0
- package/esm/typings/execution/translation/automatic-translate/translateMessages.d.ts +5 -0
- package/esm/typings/execution/utils/addUsage.d.ts +7 -0
- package/esm/typings/execution/utils/addUsage.test.d.ts +1 -0
- package/esm/typings/execution/utils/checkExpectations.d.ts +25 -0
- package/esm/typings/execution/utils/checkExpectations.test.d.ts +1 -0
- package/esm/typings/execution/utils/computeUsageCounts.d.ts +10 -0
- package/esm/typings/execution/utils/forEachAsync.d.ts +18 -0
- package/esm/typings/execution/utils/replaceParameters.d.ts +13 -0
- package/esm/typings/execution/utils/replaceParameters.test.d.ts +1 -0
- package/esm/typings/execution/utils/uncertainNumber.d.ts +9 -0
- package/esm/typings/execution/utils/usageToWorktime.d.ts +10 -0
- package/esm/typings/execution/utils/usageToWorktime.test.d.ts +1 -0
- package/esm/typings/library/PromptbookLibrary.d.ts +25 -0
- package/esm/typings/library/SimplePromptbookLibrary.d.ts +36 -0
- package/esm/typings/library/constructors/createPromptbookLibraryFromDirectory.d.ts +43 -0
- package/esm/typings/library/constructors/createPromptbookLibraryFromDirectory.test.d.ts +1 -0
- package/esm/typings/library/constructors/createPromptbookLibraryFromPromise.d.ts +23 -0
- package/esm/typings/library/constructors/createPromptbookLibraryFromPromise.test.d.ts +1 -0
- package/esm/typings/library/constructors/createPromptbookLibraryFromSources.d.ts +13 -0
- package/esm/typings/library/constructors/createPromptbookLibraryFromSources.test.d.ts +1 -0
- package/esm/typings/library/constructors/createPromptbookLibraryFromUrl.d.ts +26 -0
- package/esm/typings/library/constructors/createPromptbookSublibrary.d.ts +12 -0
- package/esm/typings/library/constructors/justTestFsImport.d.ts +7 -0
- package/esm/typings/types/Command.d.ts +101 -0
- package/esm/typings/types/ExecutionTypes.d.ts +13 -0
- package/esm/typings/types/ModelRequirements.d.ts +43 -0
- package/esm/typings/types/Parameters.d.ts +14 -0
- package/esm/typings/types/Prompt.d.ts +57 -0
- package/esm/typings/types/PromptbookJson/PromptTemplateJson.d.ts +145 -0
- package/esm/typings/types/PromptbookJson/PromptTemplateParameterJson.d.ts +26 -0
- package/esm/typings/types/PromptbookJson/PromptbookJson.d.ts +53 -0
- package/esm/typings/types/PromptbookString.d.ts +12 -0
- package/esm/typings/types/ScriptLanguage.d.ts +9 -0
- package/esm/typings/types/TaskProgress.d.ts +43 -0
- package/esm/typings/types/execution-report/ExecutionReportJson.d.ts +58 -0
- package/esm/typings/types/execution-report/ExecutionReportString.d.ts +16 -0
- package/esm/typings/types/execution-report/ExecutionReportStringOptions.d.ts +21 -0
- package/esm/typings/types/execution-report/config.d.ts +8 -0
- package/esm/typings/types/execution-report/countWorkingDuration.d.ts +7 -0
- package/esm/typings/types/execution-report/countWorkingDuration.test.d.ts +1 -0
- package/esm/typings/types/execution-report/executionReportJsonToString.d.ts +11 -0
- package/esm/typings/types/execution-report/executionReportJsonToString.test.d.ts +1 -0
- package/esm/typings/types/typeAliasEmoji.d.ts +9 -0
- package/esm/typings/types/typeAliases.d.ts +430 -0
- package/esm/typings/utils/FromtoItems.d.ts +19 -0
- package/esm/typings/utils/emojis.d.ts +22 -0
- package/esm/typings/utils/expectation-counters/countCharacters.d.ts +5 -0
- package/esm/typings/utils/expectation-counters/countCharacters.test.d.ts +1 -0
- package/esm/typings/utils/expectation-counters/countLines.d.ts +5 -0
- package/esm/typings/utils/expectation-counters/countLines.test.d.ts +1 -0
- package/esm/typings/utils/expectation-counters/countPages.d.ts +5 -0
- package/esm/typings/utils/expectation-counters/countPages.test.d.ts +1 -0
- package/esm/typings/utils/expectation-counters/countParagraphs.d.ts +5 -0
- package/esm/typings/utils/expectation-counters/countParagraphs.test.d.ts +1 -0
- package/esm/typings/utils/expectation-counters/countSentences.d.ts +9 -0
- package/esm/typings/utils/expectation-counters/countSentences.test.d.ts +1 -0
- package/esm/typings/utils/expectation-counters/countWords.d.ts +5 -0
- package/esm/typings/utils/expectation-counters/countWords.test.d.ts +1 -0
- package/esm/typings/utils/expectation-counters/index.d.ts +6 -0
- package/esm/typings/utils/extractParameters.d.ts +9 -0
- package/esm/typings/utils/extractParameters.test.d.ts +1 -0
- package/esm/typings/utils/formatNumber.d.ts +6 -0
- package/esm/typings/utils/formatNumber.test.d.ts +1 -0
- package/esm/typings/utils/getCurrentIsoDate.d.ts +7 -0
- package/esm/typings/utils/isRunningInWhatever.d.ts +12 -0
- package/esm/typings/utils/isValidJsonString.d.ts +4 -0
- package/esm/typings/utils/isValidJsonString.test.d.ts +1 -0
- package/esm/typings/utils/just.d.ts +10 -0
- package/esm/typings/utils/markdown/addAutoGeneratedSection.d.ts +11 -0
- package/esm/typings/utils/markdown/addAutoGeneratedSection.test.d.ts +1 -0
- package/esm/typings/utils/markdown/createMarkdownChart.d.ts +41 -0
- package/esm/typings/utils/markdown/createMarkdownChart.test.d.ts +1 -0
- package/esm/typings/utils/markdown/createMarkdownTable.d.ts +8 -0
- package/esm/typings/utils/markdown/createMarkdownTable.test.d.ts +1 -0
- package/esm/typings/utils/markdown/escapeMarkdownBlock.d.ts +6 -0
- package/esm/typings/utils/markdown/escapeMarkdownBlock.test.d.ts +1 -0
- package/esm/typings/utils/markdown/extractAllBlocksFromMarkdown.d.ts +27 -0
- package/esm/typings/utils/markdown/extractAllBlocksFromMarkdown.test.d.ts +1 -0
- package/esm/typings/utils/markdown/extractAllListItemsFromMarkdown.d.ts +14 -0
- package/esm/typings/utils/markdown/extractAllListItemsFromMarkdown.test.d.ts +1 -0
- package/esm/typings/utils/markdown/extractOneBlockFromMarkdown.d.ts +19 -0
- package/esm/typings/utils/markdown/extractOneBlockFromMarkdown.test.d.ts +1 -0
- package/esm/typings/utils/markdown/prettifyMarkdown.d.ts +8 -0
- package/esm/typings/utils/markdown/prettifyMarkdown.test.d.ts +1 -0
- package/esm/typings/utils/markdown/removeContentComments.d.ts +9 -0
- package/esm/typings/utils/markdown/removeContentComments.test.d.ts +1 -0
- package/esm/typings/utils/markdown/removeMarkdownFormatting.d.ts +8 -0
- package/esm/typings/utils/markdown/removeMarkdownFormatting.test.d.ts +1 -0
- package/esm/typings/utils/markdown-json/MarkdownStructure.d.ts +25 -0
- package/esm/typings/utils/markdown-json/countMarkdownStructureDeepness.d.ts +7 -0
- package/esm/typings/utils/markdown-json/countMarkdownStructureDeepness.test.d.ts +1 -0
- package/esm/typings/utils/markdown-json/markdownToMarkdownStructure.d.ts +13 -0
- package/esm/typings/utils/markdown-json/markdownToMarkdownStructure.test.d.ts +1 -0
- package/esm/typings/utils/normalization/DIACRITIC_VARIANTS_LETTERS.d.ts +10 -0
- package/esm/typings/utils/normalization/IKeywords.d.ts +18 -0
- package/esm/typings/utils/normalization/capitalize.d.ts +5 -0
- package/esm/typings/utils/normalization/capitalize.test.d.ts +1 -0
- package/esm/typings/utils/normalization/decapitalize.d.ts +5 -0
- package/esm/typings/utils/normalization/decapitalize.test.d.ts +1 -0
- package/esm/typings/utils/normalization/isValidKeyword.d.ts +8 -0
- package/esm/typings/utils/normalization/isValidKeyword.test.d.ts +1 -0
- package/esm/typings/utils/normalization/nameToUriPart.d.ts +1 -0
- package/esm/typings/utils/normalization/nameToUriPart.test.d.ts +1 -0
- package/esm/typings/utils/normalization/nameToUriParts.d.ts +1 -0
- package/esm/typings/utils/normalization/nameToUriParts.test.d.ts +1 -0
- package/esm/typings/utils/normalization/normalize-to-kebab-case.d.ts +1 -0
- package/esm/typings/utils/normalization/normalize-to-kebab-case.test.d.ts +1 -0
- package/esm/typings/utils/normalization/normalizeTo_PascalCase.d.ts +1 -0
- package/esm/typings/utils/normalization/normalizeTo_PascalCase.test.d.ts +1 -0
- package/esm/typings/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +4 -0
- package/esm/typings/utils/normalization/normalizeTo_SCREAMING_CASE.test.d.ts +1 -0
- package/esm/typings/utils/normalization/normalizeTo_camelCase.d.ts +4 -0
- package/esm/typings/utils/normalization/normalizeTo_camelCase.test.d.ts +1 -0
- package/esm/typings/utils/normalization/normalizeTo_snake_case.d.ts +1 -0
- package/esm/typings/utils/normalization/normalizeTo_snake_case.test.d.ts +1 -0
- package/esm/typings/utils/normalization/normalizeWhitespaces.d.ts +4 -0
- package/esm/typings/utils/normalization/normalizeWhitespaces.test.d.ts +1 -0
- package/esm/typings/utils/normalization/parseKeywords.d.ts +14 -0
- package/esm/typings/utils/normalization/parseKeywords.test.d.ts +1 -0
- package/esm/typings/utils/normalization/parseKeywordsFromString.d.ts +8 -0
- package/esm/typings/utils/normalization/parseKeywordsFromString.test.d.ts +1 -0
- package/esm/typings/utils/normalization/removeDiacritics.d.ts +4 -0
- package/esm/typings/utils/normalization/removeDiacritics.test.d.ts +1 -0
- package/esm/typings/utils/normalization/searchKeywords.d.ts +5 -0
- package/esm/typings/utils/normalization/searchKeywords.test.d.ts +1 -0
- package/esm/typings/utils/postprocessing/extractBlock.d.ts +12 -0
- package/esm/typings/utils/removeEmojis.d.ts +7 -0
- package/esm/typings/utils/removeEmojis.test.d.ts +1 -0
- package/esm/typings/utils/removeQuotes.d.ts +13 -0
- package/esm/typings/utils/removeQuotes.test.d.ts +1 -0
- package/esm/typings/utils/sets/difference.d.ts +4 -0
- package/esm/typings/utils/sets/difference.test.d.ts +1 -0
- package/esm/typings/utils/sets/intersection.d.ts +4 -0
- package/esm/typings/utils/sets/intersection.test.d.ts +1 -0
- package/esm/typings/utils/sets/union.d.ts +4 -0
- package/esm/typings/utils/sets/union.test.d.ts +1 -0
- package/esm/typings/utils/trimCodeBlock.d.ts +8 -0
- package/esm/typings/utils/trimCodeBlock.test.d.ts +1 -0
- package/esm/typings/utils/trimEndOfCodeBlock.d.ts +7 -0
- package/esm/typings/utils/trimEndOfCodeBlock.test.d.ts +1 -0
- package/esm/typings/utils/unwrapResult.d.ts +36 -0
- package/esm/typings/utils/unwrapResult.test.d.ts +1 -0
- package/esm/typings/utils/validators/url/isValidUrl.d.ts +7 -0
- package/esm/typings/utils/validators/url/isValidUrl.test.d.ts +1 -0
- package/esm/typings/version.d.ts +5 -0
- package/package.json +56 -0
- package/umd/index.umd.js +852 -0
- package/umd/index.umd.js.map +1 -0
- package/umd/typings/_packages/anthropic-claude.index.d.ts +5 -0
- package/umd/typings/_packages/azure-openai.index.d.ts +5 -0
- package/umd/typings/_packages/cli.index.d.ts +10 -0
- package/umd/typings/_packages/core.index.d.ts +41 -0
- package/umd/typings/_packages/execute-javascript.index.d.ts +48 -0
- package/umd/typings/_packages/fake-llm.index.d.ts +7 -0
- package/umd/typings/_packages/langtail.index.d.ts +5 -0
- package/umd/typings/_packages/node.index.d.ts +4 -0
- package/umd/typings/_packages/openai.index.d.ts +6 -0
- package/umd/typings/_packages/remote-client.index.d.ts +6 -0
- package/umd/typings/_packages/remote-server.index.d.ts +5 -0
- package/umd/typings/_packages/types.index.d.ts +28 -0
- package/umd/typings/_packages/utils.index.d.ts +71 -0
- package/umd/typings/config.d.ts +8 -0
- package/umd/typings/conversion/prettify/PrettifyOptions.d.ts +13 -0
- package/umd/typings/conversion/prettify/prettifyPromptbookString.d.ts +10 -0
- package/umd/typings/conversion/prettify/prettifyPromptbookStringCli.d.ts +9 -0
- package/umd/typings/conversion/prettify/renderPromptbookMermaid.d.ts +25 -0
- package/umd/typings/conversion/promptbookJsonToString.d.ts +12 -0
- package/umd/typings/conversion/promptbookStringToJson.d.ts +15 -0
- package/umd/typings/conversion/promptbookStringToJson.test.d.ts +1 -0
- package/umd/typings/conversion/utils/extractParametersFromPromptTemplate.d.ts +13 -0
- package/umd/typings/conversion/utils/extractParametersFromPromptTemplate.test.d.ts +1 -0
- package/umd/typings/conversion/utils/extractVariables.d.ts +13 -0
- package/umd/typings/conversion/utils/extractVariables.test.d.ts +1 -0
- package/umd/typings/conversion/utils/parseCommand.d.ts +11 -0
- package/umd/typings/conversion/utils/parseCommand.test.d.ts +4 -0
- package/umd/typings/conversion/utils/parseNumber.d.ts +15 -0
- package/umd/typings/conversion/utils/parseNumber.test.d.ts +1 -0
- package/umd/typings/conversion/utils/renameParameter.d.ts +25 -0
- package/umd/typings/conversion/utils/renameParameter.test.d.ts +1 -0
- package/umd/typings/conversion/utils/titleToName.d.ts +4 -0
- package/umd/typings/conversion/utils/titleToName.test.d.ts +1 -0
- package/umd/typings/conversion/validation/_importPromptbook.d.ts +13 -0
- package/umd/typings/conversion/validation/promptbookStringToJson-syntaxErrors.test.d.ts +1 -0
- package/umd/typings/conversion/validation/validatePromptbookJson-logicErrors.test.d.ts +1 -0
- package/umd/typings/conversion/validation/validatePromptbookJson.d.ts +27 -0
- package/umd/typings/conversion/validation/validatePromptbookJson.test.d.ts +1 -0
- package/umd/typings/errors/PromptbookExecutionError.d.ts +7 -0
- package/umd/typings/errors/PromptbookLibraryError.d.ts +7 -0
- package/umd/typings/errors/PromptbookLogicError.d.ts +7 -0
- package/umd/typings/errors/PromptbookNotFoundError.d.ts +7 -0
- package/umd/typings/errors/PromptbookReferenceError.d.ts +7 -0
- package/umd/typings/errors/PromptbookSyntaxError.d.ts +7 -0
- package/umd/typings/errors/TemplateError.d.ts +9 -0
- package/umd/typings/errors/UnexpectedError.d.ts +7 -0
- package/umd/typings/errors/_ExpectError.d.ts +10 -0
- package/umd/typings/execution/CommonExecutionToolsOptions.d.ts +9 -0
- package/umd/typings/execution/ExecutionTools.d.ts +32 -0
- package/umd/typings/execution/LlmExecutionTools.d.ts +50 -0
- package/umd/typings/execution/PromptResult.d.ts +103 -0
- package/umd/typings/execution/PromptbookExecutor.d.ts +42 -0
- package/umd/typings/execution/ScriptExecutionTools.d.ts +38 -0
- package/umd/typings/execution/UserInterfaceTools.d.ts +46 -0
- package/umd/typings/execution/addPromptResultUsage.test.d.ts +1 -0
- package/umd/typings/execution/assertsExecutionSuccessful.d.ts +11 -0
- package/umd/typings/execution/createPromptbookExecutor.d.ts +42 -0
- package/umd/typings/execution/plugins/llm-execution-tools/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +43 -0
- package/umd/typings/execution/plugins/llm-execution-tools/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +8 -0
- package/umd/typings/execution/plugins/llm-execution-tools/anthropic-claude/anthropic-claude-models.d.ts +20 -0
- package/umd/typings/execution/plugins/llm-execution-tools/anthropic-claude/playground/playground.d.ts +2 -0
- package/umd/typings/execution/plugins/llm-execution-tools/azure-openai/AzureOpenAiExecutionTools.d.ts +42 -0
- package/umd/typings/execution/plugins/llm-execution-tools/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +35 -0
- package/umd/typings/execution/plugins/llm-execution-tools/azure-openai/playground/playground.d.ts +2 -0
- package/umd/typings/execution/plugins/llm-execution-tools/langtail/LangtailExecutionTools.d.ts +7 -0
- package/umd/typings/execution/plugins/llm-execution-tools/langtail/LangtailExecutionToolsOptions.d.ts +11 -0
- package/umd/typings/execution/plugins/llm-execution-tools/langtail/playground/playground.d.ts +2 -0
- package/umd/typings/execution/plugins/llm-execution-tools/mocked/MockedEchoLlmExecutionTools.d.ts +28 -0
- package/umd/typings/execution/plugins/llm-execution-tools/mocked/MockedFackedLlmExecutionTools.d.ts +25 -0
- package/umd/typings/execution/plugins/llm-execution-tools/mocked/fakeTextToExpectations.d.ts +14 -0
- package/umd/typings/execution/plugins/llm-execution-tools/mocked/fakeTextToExpectations.test.d.ts +1 -0
- package/umd/typings/execution/plugins/llm-execution-tools/mocked/faked-completion.test.d.ts +1 -0
- package/umd/typings/execution/plugins/llm-execution-tools/mocked/joker.test.d.ts +4 -0
- package/umd/typings/execution/plugins/llm-execution-tools/mocked/mocked-chat.test.d.ts +4 -0
- package/umd/typings/execution/plugins/llm-execution-tools/mocked/mocked-completion.test.d.ts +4 -0
- package/umd/typings/execution/plugins/llm-execution-tools/multiple/MultipleLlmExecutionTools.d.ts +37 -0
- package/umd/typings/execution/plugins/llm-execution-tools/multiple/MultipleLlmExecutionToolsOptions.d.ts +24 -0
- package/umd/typings/execution/plugins/llm-execution-tools/multiple/playground/playground.d.ts +2 -0
- package/umd/typings/execution/plugins/llm-execution-tools/openai/OpenAiExecutionTools.d.ts +47 -0
- package/umd/typings/execution/plugins/llm-execution-tools/openai/OpenAiExecutionToolsOptions.d.ts +18 -0
- package/umd/typings/execution/plugins/llm-execution-tools/openai/computeOpenaiUsage.d.ts +12 -0
- package/umd/typings/execution/plugins/llm-execution-tools/openai/computeUsage.d.ts +16 -0
- package/umd/typings/execution/plugins/llm-execution-tools/openai/computeUsage.test.d.ts +1 -0
- package/umd/typings/execution/plugins/llm-execution-tools/openai/openai-models.d.ts +26 -0
- package/umd/typings/execution/plugins/llm-execution-tools/openai/playground/playground.d.ts +2 -0
- package/umd/typings/execution/plugins/llm-execution-tools/remote/RemoteLlmExecutionTools.d.ts +42 -0
- package/umd/typings/execution/plugins/llm-execution-tools/remote/RemoteLlmExecutionToolsOptions.d.ts +24 -0
- package/umd/typings/execution/plugins/llm-execution-tools/remote/interfaces/Promptbook_Server_Error.d.ts +11 -0
- package/umd/typings/execution/plugins/llm-execution-tools/remote/interfaces/Promptbook_Server_Progress.d.ts +12 -0
- package/umd/typings/execution/plugins/llm-execution-tools/remote/interfaces/Promptbook_Server_Request.d.ts +17 -0
- package/umd/typings/execution/plugins/llm-execution-tools/remote/interfaces/Promptbook_Server_Response.d.ts +12 -0
- package/umd/typings/execution/plugins/llm-execution-tools/remote/interfaces/RemoteServerOptions.d.ts +28 -0
- package/umd/typings/execution/plugins/llm-execution-tools/remote/startRemoteServer.d.ts +18 -0
- package/umd/typings/execution/plugins/script-execution-tools/custom-function-async.test.ts.test.d.ts +1 -0
- package/umd/typings/execution/plugins/script-execution-tools/custom-function-missing.test.d.ts +1 -0
- package/umd/typings/execution/plugins/script-execution-tools/custom-function-with-dependencies.test.d.ts +1 -0
- package/umd/typings/execution/plugins/script-execution-tools/custom-function.test.d.ts +1 -0
- package/umd/typings/execution/plugins/script-execution-tools/javascript/JavascriptEvalExecutionTools.d.ts +20 -0
- package/umd/typings/execution/plugins/script-execution-tools/javascript/JavascriptEvalExecutionTools.test.d.ts +4 -0
- package/umd/typings/execution/plugins/script-execution-tools/javascript/JavascriptExecutionTools.d.ts +7 -0
- package/umd/typings/execution/plugins/script-execution-tools/javascript/JavascriptExecutionToolsOptions.d.ts +26 -0
- package/umd/typings/execution/plugins/script-execution-tools/javascript/utils/preserve.d.ts +11 -0
- package/umd/typings/execution/plugins/script-execution-tools/javascript/utils/unknownToString.d.ts +7 -0
- package/umd/typings/execution/plugins/script-execution-tools/postprocessing.test.d.ts +1 -0
- package/umd/typings/execution/plugins/script-execution-tools/python/PythonExecutionTools.d.ts +16 -0
- package/umd/typings/execution/plugins/script-execution-tools/script-execution-errors.test.d.ts +1 -0
- package/umd/typings/execution/plugins/script-execution-tools/script-execution-tools.test.d.ts +1 -0
- package/umd/typings/execution/plugins/script-execution-tools/typescript/TypescriptExecutionTools.d.ts +16 -0
- package/umd/typings/execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceTools.d.ts +15 -0
- package/umd/typings/execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceToolsOptions.d.ts +12 -0
- package/umd/typings/execution/plugins/user-interface-execution-tools/simple-prompt/SimplePromptInterfaceTools.d.ts +17 -0
- package/umd/typings/execution/plugins/user-interface-execution-tools/user-interface-execution-tools.test.d.ts +1 -0
- package/umd/typings/execution/translation/automatic-translate/automatic-translators/AutomaticTranslator.d.ts +4 -0
- package/umd/typings/execution/translation/automatic-translate/automatic-translators/DebugAutomaticTranslator.d.ts +9 -0
- package/umd/typings/execution/translation/automatic-translate/automatic-translators/FakeAutomaticTranslator.d.ts +5 -0
- package/umd/typings/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +11 -0
- package/umd/typings/execution/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +4 -0
- package/umd/typings/execution/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.d.ts +7 -0
- package/umd/typings/execution/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.test.d.ts +1 -0
- package/umd/typings/execution/translation/automatic-translate/translateMessages.d.ts +5 -0
- package/umd/typings/execution/utils/addUsage.d.ts +7 -0
- package/umd/typings/execution/utils/addUsage.test.d.ts +1 -0
- package/umd/typings/execution/utils/checkExpectations.d.ts +25 -0
- package/umd/typings/execution/utils/checkExpectations.test.d.ts +1 -0
- package/umd/typings/execution/utils/computeUsageCounts.d.ts +10 -0
- package/umd/typings/execution/utils/forEachAsync.d.ts +18 -0
- package/umd/typings/execution/utils/replaceParameters.d.ts +13 -0
- package/umd/typings/execution/utils/replaceParameters.test.d.ts +1 -0
- package/umd/typings/execution/utils/uncertainNumber.d.ts +9 -0
- package/umd/typings/execution/utils/usageToWorktime.d.ts +10 -0
- package/umd/typings/execution/utils/usageToWorktime.test.d.ts +1 -0
- package/umd/typings/library/PromptbookLibrary.d.ts +25 -0
- package/umd/typings/library/SimplePromptbookLibrary.d.ts +36 -0
- package/umd/typings/library/constructors/createPromptbookLibraryFromDirectory.d.ts +43 -0
- package/umd/typings/library/constructors/createPromptbookLibraryFromDirectory.test.d.ts +1 -0
- package/umd/typings/library/constructors/createPromptbookLibraryFromPromise.d.ts +23 -0
- package/umd/typings/library/constructors/createPromptbookLibraryFromPromise.test.d.ts +1 -0
- package/umd/typings/library/constructors/createPromptbookLibraryFromSources.d.ts +13 -0
- package/umd/typings/library/constructors/createPromptbookLibraryFromSources.test.d.ts +1 -0
- package/umd/typings/library/constructors/createPromptbookLibraryFromUrl.d.ts +26 -0
- package/umd/typings/library/constructors/createPromptbookSublibrary.d.ts +12 -0
- package/umd/typings/library/constructors/justTestFsImport.d.ts +7 -0
- package/umd/typings/types/Command.d.ts +101 -0
- package/umd/typings/types/ExecutionTypes.d.ts +13 -0
- package/umd/typings/types/ModelRequirements.d.ts +43 -0
- package/umd/typings/types/Parameters.d.ts +14 -0
- package/umd/typings/types/Prompt.d.ts +57 -0
- package/umd/typings/types/PromptbookJson/PromptTemplateJson.d.ts +145 -0
- package/umd/typings/types/PromptbookJson/PromptTemplateParameterJson.d.ts +26 -0
- package/umd/typings/types/PromptbookJson/PromptbookJson.d.ts +53 -0
- package/umd/typings/types/PromptbookString.d.ts +12 -0
- package/umd/typings/types/ScriptLanguage.d.ts +9 -0
- package/umd/typings/types/TaskProgress.d.ts +43 -0
- package/umd/typings/types/execution-report/ExecutionReportJson.d.ts +58 -0
- package/umd/typings/types/execution-report/ExecutionReportString.d.ts +16 -0
- package/umd/typings/types/execution-report/ExecutionReportStringOptions.d.ts +21 -0
- package/umd/typings/types/execution-report/config.d.ts +8 -0
- package/umd/typings/types/execution-report/countWorkingDuration.d.ts +7 -0
- package/umd/typings/types/execution-report/countWorkingDuration.test.d.ts +1 -0
- package/umd/typings/types/execution-report/executionReportJsonToString.d.ts +11 -0
- package/umd/typings/types/execution-report/executionReportJsonToString.test.d.ts +1 -0
- package/umd/typings/types/typeAliasEmoji.d.ts +9 -0
- package/umd/typings/types/typeAliases.d.ts +430 -0
- package/umd/typings/utils/FromtoItems.d.ts +19 -0
- package/umd/typings/utils/emojis.d.ts +22 -0
- package/umd/typings/utils/expectation-counters/countCharacters.d.ts +5 -0
- package/umd/typings/utils/expectation-counters/countCharacters.test.d.ts +1 -0
- package/umd/typings/utils/expectation-counters/countLines.d.ts +5 -0
- package/umd/typings/utils/expectation-counters/countLines.test.d.ts +1 -0
- package/umd/typings/utils/expectation-counters/countPages.d.ts +5 -0
- package/umd/typings/utils/expectation-counters/countPages.test.d.ts +1 -0
- package/umd/typings/utils/expectation-counters/countParagraphs.d.ts +5 -0
- package/umd/typings/utils/expectation-counters/countParagraphs.test.d.ts +1 -0
- package/umd/typings/utils/expectation-counters/countSentences.d.ts +9 -0
- package/umd/typings/utils/expectation-counters/countSentences.test.d.ts +1 -0
- package/umd/typings/utils/expectation-counters/countWords.d.ts +5 -0
- package/umd/typings/utils/expectation-counters/countWords.test.d.ts +1 -0
- package/umd/typings/utils/expectation-counters/index.d.ts +6 -0
- package/umd/typings/utils/extractParameters.d.ts +9 -0
- package/umd/typings/utils/extractParameters.test.d.ts +1 -0
- package/umd/typings/utils/formatNumber.d.ts +6 -0
- package/umd/typings/utils/formatNumber.test.d.ts +1 -0
- package/umd/typings/utils/getCurrentIsoDate.d.ts +7 -0
- package/umd/typings/utils/isRunningInWhatever.d.ts +12 -0
- package/umd/typings/utils/isValidJsonString.d.ts +4 -0
- package/umd/typings/utils/isValidJsonString.test.d.ts +1 -0
- package/umd/typings/utils/just.d.ts +10 -0
- package/umd/typings/utils/markdown/addAutoGeneratedSection.d.ts +11 -0
- package/umd/typings/utils/markdown/addAutoGeneratedSection.test.d.ts +1 -0
- package/umd/typings/utils/markdown/createMarkdownChart.d.ts +41 -0
- package/umd/typings/utils/markdown/createMarkdownChart.test.d.ts +1 -0
- package/umd/typings/utils/markdown/createMarkdownTable.d.ts +8 -0
- package/umd/typings/utils/markdown/createMarkdownTable.test.d.ts +1 -0
- package/umd/typings/utils/markdown/escapeMarkdownBlock.d.ts +6 -0
- package/umd/typings/utils/markdown/escapeMarkdownBlock.test.d.ts +1 -0
- package/umd/typings/utils/markdown/extractAllBlocksFromMarkdown.d.ts +27 -0
- package/umd/typings/utils/markdown/extractAllBlocksFromMarkdown.test.d.ts +1 -0
- package/umd/typings/utils/markdown/extractAllListItemsFromMarkdown.d.ts +14 -0
- package/umd/typings/utils/markdown/extractAllListItemsFromMarkdown.test.d.ts +1 -0
- package/umd/typings/utils/markdown/extractOneBlockFromMarkdown.d.ts +19 -0
- package/umd/typings/utils/markdown/extractOneBlockFromMarkdown.test.d.ts +1 -0
- package/umd/typings/utils/markdown/prettifyMarkdown.d.ts +8 -0
- package/umd/typings/utils/markdown/prettifyMarkdown.test.d.ts +1 -0
- package/umd/typings/utils/markdown/removeContentComments.d.ts +9 -0
- package/umd/typings/utils/markdown/removeContentComments.test.d.ts +1 -0
- package/umd/typings/utils/markdown/removeMarkdownFormatting.d.ts +8 -0
- package/umd/typings/utils/markdown/removeMarkdownFormatting.test.d.ts +1 -0
- package/umd/typings/utils/markdown-json/MarkdownStructure.d.ts +25 -0
- package/umd/typings/utils/markdown-json/countMarkdownStructureDeepness.d.ts +7 -0
- package/umd/typings/utils/markdown-json/countMarkdownStructureDeepness.test.d.ts +1 -0
- package/umd/typings/utils/markdown-json/markdownToMarkdownStructure.d.ts +13 -0
- package/umd/typings/utils/markdown-json/markdownToMarkdownStructure.test.d.ts +1 -0
- package/umd/typings/utils/normalization/DIACRITIC_VARIANTS_LETTERS.d.ts +10 -0
- package/umd/typings/utils/normalization/IKeywords.d.ts +18 -0
- package/umd/typings/utils/normalization/capitalize.d.ts +5 -0
- package/umd/typings/utils/normalization/capitalize.test.d.ts +1 -0
- package/umd/typings/utils/normalization/decapitalize.d.ts +5 -0
- package/umd/typings/utils/normalization/decapitalize.test.d.ts +1 -0
- package/umd/typings/utils/normalization/isValidKeyword.d.ts +8 -0
- package/umd/typings/utils/normalization/isValidKeyword.test.d.ts +1 -0
- package/umd/typings/utils/normalization/nameToUriPart.d.ts +1 -0
- package/umd/typings/utils/normalization/nameToUriPart.test.d.ts +1 -0
- package/umd/typings/utils/normalization/nameToUriParts.d.ts +1 -0
- package/umd/typings/utils/normalization/nameToUriParts.test.d.ts +1 -0
- package/umd/typings/utils/normalization/normalize-to-kebab-case.d.ts +1 -0
- package/umd/typings/utils/normalization/normalize-to-kebab-case.test.d.ts +1 -0
- package/umd/typings/utils/normalization/normalizeTo_PascalCase.d.ts +1 -0
- package/umd/typings/utils/normalization/normalizeTo_PascalCase.test.d.ts +1 -0
- package/umd/typings/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +4 -0
- package/umd/typings/utils/normalization/normalizeTo_SCREAMING_CASE.test.d.ts +1 -0
- package/umd/typings/utils/normalization/normalizeTo_camelCase.d.ts +4 -0
- package/umd/typings/utils/normalization/normalizeTo_camelCase.test.d.ts +1 -0
- package/umd/typings/utils/normalization/normalizeTo_snake_case.d.ts +1 -0
- package/umd/typings/utils/normalization/normalizeTo_snake_case.test.d.ts +1 -0
- package/umd/typings/utils/normalization/normalizeWhitespaces.d.ts +4 -0
- package/umd/typings/utils/normalization/normalizeWhitespaces.test.d.ts +1 -0
- package/umd/typings/utils/normalization/parseKeywords.d.ts +14 -0
- package/umd/typings/utils/normalization/parseKeywords.test.d.ts +1 -0
- package/umd/typings/utils/normalization/parseKeywordsFromString.d.ts +8 -0
- package/umd/typings/utils/normalization/parseKeywordsFromString.test.d.ts +1 -0
- package/umd/typings/utils/normalization/removeDiacritics.d.ts +4 -0
- package/umd/typings/utils/normalization/removeDiacritics.test.d.ts +1 -0
- package/umd/typings/utils/normalization/searchKeywords.d.ts +5 -0
- package/umd/typings/utils/normalization/searchKeywords.test.d.ts +1 -0
- package/umd/typings/utils/postprocessing/extractBlock.d.ts +12 -0
- package/umd/typings/utils/removeEmojis.d.ts +7 -0
- package/umd/typings/utils/removeEmojis.test.d.ts +1 -0
- package/umd/typings/utils/removeQuotes.d.ts +13 -0
- package/umd/typings/utils/removeQuotes.test.d.ts +1 -0
- package/umd/typings/utils/sets/difference.d.ts +4 -0
- package/umd/typings/utils/sets/difference.test.d.ts +1 -0
- package/umd/typings/utils/sets/intersection.d.ts +4 -0
- package/umd/typings/utils/sets/intersection.test.d.ts +1 -0
- package/umd/typings/utils/sets/union.d.ts +4 -0
- package/umd/typings/utils/sets/union.test.d.ts +1 -0
- package/umd/typings/utils/trimCodeBlock.d.ts +8 -0
- package/umd/typings/utils/trimCodeBlock.test.d.ts +1 -0
- package/umd/typings/utils/trimEndOfCodeBlock.d.ts +7 -0
- package/umd/typings/utils/trimEndOfCodeBlock.test.d.ts +1 -0
- package/umd/typings/utils/unwrapResult.d.ts +36 -0
- package/umd/typings/utils/unwrapResult.test.d.ts +1 -0
- package/umd/typings/utils/validators/url/isValidUrl.d.ts +7 -0
- package/umd/typings/utils/validators/url/isValidUrl.test.d.ts +1 -0
- package/umd/typings/version.d.ts +5 -0
package/esm/index.es.js
ADDED
|
@@ -0,0 +1,843 @@
|
|
|
1
|
+
import { spaceTrim } from 'spacetrim';
|
|
2
|
+
import { LoremIpsum } from 'lorem-ipsum';
|
|
3
|
+
|
|
4
|
+
/*! *****************************************************************************
|
|
5
|
+
Copyright (c) Microsoft Corporation.
|
|
6
|
+
|
|
7
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
8
|
+
purpose with or without fee is hereby granted.
|
|
9
|
+
|
|
10
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
11
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
12
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
13
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
14
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
15
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
16
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
17
|
+
***************************************************************************** */
|
|
18
|
+
/* global Reflect, Promise */
|
|
19
|
+
|
|
20
|
+
var extendStatics = function(d, b) {
|
|
21
|
+
extendStatics = Object.setPrototypeOf ||
|
|
22
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
23
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
24
|
+
return extendStatics(d, b);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
function __extends(d, b) {
|
|
28
|
+
if (typeof b !== "function" && b !== null)
|
|
29
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
30
|
+
extendStatics(d, b);
|
|
31
|
+
function __() { this.constructor = d; }
|
|
32
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function __generator(thisArg, body) {
|
|
46
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
+
function step(op) {
|
|
50
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
+
while (_) try {
|
|
52
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
53
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
+
switch (op[0]) {
|
|
55
|
+
case 0: case 1: t = op; break;
|
|
56
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
+
default:
|
|
60
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
+
if (t[2]) _.ops.pop();
|
|
65
|
+
_.trys.pop(); continue;
|
|
66
|
+
}
|
|
67
|
+
op = body.call(thisArg, _);
|
|
68
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function __values(o) {
|
|
74
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
75
|
+
if (m) return m.call(o);
|
|
76
|
+
if (o && typeof o.length === "number") return {
|
|
77
|
+
next: function () {
|
|
78
|
+
if (o && i >= o.length) o = void 0;
|
|
79
|
+
return { value: o && o[i++], done: !o };
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function __read(o, n) {
|
|
86
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
87
|
+
if (!m) return o;
|
|
88
|
+
var i = m.call(o), r, ar = [], e;
|
|
89
|
+
try {
|
|
90
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
91
|
+
}
|
|
92
|
+
catch (error) { e = { error: error }; }
|
|
93
|
+
finally {
|
|
94
|
+
try {
|
|
95
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
96
|
+
}
|
|
97
|
+
finally { if (e) throw e.error; }
|
|
98
|
+
}
|
|
99
|
+
return ar;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Get current date in ISO 8601 format
|
|
104
|
+
*
|
|
105
|
+
* @private This is internal util of the promptbook
|
|
106
|
+
*/
|
|
107
|
+
function getCurrentIsoDate() {
|
|
108
|
+
return new Date().toISOString();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Function `addUsage` will add multiple usages into one
|
|
113
|
+
*
|
|
114
|
+
* Note: If you provide 0 values, it returns void usage
|
|
115
|
+
*/
|
|
116
|
+
function addUsage() {
|
|
117
|
+
var usageItems = [];
|
|
118
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
119
|
+
usageItems[_i] = arguments[_i];
|
|
120
|
+
}
|
|
121
|
+
var initialStructure = {
|
|
122
|
+
price: { value: 0 },
|
|
123
|
+
input: {
|
|
124
|
+
tokensCount: { value: 0 },
|
|
125
|
+
charactersCount: { value: 0 },
|
|
126
|
+
wordsCount: { value: 0 },
|
|
127
|
+
sentencesCount: { value: 0 },
|
|
128
|
+
linesCount: { value: 0 },
|
|
129
|
+
paragraphsCount: { value: 0 },
|
|
130
|
+
pagesCount: { value: 0 },
|
|
131
|
+
},
|
|
132
|
+
output: {
|
|
133
|
+
tokensCount: { value: 0 },
|
|
134
|
+
charactersCount: { value: 0 },
|
|
135
|
+
wordsCount: { value: 0 },
|
|
136
|
+
sentencesCount: { value: 0 },
|
|
137
|
+
linesCount: { value: 0 },
|
|
138
|
+
paragraphsCount: { value: 0 },
|
|
139
|
+
pagesCount: { value: 0 },
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
return usageItems.reduce(function (acc, item) {
|
|
143
|
+
var e_1, _a, e_2, _b;
|
|
144
|
+
var _c;
|
|
145
|
+
acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
|
|
146
|
+
try {
|
|
147
|
+
for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
148
|
+
var key = _e.value;
|
|
149
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
150
|
+
//@ts-ignore
|
|
151
|
+
if (item.input[key]) {
|
|
152
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
153
|
+
//@ts-ignore
|
|
154
|
+
acc.input[key].value += item.input[key].value || 0;
|
|
155
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
156
|
+
//@ts-ignore
|
|
157
|
+
if (item.input[key].isUncertain) {
|
|
158
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
159
|
+
//@ts-ignore
|
|
160
|
+
acc.input[key].isUncertain = true;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
166
|
+
finally {
|
|
167
|
+
try {
|
|
168
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
169
|
+
}
|
|
170
|
+
finally { if (e_1) throw e_1.error; }
|
|
171
|
+
}
|
|
172
|
+
try {
|
|
173
|
+
for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
174
|
+
var key = _g.value;
|
|
175
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
176
|
+
//@ts-ignore
|
|
177
|
+
if (item.output[key]) {
|
|
178
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
179
|
+
//@ts-ignore
|
|
180
|
+
acc.output[key].value += item.output[key].value || 0;
|
|
181
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
182
|
+
//@ts-ignore
|
|
183
|
+
if (item.output[key].isUncertain) {
|
|
184
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
185
|
+
//@ts-ignore
|
|
186
|
+
acc.output[key].isUncertain = true;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
192
|
+
finally {
|
|
193
|
+
try {
|
|
194
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
195
|
+
}
|
|
196
|
+
finally { if (e_2) throw e_2.error; }
|
|
197
|
+
}
|
|
198
|
+
return acc;
|
|
199
|
+
}, initialStructure);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Mocked execution Tools for just echoing the requests for testing purposes.
|
|
204
|
+
*/
|
|
205
|
+
var MockedEchoLlmExecutionTools = /** @class */ (function () {
|
|
206
|
+
function MockedEchoLlmExecutionTools(options) {
|
|
207
|
+
this.options = options;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Mocks chat model
|
|
211
|
+
*/
|
|
212
|
+
MockedEchoLlmExecutionTools.prototype.gptChat = function (prompt) {
|
|
213
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
214
|
+
return __generator(this, function (_a) {
|
|
215
|
+
if (this.options.isVerbose) {
|
|
216
|
+
console.info('๐ฌ Mocked gptChat call');
|
|
217
|
+
}
|
|
218
|
+
return [2 /*return*/, {
|
|
219
|
+
content: spaceTrim(function (block) { return "\n You said:\n ".concat(block(prompt.content), "\n "); }),
|
|
220
|
+
modelName: 'mocked-echo',
|
|
221
|
+
timing: {
|
|
222
|
+
start: getCurrentIsoDate(),
|
|
223
|
+
complete: getCurrentIsoDate(),
|
|
224
|
+
},
|
|
225
|
+
usage: addUsage( /* <- TODO: [๐ง ] Compute here at least words, characters,... etc */),
|
|
226
|
+
rawResponse: {
|
|
227
|
+
note: 'This is mocked echo',
|
|
228
|
+
},
|
|
229
|
+
// <- [๐คนโโ๏ธ]
|
|
230
|
+
}];
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* Mocks completion model
|
|
236
|
+
*/
|
|
237
|
+
MockedEchoLlmExecutionTools.prototype.gptComplete = function (prompt) {
|
|
238
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
239
|
+
return __generator(this, function (_a) {
|
|
240
|
+
if (this.options.isVerbose) {
|
|
241
|
+
console.info('๐ Mocked gptComplete call');
|
|
242
|
+
}
|
|
243
|
+
return [2 /*return*/, {
|
|
244
|
+
content: spaceTrim(function (block) { return "\n ".concat(block(prompt.content), "\n And so on...\n "); }),
|
|
245
|
+
modelName: 'mocked-echo',
|
|
246
|
+
timing: {
|
|
247
|
+
start: getCurrentIsoDate(),
|
|
248
|
+
complete: getCurrentIsoDate(),
|
|
249
|
+
},
|
|
250
|
+
usage: addUsage( /* <- TODO: [๐ง ] Compute here at least words, characters,... etc */),
|
|
251
|
+
rawResponse: {
|
|
252
|
+
note: 'This is mocked echo',
|
|
253
|
+
},
|
|
254
|
+
// <- [๐คนโโ๏ธ]
|
|
255
|
+
}];
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
};
|
|
259
|
+
/**
|
|
260
|
+
* List all available mocked-models that can be used
|
|
261
|
+
*/
|
|
262
|
+
MockedEchoLlmExecutionTools.prototype.listModels = function () {
|
|
263
|
+
return [
|
|
264
|
+
{
|
|
265
|
+
modelTitle: 'Echo chat',
|
|
266
|
+
modelName: 'mocked-echo',
|
|
267
|
+
modelVariant: 'CHAT',
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
modelTitle: 'Echo completion',
|
|
271
|
+
modelName: 'mocked-echo',
|
|
272
|
+
modelVariant: 'COMPLETION',
|
|
273
|
+
},
|
|
274
|
+
];
|
|
275
|
+
};
|
|
276
|
+
return MockedEchoLlmExecutionTools;
|
|
277
|
+
}());
|
|
278
|
+
/**
|
|
279
|
+
* TODO: Allow in spaceTrim: nesting with > ${block(prompt.request)}, same as replace params
|
|
280
|
+
*/
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* The maximum number of iterations for a loops
|
|
284
|
+
*/
|
|
285
|
+
/**
|
|
286
|
+
* The maximum number of iterations for a loops which adds characters one by one
|
|
287
|
+
*/
|
|
288
|
+
var CHARACTER_LOOP_LIMIT = 100000;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* This error occurs when some expectation is not met in the execution of the pipeline
|
|
292
|
+
*
|
|
293
|
+
* @private Always catched and rethrown as `PromptbookExecutionError`
|
|
294
|
+
* Note: This is a kindof subtype of PromptbookExecutionError
|
|
295
|
+
*/
|
|
296
|
+
var ExpectError = /** @class */ (function (_super) {
|
|
297
|
+
__extends(ExpectError, _super);
|
|
298
|
+
function ExpectError(message) {
|
|
299
|
+
var _this = _super.call(this, message) || this;
|
|
300
|
+
_this.name = 'ExpectError';
|
|
301
|
+
Object.setPrototypeOf(_this, ExpectError.prototype);
|
|
302
|
+
return _this;
|
|
303
|
+
}
|
|
304
|
+
return ExpectError;
|
|
305
|
+
}(Error));
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Counts number of characters in the text
|
|
309
|
+
*/
|
|
310
|
+
function countCharacters(text) {
|
|
311
|
+
// Remove null characters
|
|
312
|
+
text = text.replace(/\0/g, '');
|
|
313
|
+
// Replace emojis (and also ZWJ sequence) with hyphens
|
|
314
|
+
text = text.replace(/(\p{Extended_Pictographic})\p{Modifier_Symbol}/gu, '$1');
|
|
315
|
+
text = text.replace(/(\p{Extended_Pictographic})[\u{FE00}-\u{FE0F}]/gu, '$1');
|
|
316
|
+
text = text.replace(/\p{Extended_Pictographic}(\u{200D}\p{Extended_Pictographic})*/gu, '-');
|
|
317
|
+
return text.length;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Counts number of lines in the text
|
|
322
|
+
*/
|
|
323
|
+
function countLines(text) {
|
|
324
|
+
if (text === '') {
|
|
325
|
+
return 0;
|
|
326
|
+
}
|
|
327
|
+
return text.split('\n').length;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Counts number of pages in the text
|
|
332
|
+
*/
|
|
333
|
+
function countPages(text) {
|
|
334
|
+
var sentencesPerPage = 5; // Assuming each page has 5 sentences
|
|
335
|
+
var sentences = text.split(/[.!?]+/).filter(function (sentence) { return sentence.trim() !== ''; });
|
|
336
|
+
var pageCount = Math.ceil(sentences.length / sentencesPerPage);
|
|
337
|
+
return pageCount;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Counts number of paragraphs in the text
|
|
342
|
+
*/
|
|
343
|
+
function countParagraphs(text) {
|
|
344
|
+
return text.split(/\n\s*\n/).filter(function (paragraph) { return paragraph.trim() !== ''; }).length;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Split text into sentences
|
|
349
|
+
*/
|
|
350
|
+
function splitIntoSentences(text) {
|
|
351
|
+
return text.split(/[.!?]+/).filter(function (sentence) { return sentence.trim() !== ''; });
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Counts number of sentences in the text
|
|
355
|
+
*/
|
|
356
|
+
function countSentences(text) {
|
|
357
|
+
return splitIntoSentences(text).length;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
var defaultDiacriticsRemovalMap = [
|
|
361
|
+
{
|
|
362
|
+
base: 'A',
|
|
363
|
+
letters: '\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F',
|
|
364
|
+
},
|
|
365
|
+
{ base: 'AA', letters: '\uA732' },
|
|
366
|
+
{ base: 'AE', letters: '\u00C6\u01FC\u01E2' },
|
|
367
|
+
{ base: 'AO', letters: '\uA734' },
|
|
368
|
+
{ base: 'AU', letters: '\uA736' },
|
|
369
|
+
{ base: 'AV', letters: '\uA738\uA73A' },
|
|
370
|
+
{ base: 'AY', letters: '\uA73C' },
|
|
371
|
+
{
|
|
372
|
+
base: 'B',
|
|
373
|
+
letters: '\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181',
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
base: 'C',
|
|
377
|
+
letters: '\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E',
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
base: 'D',
|
|
381
|
+
letters: '\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779\u00D0',
|
|
382
|
+
},
|
|
383
|
+
{ base: 'DZ', letters: '\u01F1\u01C4' },
|
|
384
|
+
{ base: 'Dz', letters: '\u01F2\u01C5' },
|
|
385
|
+
{
|
|
386
|
+
base: 'E',
|
|
387
|
+
letters: '\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E',
|
|
388
|
+
},
|
|
389
|
+
{ base: 'F', letters: '\u0046\u24BB\uFF26\u1E1E\u0191\uA77B' },
|
|
390
|
+
{
|
|
391
|
+
base: 'G',
|
|
392
|
+
letters: '\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E',
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
base: 'H',
|
|
396
|
+
letters: '\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D',
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
base: 'I',
|
|
400
|
+
letters: '\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197',
|
|
401
|
+
},
|
|
402
|
+
{ base: 'J', letters: '\u004A\u24BF\uFF2A\u0134\u0248' },
|
|
403
|
+
{
|
|
404
|
+
base: 'K',
|
|
405
|
+
letters: '\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2',
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
base: 'L',
|
|
409
|
+
letters: '\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780',
|
|
410
|
+
},
|
|
411
|
+
{ base: 'LJ', letters: '\u01C7' },
|
|
412
|
+
{ base: 'Lj', letters: '\u01C8' },
|
|
413
|
+
{ base: 'M', letters: '\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C' },
|
|
414
|
+
{
|
|
415
|
+
base: 'N',
|
|
416
|
+
letters: '\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4',
|
|
417
|
+
},
|
|
418
|
+
{ base: 'NJ', letters: '\u01CA' },
|
|
419
|
+
{ base: 'Nj', letters: '\u01CB' },
|
|
420
|
+
{
|
|
421
|
+
base: 'O',
|
|
422
|
+
letters: '\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C',
|
|
423
|
+
},
|
|
424
|
+
{ base: 'OI', letters: '\u01A2' },
|
|
425
|
+
{ base: 'OO', letters: '\uA74E' },
|
|
426
|
+
{ base: 'OU', letters: '\u0222' },
|
|
427
|
+
{ base: 'OE', letters: '\u008C\u0152' },
|
|
428
|
+
{ base: 'oe', letters: '\u009C\u0153' },
|
|
429
|
+
{
|
|
430
|
+
base: 'P',
|
|
431
|
+
letters: '\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754',
|
|
432
|
+
},
|
|
433
|
+
{ base: 'Q', letters: '\u0051\u24C6\uFF31\uA756\uA758\u024A' },
|
|
434
|
+
{
|
|
435
|
+
base: 'R',
|
|
436
|
+
letters: '\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782',
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
base: 'S',
|
|
440
|
+
letters: '\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784',
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
base: 'T',
|
|
444
|
+
letters: '\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786',
|
|
445
|
+
},
|
|
446
|
+
{ base: 'TZ', letters: '\uA728' },
|
|
447
|
+
{
|
|
448
|
+
base: 'U',
|
|
449
|
+
letters: '\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244',
|
|
450
|
+
},
|
|
451
|
+
{ base: 'V', letters: '\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245' },
|
|
452
|
+
{ base: 'VY', letters: '\uA760' },
|
|
453
|
+
{
|
|
454
|
+
base: 'W',
|
|
455
|
+
letters: '\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72',
|
|
456
|
+
},
|
|
457
|
+
{ base: 'X', letters: '\u0058\u24CD\uFF38\u1E8A\u1E8C' },
|
|
458
|
+
{
|
|
459
|
+
base: 'Y',
|
|
460
|
+
letters: '\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE',
|
|
461
|
+
},
|
|
462
|
+
{
|
|
463
|
+
base: 'Z',
|
|
464
|
+
letters: '\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762',
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
base: 'a',
|
|
468
|
+
letters: '\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250',
|
|
469
|
+
},
|
|
470
|
+
{ base: 'aa', letters: '\uA733' },
|
|
471
|
+
{ base: 'ae', letters: '\u00E6\u01FD\u01E3' },
|
|
472
|
+
{ base: 'ao', letters: '\uA735' },
|
|
473
|
+
{ base: 'au', letters: '\uA737' },
|
|
474
|
+
{ base: 'av', letters: '\uA739\uA73B' },
|
|
475
|
+
{ base: 'ay', letters: '\uA73D' },
|
|
476
|
+
{
|
|
477
|
+
base: 'b',
|
|
478
|
+
letters: '\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253',
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
base: 'c',
|
|
482
|
+
letters: '\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184',
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
base: 'd',
|
|
486
|
+
letters: '\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A',
|
|
487
|
+
},
|
|
488
|
+
{ base: 'dz', letters: '\u01F3\u01C6' },
|
|
489
|
+
{
|
|
490
|
+
base: 'e',
|
|
491
|
+
letters: '\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD',
|
|
492
|
+
},
|
|
493
|
+
{ base: 'f', letters: '\u0066\u24D5\uFF46\u1E1F\u0192\uA77C' },
|
|
494
|
+
{
|
|
495
|
+
base: 'g',
|
|
496
|
+
letters: '\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F',
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
base: 'h',
|
|
500
|
+
letters: '\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265',
|
|
501
|
+
},
|
|
502
|
+
{ base: 'hv', letters: '\u0195' },
|
|
503
|
+
{
|
|
504
|
+
base: 'i',
|
|
505
|
+
letters: '\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131',
|
|
506
|
+
},
|
|
507
|
+
{ base: 'j', letters: '\u006A\u24D9\uFF4A\u0135\u01F0\u0249' },
|
|
508
|
+
{
|
|
509
|
+
base: 'k',
|
|
510
|
+
letters: '\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3',
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
base: 'l',
|
|
514
|
+
letters: '\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747',
|
|
515
|
+
},
|
|
516
|
+
{ base: 'lj', letters: '\u01C9' },
|
|
517
|
+
{ base: 'm', letters: '\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F' },
|
|
518
|
+
{
|
|
519
|
+
base: 'n',
|
|
520
|
+
letters: '\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5',
|
|
521
|
+
},
|
|
522
|
+
{ base: 'nj', letters: '\u01CC' },
|
|
523
|
+
{
|
|
524
|
+
base: 'o',
|
|
525
|
+
letters: '\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275',
|
|
526
|
+
},
|
|
527
|
+
{ base: 'oi', letters: '\u01A3' },
|
|
528
|
+
{ base: 'ou', letters: '\u0223' },
|
|
529
|
+
{ base: 'oo', letters: '\uA74F' },
|
|
530
|
+
{
|
|
531
|
+
base: 'p',
|
|
532
|
+
letters: '\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755',
|
|
533
|
+
},
|
|
534
|
+
{ base: 'q', letters: '\u0071\u24E0\uFF51\u024B\uA757\uA759' },
|
|
535
|
+
{
|
|
536
|
+
base: 'r',
|
|
537
|
+
letters: '\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783',
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
base: 's',
|
|
541
|
+
letters: '\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B',
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
base: 't',
|
|
545
|
+
letters: '\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787',
|
|
546
|
+
},
|
|
547
|
+
{ base: 'tz', letters: '\uA729' },
|
|
548
|
+
{
|
|
549
|
+
base: 'u',
|
|
550
|
+
letters: '\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289',
|
|
551
|
+
},
|
|
552
|
+
{ base: 'v', letters: '\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C' },
|
|
553
|
+
{ base: 'vy', letters: '\uA761' },
|
|
554
|
+
{
|
|
555
|
+
base: 'w',
|
|
556
|
+
letters: '\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73',
|
|
557
|
+
},
|
|
558
|
+
{ base: 'x', letters: '\u0078\u24E7\uFF58\u1E8B\u1E8D' },
|
|
559
|
+
{
|
|
560
|
+
base: 'y',
|
|
561
|
+
letters: '\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF',
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
base: 'z',
|
|
565
|
+
letters: '\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763',
|
|
566
|
+
},
|
|
567
|
+
];
|
|
568
|
+
/**
|
|
569
|
+
* Map of letters from diacritic variant to diacritless variant
|
|
570
|
+
* Contains lowercase and uppercase separatelly
|
|
571
|
+
*
|
|
572
|
+
* > "รก" => "a"
|
|
573
|
+
* > "ฤ" => "e"
|
|
574
|
+
* > "ฤ" => "A"
|
|
575
|
+
* > ...
|
|
576
|
+
*/
|
|
577
|
+
var DIACRITIC_VARIANTS_LETTERS = {};
|
|
578
|
+
// tslint:disable-next-line: prefer-for-of
|
|
579
|
+
for (var i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
|
|
580
|
+
var letters = defaultDiacriticsRemovalMap[i].letters;
|
|
581
|
+
// tslint:disable-next-line: prefer-for-of
|
|
582
|
+
for (var j = 0; j < letters.length; j++) {
|
|
583
|
+
DIACRITIC_VARIANTS_LETTERS[letters[j]] = defaultDiacriticsRemovalMap[i].base;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
// <- TODO: [๐] Put to maker function to save execution time if not needed
|
|
587
|
+
/*
|
|
588
|
+
@see https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript
|
|
589
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
590
|
+
you may not use this file except in compliance with the License.
|
|
591
|
+
You may obtain a copy of the License at
|
|
592
|
+
|
|
593
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
594
|
+
|
|
595
|
+
Unless required by applicable law or agreed to in writing, software
|
|
596
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
597
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
598
|
+
See the License for the specific language governing permissions and
|
|
599
|
+
limitations under the License.
|
|
600
|
+
*/
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
*
|
|
604
|
+
*/
|
|
605
|
+
function removeDiacritics(input) {
|
|
606
|
+
/*eslint no-control-regex: "off"*/
|
|
607
|
+
return input.replace(/[^\u0000-\u007E]/g, function (a) {
|
|
608
|
+
return DIACRITIC_VARIANTS_LETTERS[a] || a;
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* Counts number of words in the text
|
|
614
|
+
*/
|
|
615
|
+
function countWords(text) {
|
|
616
|
+
text = text.replace(/[\p{Extended_Pictographic}]/gu, 'a');
|
|
617
|
+
text = removeDiacritics(text);
|
|
618
|
+
return text.split(/[^a-zะฐ-ั0-9]+/i).filter(function (word) { return word.length > 0; }).length;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* Index of all counter functions
|
|
623
|
+
*/
|
|
624
|
+
var CountUtils = {
|
|
625
|
+
CHARACTERS: countCharacters,
|
|
626
|
+
WORDS: countWords,
|
|
627
|
+
SENTENCES: countSentences,
|
|
628
|
+
PARAGRAPHS: countParagraphs,
|
|
629
|
+
LINES: countLines,
|
|
630
|
+
PAGES: countPages,
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* Function checkExpectations will check if the expectations on given value are met
|
|
635
|
+
*
|
|
636
|
+
* Note: There are two simmilar functions:
|
|
637
|
+
* - `checkExpectations` which throws an error if the expectations are not met
|
|
638
|
+
* - `isPassingExpectations` which returns a boolean
|
|
639
|
+
*
|
|
640
|
+
* @throws {ExpectError} if the expectations are not met
|
|
641
|
+
* @returns {void} Nothing
|
|
642
|
+
*/
|
|
643
|
+
function checkExpectations(expectations, value) {
|
|
644
|
+
var e_1, _a;
|
|
645
|
+
try {
|
|
646
|
+
for (var _b = __values(Object.entries(expectations)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
647
|
+
var _d = __read(_c.value, 2), unit = _d[0], _e = _d[1], max = _e.max, min = _e.min;
|
|
648
|
+
var amount = CountUtils[unit.toUpperCase()](value);
|
|
649
|
+
if (min && amount < min) {
|
|
650
|
+
throw new ExpectError("Expected at least ".concat(min, " ").concat(unit, " but got ").concat(amount));
|
|
651
|
+
} /* not else */
|
|
652
|
+
if (max && amount > max) {
|
|
653
|
+
throw new ExpectError("Expected at most ".concat(max, " ").concat(unit, " but got ").concat(amount));
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
658
|
+
finally {
|
|
659
|
+
try {
|
|
660
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
661
|
+
}
|
|
662
|
+
finally { if (e_1) throw e_1.error; }
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Function checkExpectations will check if the expectations on given value are met
|
|
667
|
+
*
|
|
668
|
+
* Note: There are two simmilar functions:
|
|
669
|
+
* - `checkExpectations` which throws an error if the expectations are not met
|
|
670
|
+
* - `isPassingExpectations` which returns a boolean
|
|
671
|
+
*
|
|
672
|
+
* @returns {boolean} True if the expectations are met
|
|
673
|
+
*/
|
|
674
|
+
function isPassingExpectations(expectations, value) {
|
|
675
|
+
try {
|
|
676
|
+
checkExpectations(expectations, value);
|
|
677
|
+
return true;
|
|
678
|
+
}
|
|
679
|
+
catch (error) {
|
|
680
|
+
if (!(error instanceof ExpectError)) {
|
|
681
|
+
throw error;
|
|
682
|
+
}
|
|
683
|
+
return false;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* TODO: [๐] Unite object for expecting amount and format
|
|
688
|
+
*/
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* Gets the expectations and creates a fake text that meets the expectations
|
|
692
|
+
*
|
|
693
|
+
* Note: You can provide postprocessing functions to modify the text before checking the expectations
|
|
694
|
+
* The result will be the text BEFORE the postprocessing
|
|
695
|
+
*
|
|
696
|
+
* @private internal util for MockedFackedLlmExecutionTools
|
|
697
|
+
*/
|
|
698
|
+
function $fakeTextToExpectations(expectations, postprocessing) {
|
|
699
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
700
|
+
var lorem, loremText, text, loopLimit, textToCheck, _a, _b, func, e_1_1;
|
|
701
|
+
var e_1, _c;
|
|
702
|
+
return __generator(this, function (_d) {
|
|
703
|
+
switch (_d.label) {
|
|
704
|
+
case 0:
|
|
705
|
+
lorem = new LoremIpsum({
|
|
706
|
+
wordsPerSentence: { min: 5, max: 15 },
|
|
707
|
+
sentencesPerParagraph: { min: 5, max: 15 },
|
|
708
|
+
});
|
|
709
|
+
loremText = '';
|
|
710
|
+
text = '';
|
|
711
|
+
loopLimit = CHARACTER_LOOP_LIMIT;
|
|
712
|
+
_d.label = 1;
|
|
713
|
+
case 1:
|
|
714
|
+
if (!(loopLimit-- > 0)) return [3 /*break*/, 11];
|
|
715
|
+
textToCheck = text;
|
|
716
|
+
_d.label = 2;
|
|
717
|
+
case 2:
|
|
718
|
+
_d.trys.push([2, 7, 8, 9]);
|
|
719
|
+
_a = (e_1 = void 0, __values(postprocessing || [])), _b = _a.next();
|
|
720
|
+
_d.label = 3;
|
|
721
|
+
case 3:
|
|
722
|
+
if (!!_b.done) return [3 /*break*/, 6];
|
|
723
|
+
func = _b.value;
|
|
724
|
+
return [4 /*yield*/, func(textToCheck)];
|
|
725
|
+
case 4:
|
|
726
|
+
textToCheck = _d.sent();
|
|
727
|
+
_d.label = 5;
|
|
728
|
+
case 5:
|
|
729
|
+
_b = _a.next();
|
|
730
|
+
return [3 /*break*/, 3];
|
|
731
|
+
case 6: return [3 /*break*/, 9];
|
|
732
|
+
case 7:
|
|
733
|
+
e_1_1 = _d.sent();
|
|
734
|
+
e_1 = { error: e_1_1 };
|
|
735
|
+
return [3 /*break*/, 9];
|
|
736
|
+
case 8:
|
|
737
|
+
try {
|
|
738
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
739
|
+
}
|
|
740
|
+
finally { if (e_1) throw e_1.error; }
|
|
741
|
+
return [7 /*endfinally*/];
|
|
742
|
+
case 9:
|
|
743
|
+
if (isPassingExpectations(expectations, textToCheck)) {
|
|
744
|
+
return [2 /*return*/, text]; // <- Note: Returning the text because the postprocessing
|
|
745
|
+
}
|
|
746
|
+
if (loremText === '') {
|
|
747
|
+
loremText = lorem.generateParagraphs(1) + '\n\n';
|
|
748
|
+
}
|
|
749
|
+
text += loremText.substring(0, 1);
|
|
750
|
+
loremText = loremText.substring(1);
|
|
751
|
+
_d.label = 10;
|
|
752
|
+
case 10: return [3 /*break*/, 1];
|
|
753
|
+
case 11: throw new Error(spaceTrim(function (block) { return "\n Can not generate fake text to met the expectations\n\n Loop limit reached\n The expectations:\n ".concat(block(JSON.stringify(expectations, null, 4)), "\n\n The draft text:\n ").concat(block(text), "\n\n "); }));
|
|
754
|
+
}
|
|
755
|
+
});
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* TODO: [๐] Unite object for expecting amount and format - use here also a format
|
|
760
|
+
*/
|
|
761
|
+
|
|
762
|
+
/**
|
|
763
|
+
* Mocked execution Tools for just faking expected responses for testing purposes
|
|
764
|
+
*/
|
|
765
|
+
var MockedFackedLlmExecutionTools = /** @class */ (function () {
|
|
766
|
+
function MockedFackedLlmExecutionTools(options) {
|
|
767
|
+
this.options = options;
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* Fakes chat model
|
|
771
|
+
*/
|
|
772
|
+
MockedFackedLlmExecutionTools.prototype.gptChat = function (prompt) {
|
|
773
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
774
|
+
var content, result;
|
|
775
|
+
return __generator(this, function (_a) {
|
|
776
|
+
switch (_a.label) {
|
|
777
|
+
case 0:
|
|
778
|
+
if (this.options.isVerbose) {
|
|
779
|
+
console.info('๐ฌ Mocked faked prompt', prompt);
|
|
780
|
+
}
|
|
781
|
+
return [4 /*yield*/, $fakeTextToExpectations(prompt.expectations || {
|
|
782
|
+
sentences: { min: 1, max: 1 },
|
|
783
|
+
}, prompt.postprocessing)];
|
|
784
|
+
case 1:
|
|
785
|
+
content = _a.sent();
|
|
786
|
+
result = {
|
|
787
|
+
content: content,
|
|
788
|
+
modelName: 'mocked-facked',
|
|
789
|
+
timing: {
|
|
790
|
+
start: getCurrentIsoDate(),
|
|
791
|
+
complete: getCurrentIsoDate(),
|
|
792
|
+
},
|
|
793
|
+
usage: addUsage( /* <- TODO: [๐ง ] Compute here at least words, characters,... etc */),
|
|
794
|
+
rawResponse: {
|
|
795
|
+
note: 'This is mocked echo',
|
|
796
|
+
},
|
|
797
|
+
// <- [๐คนโโ๏ธ]
|
|
798
|
+
};
|
|
799
|
+
if (this.options.isVerbose) {
|
|
800
|
+
console.info('๐ฌ Mocked faked result', result);
|
|
801
|
+
}
|
|
802
|
+
return [2 /*return*/, result];
|
|
803
|
+
}
|
|
804
|
+
});
|
|
805
|
+
});
|
|
806
|
+
};
|
|
807
|
+
/**
|
|
808
|
+
* Fakes completion model
|
|
809
|
+
*/
|
|
810
|
+
MockedFackedLlmExecutionTools.prototype.gptComplete = function (prompt) {
|
|
811
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
812
|
+
return __generator(this, function (_a) {
|
|
813
|
+
return [2 /*return*/, this.gptChat(prompt)];
|
|
814
|
+
});
|
|
815
|
+
});
|
|
816
|
+
};
|
|
817
|
+
/**
|
|
818
|
+
* List all available fake-models that can be used
|
|
819
|
+
*/
|
|
820
|
+
MockedFackedLlmExecutionTools.prototype.listModels = function () {
|
|
821
|
+
return [
|
|
822
|
+
{
|
|
823
|
+
modelTitle: 'Fake chat',
|
|
824
|
+
modelName: 'mocked-echo',
|
|
825
|
+
modelVariant: 'CHAT',
|
|
826
|
+
},
|
|
827
|
+
{
|
|
828
|
+
modelTitle: 'Fake completion',
|
|
829
|
+
modelName: 'mocked-echo',
|
|
830
|
+
modelVariant: 'COMPLETION',
|
|
831
|
+
},
|
|
832
|
+
];
|
|
833
|
+
};
|
|
834
|
+
return MockedFackedLlmExecutionTools;
|
|
835
|
+
}());
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* The version of the Promptbook library
|
|
839
|
+
*/
|
|
840
|
+
var PROMPTBOOK_VERSION = '0.56.0-2';
|
|
841
|
+
|
|
842
|
+
export { MockedEchoLlmExecutionTools, MockedFackedLlmExecutionTools, PROMPTBOOK_VERSION };
|
|
843
|
+
//# sourceMappingURL=index.es.js.map
|