@promptbook/core 0.59.0-8 → 0.59.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/esm/index.es.js +559 -528
- package/esm/index.es.js.map +1 -1
- package/esm/typings/promptbook-library/index.d.ts +25 -0
- package/esm/typings/src/_packages/cli.index.d.ts +10 -0
- package/{umd/typings → esm/typings/src}/_packages/core.index.d.ts +11 -9
- package/esm/typings/src/_packages/node.index.d.ts +4 -0
- package/{umd/typings → esm/typings/src}/_packages/types.index.d.ts +4 -3
- package/esm/typings/src/cli/actions/hello.d.ts +7 -0
- package/esm/typings/src/cli/actions/make.d.ts +7 -0
- package/esm/typings/src/cli/actions/prettify.d.ts +7 -0
- package/esm/typings/{conversion/prettify/prettifyPromptbookStringCli.d.ts → src/cli/promptbookCli.d.ts} +2 -2
- package/esm/typings/{config.d.ts → src/config.d.ts} +4 -0
- package/esm/typings/{conversion → src/conversion}/promptbookStringToJson.d.ts +5 -3
- package/esm/typings/src/conversion/promptbookStringToJsonSync.d.ts +23 -0
- package/{umd/typings/conversion/validation/validatePromptbookJson.d.ts → esm/typings/src/conversion/validation/validatePromptbook.d.ts} +2 -2
- package/esm/typings/src/execution/EmbeddingVector.d.ts +8 -0
- package/esm/typings/{execution → src/execution}/LlmExecutionTools.d.ts +1 -0
- package/esm/typings/{execution → src/execution}/PromptResult.d.ts +11 -0
- package/esm/typings/src/execution/embeddingVectorToString.d.ts +5 -0
- package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +21 -0
- package/esm/typings/{promptbook-library → src/library}/SimplePromptbookLibrary.d.ts +3 -1
- package/esm/typings/{promptbook-library/constructors/createPromptbookLibraryFromDirectory.d.ts → src/library/constructors/createLibraryFromDirectory.d.ts} +2 -2
- package/esm/typings/src/library/constructors/createLibraryFromJson.d.ts +12 -0
- package/esm/typings/{promptbook-library/constructors/createPromptbookLibraryFromPromise.d.ts → src/library/constructors/createLibraryFromPromise.d.ts} +3 -7
- package/esm/typings/{promptbook-library/constructors/createPromptbookLibraryFromUrl.d.ts → src/library/constructors/createLibraryFromUrl.d.ts} +2 -2
- package/esm/typings/{promptbook-library/constructors/createPromptbookSublibrary.d.ts → src/library/constructors/createSublibrary.d.ts} +1 -1
- package/esm/typings/src/library/libraryToJson.d.ts +8 -0
- package/{umd/typings → esm/typings/src}/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +4 -0
- package/esm/typings/{llm-providers → src/llm-providers}/anthropic-claude/anthropic-claude-models.d.ts +1 -0
- package/{umd/typings → esm/typings/src}/llm-providers/openai/OpenAiExecutionTools.d.ts +13 -0
- package/esm/typings/{llm-providers → src/llm-providers}/openai/computeOpenaiUsage.d.ts +4 -2
- package/{umd/typings → esm/typings/src}/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +1 -1
- package/esm/typings/{llm-providers → src/llm-providers}/remote/startRemoteServer.d.ts +1 -1
- package/{umd/typings → esm/typings/src}/types/ModelRequirements.d.ts +1 -1
- package/esm/typings/{types → src/types}/PromptbookJson/KnowledgeJson.d.ts +1 -1
- package/esm/typings/{types → src/types}/PromptbookJson/MaterialKnowledgePieceJson.d.ts +4 -3
- package/package.json +2 -2
- package/umd/index.umd.js +566 -533
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/promptbook-library/index.d.ts +25 -0
- package/umd/typings/src/_packages/cli.index.d.ts +10 -0
- package/{esm/typings → umd/typings/src}/_packages/core.index.d.ts +11 -9
- package/umd/typings/src/_packages/node.index.d.ts +4 -0
- package/{esm/typings → umd/typings/src}/_packages/types.index.d.ts +4 -3
- package/umd/typings/src/cli/actions/hello.d.ts +7 -0
- package/umd/typings/src/cli/actions/make.d.ts +7 -0
- package/umd/typings/src/cli/actions/prettify.d.ts +7 -0
- package/umd/typings/{conversion/prettify/prettifyPromptbookStringCli.d.ts → src/cli/promptbookCli.d.ts} +2 -2
- package/umd/typings/{config.d.ts → src/config.d.ts} +4 -0
- package/umd/typings/{conversion → src/conversion}/promptbookStringToJson.d.ts +5 -3
- package/umd/typings/src/conversion/promptbookStringToJsonSync.d.ts +23 -0
- package/{esm/typings/conversion/validation/validatePromptbookJson.d.ts → umd/typings/src/conversion/validation/validatePromptbook.d.ts} +2 -2
- package/umd/typings/src/execution/EmbeddingVector.d.ts +8 -0
- package/umd/typings/{execution → src/execution}/LlmExecutionTools.d.ts +1 -0
- package/umd/typings/{execution → src/execution}/PromptResult.d.ts +11 -0
- package/umd/typings/src/execution/embeddingVectorToString.d.ts +5 -0
- package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +21 -0
- package/umd/typings/{promptbook-library → src/library}/SimplePromptbookLibrary.d.ts +3 -1
- package/umd/typings/{promptbook-library/constructors/createPromptbookLibraryFromDirectory.d.ts → src/library/constructors/createLibraryFromDirectory.d.ts} +2 -2
- package/umd/typings/src/library/constructors/createLibraryFromJson.d.ts +12 -0
- package/umd/typings/{promptbook-library/constructors/createPromptbookLibraryFromPromise.d.ts → src/library/constructors/createLibraryFromPromise.d.ts} +3 -7
- package/umd/typings/{promptbook-library/constructors/createPromptbookLibraryFromUrl.d.ts → src/library/constructors/createLibraryFromUrl.d.ts} +2 -2
- package/umd/typings/{promptbook-library/constructors/createPromptbookSublibrary.d.ts → src/library/constructors/createSublibrary.d.ts} +1 -1
- package/umd/typings/src/library/libraryToJson.d.ts +8 -0
- package/{esm/typings → umd/typings/src}/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +4 -0
- package/umd/typings/{llm-providers → src/llm-providers}/anthropic-claude/anthropic-claude-models.d.ts +1 -0
- package/{esm/typings → umd/typings/src}/llm-providers/openai/OpenAiExecutionTools.d.ts +13 -0
- package/umd/typings/{llm-providers → src/llm-providers}/openai/computeOpenaiUsage.d.ts +4 -2
- package/{esm/typings → umd/typings/src}/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +1 -1
- package/umd/typings/{llm-providers → src/llm-providers}/remote/startRemoteServer.d.ts +1 -1
- package/{esm/typings → umd/typings/src}/types/ModelRequirements.d.ts +1 -1
- package/umd/typings/{types → src/types}/PromptbookJson/KnowledgeJson.d.ts +1 -1
- package/umd/typings/{types → src/types}/PromptbookJson/MaterialKnowledgePieceJson.d.ts +4 -3
- package/umd/typings/src/utils/trimCodeBlock.test.d.ts +1 -0
- package/umd/typings/src/utils/trimEndOfCodeBlock.test.d.ts +1 -0
- package/umd/typings/src/utils/unwrapResult.test.d.ts +1 -0
- package/umd/typings/src/utils/validators/url/isValidUrl.test.d.ts +1 -0
- package/esm/typings/_packages/cli.index.d.ts +0 -10
- package/esm/typings/_packages/node.index.d.ts +0 -4
- package/esm/typings/knowledge/prepare-knowledge/_common/IndexPreparer.d.ts +0 -4
- package/esm/typings/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +0 -7
- package/esm/typings/promptbook-library/constructors/createPromptbookLibraryFromSources.d.ts +0 -16
- package/umd/typings/_packages/cli.index.d.ts +0 -10
- package/umd/typings/_packages/node.index.d.ts +0 -4
- package/umd/typings/knowledge/prepare-knowledge/_common/IndexPreparer.d.ts +0 -4
- package/umd/typings/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +0 -7
- package/umd/typings/promptbook-library/constructors/createPromptbookLibraryFromSources.d.ts +0 -16
- /package/esm/typings/{_packages → src/_packages}/anthropic-claude.index.d.ts +0 -0
- /package/esm/typings/{_packages → src/_packages}/azure-openai.index.d.ts +0 -0
- /package/esm/typings/{_packages → src/_packages}/execute-javascript.index.d.ts +0 -0
- /package/esm/typings/{_packages → src/_packages}/fake-llm.index.d.ts +0 -0
- /package/esm/typings/{_packages → src/_packages}/langtail.index.d.ts +0 -0
- /package/esm/typings/{_packages → src/_packages}/openai.index.d.ts +0 -0
- /package/esm/typings/{_packages → src/_packages}/remote-client.index.d.ts +0 -0
- /package/esm/typings/{_packages → src/_packages}/remote-server.index.d.ts +0 -0
- /package/esm/typings/{_packages → src/_packages}/utils.index.d.ts +0 -0
- /package/esm/typings/{conversion → src/conversion}/prettify/PrettifyOptions.d.ts +0 -0
- /package/esm/typings/{conversion → src/conversion}/prettify/prettifyPromptbookString.d.ts +0 -0
- /package/esm/typings/{conversion → src/conversion}/prettify/renderPromptbookMermaid.d.ts +0 -0
- /package/esm/typings/{conversion → src/conversion}/promptbookJsonToString.d.ts +0 -0
- /package/esm/typings/{conversion → src/conversion}/promptbookStringToJson.test.d.ts +0 -0
- /package/esm/typings/{conversion/utils/extractParametersFromPromptTemplate.test.d.ts → src/conversion/promptbookStringToJsonSync.test.d.ts} +0 -0
- /package/esm/typings/{conversion → src/conversion}/utils/extractParametersFromPromptTemplate.d.ts +0 -0
- /package/{umd/typings → esm/typings/src}/conversion/utils/extractParametersFromPromptTemplate.test.d.ts +0 -0
- /package/esm/typings/{conversion → src/conversion}/utils/extractVariables.d.ts +0 -0
- /package/esm/typings/{conversion → src/conversion}/utils/extractVariables.test.d.ts +0 -0
- /package/esm/typings/{conversion → src/conversion}/utils/parseCommand.d.ts +0 -0
- /package/esm/typings/{conversion → src/conversion}/utils/parseCommand.test.d.ts +0 -0
- /package/esm/typings/{conversion → src/conversion}/utils/parseNumber.d.ts +0 -0
- /package/esm/typings/{conversion → src/conversion}/utils/parseNumber.test.d.ts +0 -0
- /package/esm/typings/{conversion → src/conversion}/utils/renameParameter.d.ts +0 -0
- /package/esm/typings/{conversion → src/conversion}/utils/renameParameter.test.d.ts +0 -0
- /package/esm/typings/{conversion → src/conversion}/utils/titleToName.d.ts +0 -0
- /package/esm/typings/{conversion → src/conversion}/utils/titleToName.test.d.ts +0 -0
- /package/esm/typings/{conversion → src/conversion}/validation/_importPromptbook.d.ts +0 -0
- /package/esm/typings/{conversion → src/conversion}/validation/promptbookStringToJson-syntaxErrors.test.d.ts +0 -0
- /package/esm/typings/{conversion/validation/validatePromptbookJson-logicErrors.test.d.ts → src/conversion/validation/validatePromptbook-logicErrors.test.d.ts} +0 -0
- /package/esm/typings/{conversion/validation/validatePromptbookJson.test.d.ts → src/conversion/validation/validatePromptbook.test.d.ts} +0 -0
- /package/esm/typings/{errors → src/errors}/PromptbookExecutionError.d.ts +0 -0
- /package/esm/typings/{errors → src/errors}/PromptbookLibraryError.d.ts +0 -0
- /package/esm/typings/{errors → src/errors}/PromptbookLogicError.d.ts +0 -0
- /package/esm/typings/{errors → src/errors}/PromptbookNotFoundError.d.ts +0 -0
- /package/esm/typings/{errors → src/errors}/PromptbookReferenceError.d.ts +0 -0
- /package/esm/typings/{errors → src/errors}/PromptbookSyntaxError.d.ts +0 -0
- /package/esm/typings/{errors → src/errors}/TemplateError.d.ts +0 -0
- /package/esm/typings/{errors → src/errors}/UnexpectedError.d.ts +0 -0
- /package/esm/typings/{errors → src/errors}/_ExpectError.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/CommonExecutionToolsOptions.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/ExecutionTools.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/PromptbookExecutor.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/ScriptExecutionTools.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/UserInterfaceTools.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/addPromptResultUsage.test.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/assertsExecutionSuccessful.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/createPromptbookExecutor.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/AutomaticTranslator.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/DebugAutomaticTranslator.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/FakeAutomaticTranslator.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.test.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/translation/automatic-translate/translateMessages.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/utils/addUsage.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/utils/addUsage.test.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/utils/checkExpectations.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/utils/checkExpectations.test.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/utils/computeUsageCounts.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/utils/forEachAsync.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/utils/replaceParameters.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/utils/replaceParameters.test.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/utils/uncertainNumber.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/utils/usageToWorktime.d.ts +0 -0
- /package/esm/typings/{execution → src/execution}/utils/usageToWorktime.test.d.ts +0 -0
- /package/esm/typings/{expectations → src/expectations}/drafts/isDomainNameFree.d.ts +0 -0
- /package/esm/typings/{expectations → src/expectations}/drafts/isGithubNameFree.d.ts +0 -0
- /package/esm/typings/{formats → src/formats}/_common/FormatDefinition.d.ts +0 -0
- /package/esm/typings/{formats → src/formats}/csv/ListFormatDefinition.d.ts +0 -0
- /package/esm/typings/{formats → src/formats}/index.d.ts +0 -0
- /package/esm/typings/{formats → src/formats}/json/JsonFormatDefinition.d.ts +0 -0
- /package/esm/typings/{formats → src/formats}/json/utils/isValidJsonString.d.ts +0 -0
- /package/esm/typings/{formats → src/formats}/json/utils/isValidJsonString.test.d.ts +0 -0
- /package/esm/typings/{formats → src/formats}/list/ListFormatDefinition.d.ts +0 -0
- /package/esm/typings/{formats → src/formats}/xml/XmlFormatDefinition.d.ts +0 -0
- /package/esm/typings/{knowledge → src/knowledge}/dialogs/callback/CallbackInterfaceTools.d.ts +0 -0
- /package/esm/typings/{knowledge → src/knowledge}/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +0 -0
- /package/esm/typings/{knowledge → src/knowledge}/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +0 -0
- /package/esm/typings/{knowledge → src/knowledge}/dialogs/user-interface-execution-tools.test.d.ts +0 -0
- /package/esm/typings/{knowledge → src/knowledge}/prepare-knowledge/markdown/playground/markdown-knowledge-playground.d.ts +0 -0
- /package/esm/typings/{knowledge → src/knowledge}/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +0 -0
- /package/esm/typings/{knowledge → src/knowledge}/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +0 -0
- /package/esm/typings/{knowledge → src/knowledge}/prepare-knowledge/pdf/prepareKnowledgeFromPdf.test.d.ts +0 -0
- /package/esm/typings/{promptbook-library → src/library}/PromptbookLibrary.d.ts +0 -0
- /package/esm/typings/{llm-providers/mocked/fakeTextToExpectations.test.d.ts → src/library/constructors/createLibraryFromDirectory.test.d.ts} +0 -0
- /package/esm/typings/{llm-providers/mocked/faked-completion.test.d.ts → src/library/constructors/createLibraryFromJson.test.d.ts} +0 -0
- /package/esm/typings/{llm-providers/openai/computeUsage.test.d.ts → src/library/constructors/createLibraryFromPromise.test.d.ts} +0 -0
- /package/esm/typings/{promptbook-library → src/library}/constructors/justTestFsImport.d.ts +0 -0
- /package/esm/typings/{promptbook-library/constructors/createPromptbookLibraryFromDirectory.test.d.ts → src/library/libraryToJson.test.d.ts} +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/anthropic-claude/playground/playground.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/azure-openai/AzureOpenAiExecutionTools.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/azure-openai/playground/playground.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/langtail/LangtailExecutionTools.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/langtail/LangtailExecutionToolsOptions.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/langtail/playground/playground.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/mocked/MockedEchoLlmExecutionTools.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/mocked/MockedFackedLlmExecutionTools.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/mocked/fakeTextToExpectations.d.ts +0 -0
- /package/{umd/typings → esm/typings/src}/llm-providers/mocked/fakeTextToExpectations.test.d.ts +0 -0
- /package/{umd/typings → esm/typings/src}/llm-providers/mocked/faked-completion.test.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/mocked/joker.test.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/mocked/mocked-chat.test.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/mocked/mocked-completion.test.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/multiple/MultipleLlmExecutionTools.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/multiple/MultipleLlmExecutionToolsOptions.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/multiple/playground/playground.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/openai/OpenAiExecutionToolsOptions.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/openai/computeUsage.d.ts +0 -0
- /package/{umd/typings → esm/typings/src}/llm-providers/openai/computeUsage.test.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/openai/openai-models.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/openai/playground/playground.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/remote/RemoteLlmExecutionTools.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/remote/RemoteLlmExecutionToolsOptions.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/remote/interfaces/Promptbook_Server_Error.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/remote/interfaces/Promptbook_Server_Progress.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/remote/interfaces/Promptbook_Server_Request.d.ts +0 -0
- /package/esm/typings/{llm-providers → src/llm-providers}/remote/interfaces/Promptbook_Server_Response.d.ts +0 -0
- /package/esm/typings/{scripting → src/scripting}/_test/custom-function-async.test.ts.test.d.ts +0 -0
- /package/esm/typings/{scripting → src/scripting}/_test/custom-function-missing.test.d.ts +0 -0
- /package/esm/typings/{scripting → src/scripting}/_test/custom-function-with-dependencies.test.d.ts +0 -0
- /package/esm/typings/{scripting → src/scripting}/_test/custom-function.test.d.ts +0 -0
- /package/esm/typings/{scripting → src/scripting}/_test/postprocessing.test.d.ts +0 -0
- /package/esm/typings/{scripting → src/scripting}/_test/script-execution-errors.test.d.ts +0 -0
- /package/esm/typings/{scripting → src/scripting}/_test/script-execution-tools.test.d.ts +0 -0
- /package/esm/typings/{scripting → src/scripting}/javascript/JavascriptEvalExecutionTools.d.ts +0 -0
- /package/esm/typings/{scripting → src/scripting}/javascript/JavascriptEvalExecutionTools.test.d.ts +0 -0
- /package/esm/typings/{scripting → src/scripting}/javascript/JavascriptExecutionTools.d.ts +0 -0
- /package/esm/typings/{scripting → src/scripting}/javascript/JavascriptExecutionToolsOptions.d.ts +0 -0
- /package/esm/typings/{scripting → src/scripting}/javascript/utils/preserve.d.ts +0 -0
- /package/esm/typings/{scripting → src/scripting}/javascript/utils/unknownToString.d.ts +0 -0
- /package/esm/typings/{scripting → src/scripting}/python/PythonExecutionTools.d.ts +0 -0
- /package/esm/typings/{scripting → src/scripting}/typescript/TypescriptExecutionTools.d.ts +0 -0
- /package/esm/typings/{types → src/types}/Command.d.ts +0 -0
- /package/esm/typings/{types → src/types}/ExecutionTypes.d.ts +0 -0
- /package/esm/typings/{types → src/types}/Parameters.d.ts +0 -0
- /package/esm/typings/{types → src/types}/Prompt.d.ts +0 -0
- /package/esm/typings/{types → src/types}/PromptbookJson/PromptTemplateJson.d.ts +0 -0
- /package/esm/typings/{types → src/types}/PromptbookJson/PromptTemplateParameterJson.d.ts +0 -0
- /package/esm/typings/{types → src/types}/PromptbookJson/PromptbookJson.d.ts +0 -0
- /package/esm/typings/{types → src/types}/PromptbookString.d.ts +0 -0
- /package/esm/typings/{types → src/types}/ScriptLanguage.d.ts +0 -0
- /package/esm/typings/{types → src/types}/TaskProgress.d.ts +0 -0
- /package/esm/typings/{types → src/types}/execution-report/ExecutionReportJson.d.ts +0 -0
- /package/esm/typings/{types → src/types}/execution-report/ExecutionReportString.d.ts +0 -0
- /package/esm/typings/{types → src/types}/execution-report/ExecutionReportStringOptions.d.ts +0 -0
- /package/esm/typings/{types → src/types}/execution-report/config.d.ts +0 -0
- /package/esm/typings/{types → src/types}/execution-report/countWorkingDuration.d.ts +0 -0
- /package/esm/typings/{types → src/types}/execution-report/countWorkingDuration.test.d.ts +0 -0
- /package/esm/typings/{types → src/types}/execution-report/executionReportJsonToString.d.ts +0 -0
- /package/esm/typings/{types → src/types}/typeAliasEmoji.d.ts +0 -0
- /package/esm/typings/{types → src/types}/typeAliases.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/FromtoItems.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/emojis.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/expectation-counters/countCharacters.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/expectation-counters/countCharacters.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/expectation-counters/countLines.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/expectation-counters/countLines.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/expectation-counters/countPages.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/expectation-counters/countPages.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/expectation-counters/countParagraphs.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/expectation-counters/countParagraphs.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/expectation-counters/countSentences.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/expectation-counters/countSentences.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/expectation-counters/countWords.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/expectation-counters/countWords.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/expectation-counters/index.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/extractParameters.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/extractParameters.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/formatNumber.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/formatNumber.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/getCurrentIsoDate.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/isRunningInWhatever.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/just.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown/addAutoGeneratedSection.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown/addAutoGeneratedSection.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown/createMarkdownChart.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown/createMarkdownChart.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown/createMarkdownTable.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown/createMarkdownTable.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown/escapeMarkdownBlock.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown/escapeMarkdownBlock.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown/extractAllBlocksFromMarkdown.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown/extractAllBlocksFromMarkdown.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown/extractAllListItemsFromMarkdown.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown/extractAllListItemsFromMarkdown.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown/extractOneBlockFromMarkdown.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown/extractOneBlockFromMarkdown.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown/prettifyMarkdown.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown/prettifyMarkdown.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown/removeContentComments.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown/removeContentComments.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown/removeMarkdownFormatting.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown/removeMarkdownFormatting.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown-json/MarkdownStructure.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown-json/countMarkdownStructureDeepness.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown-json/countMarkdownStructureDeepness.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown-json/markdownToMarkdownStructure.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/markdown-json/markdownToMarkdownStructure.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/DIACRITIC_VARIANTS_LETTERS.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/IKeywords.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/capitalize.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/capitalize.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/decapitalize.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/decapitalize.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/isValidKeyword.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/isValidKeyword.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/nameToUriPart.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/nameToUriPart.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/nameToUriParts.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/nameToUriParts.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/normalize-to-kebab-case.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/normalize-to-kebab-case.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/normalizeTo_PascalCase.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/normalizeTo_PascalCase.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/normalizeTo_SCREAMING_CASE.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/normalizeTo_SCREAMING_CASE.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/normalizeTo_camelCase.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/normalizeTo_camelCase.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/normalizeTo_snake_case.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/normalizeTo_snake_case.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/normalizeWhitespaces.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/normalizeWhitespaces.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/parseKeywords.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/parseKeywords.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/parseKeywordsFromString.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/parseKeywordsFromString.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/removeDiacritics.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/removeDiacritics.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/searchKeywords.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/normalization/searchKeywords.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/postprocessing/extractBlock.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/removeEmojis.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/removeEmojis.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/removeQuotes.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/removeQuotes.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/sets/difference.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/sets/difference.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/sets/intersection.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/sets/intersection.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/sets/union.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/sets/union.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/trimCodeBlock.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/trimCodeBlock.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/trimEndOfCodeBlock.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/trimEndOfCodeBlock.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/unwrapResult.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/unwrapResult.test.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/validators/url/isValidUrl.d.ts +0 -0
- /package/esm/typings/{utils → src/utils}/validators/url/isValidUrl.test.d.ts +0 -0
- /package/esm/typings/{version.d.ts → src/version.d.ts} +0 -0
- /package/umd/typings/{_packages → src/_packages}/anthropic-claude.index.d.ts +0 -0
- /package/umd/typings/{_packages → src/_packages}/azure-openai.index.d.ts +0 -0
- /package/umd/typings/{_packages → src/_packages}/execute-javascript.index.d.ts +0 -0
- /package/umd/typings/{_packages → src/_packages}/fake-llm.index.d.ts +0 -0
- /package/umd/typings/{_packages → src/_packages}/langtail.index.d.ts +0 -0
- /package/umd/typings/{_packages → src/_packages}/openai.index.d.ts +0 -0
- /package/umd/typings/{_packages → src/_packages}/remote-client.index.d.ts +0 -0
- /package/umd/typings/{_packages → src/_packages}/remote-server.index.d.ts +0 -0
- /package/umd/typings/{_packages → src/_packages}/utils.index.d.ts +0 -0
- /package/umd/typings/{conversion → src/conversion}/prettify/PrettifyOptions.d.ts +0 -0
- /package/umd/typings/{conversion → src/conversion}/prettify/prettifyPromptbookString.d.ts +0 -0
- /package/umd/typings/{conversion → src/conversion}/prettify/renderPromptbookMermaid.d.ts +0 -0
- /package/umd/typings/{conversion → src/conversion}/promptbookJsonToString.d.ts +0 -0
- /package/umd/typings/{conversion → src/conversion}/promptbookStringToJson.test.d.ts +0 -0
- /package/{esm/typings/promptbook-library/constructors/createPromptbookLibraryFromPromise.test.d.ts → umd/typings/src/conversion/promptbookStringToJsonSync.test.d.ts} +0 -0
- /package/umd/typings/{conversion → src/conversion}/utils/extractParametersFromPromptTemplate.d.ts +0 -0
- /package/{esm/typings/promptbook-library/constructors/createPromptbookLibraryFromSources.test.d.ts → umd/typings/src/conversion/utils/extractParametersFromPromptTemplate.test.d.ts} +0 -0
- /package/umd/typings/{conversion → src/conversion}/utils/extractVariables.d.ts +0 -0
- /package/umd/typings/{conversion → src/conversion}/utils/extractVariables.test.d.ts +0 -0
- /package/umd/typings/{conversion → src/conversion}/utils/parseCommand.d.ts +0 -0
- /package/umd/typings/{conversion → src/conversion}/utils/parseCommand.test.d.ts +0 -0
- /package/umd/typings/{conversion → src/conversion}/utils/parseNumber.d.ts +0 -0
- /package/umd/typings/{conversion → src/conversion}/utils/parseNumber.test.d.ts +0 -0
- /package/umd/typings/{conversion → src/conversion}/utils/renameParameter.d.ts +0 -0
- /package/umd/typings/{conversion → src/conversion}/utils/renameParameter.test.d.ts +0 -0
- /package/umd/typings/{conversion → src/conversion}/utils/titleToName.d.ts +0 -0
- /package/umd/typings/{conversion → src/conversion}/utils/titleToName.test.d.ts +0 -0
- /package/umd/typings/{conversion → src/conversion}/validation/_importPromptbook.d.ts +0 -0
- /package/umd/typings/{conversion → src/conversion}/validation/promptbookStringToJson-syntaxErrors.test.d.ts +0 -0
- /package/umd/typings/{conversion/validation/validatePromptbookJson-logicErrors.test.d.ts → src/conversion/validation/validatePromptbook-logicErrors.test.d.ts} +0 -0
- /package/umd/typings/{conversion/validation/validatePromptbookJson.test.d.ts → src/conversion/validation/validatePromptbook.test.d.ts} +0 -0
- /package/umd/typings/{errors → src/errors}/PromptbookExecutionError.d.ts +0 -0
- /package/umd/typings/{errors → src/errors}/PromptbookLibraryError.d.ts +0 -0
- /package/umd/typings/{errors → src/errors}/PromptbookLogicError.d.ts +0 -0
- /package/umd/typings/{errors → src/errors}/PromptbookNotFoundError.d.ts +0 -0
- /package/umd/typings/{errors → src/errors}/PromptbookReferenceError.d.ts +0 -0
- /package/umd/typings/{errors → src/errors}/PromptbookSyntaxError.d.ts +0 -0
- /package/umd/typings/{errors → src/errors}/TemplateError.d.ts +0 -0
- /package/umd/typings/{errors → src/errors}/UnexpectedError.d.ts +0 -0
- /package/umd/typings/{errors → src/errors}/_ExpectError.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/CommonExecutionToolsOptions.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/ExecutionTools.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/PromptbookExecutor.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/ScriptExecutionTools.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/UserInterfaceTools.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/addPromptResultUsage.test.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/assertsExecutionSuccessful.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/createPromptbookExecutor.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/AutomaticTranslator.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/DebugAutomaticTranslator.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/FakeAutomaticTranslator.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.test.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/translation/automatic-translate/translateMessages.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/utils/addUsage.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/utils/addUsage.test.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/utils/checkExpectations.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/utils/checkExpectations.test.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/utils/computeUsageCounts.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/utils/forEachAsync.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/utils/replaceParameters.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/utils/replaceParameters.test.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/utils/uncertainNumber.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/utils/usageToWorktime.d.ts +0 -0
- /package/umd/typings/{execution → src/execution}/utils/usageToWorktime.test.d.ts +0 -0
- /package/umd/typings/{expectations → src/expectations}/drafts/isDomainNameFree.d.ts +0 -0
- /package/umd/typings/{expectations → src/expectations}/drafts/isGithubNameFree.d.ts +0 -0
- /package/umd/typings/{formats → src/formats}/_common/FormatDefinition.d.ts +0 -0
- /package/umd/typings/{formats → src/formats}/csv/ListFormatDefinition.d.ts +0 -0
- /package/umd/typings/{formats → src/formats}/index.d.ts +0 -0
- /package/umd/typings/{formats → src/formats}/json/JsonFormatDefinition.d.ts +0 -0
- /package/umd/typings/{formats → src/formats}/json/utils/isValidJsonString.d.ts +0 -0
- /package/umd/typings/{formats → src/formats}/json/utils/isValidJsonString.test.d.ts +0 -0
- /package/umd/typings/{formats → src/formats}/list/ListFormatDefinition.d.ts +0 -0
- /package/umd/typings/{formats → src/formats}/xml/XmlFormatDefinition.d.ts +0 -0
- /package/umd/typings/{knowledge → src/knowledge}/dialogs/callback/CallbackInterfaceTools.d.ts +0 -0
- /package/umd/typings/{knowledge → src/knowledge}/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +0 -0
- /package/umd/typings/{knowledge → src/knowledge}/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +0 -0
- /package/umd/typings/{knowledge → src/knowledge}/dialogs/user-interface-execution-tools.test.d.ts +0 -0
- /package/umd/typings/{knowledge → src/knowledge}/prepare-knowledge/markdown/playground/markdown-knowledge-playground.d.ts +0 -0
- /package/umd/typings/{knowledge → src/knowledge}/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +0 -0
- /package/umd/typings/{knowledge → src/knowledge}/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +0 -0
- /package/umd/typings/{knowledge → src/knowledge}/prepare-knowledge/pdf/prepareKnowledgeFromPdf.test.d.ts +0 -0
- /package/umd/typings/{promptbook-library → src/library}/PromptbookLibrary.d.ts +0 -0
- /package/umd/typings/{promptbook-library/constructors/createPromptbookLibraryFromDirectory.test.d.ts → src/library/constructors/createLibraryFromDirectory.test.d.ts} +0 -0
- /package/umd/typings/{promptbook-library/constructors/createPromptbookLibraryFromPromise.test.d.ts → src/library/constructors/createLibraryFromJson.test.d.ts} +0 -0
- /package/umd/typings/{promptbook-library/constructors/createPromptbookLibraryFromSources.test.d.ts → src/library/constructors/createLibraryFromPromise.test.d.ts} +0 -0
- /package/umd/typings/{promptbook-library → src/library}/constructors/justTestFsImport.d.ts +0 -0
- /package/umd/typings/{scripting/_test/custom-function-async.test.ts.test.d.ts → src/library/libraryToJson.test.d.ts} +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/anthropic-claude/playground/playground.d.ts +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/azure-openai/AzureOpenAiExecutionTools.d.ts +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/azure-openai/playground/playground.d.ts +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/langtail/LangtailExecutionTools.d.ts +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/langtail/LangtailExecutionToolsOptions.d.ts +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/langtail/playground/playground.d.ts +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/mocked/MockedEchoLlmExecutionTools.d.ts +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/mocked/MockedFackedLlmExecutionTools.d.ts +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/mocked/fakeTextToExpectations.d.ts +0 -0
- /package/umd/typings/{scripting/_test/custom-function-missing.test.d.ts → src/llm-providers/mocked/fakeTextToExpectations.test.d.ts} +0 -0
- /package/umd/typings/{scripting/_test/custom-function-with-dependencies.test.d.ts → src/llm-providers/mocked/faked-completion.test.d.ts} +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/mocked/joker.test.d.ts +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/mocked/mocked-chat.test.d.ts +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/mocked/mocked-completion.test.d.ts +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/multiple/MultipleLlmExecutionTools.d.ts +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/multiple/MultipleLlmExecutionToolsOptions.d.ts +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/multiple/playground/playground.d.ts +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/openai/OpenAiExecutionToolsOptions.d.ts +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/openai/computeUsage.d.ts +0 -0
- /package/umd/typings/{scripting/_test/custom-function.test.d.ts → src/llm-providers/openai/computeUsage.test.d.ts} +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/openai/openai-models.d.ts +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/openai/playground/playground.d.ts +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/remote/RemoteLlmExecutionTools.d.ts +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/remote/RemoteLlmExecutionToolsOptions.d.ts +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/remote/interfaces/Promptbook_Server_Error.d.ts +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/remote/interfaces/Promptbook_Server_Progress.d.ts +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/remote/interfaces/Promptbook_Server_Request.d.ts +0 -0
- /package/umd/typings/{llm-providers → src/llm-providers}/remote/interfaces/Promptbook_Server_Response.d.ts +0 -0
- /package/umd/typings/{scripting/_test/postprocessing.test.d.ts → src/scripting/_test/custom-function-async.test.ts.test.d.ts} +0 -0
- /package/umd/typings/{scripting/_test/script-execution-errors.test.d.ts → src/scripting/_test/custom-function-missing.test.d.ts} +0 -0
- /package/umd/typings/{scripting/_test/script-execution-tools.test.d.ts → src/scripting/_test/custom-function-with-dependencies.test.d.ts} +0 -0
- /package/umd/typings/{types/execution-report/countWorkingDuration.test.d.ts → src/scripting/_test/custom-function.test.d.ts} +0 -0
- /package/umd/typings/{utils/expectation-counters/countCharacters.test.d.ts → src/scripting/_test/postprocessing.test.d.ts} +0 -0
- /package/umd/typings/{utils/expectation-counters/countLines.test.d.ts → src/scripting/_test/script-execution-errors.test.d.ts} +0 -0
- /package/umd/typings/{utils/expectation-counters/countPages.test.d.ts → src/scripting/_test/script-execution-tools.test.d.ts} +0 -0
- /package/umd/typings/{scripting → src/scripting}/javascript/JavascriptEvalExecutionTools.d.ts +0 -0
- /package/umd/typings/{scripting → src/scripting}/javascript/JavascriptEvalExecutionTools.test.d.ts +0 -0
- /package/umd/typings/{scripting → src/scripting}/javascript/JavascriptExecutionTools.d.ts +0 -0
- /package/umd/typings/{scripting → src/scripting}/javascript/JavascriptExecutionToolsOptions.d.ts +0 -0
- /package/umd/typings/{scripting → src/scripting}/javascript/utils/preserve.d.ts +0 -0
- /package/umd/typings/{scripting → src/scripting}/javascript/utils/unknownToString.d.ts +0 -0
- /package/umd/typings/{scripting → src/scripting}/python/PythonExecutionTools.d.ts +0 -0
- /package/umd/typings/{scripting → src/scripting}/typescript/TypescriptExecutionTools.d.ts +0 -0
- /package/umd/typings/{types → src/types}/Command.d.ts +0 -0
- /package/umd/typings/{types → src/types}/ExecutionTypes.d.ts +0 -0
- /package/umd/typings/{types → src/types}/Parameters.d.ts +0 -0
- /package/umd/typings/{types → src/types}/Prompt.d.ts +0 -0
- /package/umd/typings/{types → src/types}/PromptbookJson/PromptTemplateJson.d.ts +0 -0
- /package/umd/typings/{types → src/types}/PromptbookJson/PromptTemplateParameterJson.d.ts +0 -0
- /package/umd/typings/{types → src/types}/PromptbookJson/PromptbookJson.d.ts +0 -0
- /package/umd/typings/{types → src/types}/PromptbookString.d.ts +0 -0
- /package/umd/typings/{types → src/types}/ScriptLanguage.d.ts +0 -0
- /package/umd/typings/{types → src/types}/TaskProgress.d.ts +0 -0
- /package/umd/typings/{types → src/types}/execution-report/ExecutionReportJson.d.ts +0 -0
- /package/umd/typings/{types → src/types}/execution-report/ExecutionReportString.d.ts +0 -0
- /package/umd/typings/{types → src/types}/execution-report/ExecutionReportStringOptions.d.ts +0 -0
- /package/umd/typings/{types → src/types}/execution-report/config.d.ts +0 -0
- /package/umd/typings/{types → src/types}/execution-report/countWorkingDuration.d.ts +0 -0
- /package/umd/typings/{utils/expectation-counters/countParagraphs.test.d.ts → src/types/execution-report/countWorkingDuration.test.d.ts} +0 -0
- /package/umd/typings/{types → src/types}/execution-report/executionReportJsonToString.d.ts +0 -0
- /package/umd/typings/{types → src/types}/typeAliasEmoji.d.ts +0 -0
- /package/umd/typings/{types → src/types}/typeAliases.d.ts +0 -0
- /package/umd/typings/{utils → src/utils}/FromtoItems.d.ts +0 -0
- /package/umd/typings/{utils → src/utils}/emojis.d.ts +0 -0
- /package/umd/typings/{utils → src/utils}/expectation-counters/countCharacters.d.ts +0 -0
- /package/umd/typings/{utils/expectation-counters/countSentences.test.d.ts → src/utils/expectation-counters/countCharacters.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/expectation-counters/countLines.d.ts +0 -0
- /package/umd/typings/{utils/expectation-counters/countWords.test.d.ts → src/utils/expectation-counters/countLines.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/expectation-counters/countPages.d.ts +0 -0
- /package/umd/typings/{utils/extractParameters.test.d.ts → src/utils/expectation-counters/countPages.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/expectation-counters/countParagraphs.d.ts +0 -0
- /package/umd/typings/{utils/formatNumber.test.d.ts → src/utils/expectation-counters/countParagraphs.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/expectation-counters/countSentences.d.ts +0 -0
- /package/umd/typings/{utils/markdown-json/countMarkdownStructureDeepness.test.d.ts → src/utils/expectation-counters/countSentences.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/expectation-counters/countWords.d.ts +0 -0
- /package/umd/typings/{utils/markdown-json/markdownToMarkdownStructure.test.d.ts → src/utils/expectation-counters/countWords.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/expectation-counters/index.d.ts +0 -0
- /package/umd/typings/{utils → src/utils}/extractParameters.d.ts +0 -0
- /package/umd/typings/{utils/markdown/addAutoGeneratedSection.test.d.ts → src/utils/extractParameters.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/formatNumber.d.ts +0 -0
- /package/umd/typings/{utils/markdown/createMarkdownChart.test.d.ts → src/utils/formatNumber.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/getCurrentIsoDate.d.ts +0 -0
- /package/umd/typings/{utils → src/utils}/isRunningInWhatever.d.ts +0 -0
- /package/umd/typings/{utils → src/utils}/just.d.ts +0 -0
- /package/umd/typings/{utils → src/utils}/markdown/addAutoGeneratedSection.d.ts +0 -0
- /package/umd/typings/{utils/markdown/extractAllBlocksFromMarkdown.test.d.ts → src/utils/markdown/addAutoGeneratedSection.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/markdown/createMarkdownChart.d.ts +0 -0
- /package/umd/typings/{utils/markdown/extractAllListItemsFromMarkdown.test.d.ts → src/utils/markdown/createMarkdownChart.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/markdown/createMarkdownTable.d.ts +0 -0
- /package/umd/typings/{utils/markdown/extractOneBlockFromMarkdown.test.d.ts → src/utils/markdown/createMarkdownTable.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/markdown/escapeMarkdownBlock.d.ts +0 -0
- /package/umd/typings/{utils/markdown/prettifyMarkdown.test.d.ts → src/utils/markdown/escapeMarkdownBlock.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/markdown/extractAllBlocksFromMarkdown.d.ts +0 -0
- /package/umd/typings/{utils/markdown/removeContentComments.test.d.ts → src/utils/markdown/extractAllBlocksFromMarkdown.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/markdown/extractAllListItemsFromMarkdown.d.ts +0 -0
- /package/umd/typings/{utils/markdown/removeMarkdownFormatting.test.d.ts → src/utils/markdown/extractAllListItemsFromMarkdown.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/markdown/extractOneBlockFromMarkdown.d.ts +0 -0
- /package/umd/typings/{utils/normalization/capitalize.test.d.ts → src/utils/markdown/extractOneBlockFromMarkdown.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/markdown/prettifyMarkdown.d.ts +0 -0
- /package/umd/typings/{utils/normalization/decapitalize.test.d.ts → src/utils/markdown/prettifyMarkdown.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/markdown/removeContentComments.d.ts +0 -0
- /package/umd/typings/{utils/normalization/isValidKeyword.test.d.ts → src/utils/markdown/removeContentComments.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/markdown/removeMarkdownFormatting.d.ts +0 -0
- /package/umd/typings/{utils/normalization/nameToUriPart.test.d.ts → src/utils/markdown/removeMarkdownFormatting.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/markdown-json/MarkdownStructure.d.ts +0 -0
- /package/umd/typings/{utils → src/utils}/markdown-json/countMarkdownStructureDeepness.d.ts +0 -0
- /package/umd/typings/{utils/markdown/createMarkdownTable.test.d.ts → src/utils/markdown-json/countMarkdownStructureDeepness.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/markdown-json/markdownToMarkdownStructure.d.ts +0 -0
- /package/umd/typings/{utils/markdown/escapeMarkdownBlock.test.d.ts → src/utils/markdown-json/markdownToMarkdownStructure.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/normalization/DIACRITIC_VARIANTS_LETTERS.d.ts +0 -0
- /package/umd/typings/{utils → src/utils}/normalization/IKeywords.d.ts +0 -0
- /package/umd/typings/{utils → src/utils}/normalization/capitalize.d.ts +0 -0
- /package/umd/typings/{utils/normalization/nameToUriParts.test.d.ts → src/utils/normalization/capitalize.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/normalization/decapitalize.d.ts +0 -0
- /package/umd/typings/{utils/normalization/normalize-to-kebab-case.test.d.ts → src/utils/normalization/decapitalize.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/normalization/isValidKeyword.d.ts +0 -0
- /package/umd/typings/{utils/normalization/normalizeTo_PascalCase.test.d.ts → src/utils/normalization/isValidKeyword.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/normalization/nameToUriPart.d.ts +0 -0
- /package/umd/typings/{utils/normalization/normalizeTo_SCREAMING_CASE.test.d.ts → src/utils/normalization/nameToUriPart.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/normalization/nameToUriParts.d.ts +0 -0
- /package/umd/typings/{utils/normalization/normalizeTo_camelCase.test.d.ts → src/utils/normalization/nameToUriParts.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/normalization/normalize-to-kebab-case.d.ts +0 -0
- /package/umd/typings/{utils/normalization/normalizeTo_snake_case.test.d.ts → src/utils/normalization/normalize-to-kebab-case.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/normalization/normalizeTo_PascalCase.d.ts +0 -0
- /package/umd/typings/{utils/normalization/normalizeWhitespaces.test.d.ts → src/utils/normalization/normalizeTo_PascalCase.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/normalization/normalizeTo_SCREAMING_CASE.d.ts +0 -0
- /package/umd/typings/{utils/normalization/parseKeywords.test.d.ts → src/utils/normalization/normalizeTo_SCREAMING_CASE.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/normalization/normalizeTo_camelCase.d.ts +0 -0
- /package/umd/typings/{utils/normalization/parseKeywordsFromString.test.d.ts → src/utils/normalization/normalizeTo_camelCase.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/normalization/normalizeTo_snake_case.d.ts +0 -0
- /package/umd/typings/{utils/normalization/removeDiacritics.test.d.ts → src/utils/normalization/normalizeTo_snake_case.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/normalization/normalizeWhitespaces.d.ts +0 -0
- /package/umd/typings/{utils/normalization/searchKeywords.test.d.ts → src/utils/normalization/normalizeWhitespaces.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/normalization/parseKeywords.d.ts +0 -0
- /package/umd/typings/{utils/removeEmojis.test.d.ts → src/utils/normalization/parseKeywords.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/normalization/parseKeywordsFromString.d.ts +0 -0
- /package/umd/typings/{utils/removeQuotes.test.d.ts → src/utils/normalization/parseKeywordsFromString.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/normalization/removeDiacritics.d.ts +0 -0
- /package/umd/typings/{utils/sets/difference.test.d.ts → src/utils/normalization/removeDiacritics.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/normalization/searchKeywords.d.ts +0 -0
- /package/umd/typings/{utils/sets/intersection.test.d.ts → src/utils/normalization/searchKeywords.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/postprocessing/extractBlock.d.ts +0 -0
- /package/umd/typings/{utils → src/utils}/removeEmojis.d.ts +0 -0
- /package/umd/typings/{utils/sets/union.test.d.ts → src/utils/removeEmojis.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/removeQuotes.d.ts +0 -0
- /package/umd/typings/{utils/trimCodeBlock.test.d.ts → src/utils/removeQuotes.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/sets/difference.d.ts +0 -0
- /package/umd/typings/{utils/trimEndOfCodeBlock.test.d.ts → src/utils/sets/difference.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/sets/intersection.d.ts +0 -0
- /package/umd/typings/{utils/unwrapResult.test.d.ts → src/utils/sets/intersection.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/sets/union.d.ts +0 -0
- /package/umd/typings/{utils/validators/url/isValidUrl.test.d.ts → src/utils/sets/union.test.d.ts} +0 -0
- /package/umd/typings/{utils → src/utils}/trimCodeBlock.d.ts +0 -0
- /package/umd/typings/{utils → src/utils}/trimEndOfCodeBlock.d.ts +0 -0
- /package/umd/typings/{utils → src/utils}/unwrapResult.d.ts +0 -0
- /package/umd/typings/{utils → src/utils}/validators/url/isValidUrl.d.ts +0 -0
- /package/umd/typings/{version.d.ts → src/version.d.ts} +0 -0
package/esm/index.es.js
CHANGED
|
@@ -185,19 +185,7 @@ function prettifyMarkdown(content) {
|
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
|
|
189
|
-
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
190
|
-
*/
|
|
191
|
-
var PromptbookSyntaxError = /** @class */ (function (_super) {
|
|
192
|
-
__extends(PromptbookSyntaxError, _super);
|
|
193
|
-
function PromptbookSyntaxError(message) {
|
|
194
|
-
var _this = _super.call(this, message) || this;
|
|
195
|
-
_this.name = 'PromptbookSyntaxError';
|
|
196
|
-
Object.setPrototypeOf(_this, PromptbookSyntaxError.prototype);
|
|
197
|
-
return _this;
|
|
198
|
-
}
|
|
199
|
-
return PromptbookSyntaxError;
|
|
200
|
-
}(Error));
|
|
188
|
+
var promptbookLibrary = [{title:"Prepare Keywords",promptbookUrl:"https://promptbook.studio/promptbook/prepare-keywords.ptbk.md",promptbookVersion:"0.59.0-36",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],executionType:"PROMPT_TEMPLATE",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {content}",resultingParameterName:"keywords"}],knowledge:[]},{title:"Prepare Knowledge from Markdown",promptbookUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.59.0-36",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledge",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],executionType:"PROMPT_TEMPLATE",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {content}",resultingParameterName:"knowledge"}],knowledge:[]}];
|
|
201
189
|
|
|
202
190
|
/**
|
|
203
191
|
* This error indicates errors during the execution of the promptbook
|
|
@@ -257,6 +245,20 @@ var PromptbookLogicError = /** @class */ (function (_super) {
|
|
|
257
245
|
return PromptbookLogicError;
|
|
258
246
|
}(Error));
|
|
259
247
|
|
|
248
|
+
/**
|
|
249
|
+
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
250
|
+
*/
|
|
251
|
+
var PromptbookSyntaxError = /** @class */ (function (_super) {
|
|
252
|
+
__extends(PromptbookSyntaxError, _super);
|
|
253
|
+
function PromptbookSyntaxError(message) {
|
|
254
|
+
var _this = _super.call(this, message) || this;
|
|
255
|
+
_this.name = 'PromptbookSyntaxError';
|
|
256
|
+
Object.setPrototypeOf(_this, PromptbookSyntaxError.prototype);
|
|
257
|
+
return _this;
|
|
258
|
+
}
|
|
259
|
+
return PromptbookSyntaxError;
|
|
260
|
+
}(Error));
|
|
261
|
+
|
|
260
262
|
/**
|
|
261
263
|
* This error type indicates that the error should not happen and its last check before crashing with some other error
|
|
262
264
|
*/
|
|
@@ -310,7 +312,7 @@ function isValidUrl(url) {
|
|
|
310
312
|
* @returns the same promptbook if it is logically valid
|
|
311
313
|
* @throws {PromptbookLogicError} on logical error in the promptbook
|
|
312
314
|
*/
|
|
313
|
-
function
|
|
315
|
+
function validatePromptbook(promptbook) {
|
|
314
316
|
// TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
|
|
315
317
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
316
318
|
if (promptbook.promptbookUrl !== undefined) {
|
|
@@ -374,8 +376,7 @@ function validatePromptbookJson(promptbook) {
|
|
|
374
376
|
throw new PromptbookLogicError("Parameter {".concat(template.resultingParameterName, "} is defined multiple times"));
|
|
375
377
|
}
|
|
376
378
|
definedParameters.add(template.resultingParameterName);
|
|
377
|
-
if (template.executionType === 'PROMPT_TEMPLATE' &&
|
|
378
|
-
(template.modelRequirements.modelVariant === undefined)) {
|
|
379
|
+
if (template.executionType === 'PROMPT_TEMPLATE' && template.modelRequirements.modelVariant === undefined) {
|
|
379
380
|
throw new PromptbookLogicError(spaceTrim("\n\n You must specify MODEL VARIANT in the prompt template \"".concat(template.title, "\"\n\n For example:\n - MODEL VARIANT Chat\n - MODEL NAME `gpt-4-1106-preview`\n\n ")));
|
|
380
381
|
}
|
|
381
382
|
if (template.jokers && template.jokers.length > 0) {
|
|
@@ -445,7 +446,7 @@ function validatePromptbookJson(promptbook) {
|
|
|
445
446
|
var loopLimit = LOOP_LIMIT;
|
|
446
447
|
var _loop_2 = function () {
|
|
447
448
|
if (loopLimit-- < 0) {
|
|
448
|
-
throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `
|
|
449
|
+
throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `validatePromptbook`');
|
|
449
450
|
}
|
|
450
451
|
var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
|
|
451
452
|
return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
|
|
@@ -480,7 +481,7 @@ function validatePromptbookJson(promptbook) {
|
|
|
480
481
|
* > * It checks:
|
|
481
482
|
* > * - it has a valid structure
|
|
482
483
|
* > * - ...
|
|
483
|
-
* > ex port function
|
|
484
|
+
* > ex port function validatePromptbook(promptbook: unknown): asserts promptbook is PromptbookJson {
|
|
484
485
|
*/
|
|
485
486
|
|
|
486
487
|
/**
|
|
@@ -522,7 +523,7 @@ function isValidJsonString(value /* <-[👨⚖️] */) {
|
|
|
522
523
|
/**
|
|
523
524
|
* The version of the Promptbook library
|
|
524
525
|
*/
|
|
525
|
-
var PROMPTBOOK_VERSION = '0.59.0-
|
|
526
|
+
var PROMPTBOOK_VERSION = '0.59.0-36';
|
|
526
527
|
|
|
527
528
|
/**
|
|
528
529
|
* Function `addUsage` will add multiple usages into one
|
|
@@ -1084,7 +1085,7 @@ function createPromptbookExecutor(options) {
|
|
|
1084
1085
|
var _this = this;
|
|
1085
1086
|
var promptbook = options.promptbook, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
|
|
1086
1087
|
var _b = settings.maxExecutionAttempts, maxExecutionAttempts = _b === void 0 ? 3 : _b;
|
|
1087
|
-
|
|
1088
|
+
validatePromptbook(promptbook);
|
|
1088
1089
|
var promptbookExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
1089
1090
|
function executeSingleTemplate(currentTemplate) {
|
|
1090
1091
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1515,7 +1516,7 @@ function createPromptbookExecutor(options) {
|
|
|
1515
1516
|
return template.dependentParameterNames.every(function (name) { return resovedParameters_1.includes(name); });
|
|
1516
1517
|
});
|
|
1517
1518
|
if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
|
|
1518
|
-
throw new UnexpectedError(spaceTrim("\n Can not resolve some parameters\n\n Note: This should be catched during
|
|
1519
|
+
throw new UnexpectedError(spaceTrim("\n Can not resolve some parameters\n\n Note: This should be catched during validatePromptbook\n "));
|
|
1519
1520
|
case 1:
|
|
1520
1521
|
if (!!currentTemplate) return [3 /*break*/, 3];
|
|
1521
1522
|
/* [5] */ return [4 /*yield*/, Promise.race(resolving_1)];
|
|
@@ -1844,6 +1845,7 @@ var PromptbookReferenceError = /** @class */ (function (_super) {
|
|
|
1844
1845
|
* Library of promptbooks that groups together promptbooks for an application.
|
|
1845
1846
|
* This implementation is a very thin wrapper around the Array / Map of promptbooks.
|
|
1846
1847
|
*
|
|
1848
|
+
* @private use `createLibraryFromJson` instead
|
|
1847
1849
|
* @see https://github.com/webgptorg/promptbook#promptbook-library
|
|
1848
1850
|
*/
|
|
1849
1851
|
var SimplePromptbookLibrary = /** @class */ (function () {
|
|
@@ -1852,8 +1854,9 @@ var SimplePromptbookLibrary = /** @class */ (function () {
|
|
|
1852
1854
|
*
|
|
1853
1855
|
* @param promptbooks !!!
|
|
1854
1856
|
*
|
|
1857
|
+
* @private Use instead `createLibraryFromJson`
|
|
1855
1858
|
* Note: During the construction logic of all promptbooks are validated
|
|
1856
|
-
* Note: It is not recommended to use this constructor directly, use `
|
|
1859
|
+
* Note: It is not recommended to use this constructor directly, use `createLibraryFromJson` *(or other variant)* instead
|
|
1857
1860
|
*/
|
|
1858
1861
|
function SimplePromptbookLibrary() {
|
|
1859
1862
|
var e_1, _a;
|
|
@@ -1868,7 +1871,7 @@ var SimplePromptbookLibrary = /** @class */ (function () {
|
|
|
1868
1871
|
if (promptbook.promptbookUrl === undefined) {
|
|
1869
1872
|
throw new PromptbookReferenceError(spaceTrim("\n Promptbook with name \"".concat(promptbook.title, "\" does not have defined URL\n\n Note: Promptbooks without URLs are called anonymous promptbooks\n They can be used as standalone promptbooks, but they cannot be referenced by other promptbooks\n And also they cannot be used in the promptbook library\n\n ")));
|
|
1870
1873
|
}
|
|
1871
|
-
|
|
1874
|
+
validatePromptbook(promptbook);
|
|
1872
1875
|
// Note: [🦄]
|
|
1873
1876
|
if (this.library.has(promptbook.promptbookUrl) &&
|
|
1874
1877
|
promptbookJsonToString(promptbook) !==
|
|
@@ -1922,68 +1925,19 @@ var SimplePromptbookLibrary = /** @class */ (function () {
|
|
|
1922
1925
|
/**
|
|
1923
1926
|
* Creates PromptbookLibrary from array of PromptbookJson or PromptbookString
|
|
1924
1927
|
*
|
|
1925
|
-
* Note:
|
|
1928
|
+
* Note: Functions `libraryToJson` and `createLibraryFromJson` are complementary
|
|
1926
1929
|
* Note: During the construction syntax and logic of all sources are validated
|
|
1927
1930
|
*
|
|
1928
1931
|
* @param promptbookSources
|
|
1929
1932
|
* @returns PromptbookLibrary
|
|
1930
1933
|
*/
|
|
1931
|
-
function
|
|
1932
|
-
var
|
|
1934
|
+
function createLibraryFromJson() {
|
|
1935
|
+
var promptbooks = [];
|
|
1933
1936
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1934
|
-
|
|
1937
|
+
promptbooks[_i] = arguments[_i];
|
|
1935
1938
|
}
|
|
1936
|
-
return
|
|
1937
|
-
var promptbooks, promptbookSources_1, promptbookSources_1_1, source, promptbook, e_1_1;
|
|
1938
|
-
var e_1, _a;
|
|
1939
|
-
return __generator(this, function (_b) {
|
|
1940
|
-
switch (_b.label) {
|
|
1941
|
-
case 0:
|
|
1942
|
-
promptbooks = new Array();
|
|
1943
|
-
_b.label = 1;
|
|
1944
|
-
case 1:
|
|
1945
|
-
_b.trys.push([1, 8, 9, 10]);
|
|
1946
|
-
promptbookSources_1 = __values(promptbookSources), promptbookSources_1_1 = promptbookSources_1.next();
|
|
1947
|
-
_b.label = 2;
|
|
1948
|
-
case 2:
|
|
1949
|
-
if (!!promptbookSources_1_1.done) return [3 /*break*/, 7];
|
|
1950
|
-
source = promptbookSources_1_1.value;
|
|
1951
|
-
promptbook = void 0;
|
|
1952
|
-
if (!(typeof source === 'string')) return [3 /*break*/, 4];
|
|
1953
|
-
return [4 /*yield*/, promptbookStringToJson(source)];
|
|
1954
|
-
case 3:
|
|
1955
|
-
// Note: When directly creating from string, no need to validate the source
|
|
1956
|
-
// The validation is performed always before execution
|
|
1957
|
-
promptbook = _b.sent();
|
|
1958
|
-
return [3 /*break*/, 5];
|
|
1959
|
-
case 4:
|
|
1960
|
-
promptbook = source;
|
|
1961
|
-
_b.label = 5;
|
|
1962
|
-
case 5:
|
|
1963
|
-
promptbooks.push(promptbook);
|
|
1964
|
-
_b.label = 6;
|
|
1965
|
-
case 6:
|
|
1966
|
-
promptbookSources_1_1 = promptbookSources_1.next();
|
|
1967
|
-
return [3 /*break*/, 2];
|
|
1968
|
-
case 7: return [3 /*break*/, 10];
|
|
1969
|
-
case 8:
|
|
1970
|
-
e_1_1 = _b.sent();
|
|
1971
|
-
e_1 = { error: e_1_1 };
|
|
1972
|
-
return [3 /*break*/, 10];
|
|
1973
|
-
case 9:
|
|
1974
|
-
try {
|
|
1975
|
-
if (promptbookSources_1_1 && !promptbookSources_1_1.done && (_a = promptbookSources_1.return)) _a.call(promptbookSources_1);
|
|
1976
|
-
}
|
|
1977
|
-
finally { if (e_1) throw e_1.error; }
|
|
1978
|
-
return [7 /*endfinally*/];
|
|
1979
|
-
case 10: return [2 /*return*/, new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))()];
|
|
1980
|
-
}
|
|
1981
|
-
});
|
|
1982
|
-
});
|
|
1939
|
+
return new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))();
|
|
1983
1940
|
}
|
|
1984
|
-
/**
|
|
1985
|
-
* TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
|
|
1986
|
-
*/
|
|
1987
1941
|
|
|
1988
1942
|
/* tslint:disable */
|
|
1989
1943
|
function normalizeToKebabCase(sentence) {
|
|
@@ -2042,96 +1996,106 @@ function normalizeToKebabCase(sentence) {
|
|
|
2042
1996
|
|
|
2043
1997
|
function prepareKnowledgeFromMarkdown(options) {
|
|
2044
1998
|
return __awaiter(this, void 0, void 0, function () {
|
|
2045
|
-
var content, llmTools, library,
|
|
1999
|
+
var content, llmTools, _a, isVerbose, library, prepareKnowledgeFromMarkdownPromptbook, prepareKnowledgeFromMarkdownExecutor, prepareKeywordsPromptbook, prepareKeywordsExecutor, result, outputParameters, knowledgeRaw, knowledgeTextPieces, knowledge;
|
|
2046
2000
|
var _this = this;
|
|
2047
|
-
return __generator(this, function (
|
|
2048
|
-
switch (
|
|
2001
|
+
return __generator(this, function (_b) {
|
|
2002
|
+
switch (_b.label) {
|
|
2049
2003
|
case 0:
|
|
2050
|
-
content = options.content, llmTools = options.llmTools;
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
title: 'Prepare Knowledge from Markdown',
|
|
2054
|
-
promptbookUrl: 'https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md',
|
|
2055
|
-
promptbookVersion: '0.59.0-5',
|
|
2056
|
-
parameters: [
|
|
2057
|
-
{ name: 'content', description: 'Markdown document content', isInput: true, isOutput: false },
|
|
2058
|
-
{ name: 'knowledge', description: 'The knowledge JSON object', isInput: false, isOutput: true },
|
|
2059
|
-
],
|
|
2060
|
-
promptTemplates: [
|
|
2061
|
-
{
|
|
2062
|
-
name: 'knowledge',
|
|
2063
|
-
title: 'Knowledge',
|
|
2064
|
-
dependentParameterNames: ['content'],
|
|
2065
|
-
executionType: 'PROMPT_TEMPLATE',
|
|
2066
|
-
modelRequirements: { modelVariant: 'CHAT', modelName: 'claude-3-opus-20240229' },
|
|
2067
|
-
content: 'You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {content}',
|
|
2068
|
-
resultingParameterName: 'knowledge',
|
|
2069
|
-
},
|
|
2070
|
-
],
|
|
2071
|
-
knowledge: [],
|
|
2072
|
-
})];
|
|
2004
|
+
content = options.content, llmTools = options.llmTools, _a = options.isVerbose, isVerbose = _a === void 0 ? false : _a;
|
|
2005
|
+
library = createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookLibrary), false));
|
|
2006
|
+
return [4 /*yield*/, library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md')];
|
|
2073
2007
|
case 1:
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
promptbook: promptbook,
|
|
2008
|
+
prepareKnowledgeFromMarkdownPromptbook = _b.sent();
|
|
2009
|
+
prepareKnowledgeFromMarkdownExecutor = createPromptbookExecutor({
|
|
2010
|
+
promptbook: prepareKnowledgeFromMarkdownPromptbook,
|
|
2078
2011
|
tools: {
|
|
2079
2012
|
llm: llmTools,
|
|
2080
2013
|
script: [
|
|
2081
|
-
/* <- TODO: Allow to just
|
|
2014
|
+
/* <- TODO: Allow to just keep script undefined */
|
|
2082
2015
|
],
|
|
2083
2016
|
},
|
|
2084
2017
|
});
|
|
2085
|
-
return [4 /*yield*/,
|
|
2018
|
+
return [4 /*yield*/, library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-keywords.ptbk.md')];
|
|
2086
2019
|
case 2:
|
|
2087
|
-
|
|
2020
|
+
prepareKeywordsPromptbook = _b.sent();
|
|
2021
|
+
prepareKeywordsExecutor = createPromptbookExecutor({
|
|
2022
|
+
promptbook: prepareKeywordsPromptbook,
|
|
2023
|
+
tools: {
|
|
2024
|
+
llm: llmTools,
|
|
2025
|
+
script: [
|
|
2026
|
+
/* <- TODO: Allow to just keep script undefined */
|
|
2027
|
+
],
|
|
2028
|
+
},
|
|
2029
|
+
});
|
|
2030
|
+
return [4 /*yield*/, prepareKnowledgeFromMarkdownExecutor({ content: content })];
|
|
2031
|
+
case 3:
|
|
2032
|
+
result = _b.sent();
|
|
2088
2033
|
assertsExecutionSuccessful(result);
|
|
2089
2034
|
outputParameters = result.outputParameters;
|
|
2090
2035
|
knowledgeRaw = outputParameters.knowledge;
|
|
2091
2036
|
knowledgeTextPieces = (knowledgeRaw || '').split('\n---\n');
|
|
2037
|
+
if (isVerbose) {
|
|
2038
|
+
console.info('knowledgeTextPieces:', knowledgeTextPieces);
|
|
2039
|
+
}
|
|
2092
2040
|
return [4 /*yield*/, Promise.all(knowledgeTextPieces.map(function (knowledgeTextPiece, i) { return __awaiter(_this, void 0, void 0, function () {
|
|
2093
|
-
var name, title, content, keywords, index, sources;
|
|
2094
|
-
return __generator(this, function (
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2041
|
+
var name, title, content, keywords, index, sources, result_1, _a, outputParameters_1, keywordsRaw, error_1;
|
|
2042
|
+
return __generator(this, function (_b) {
|
|
2043
|
+
switch (_b.label) {
|
|
2044
|
+
case 0:
|
|
2045
|
+
name = "piece-".concat(i);
|
|
2046
|
+
title = spaceTrim$1(knowledgeTextPiece.substring(0, 100));
|
|
2047
|
+
content = spaceTrim$1(knowledgeTextPiece);
|
|
2048
|
+
keywords = [];
|
|
2049
|
+
index = [];
|
|
2050
|
+
sources = [];
|
|
2051
|
+
_b.label = 1;
|
|
2052
|
+
case 1:
|
|
2053
|
+
_b.trys.push([1, 3, , 4]);
|
|
2054
|
+
// TODO: !!!! Summarize name and title from the content
|
|
2055
|
+
title = spaceTrim$1(knowledgeTextPiece.substring(0, 30));
|
|
2056
|
+
name = normalizeToKebabCase(title);
|
|
2057
|
+
return [4 /*yield*/, prepareKeywordsExecutor({ content: content })];
|
|
2058
|
+
case 2:
|
|
2059
|
+
result_1 = _b.sent();
|
|
2060
|
+
_a = result_1.outputParameters, outputParameters_1 = _a === void 0 ? {} : _a;
|
|
2061
|
+
keywordsRaw = outputParameters_1.keywords;
|
|
2062
|
+
keywords = (keywordsRaw || '')
|
|
2063
|
+
.split(',')
|
|
2064
|
+
.map(function (keyword) { return keyword.trim(); })
|
|
2065
|
+
.filter(function (keyword) { return keyword !== ''; });
|
|
2066
|
+
if (isVerbose) {
|
|
2067
|
+
console.info("Keywords for \"".concat(title, "\":"), keywords);
|
|
2068
|
+
}
|
|
2069
|
+
// ---
|
|
2070
|
+
// TODO: !!!! Index through LLM model
|
|
2071
|
+
index.push({
|
|
2072
|
+
modelName: 'fake-model',
|
|
2073
|
+
position: new Array(25).fill(0).map(function () { return Math.random() * 2 - 1; }),
|
|
2074
|
+
});
|
|
2075
|
+
return [3 /*break*/, 4];
|
|
2076
|
+
case 3:
|
|
2077
|
+
error_1 = _b.sent();
|
|
2078
|
+
console.error(error_1);
|
|
2079
|
+
return [3 /*break*/, 4];
|
|
2080
|
+
case 4: return [2 /*return*/, {
|
|
2081
|
+
name: name,
|
|
2082
|
+
title: title,
|
|
2083
|
+
content: content,
|
|
2084
|
+
keywords: keywords,
|
|
2085
|
+
index: index,
|
|
2086
|
+
sources: sources,
|
|
2087
|
+
}];
|
|
2111
2088
|
}
|
|
2112
|
-
return [2 /*return*/, {
|
|
2113
|
-
name: name,
|
|
2114
|
-
title: title,
|
|
2115
|
-
content: content,
|
|
2116
|
-
keywords: keywords,
|
|
2117
|
-
index: index,
|
|
2118
|
-
sources: sources,
|
|
2119
|
-
}];
|
|
2120
2089
|
});
|
|
2121
2090
|
}); }))];
|
|
2122
|
-
case
|
|
2123
|
-
knowledge =
|
|
2091
|
+
case 4:
|
|
2092
|
+
knowledge = _b.sent();
|
|
2124
2093
|
return [2 /*return*/, knowledge];
|
|
2125
2094
|
}
|
|
2126
2095
|
});
|
|
2127
2096
|
});
|
|
2128
2097
|
}
|
|
2129
2098
|
|
|
2130
|
-
/**
|
|
2131
|
-
* Supported script languages
|
|
2132
|
-
*/
|
|
2133
|
-
var SUPPORTED_SCRIPT_LANGUAGES = ['javascript', 'typescript', 'python'];
|
|
2134
|
-
|
|
2135
2099
|
/**
|
|
2136
2100
|
* Returns the same value that is passed as argument.
|
|
2137
2101
|
* No side effects.
|
|
@@ -2149,6 +2113,11 @@ function just(value) {
|
|
|
2149
2113
|
return value;
|
|
2150
2114
|
}
|
|
2151
2115
|
|
|
2116
|
+
/**
|
|
2117
|
+
* Supported script languages
|
|
2118
|
+
*/
|
|
2119
|
+
var SUPPORTED_SCRIPT_LANGUAGES = ['javascript', 'typescript', 'python'];
|
|
2120
|
+
|
|
2152
2121
|
/**
|
|
2153
2122
|
* Computes the deepness of the markdown structure.
|
|
2154
2123
|
*
|
|
@@ -2976,9 +2945,279 @@ function titleToName(value) {
|
|
|
2976
2945
|
return value;
|
|
2977
2946
|
}
|
|
2978
2947
|
|
|
2948
|
+
/**
|
|
2949
|
+
* Compile promptbook from string (markdown) format to JSON format synchronously
|
|
2950
|
+
*
|
|
2951
|
+
* Note: There are two similar functions:
|
|
2952
|
+
* - `promptbookStringToJson` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
|
|
2953
|
+
* - `promptbookStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
|
|
2954
|
+
*
|
|
2955
|
+
* @param promptbookString {Promptbook} in string markdown format (.ptbk.md)
|
|
2956
|
+
* @param options - Options and tools for the compilation
|
|
2957
|
+
* @returns {Promptbook} compiled in JSON format (.ptbk.json)
|
|
2958
|
+
* @throws {PromptbookSyntaxError} if the promptbook string is not valid
|
|
2959
|
+
*
|
|
2960
|
+
* Note: This function does not validate logic of the pipeline only the syntax
|
|
2961
|
+
* Note: This function acts as compilation process
|
|
2962
|
+
*/
|
|
2963
|
+
function promptbookStringToJsonSync(promptbookString) {
|
|
2964
|
+
var e_1, _a, e_2, _b;
|
|
2965
|
+
var promptbookJson = {
|
|
2966
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2967
|
+
title: undefined /* <- Note: Putting here placeholder to keep `title` on top at final JSON */,
|
|
2968
|
+
promptbookUrl: undefined /* <- Note: Putting here placeholder to keep `promptbookUrl` on top at final JSON */,
|
|
2969
|
+
promptbookVersion: PROMPTBOOK_VERSION,
|
|
2970
|
+
description: undefined /* <- Note: Putting here placeholder to keep `description` on top at final JSON */,
|
|
2971
|
+
parameters: [],
|
|
2972
|
+
promptTemplates: [],
|
|
2973
|
+
knowledge: [],
|
|
2974
|
+
};
|
|
2975
|
+
// =============================================================
|
|
2976
|
+
// Note: 1️⃣ Normalization of the PROMPTBOOK string
|
|
2977
|
+
promptbookString = removeContentComments(promptbookString);
|
|
2978
|
+
promptbookString = promptbookString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
|
|
2979
|
+
promptbookString = promptbookString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
2980
|
+
// =============================================================
|
|
2981
|
+
///Note: 2️⃣ Function for adding parameters
|
|
2982
|
+
var addParam = function (parameterCommand) {
|
|
2983
|
+
var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
|
|
2984
|
+
var existingParameter = promptbookJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
|
|
2985
|
+
if (existingParameter &&
|
|
2986
|
+
existingParameter.description &&
|
|
2987
|
+
existingParameter.description !== parameterDescription &&
|
|
2988
|
+
parameterDescription) {
|
|
2989
|
+
throw new PromptbookSyntaxError(spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description.\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
|
|
2990
|
+
}
|
|
2991
|
+
if (existingParameter) {
|
|
2992
|
+
if (parameterDescription) {
|
|
2993
|
+
existingParameter.description = parameterDescription;
|
|
2994
|
+
}
|
|
2995
|
+
}
|
|
2996
|
+
else {
|
|
2997
|
+
promptbookJson.parameters.push({
|
|
2998
|
+
name: parameterName,
|
|
2999
|
+
description: parameterDescription || undefined,
|
|
3000
|
+
isInput: isInput,
|
|
3001
|
+
isOutput: isOutput,
|
|
3002
|
+
});
|
|
3003
|
+
}
|
|
3004
|
+
};
|
|
3005
|
+
// =============================================================
|
|
3006
|
+
// Note: 3️⃣ Parse the dynamic part - the template pipeline
|
|
3007
|
+
var markdownStructure = markdownToMarkdownStructure(promptbookString);
|
|
3008
|
+
var markdownStructureDeepness = countMarkdownStructureDeepness(markdownStructure);
|
|
3009
|
+
if (markdownStructureDeepness !== 2) {
|
|
3010
|
+
throw new PromptbookSyntaxError(spaceTrim("\n Invalid markdown structure.\n The markdown must have exactly 2 levels of headings (one top-level section and one section for each template).\n Now it has ".concat(markdownStructureDeepness, " levels of headings.\n ")));
|
|
3011
|
+
}
|
|
3012
|
+
promptbookJson.title = markdownStructure.title;
|
|
3013
|
+
// TODO: [1] DRY description
|
|
3014
|
+
var description = markdownStructure.content;
|
|
3015
|
+
// Note: Remove codeblocks
|
|
3016
|
+
description = description.split(/^```.*^```/gms).join('');
|
|
3017
|
+
//Note: Remove lists and return statement
|
|
3018
|
+
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
3019
|
+
description = spaceTrim(description);
|
|
3020
|
+
if (description === '') {
|
|
3021
|
+
description = undefined;
|
|
3022
|
+
}
|
|
3023
|
+
promptbookJson.description = description;
|
|
3024
|
+
var defaultModelRequirements = {};
|
|
3025
|
+
var listItems = extractAllListItemsFromMarkdown(markdownStructure.content);
|
|
3026
|
+
try {
|
|
3027
|
+
for (var listItems_1 = __values(listItems), listItems_1_1 = listItems_1.next(); !listItems_1_1.done; listItems_1_1 = listItems_1.next()) {
|
|
3028
|
+
var listItem = listItems_1_1.value;
|
|
3029
|
+
var command = parseCommand(listItem);
|
|
3030
|
+
switch (command.type) {
|
|
3031
|
+
case 'PROMPTBOOK_URL':
|
|
3032
|
+
promptbookJson.promptbookUrl = command.promptbookUrl.href;
|
|
3033
|
+
break;
|
|
3034
|
+
case 'PROMPTBOOK_VERSION':
|
|
3035
|
+
promptbookJson.promptbookVersion = command.promptbookVersion;
|
|
3036
|
+
break;
|
|
3037
|
+
case 'MODEL':
|
|
3038
|
+
defaultModelRequirements[command.key] = command.value;
|
|
3039
|
+
break;
|
|
3040
|
+
case 'PARAMETER':
|
|
3041
|
+
addParam(command);
|
|
3042
|
+
break;
|
|
3043
|
+
default:
|
|
3044
|
+
throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the prompt template block"));
|
|
3045
|
+
}
|
|
3046
|
+
}
|
|
3047
|
+
}
|
|
3048
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
3049
|
+
finally {
|
|
3050
|
+
try {
|
|
3051
|
+
if (listItems_1_1 && !listItems_1_1.done && (_a = listItems_1.return)) _a.call(listItems_1);
|
|
3052
|
+
}
|
|
3053
|
+
finally { if (e_1) throw e_1.error; }
|
|
3054
|
+
}
|
|
3055
|
+
var _loop_1 = function (section) {
|
|
3056
|
+
var e_3, _e;
|
|
3057
|
+
// TODO: Parse prompt template description (the content out of the codeblock and lists)
|
|
3058
|
+
var templateModelRequirements = __assign({}, defaultModelRequirements);
|
|
3059
|
+
var listItems_3 = extractAllListItemsFromMarkdown(section.content);
|
|
3060
|
+
var dependentParameterNames = new Set();
|
|
3061
|
+
var executionType = 'PROMPT_TEMPLATE';
|
|
3062
|
+
var jokers = [];
|
|
3063
|
+
var postprocessing = [];
|
|
3064
|
+
var expectAmount = {};
|
|
3065
|
+
var expectFormat = undefined;
|
|
3066
|
+
var isExecutionTypeChanged = false;
|
|
3067
|
+
try {
|
|
3068
|
+
for (var listItems_2 = (e_3 = void 0, __values(listItems_3)), listItems_2_1 = listItems_2.next(); !listItems_2_1.done; listItems_2_1 = listItems_2.next()) {
|
|
3069
|
+
var listItem = listItems_2_1.value;
|
|
3070
|
+
var command = parseCommand(listItem);
|
|
3071
|
+
switch (command.type) {
|
|
3072
|
+
case 'JOKER':
|
|
3073
|
+
jokers.push(command.parameterName);
|
|
3074
|
+
dependentParameterNames.add(command.parameterName);
|
|
3075
|
+
break;
|
|
3076
|
+
case 'EXECUTE':
|
|
3077
|
+
if (isExecutionTypeChanged) {
|
|
3078
|
+
throw new PromptbookSyntaxError('Execution type is already defined in the prompt template. It can be defined only once.');
|
|
3079
|
+
}
|
|
3080
|
+
executionType = command.executionType;
|
|
3081
|
+
isExecutionTypeChanged = true;
|
|
3082
|
+
break;
|
|
3083
|
+
case 'MODEL':
|
|
3084
|
+
templateModelRequirements[command.key] = command.value;
|
|
3085
|
+
break;
|
|
3086
|
+
case 'PARAMETER':
|
|
3087
|
+
// Note: This is just for detecting resulitng parameter name
|
|
3088
|
+
addParam(command);
|
|
3089
|
+
break;
|
|
3090
|
+
case 'POSTPROCESS':
|
|
3091
|
+
postprocessing.push(command.functionName);
|
|
3092
|
+
break;
|
|
3093
|
+
case 'EXPECT_AMOUNT':
|
|
3094
|
+
// eslint-disable-next-line no-case-declarations
|
|
3095
|
+
var unit = command.unit.toLowerCase();
|
|
3096
|
+
expectAmount[unit] = expectAmount[unit] || {};
|
|
3097
|
+
if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
|
|
3098
|
+
if (expectAmount[unit].min !== undefined) {
|
|
3099
|
+
throw new PromptbookSyntaxError("Already defined minumum ".concat(expectAmount[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
|
|
3100
|
+
}
|
|
3101
|
+
expectAmount[unit].min = command.amount;
|
|
3102
|
+
} /* not else */
|
|
3103
|
+
if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
|
|
3104
|
+
if (expectAmount[unit].max !== undefined) {
|
|
3105
|
+
throw new PromptbookSyntaxError("Already defined maximum ".concat(expectAmount[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
|
|
3106
|
+
}
|
|
3107
|
+
expectAmount[unit].max = command.amount;
|
|
3108
|
+
}
|
|
3109
|
+
break;
|
|
3110
|
+
case 'EXPECT_FORMAT':
|
|
3111
|
+
if (expectFormat !== undefined && command.format !== expectFormat) {
|
|
3112
|
+
throw new PromptbookSyntaxError("Expect format is already defined to \"".concat(expectFormat, "\". Now you try to redefine it by \"").concat(command.format, "\"."));
|
|
3113
|
+
}
|
|
3114
|
+
expectFormat = command.format;
|
|
3115
|
+
break;
|
|
3116
|
+
default:
|
|
3117
|
+
throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the promptbook"));
|
|
3118
|
+
}
|
|
3119
|
+
}
|
|
3120
|
+
}
|
|
3121
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
3122
|
+
finally {
|
|
3123
|
+
try {
|
|
3124
|
+
if (listItems_2_1 && !listItems_2_1.done && (_e = listItems_2.return)) _e.call(listItems_2);
|
|
3125
|
+
}
|
|
3126
|
+
finally { if (e_3) throw e_3.error; }
|
|
3127
|
+
}
|
|
3128
|
+
var _f = extractOneBlockFromMarkdown(section.content), language = _f.language, content = _f.content;
|
|
3129
|
+
if (executionType === 'SCRIPT') {
|
|
3130
|
+
if (!language) {
|
|
3131
|
+
throw new PromptbookSyntaxError('You must specify the language of the script in the prompt template');
|
|
3132
|
+
}
|
|
3133
|
+
else if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
|
|
3134
|
+
throw new PromptbookSyntaxError(spaceTrim(function (block) { return "\n Script language ".concat(language, " is not supported.\n\n Supported languages are:\n ").concat(block(SUPPORTED_SCRIPT_LANGUAGES.join(', ')), "\n\n "); }));
|
|
3135
|
+
}
|
|
3136
|
+
}
|
|
3137
|
+
var lastLine = section.content.split('\n').pop();
|
|
3138
|
+
var match = /^->\s*\{(?<resultingParamName>[a-z0-9_]+)\}/im.exec(lastLine);
|
|
3139
|
+
if (!match || match.groups === undefined || match.groups.resultingParamName === undefined) {
|
|
3140
|
+
throw new PromptbookSyntaxError(spaceTrim(function (block) { return "\n Invalid template - each section must end with \"-> {...}\"\n\n Invalid section:\n ".concat(block(
|
|
3141
|
+
// TODO: Show code of invalid sections each time + DRY
|
|
3142
|
+
section.content
|
|
3143
|
+
.split('\n')
|
|
3144
|
+
.map(function (line) { return "> ".concat(line); })
|
|
3145
|
+
.join('\n')), "\n "); }));
|
|
3146
|
+
}
|
|
3147
|
+
var resultingParameterName = match.groups.resultingParamName;
|
|
3148
|
+
// TODO: [1] DRY description
|
|
3149
|
+
var description_1 = section.content;
|
|
3150
|
+
// Note: Remove codeblocks
|
|
3151
|
+
description_1 = description_1.split(/^```.*^```/gms).join('');
|
|
3152
|
+
//Note: Remove lists and return statement
|
|
3153
|
+
description_1 = description_1.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
3154
|
+
description_1 = spaceTrim(description_1);
|
|
3155
|
+
if (description_1 === '') {
|
|
3156
|
+
description_1 = undefined;
|
|
3157
|
+
}
|
|
3158
|
+
if (Object.keys(jokers).length === 0) {
|
|
3159
|
+
jokers = undefined;
|
|
3160
|
+
}
|
|
3161
|
+
if (Object.keys(expectAmount).length === 0) {
|
|
3162
|
+
expectAmount = undefined;
|
|
3163
|
+
}
|
|
3164
|
+
if (Object.keys(postprocessing).length === 0) {
|
|
3165
|
+
postprocessing = undefined;
|
|
3166
|
+
}
|
|
3167
|
+
dependentParameterNames = union(dependentParameterNames, extractParametersFromPromptTemplate(__assign(__assign({}, section), { description: description_1, executionType: executionType, content: content })));
|
|
3168
|
+
if (templateModelRequirements.modelVariant === undefined) {
|
|
3169
|
+
templateModelRequirements.modelVariant = 'CHAT';
|
|
3170
|
+
}
|
|
3171
|
+
var template = {
|
|
3172
|
+
name: titleToName(section.title),
|
|
3173
|
+
title: section.title,
|
|
3174
|
+
description: description_1,
|
|
3175
|
+
dependentParameterNames: Array.from(dependentParameterNames),
|
|
3176
|
+
executionType: executionType,
|
|
3177
|
+
jokers: jokers,
|
|
3178
|
+
postprocessing: postprocessing,
|
|
3179
|
+
expectations: expectAmount,
|
|
3180
|
+
expectFormat: expectFormat,
|
|
3181
|
+
modelRequirements: templateModelRequirements,
|
|
3182
|
+
contentLanguage: executionType === 'SCRIPT' ? language : undefined,
|
|
3183
|
+
content: content,
|
|
3184
|
+
resultingParameterName: resultingParameterName,
|
|
3185
|
+
};
|
|
3186
|
+
if (executionType !== 'PROMPT_TEMPLATE') {
|
|
3187
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3188
|
+
delete template.modelRequirements;
|
|
3189
|
+
}
|
|
3190
|
+
promptbookJson.promptTemplates.push(template);
|
|
3191
|
+
};
|
|
3192
|
+
try {
|
|
3193
|
+
for (var _c = __values(markdownStructure.sections), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
3194
|
+
var section = _d.value;
|
|
3195
|
+
_loop_1(section);
|
|
3196
|
+
}
|
|
3197
|
+
}
|
|
3198
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
3199
|
+
finally {
|
|
3200
|
+
try {
|
|
3201
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
3202
|
+
}
|
|
3203
|
+
finally { if (e_2) throw e_2.error; }
|
|
3204
|
+
}
|
|
3205
|
+
// =============================================================
|
|
3206
|
+
return promptbookJson;
|
|
3207
|
+
}
|
|
3208
|
+
/**
|
|
3209
|
+
* TODO: Report here line/column of error
|
|
3210
|
+
* TODO: Use spaceTrim more effectively
|
|
3211
|
+
* TODO: [🧠] Parameter flags - isInput, isOutput, isInternal
|
|
3212
|
+
*/
|
|
3213
|
+
|
|
2979
3214
|
/**
|
|
2980
3215
|
* Compile promptbook from string (markdown) format to JSON format
|
|
2981
3216
|
*
|
|
3217
|
+
* Note: There are two similar functions:
|
|
3218
|
+
* - `promptbookStringToJson` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
|
|
3219
|
+
* - `promptbookStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
|
|
3220
|
+
*
|
|
2982
3221
|
* @param promptbookString {Promptbook} in string markdown format (.ptbk.md)
|
|
2983
3222
|
* @param options - Options and tools for the compilation
|
|
2984
3223
|
* @returns {Promptbook} compiled in JSON format (.ptbk.json)
|
|
@@ -2990,262 +3229,29 @@ function titleToName(value) {
|
|
|
2990
3229
|
function promptbookStringToJson(promptbookString, options) {
|
|
2991
3230
|
if (options === void 0) { options = {}; }
|
|
2992
3231
|
return __awaiter(this, void 0, void 0, function () {
|
|
2993
|
-
var llmTools,
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
switch (_e.label) {
|
|
3232
|
+
var llmTools, knowledge, promptbookJson;
|
|
3233
|
+
return __generator(this, function (_a) {
|
|
3234
|
+
switch (_a.label) {
|
|
2997
3235
|
case 0:
|
|
2998
3236
|
llmTools = options.llmTools;
|
|
2999
|
-
promptbookJson = {
|
|
3000
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3001
|
-
title: undefined /* <- Note: Putting here placeholder to keep `title` on top at final JSON */,
|
|
3002
|
-
promptbookUrl: undefined /* <- Note: Putting here placeholder to keep `promptbookUrl` on top at final JSON */,
|
|
3003
|
-
promptbookVersion: PROMPTBOOK_VERSION,
|
|
3004
|
-
description: undefined /* <- Note: Putting here placeholder to keep `description` on top at final JSON */,
|
|
3005
|
-
parameters: [],
|
|
3006
|
-
promptTemplates: [],
|
|
3007
|
-
knowledge: [],
|
|
3008
|
-
};
|
|
3009
3237
|
if (!llmTools) return [3 /*break*/, 2];
|
|
3010
3238
|
return [4 /*yield*/, prepareKnowledgeFromMarkdown({
|
|
3011
3239
|
content: 'Roses are red, violets are blue, programmers use Promptbook, users too',
|
|
3012
3240
|
llmTools: llmTools,
|
|
3013
3241
|
})];
|
|
3014
3242
|
case 1:
|
|
3015
|
-
knowledge =
|
|
3243
|
+
knowledge = _a.sent();
|
|
3016
3244
|
console.info('!!!! knowledge', knowledge);
|
|
3017
|
-
|
|
3245
|
+
_a.label = 2;
|
|
3018
3246
|
case 2:
|
|
3019
|
-
|
|
3020
|
-
// Note: 1️⃣ Normalization of the PROMPTBOOK string
|
|
3021
|
-
promptbookString = removeContentComments(promptbookString);
|
|
3022
|
-
promptbookString = promptbookString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
|
|
3023
|
-
promptbookString = promptbookString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
3024
|
-
addParam = function (parameterCommand) {
|
|
3025
|
-
var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
|
|
3026
|
-
var existingParameter = promptbookJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
|
|
3027
|
-
if (existingParameter &&
|
|
3028
|
-
existingParameter.description &&
|
|
3029
|
-
existingParameter.description !== parameterDescription &&
|
|
3030
|
-
parameterDescription) {
|
|
3031
|
-
throw new PromptbookSyntaxError(spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description.\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
|
|
3032
|
-
}
|
|
3033
|
-
if (existingParameter) {
|
|
3034
|
-
if (parameterDescription) {
|
|
3035
|
-
existingParameter.description = parameterDescription;
|
|
3036
|
-
}
|
|
3037
|
-
}
|
|
3038
|
-
else {
|
|
3039
|
-
promptbookJson.parameters.push({
|
|
3040
|
-
name: parameterName,
|
|
3041
|
-
description: parameterDescription || undefined,
|
|
3042
|
-
isInput: isInput,
|
|
3043
|
-
isOutput: isOutput,
|
|
3044
|
-
});
|
|
3045
|
-
}
|
|
3046
|
-
};
|
|
3047
|
-
markdownStructure = markdownToMarkdownStructure(promptbookString);
|
|
3048
|
-
markdownStructureDeepness = countMarkdownStructureDeepness(markdownStructure);
|
|
3049
|
-
if (markdownStructureDeepness !== 2) {
|
|
3050
|
-
throw new PromptbookSyntaxError(spaceTrim("\n Invalid markdown structure.\n The markdown must have exactly 2 levels of headings (one top-level section and one section for each template).\n Now it has ".concat(markdownStructureDeepness, " levels of headings.\n ")));
|
|
3051
|
-
}
|
|
3052
|
-
promptbookJson.title = markdownStructure.title;
|
|
3053
|
-
description = markdownStructure.content;
|
|
3054
|
-
// Note: Remove codeblocks
|
|
3055
|
-
description = description.split(/^```.*^```/gms).join('');
|
|
3056
|
-
//Note: Remove lists and return statement
|
|
3057
|
-
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
3058
|
-
description = spaceTrim(description);
|
|
3059
|
-
if (description === '') {
|
|
3060
|
-
description = undefined;
|
|
3061
|
-
}
|
|
3062
|
-
promptbookJson.description = description;
|
|
3063
|
-
defaultModelRequirements = {};
|
|
3064
|
-
listItems = extractAllListItemsFromMarkdown(markdownStructure.content);
|
|
3065
|
-
try {
|
|
3066
|
-
for (listItems_1 = __values(listItems), listItems_1_1 = listItems_1.next(); !listItems_1_1.done; listItems_1_1 = listItems_1.next()) {
|
|
3067
|
-
listItem = listItems_1_1.value;
|
|
3068
|
-
command = parseCommand(listItem);
|
|
3069
|
-
switch (command.type) {
|
|
3070
|
-
case 'PROMPTBOOK_URL':
|
|
3071
|
-
promptbookJson.promptbookUrl = command.promptbookUrl.href;
|
|
3072
|
-
break;
|
|
3073
|
-
case 'PROMPTBOOK_VERSION':
|
|
3074
|
-
promptbookJson.promptbookVersion = command.promptbookVersion;
|
|
3075
|
-
break;
|
|
3076
|
-
case 'MODEL':
|
|
3077
|
-
defaultModelRequirements[command.key] = command.value;
|
|
3078
|
-
break;
|
|
3079
|
-
case 'PARAMETER':
|
|
3080
|
-
addParam(command);
|
|
3081
|
-
break;
|
|
3082
|
-
default:
|
|
3083
|
-
throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the prompt template block"));
|
|
3084
|
-
}
|
|
3085
|
-
}
|
|
3086
|
-
}
|
|
3087
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
3088
|
-
finally {
|
|
3089
|
-
try {
|
|
3090
|
-
if (listItems_1_1 && !listItems_1_1.done && (_c = listItems_1.return)) _c.call(listItems_1);
|
|
3091
|
-
}
|
|
3092
|
-
finally { if (e_1) throw e_1.error; }
|
|
3093
|
-
}
|
|
3094
|
-
_loop_1 = function (section) {
|
|
3095
|
-
var e_3, _f;
|
|
3096
|
-
// TODO: Parse prompt template description (the content out of the codeblock and lists)
|
|
3097
|
-
var templateModelRequirements = __assign({}, defaultModelRequirements);
|
|
3098
|
-
var listItems_3 = extractAllListItemsFromMarkdown(section.content);
|
|
3099
|
-
var dependentParameterNames = new Set();
|
|
3100
|
-
var executionType = 'PROMPT_TEMPLATE';
|
|
3101
|
-
var jokers = [];
|
|
3102
|
-
var postprocessing = [];
|
|
3103
|
-
var expectAmount = {};
|
|
3104
|
-
var expectFormat = undefined;
|
|
3105
|
-
var isExecutionTypeChanged = false;
|
|
3106
|
-
try {
|
|
3107
|
-
for (var listItems_2 = (e_3 = void 0, __values(listItems_3)), listItems_2_1 = listItems_2.next(); !listItems_2_1.done; listItems_2_1 = listItems_2.next()) {
|
|
3108
|
-
var listItem = listItems_2_1.value;
|
|
3109
|
-
var command = parseCommand(listItem);
|
|
3110
|
-
switch (command.type) {
|
|
3111
|
-
case 'JOKER':
|
|
3112
|
-
jokers.push(command.parameterName);
|
|
3113
|
-
dependentParameterNames.add(command.parameterName);
|
|
3114
|
-
break;
|
|
3115
|
-
case 'EXECUTE':
|
|
3116
|
-
if (isExecutionTypeChanged) {
|
|
3117
|
-
throw new PromptbookSyntaxError('Execution type is already defined in the prompt template. It can be defined only once.');
|
|
3118
|
-
}
|
|
3119
|
-
executionType = command.executionType;
|
|
3120
|
-
isExecutionTypeChanged = true;
|
|
3121
|
-
break;
|
|
3122
|
-
case 'MODEL':
|
|
3123
|
-
templateModelRequirements[command.key] = command.value;
|
|
3124
|
-
break;
|
|
3125
|
-
case 'PARAMETER':
|
|
3126
|
-
// Note: This is just for detecting resulitng parameter name
|
|
3127
|
-
addParam(command);
|
|
3128
|
-
break;
|
|
3129
|
-
case 'POSTPROCESS':
|
|
3130
|
-
postprocessing.push(command.functionName);
|
|
3131
|
-
break;
|
|
3132
|
-
case 'EXPECT_AMOUNT':
|
|
3133
|
-
// eslint-disable-next-line no-case-declarations
|
|
3134
|
-
var unit = command.unit.toLowerCase();
|
|
3135
|
-
expectAmount[unit] = expectAmount[unit] || {};
|
|
3136
|
-
if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
|
|
3137
|
-
if (expectAmount[unit].min !== undefined) {
|
|
3138
|
-
throw new PromptbookSyntaxError("Already defined minumum ".concat(expectAmount[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
|
|
3139
|
-
}
|
|
3140
|
-
expectAmount[unit].min = command.amount;
|
|
3141
|
-
} /* not else */
|
|
3142
|
-
if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
|
|
3143
|
-
if (expectAmount[unit].max !== undefined) {
|
|
3144
|
-
throw new PromptbookSyntaxError("Already defined maximum ".concat(expectAmount[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
|
|
3145
|
-
}
|
|
3146
|
-
expectAmount[unit].max = command.amount;
|
|
3147
|
-
}
|
|
3148
|
-
break;
|
|
3149
|
-
case 'EXPECT_FORMAT':
|
|
3150
|
-
if (expectFormat !== undefined && command.format !== expectFormat) {
|
|
3151
|
-
throw new PromptbookSyntaxError("Expect format is already defined to \"".concat(expectFormat, "\". Now you try to redefine it by \"").concat(command.format, "\"."));
|
|
3152
|
-
}
|
|
3153
|
-
expectFormat = command.format;
|
|
3154
|
-
break;
|
|
3155
|
-
default:
|
|
3156
|
-
throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the promptbook"));
|
|
3157
|
-
}
|
|
3158
|
-
}
|
|
3159
|
-
}
|
|
3160
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
3161
|
-
finally {
|
|
3162
|
-
try {
|
|
3163
|
-
if (listItems_2_1 && !listItems_2_1.done && (_f = listItems_2.return)) _f.call(listItems_2);
|
|
3164
|
-
}
|
|
3165
|
-
finally { if (e_3) throw e_3.error; }
|
|
3166
|
-
}
|
|
3167
|
-
var _g = extractOneBlockFromMarkdown(section.content), language = _g.language, content = _g.content;
|
|
3168
|
-
if (executionType === 'SCRIPT') {
|
|
3169
|
-
if (!language) {
|
|
3170
|
-
throw new PromptbookSyntaxError('You must specify the language of the script in the prompt template');
|
|
3171
|
-
}
|
|
3172
|
-
else if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
|
|
3173
|
-
throw new PromptbookSyntaxError(spaceTrim(function (block) { return "\n Script language ".concat(language, " is not supported.\n\n Supported languages are:\n ").concat(block(SUPPORTED_SCRIPT_LANGUAGES.join(', ')), "\n\n "); }));
|
|
3174
|
-
}
|
|
3175
|
-
}
|
|
3176
|
-
var lastLine = section.content.split('\n').pop();
|
|
3177
|
-
var match = /^->\s*\{(?<resultingParamName>[a-z0-9_]+)\}/im.exec(lastLine);
|
|
3178
|
-
if (!match || match.groups === undefined || match.groups.resultingParamName === undefined) {
|
|
3179
|
-
throw new PromptbookSyntaxError(spaceTrim(function (block) { return "\n Invalid template - each section must end with \"-> {...}\"\n\n Invalid section:\n ".concat(block(
|
|
3180
|
-
// TODO: Show code of invalid sections each time + DRY
|
|
3181
|
-
section.content
|
|
3182
|
-
.split('\n')
|
|
3183
|
-
.map(function (line) { return "> ".concat(line); })
|
|
3184
|
-
.join('\n')), "\n "); }));
|
|
3185
|
-
}
|
|
3186
|
-
var resultingParameterName = match.groups.resultingParamName;
|
|
3187
|
-
// TODO: [1] DRY description
|
|
3188
|
-
var description_1 = section.content;
|
|
3189
|
-
// Note: Remove codeblocks
|
|
3190
|
-
description_1 = description_1.split(/^```.*^```/gms).join('');
|
|
3191
|
-
//Note: Remove lists and return statement
|
|
3192
|
-
description_1 = description_1.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
3193
|
-
description_1 = spaceTrim(description_1);
|
|
3194
|
-
if (description_1 === '') {
|
|
3195
|
-
description_1 = undefined;
|
|
3196
|
-
}
|
|
3197
|
-
if (Object.keys(jokers).length === 0) {
|
|
3198
|
-
jokers = undefined;
|
|
3199
|
-
}
|
|
3200
|
-
if (Object.keys(expectAmount).length === 0) {
|
|
3201
|
-
expectAmount = undefined;
|
|
3202
|
-
}
|
|
3203
|
-
if (Object.keys(postprocessing).length === 0) {
|
|
3204
|
-
postprocessing = undefined;
|
|
3205
|
-
}
|
|
3206
|
-
dependentParameterNames = union(dependentParameterNames, extractParametersFromPromptTemplate(__assign(__assign({}, section), { description: description_1, executionType: executionType, content: content })));
|
|
3207
|
-
if (templateModelRequirements.modelVariant === undefined) {
|
|
3208
|
-
templateModelRequirements.modelVariant = 'CHAT';
|
|
3209
|
-
}
|
|
3210
|
-
promptbookJson.promptTemplates.push({
|
|
3211
|
-
name: titleToName(section.title),
|
|
3212
|
-
title: section.title,
|
|
3213
|
-
description: description_1,
|
|
3214
|
-
dependentParameterNames: Array.from(dependentParameterNames),
|
|
3215
|
-
executionType: executionType,
|
|
3216
|
-
jokers: jokers,
|
|
3217
|
-
postprocessing: postprocessing,
|
|
3218
|
-
expectations: expectAmount,
|
|
3219
|
-
expectFormat: expectFormat,
|
|
3220
|
-
modelRequirements: templateModelRequirements,
|
|
3221
|
-
contentLanguage: executionType === 'SCRIPT' ? language : undefined,
|
|
3222
|
-
content: content,
|
|
3223
|
-
resultingParameterName: resultingParameterName,
|
|
3224
|
-
});
|
|
3225
|
-
};
|
|
3226
|
-
try {
|
|
3227
|
-
for (_a = __values(markdownStructure.sections), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
3228
|
-
section = _b.value;
|
|
3229
|
-
_loop_1(section);
|
|
3230
|
-
}
|
|
3231
|
-
}
|
|
3232
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
3233
|
-
finally {
|
|
3234
|
-
try {
|
|
3235
|
-
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
3236
|
-
}
|
|
3237
|
-
finally { if (e_2) throw e_2.error; }
|
|
3238
|
-
}
|
|
3239
|
-
// =============================================================
|
|
3247
|
+
promptbookJson = promptbookStringToJsonSync(promptbookString);
|
|
3240
3248
|
return [2 /*return*/, promptbookJson];
|
|
3241
3249
|
}
|
|
3242
3250
|
});
|
|
3243
3251
|
});
|
|
3244
3252
|
}
|
|
3245
3253
|
/**
|
|
3246
|
-
* TODO:
|
|
3247
|
-
* TODO: Use spaceTrim more effectively
|
|
3248
|
-
* TODO: [🧠] Parameter flags - isInput, isOutput, isInternal
|
|
3254
|
+
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
3249
3255
|
*/
|
|
3250
3256
|
|
|
3251
3257
|
/* tslint:disable */
|
|
@@ -3372,7 +3378,7 @@ function prettifyPromptbookString(promptbookString, options) {
|
|
|
3372
3378
|
case 0:
|
|
3373
3379
|
isGraphAdded = options.isGraphAdded, isPrettifyed = options.isPrettifyed;
|
|
3374
3380
|
if (!isGraphAdded) return [3 /*break*/, 2];
|
|
3375
|
-
return [4 /*yield*/, promptbookStringToJson(promptbookString
|
|
3381
|
+
return [4 /*yield*/, promptbookStringToJson(promptbookString)];
|
|
3376
3382
|
case 1:
|
|
3377
3383
|
promptbookJson = _a.sent();
|
|
3378
3384
|
promptbookMermaid_1 = renderPromptbookMermaid(promptbookJson, {
|
|
@@ -3414,6 +3420,14 @@ var PromptbookLibraryError = /** @class */ (function (_super) {
|
|
|
3414
3420
|
return PromptbookLibraryError;
|
|
3415
3421
|
}(Error));
|
|
3416
3422
|
|
|
3423
|
+
/**
|
|
3424
|
+
* Pretty print an embedding vector for logging
|
|
3425
|
+
*/
|
|
3426
|
+
function embeddingVectorToString(embeddingVector) {
|
|
3427
|
+
var vectorLength = Math.pow(embeddingVector.reduce(function (acc, val) { return acc + Math.pow(val, 2); }, 0), 0.5);
|
|
3428
|
+
return "[EmbeddingVector; ".concat(embeddingVector.length, " dimensions; length: ").concat(vectorLength.toFixed(2), "; ").concat(embeddingVector.slice(0, 3).join(', '), "...]");
|
|
3429
|
+
}
|
|
3430
|
+
|
|
3417
3431
|
/**
|
|
3418
3432
|
* Function usageToWorktime will take usage and estimate saved worktime in hours of reading / writing
|
|
3419
3433
|
*
|
|
@@ -3494,137 +3508,6 @@ var SimplePromptInterfaceTools = /** @class */ (function () {
|
|
|
3494
3508
|
return SimplePromptInterfaceTools;
|
|
3495
3509
|
}());
|
|
3496
3510
|
|
|
3497
|
-
/**
|
|
3498
|
-
* Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
|
|
3499
|
-
*
|
|
3500
|
-
* @see https://github.com/webgptorg/promptbook#multiple-server
|
|
3501
|
-
*/
|
|
3502
|
-
var MultipleLlmExecutionTools = /** @class */ (function () {
|
|
3503
|
-
/**
|
|
3504
|
-
* Gets array of execution tools in order of priority
|
|
3505
|
-
*/
|
|
3506
|
-
function MultipleLlmExecutionTools() {
|
|
3507
|
-
var llmExecutionTools = [];
|
|
3508
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3509
|
-
llmExecutionTools[_i] = arguments[_i];
|
|
3510
|
-
}
|
|
3511
|
-
this.llmExecutionTools = llmExecutionTools;
|
|
3512
|
-
}
|
|
3513
|
-
/**
|
|
3514
|
-
* Calls the best available chat model
|
|
3515
|
-
*/
|
|
3516
|
-
MultipleLlmExecutionTools.prototype.gptChat = function (prompt) {
|
|
3517
|
-
return this.gptCommon(prompt);
|
|
3518
|
-
};
|
|
3519
|
-
/**
|
|
3520
|
-
* Calls the best available completion model
|
|
3521
|
-
*/
|
|
3522
|
-
MultipleLlmExecutionTools.prototype.gptComplete = function (prompt) {
|
|
3523
|
-
return this.gptCommon(prompt);
|
|
3524
|
-
};
|
|
3525
|
-
/**
|
|
3526
|
-
* Calls the best available model
|
|
3527
|
-
*/
|
|
3528
|
-
MultipleLlmExecutionTools.prototype.gptCommon = function (prompt) {
|
|
3529
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
3530
|
-
var errors, _a, _b, llmExecutionTools, error_1, e_1_1;
|
|
3531
|
-
var e_1, _c;
|
|
3532
|
-
return __generator(this, function (_d) {
|
|
3533
|
-
switch (_d.label) {
|
|
3534
|
-
case 0:
|
|
3535
|
-
errors = [];
|
|
3536
|
-
_d.label = 1;
|
|
3537
|
-
case 1:
|
|
3538
|
-
_d.trys.push([1, 11, 12, 13]);
|
|
3539
|
-
_a = __values(this.llmExecutionTools), _b = _a.next();
|
|
3540
|
-
_d.label = 2;
|
|
3541
|
-
case 2:
|
|
3542
|
-
if (!!_b.done) return [3 /*break*/, 10];
|
|
3543
|
-
llmExecutionTools = _b.value;
|
|
3544
|
-
_d.label = 3;
|
|
3545
|
-
case 3:
|
|
3546
|
-
_d.trys.push([3, 8, , 9]);
|
|
3547
|
-
if (!(prompt.modelRequirements.modelVariant === 'CHAT')) return [3 /*break*/, 5];
|
|
3548
|
-
return [4 /*yield*/, llmExecutionTools.gptChat(prompt)];
|
|
3549
|
-
case 4: return [2 /*return*/, _d.sent()];
|
|
3550
|
-
case 5:
|
|
3551
|
-
if (!(prompt.modelRequirements.modelVariant === 'COMPLETION')) return [3 /*break*/, 7];
|
|
3552
|
-
return [4 /*yield*/, llmExecutionTools.gptComplete(prompt)];
|
|
3553
|
-
case 6: return [2 /*return*/, _d.sent()];
|
|
3554
|
-
case 7: return [3 /*break*/, 9];
|
|
3555
|
-
case 8:
|
|
3556
|
-
error_1 = _d.sent();
|
|
3557
|
-
if (!(error_1 instanceof Error)) {
|
|
3558
|
-
throw error_1;
|
|
3559
|
-
}
|
|
3560
|
-
errors.push(error_1);
|
|
3561
|
-
return [3 /*break*/, 9];
|
|
3562
|
-
case 9:
|
|
3563
|
-
_b = _a.next();
|
|
3564
|
-
return [3 /*break*/, 2];
|
|
3565
|
-
case 10: return [3 /*break*/, 13];
|
|
3566
|
-
case 11:
|
|
3567
|
-
e_1_1 = _d.sent();
|
|
3568
|
-
e_1 = { error: e_1_1 };
|
|
3569
|
-
return [3 /*break*/, 13];
|
|
3570
|
-
case 12:
|
|
3571
|
-
try {
|
|
3572
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
3573
|
-
}
|
|
3574
|
-
finally { if (e_1) throw e_1.error; }
|
|
3575
|
-
return [7 /*endfinally*/];
|
|
3576
|
-
case 13: throw new Error(spaceTrim$1(function (block) { return "\n All execution tools failed:\n \n ".concat(block(errors.map(function (error) { return "- ".concat(error.name || 'Error', ": ").concat(error.message); }).join('\n')), "\n \n "); }));
|
|
3577
|
-
}
|
|
3578
|
-
});
|
|
3579
|
-
});
|
|
3580
|
-
};
|
|
3581
|
-
/**
|
|
3582
|
-
* List all available models that can be used
|
|
3583
|
-
* This liost is a combination of all available models from all execution tools
|
|
3584
|
-
*/
|
|
3585
|
-
MultipleLlmExecutionTools.prototype.listModels = function () {
|
|
3586
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
3587
|
-
var availableModels, _a, _b, llmExecutionTools, models, e_2_1;
|
|
3588
|
-
var e_2, _c;
|
|
3589
|
-
return __generator(this, function (_d) {
|
|
3590
|
-
switch (_d.label) {
|
|
3591
|
-
case 0:
|
|
3592
|
-
availableModels = [];
|
|
3593
|
-
_d.label = 1;
|
|
3594
|
-
case 1:
|
|
3595
|
-
_d.trys.push([1, 6, 7, 8]);
|
|
3596
|
-
_a = __values(this.llmExecutionTools), _b = _a.next();
|
|
3597
|
-
_d.label = 2;
|
|
3598
|
-
case 2:
|
|
3599
|
-
if (!!_b.done) return [3 /*break*/, 5];
|
|
3600
|
-
llmExecutionTools = _b.value;
|
|
3601
|
-
return [4 /*yield*/, llmExecutionTools.listModels()];
|
|
3602
|
-
case 3:
|
|
3603
|
-
models = _d.sent();
|
|
3604
|
-
availableModels.push.apply(availableModels, __spreadArray([], __read(models), false));
|
|
3605
|
-
_d.label = 4;
|
|
3606
|
-
case 4:
|
|
3607
|
-
_b = _a.next();
|
|
3608
|
-
return [3 /*break*/, 2];
|
|
3609
|
-
case 5: return [3 /*break*/, 8];
|
|
3610
|
-
case 6:
|
|
3611
|
-
e_2_1 = _d.sent();
|
|
3612
|
-
e_2 = { error: e_2_1 };
|
|
3613
|
-
return [3 /*break*/, 8];
|
|
3614
|
-
case 7:
|
|
3615
|
-
try {
|
|
3616
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
3617
|
-
}
|
|
3618
|
-
finally { if (e_2) throw e_2.error; }
|
|
3619
|
-
return [7 /*endfinally*/];
|
|
3620
|
-
case 8: return [2 /*return*/, availableModels];
|
|
3621
|
-
}
|
|
3622
|
-
});
|
|
3623
|
-
});
|
|
3624
|
-
};
|
|
3625
|
-
return MultipleLlmExecutionTools;
|
|
3626
|
-
}());
|
|
3627
|
-
|
|
3628
3511
|
/**
|
|
3629
3512
|
* Constructs Promptbook from async sources
|
|
3630
3513
|
* It can be one of the following:
|
|
@@ -3632,19 +3515,19 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
|
|
|
3632
3515
|
* - Factory function that returns Promise of array of PromptbookJson or PromptbookString
|
|
3633
3516
|
*
|
|
3634
3517
|
* Note: This is useful as internal tool for other constructor functions like
|
|
3635
|
-
* `
|
|
3518
|
+
* `createLibraryFromUrl` or `createLibraryFromDirectory`
|
|
3636
3519
|
* Consider using those functions instead of this one
|
|
3637
3520
|
*
|
|
3638
3521
|
* Note: The function does NOT return promise it returns the library directly which waits for the sources to be resolved
|
|
3639
3522
|
* when error occurs in given promise or factory function, it is thrown during `listPromptbooks` or `getPromptbookByUrl` call
|
|
3640
3523
|
*
|
|
3641
|
-
* Note: Consider using `
|
|
3524
|
+
* Note: Consider using `createLibraryFromDirectory` or `createLibraryFromUrl`
|
|
3642
3525
|
*
|
|
3643
3526
|
* @param promptbookSourcesPromiseOrFactory
|
|
3644
3527
|
* @returns PromptbookLibrary
|
|
3645
3528
|
* @deprecated Do not use, it will became internal tool for other constructor functions
|
|
3646
3529
|
*/
|
|
3647
|
-
function
|
|
3530
|
+
function createLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
|
|
3648
3531
|
var library;
|
|
3649
3532
|
function forSources() {
|
|
3650
3533
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -3659,9 +3542,7 @@ function createPromptbookLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
|
|
|
3659
3542
|
return [4 /*yield*/, promptbookSourcesPromiseOrFactory];
|
|
3660
3543
|
case 1:
|
|
3661
3544
|
promptbookSources = _a.sent();
|
|
3662
|
-
|
|
3663
|
-
case 2:
|
|
3664
|
-
library = _a.sent();
|
|
3545
|
+
library = createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookSources), false));
|
|
3665
3546
|
return [2 /*return*/];
|
|
3666
3547
|
}
|
|
3667
3548
|
});
|
|
@@ -3709,16 +3590,13 @@ function createPromptbookLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
|
|
|
3709
3590
|
isResponsibleForPrompt: isResponsibleForPrompt,
|
|
3710
3591
|
};
|
|
3711
3592
|
}
|
|
3712
|
-
/**
|
|
3713
|
-
* TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
|
|
3714
|
-
*/
|
|
3715
3593
|
|
|
3716
3594
|
/**
|
|
3717
3595
|
* Constructs Promptbook from remote Promptbase URL
|
|
3718
3596
|
|
|
3719
3597
|
* @returns PromptbookLibrary
|
|
3720
3598
|
*/
|
|
3721
|
-
function
|
|
3599
|
+
function createLibraryFromUrl(url, options) {
|
|
3722
3600
|
return __awaiter(this, void 0, void 0, function () {
|
|
3723
3601
|
var _a, _b, isVerbose, _c, isLazyLoaded, library;
|
|
3724
3602
|
var _this = this;
|
|
@@ -3726,7 +3604,7 @@ function createPromptbookLibraryFromUrl(url, options) {
|
|
|
3726
3604
|
switch (_d.label) {
|
|
3727
3605
|
case 0:
|
|
3728
3606
|
_a = options || {}, _b = _a.isVerbose, isVerbose = _b === void 0 ? false : _b, _c = _a.isLazyLoaded, isLazyLoaded = _c === void 0 ? false : _c;
|
|
3729
|
-
library =
|
|
3607
|
+
library = createLibraryFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3730
3608
|
return __generator(this, function (_a) {
|
|
3731
3609
|
if (isVerbose) {
|
|
3732
3610
|
console.info("Creating promptbook library from url ".concat(url.toString()));
|
|
@@ -3757,7 +3635,7 @@ function createPromptbookLibraryFromUrl(url, options) {
|
|
|
3757
3635
|
* @param promptbookSources
|
|
3758
3636
|
* @returns PromptbookLibrary
|
|
3759
3637
|
*/
|
|
3760
|
-
function
|
|
3638
|
+
function createSublibrary(library, predicate) {
|
|
3761
3639
|
function listPromptbooks() {
|
|
3762
3640
|
return __awaiter(this, void 0, void 0, function () {
|
|
3763
3641
|
var promptbooks;
|
|
@@ -3827,6 +3705,159 @@ function createPromptbookSublibrary(library, predicate) {
|
|
|
3827
3705
|
};
|
|
3828
3706
|
}
|
|
3829
3707
|
|
|
3708
|
+
/**
|
|
3709
|
+
* Converts PromptbookLibrary to serialized JSON
|
|
3710
|
+
*
|
|
3711
|
+
* Note: Functions `libraryToJson` and `createLibraryFromJson` are complementary
|
|
3712
|
+
*/
|
|
3713
|
+
function libraryToJson(library) {
|
|
3714
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3715
|
+
var promptbookUrls, promptbooks;
|
|
3716
|
+
return __generator(this, function (_a) {
|
|
3717
|
+
switch (_a.label) {
|
|
3718
|
+
case 0: return [4 /*yield*/, library.listPromptbooks()];
|
|
3719
|
+
case 1:
|
|
3720
|
+
promptbookUrls = _a.sent();
|
|
3721
|
+
return [4 /*yield*/, Promise.all(promptbookUrls.map(function (url) { return library.getPromptbookByUrl(url); }))];
|
|
3722
|
+
case 2:
|
|
3723
|
+
promptbooks = _a.sent();
|
|
3724
|
+
return [2 /*return*/, promptbooks];
|
|
3725
|
+
}
|
|
3726
|
+
});
|
|
3727
|
+
});
|
|
3728
|
+
}
|
|
3729
|
+
|
|
3730
|
+
/**
|
|
3731
|
+
* Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
|
|
3732
|
+
*
|
|
3733
|
+
* @see https://github.com/webgptorg/promptbook#multiple-server
|
|
3734
|
+
*/
|
|
3735
|
+
var MultipleLlmExecutionTools = /** @class */ (function () {
|
|
3736
|
+
/**
|
|
3737
|
+
* Gets array of execution tools in order of priority
|
|
3738
|
+
*/
|
|
3739
|
+
function MultipleLlmExecutionTools() {
|
|
3740
|
+
var llmExecutionTools = [];
|
|
3741
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3742
|
+
llmExecutionTools[_i] = arguments[_i];
|
|
3743
|
+
}
|
|
3744
|
+
this.llmExecutionTools = llmExecutionTools;
|
|
3745
|
+
}
|
|
3746
|
+
/**
|
|
3747
|
+
* Calls the best available chat model
|
|
3748
|
+
*/
|
|
3749
|
+
MultipleLlmExecutionTools.prototype.gptChat = function (prompt) {
|
|
3750
|
+
return this.gptCommon(prompt);
|
|
3751
|
+
};
|
|
3752
|
+
/**
|
|
3753
|
+
* Calls the best available completion model
|
|
3754
|
+
*/
|
|
3755
|
+
MultipleLlmExecutionTools.prototype.gptComplete = function (prompt) {
|
|
3756
|
+
return this.gptCommon(prompt);
|
|
3757
|
+
};
|
|
3758
|
+
/**
|
|
3759
|
+
* Calls the best available model
|
|
3760
|
+
*/
|
|
3761
|
+
MultipleLlmExecutionTools.prototype.gptCommon = function (prompt) {
|
|
3762
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3763
|
+
var errors, _a, _b, llmExecutionTools, error_1, e_1_1;
|
|
3764
|
+
var e_1, _c;
|
|
3765
|
+
return __generator(this, function (_d) {
|
|
3766
|
+
switch (_d.label) {
|
|
3767
|
+
case 0:
|
|
3768
|
+
errors = [];
|
|
3769
|
+
_d.label = 1;
|
|
3770
|
+
case 1:
|
|
3771
|
+
_d.trys.push([1, 11, 12, 13]);
|
|
3772
|
+
_a = __values(this.llmExecutionTools), _b = _a.next();
|
|
3773
|
+
_d.label = 2;
|
|
3774
|
+
case 2:
|
|
3775
|
+
if (!!_b.done) return [3 /*break*/, 10];
|
|
3776
|
+
llmExecutionTools = _b.value;
|
|
3777
|
+
_d.label = 3;
|
|
3778
|
+
case 3:
|
|
3779
|
+
_d.trys.push([3, 8, , 9]);
|
|
3780
|
+
if (!(prompt.modelRequirements.modelVariant === 'CHAT')) return [3 /*break*/, 5];
|
|
3781
|
+
return [4 /*yield*/, llmExecutionTools.gptChat(prompt)];
|
|
3782
|
+
case 4: return [2 /*return*/, _d.sent()];
|
|
3783
|
+
case 5:
|
|
3784
|
+
if (!(prompt.modelRequirements.modelVariant === 'COMPLETION')) return [3 /*break*/, 7];
|
|
3785
|
+
return [4 /*yield*/, llmExecutionTools.gptComplete(prompt)];
|
|
3786
|
+
case 6: return [2 /*return*/, _d.sent()];
|
|
3787
|
+
case 7: return [3 /*break*/, 9];
|
|
3788
|
+
case 8:
|
|
3789
|
+
error_1 = _d.sent();
|
|
3790
|
+
if (!(error_1 instanceof Error)) {
|
|
3791
|
+
throw error_1;
|
|
3792
|
+
}
|
|
3793
|
+
errors.push(error_1);
|
|
3794
|
+
return [3 /*break*/, 9];
|
|
3795
|
+
case 9:
|
|
3796
|
+
_b = _a.next();
|
|
3797
|
+
return [3 /*break*/, 2];
|
|
3798
|
+
case 10: return [3 /*break*/, 13];
|
|
3799
|
+
case 11:
|
|
3800
|
+
e_1_1 = _d.sent();
|
|
3801
|
+
e_1 = { error: e_1_1 };
|
|
3802
|
+
return [3 /*break*/, 13];
|
|
3803
|
+
case 12:
|
|
3804
|
+
try {
|
|
3805
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
3806
|
+
}
|
|
3807
|
+
finally { if (e_1) throw e_1.error; }
|
|
3808
|
+
return [7 /*endfinally*/];
|
|
3809
|
+
case 13: throw new Error(spaceTrim$1(function (block) { return "\n All execution tools failed:\n \n ".concat(block(errors.map(function (error) { return "- ".concat(error.name || 'Error', ": ").concat(error.message); }).join('\n')), "\n \n "); }));
|
|
3810
|
+
}
|
|
3811
|
+
});
|
|
3812
|
+
});
|
|
3813
|
+
};
|
|
3814
|
+
/**
|
|
3815
|
+
* List all available models that can be used
|
|
3816
|
+
* This liost is a combination of all available models from all execution tools
|
|
3817
|
+
*/
|
|
3818
|
+
MultipleLlmExecutionTools.prototype.listModels = function () {
|
|
3819
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3820
|
+
var availableModels, _a, _b, llmExecutionTools, models, e_2_1;
|
|
3821
|
+
var e_2, _c;
|
|
3822
|
+
return __generator(this, function (_d) {
|
|
3823
|
+
switch (_d.label) {
|
|
3824
|
+
case 0:
|
|
3825
|
+
availableModels = [];
|
|
3826
|
+
_d.label = 1;
|
|
3827
|
+
case 1:
|
|
3828
|
+
_d.trys.push([1, 6, 7, 8]);
|
|
3829
|
+
_a = __values(this.llmExecutionTools), _b = _a.next();
|
|
3830
|
+
_d.label = 2;
|
|
3831
|
+
case 2:
|
|
3832
|
+
if (!!_b.done) return [3 /*break*/, 5];
|
|
3833
|
+
llmExecutionTools = _b.value;
|
|
3834
|
+
return [4 /*yield*/, llmExecutionTools.listModels()];
|
|
3835
|
+
case 3:
|
|
3836
|
+
models = _d.sent();
|
|
3837
|
+
availableModels.push.apply(availableModels, __spreadArray([], __read(models), false));
|
|
3838
|
+
_d.label = 4;
|
|
3839
|
+
case 4:
|
|
3840
|
+
_b = _a.next();
|
|
3841
|
+
return [3 /*break*/, 2];
|
|
3842
|
+
case 5: return [3 /*break*/, 8];
|
|
3843
|
+
case 6:
|
|
3844
|
+
e_2_1 = _d.sent();
|
|
3845
|
+
e_2 = { error: e_2_1 };
|
|
3846
|
+
return [3 /*break*/, 8];
|
|
3847
|
+
case 7:
|
|
3848
|
+
try {
|
|
3849
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
3850
|
+
}
|
|
3851
|
+
finally { if (e_2) throw e_2.error; }
|
|
3852
|
+
return [7 /*endfinally*/];
|
|
3853
|
+
case 8: return [2 /*return*/, availableModels];
|
|
3854
|
+
}
|
|
3855
|
+
});
|
|
3856
|
+
});
|
|
3857
|
+
};
|
|
3858
|
+
return MultipleLlmExecutionTools;
|
|
3859
|
+
}());
|
|
3860
|
+
|
|
3830
3861
|
/**
|
|
3831
3862
|
* Format either small or big number
|
|
3832
3863
|
*
|
|
@@ -4130,5 +4161,5 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
4130
4161
|
* TODO: [🧠] Allow to filter out some parts of the report by options
|
|
4131
4162
|
*/
|
|
4132
4163
|
|
|
4133
|
-
export { CallbackInterfaceTools, ExecutionReportStringOptionsDefaults, ExecutionTypes, ExpectError, MultipleLlmExecutionTools, PROMPTBOOK_VERSION, PromptbookExecutionError, PromptbookLibraryError, PromptbookLogicError, PromptbookNotFoundError, PromptbookReferenceError, PromptbookSyntaxError, SimplePromptInterfaceTools,
|
|
4164
|
+
export { CallbackInterfaceTools, ExecutionReportStringOptionsDefaults, ExecutionTypes, ExpectError, MultipleLlmExecutionTools, PROMPTBOOK_VERSION, PromptbookExecutionError, PromptbookLibraryError, PromptbookLogicError, PromptbookNotFoundError, PromptbookReferenceError, PromptbookSyntaxError, SimplePromptInterfaceTools, TemplateError, UnexpectedError, addUsage, assertsExecutionSuccessful, checkExpectations, createLibraryFromJson, createLibraryFromPromise, createLibraryFromUrl, createPromptbookExecutor, createSublibrary, embeddingVectorToString, executionReportJsonToString, isPassingExpectations, libraryToJson, prepareKnowledgeFromMarkdown, prettifyPromptbookString, promptbookJsonToString, promptbookStringToJson, promptbookStringToJsonSync, usageToWorktime, validatePromptbook };
|
|
4134
4165
|
//# sourceMappingURL=index.es.js.map
|