@promptbook/node 0.57.2 → 0.59.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.es.js +311 -271
- package/esm/index.es.js.map +1 -1
- package/esm/typings/_packages/anthropic-claude.index.d.ts +2 -2
- package/esm/typings/_packages/azure-openai.index.d.ts +3 -4
- package/esm/typings/_packages/core.index.d.ts +11 -10
- package/esm/typings/_packages/execute-javascript.index.d.ts +2 -2
- package/esm/typings/_packages/fake-llm.index.d.ts +2 -2
- package/esm/typings/_packages/langtail.index.d.ts +3 -4
- package/esm/typings/_packages/node.index.d.ts +1 -1
- package/esm/typings/_packages/openai.index.d.ts +4 -5
- package/esm/typings/_packages/remote-client.index.d.ts +4 -5
- package/esm/typings/_packages/remote-server.index.d.ts +3 -4
- package/esm/typings/_packages/types.index.d.ts +4 -2
- package/esm/typings/_packages/utils.index.d.ts +6 -4
- package/esm/typings/conversion/prettify/prettifyPromptbookString.d.ts +1 -1
- package/esm/typings/conversion/promptbookStringToJson.d.ts +7 -2
- package/esm/typings/execution/ScriptExecutionTools.d.ts +1 -1
- package/esm/typings/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +1 -1
- package/esm/typings/execution/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +1 -1
- package/esm/typings/expectations/drafts/isDomainNameFree.d.ts +6 -0
- package/esm/typings/expectations/drafts/isGithubNameFree.d.ts +6 -0
- package/esm/typings/formats/_common/FormatDefinition.d.ts +69 -0
- package/esm/typings/formats/csv/ListFormatDefinition.d.ts +11 -0
- package/esm/typings/formats/index.d.ts +4 -0
- package/esm/typings/formats/json/JsonFormatDefinition.d.ts +15 -0
- package/esm/typings/formats/list/ListFormatDefinition.d.ts +13 -0
- package/esm/typings/formats/xml/XmlFormatDefinition.d.ts +15 -0
- package/{umd/typings/execution/plugins/user-interface-execution-tools → esm/typings/knowledge/dialogs}/callback/CallbackInterfaceTools.d.ts +2 -2
- package/esm/typings/{execution/plugins/user-interface-execution-tools → knowledge/dialogs}/callback/CallbackInterfaceToolsOptions.d.ts +2 -2
- package/{umd/typings/execution/plugins/user-interface-execution-tools → esm/typings/knowledge/dialogs}/simple-prompt/SimplePromptInterfaceTools.d.ts +4 -4
- package/esm/typings/knowledge/prepare-knowledge/_common/IndexPreparer.d.ts +4 -0
- package/esm/typings/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +7 -0
- package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +6 -6
- package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
- package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/anthropic-claude/anthropic-claude-models.d.ts +2 -2
- package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/azure-openai/AzureOpenAiExecutionTools.d.ts +5 -5
- package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +3 -3
- package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/langtail/LangtailExecutionTools.d.ts +1 -1
- package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/mocked/MockedEchoLlmExecutionTools.d.ts +7 -7
- package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/mocked/MockedFackedLlmExecutionTools.d.ts +7 -7
- package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/fakeTextToExpectations.d.ts +2 -2
- package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/multiple/MultipleLlmExecutionTools.d.ts +5 -5
- package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/multiple/MultipleLlmExecutionToolsOptions.d.ts +3 -3
- package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/openai/OpenAiExecutionTools.d.ts +6 -6
- package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/openai/OpenAiExecutionToolsOptions.d.ts +2 -2
- package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/openai/computeOpenaiUsage.d.ts +3 -3
- package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/openai/openai-models.d.ts +2 -2
- package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/RemoteLlmExecutionTools.d.ts +5 -5
- package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/remote/RemoteLlmExecutionToolsOptions.d.ts +3 -3
- package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/interfaces/Promptbook_Server_Progress.d.ts +1 -1
- package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/remote/interfaces/Promptbook_Server_Request.d.ts +2 -2
- package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/interfaces/Promptbook_Server_Response.d.ts +1 -1
- package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/remote/interfaces/RemoteServerOptions.d.ts +5 -5
- package/esm/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromDirectory.d.ts +3 -0
- package/esm/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromPromise.d.ts +3 -0
- package/esm/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromSources.d.ts +4 -1
- package/esm/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromUrl.d.ts +3 -0
- package/esm/typings/{execution/plugins/script-execution-tools → scripting}/javascript/JavascriptEvalExecutionTools.d.ts +2 -2
- package/esm/typings/{execution/plugins/script-execution-tools → scripting}/javascript/JavascriptExecutionToolsOptions.d.ts +2 -2
- package/esm/typings/scripting/python/PythonExecutionTools.d.ts +16 -0
- package/esm/typings/scripting/typescript/TypescriptExecutionTools.d.ts +16 -0
- package/esm/typings/types/Prompt.d.ts +1 -1
- package/esm/typings/types/PromptbookJson/KnowledgeJson.d.ts +6 -0
- package/esm/typings/types/PromptbookJson/MaterialKnowledgePieceJson.d.ts +27 -0
- package/esm/typings/types/PromptbookJson/PromptbookJson.d.ts +8 -6
- package/package.json +3 -3
- package/umd/index.umd.js +311 -271
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/_packages/anthropic-claude.index.d.ts +2 -2
- package/umd/typings/_packages/azure-openai.index.d.ts +3 -4
- package/umd/typings/_packages/core.index.d.ts +11 -10
- package/umd/typings/_packages/execute-javascript.index.d.ts +2 -2
- package/umd/typings/_packages/fake-llm.index.d.ts +2 -2
- package/umd/typings/_packages/langtail.index.d.ts +3 -4
- package/umd/typings/_packages/node.index.d.ts +1 -1
- package/umd/typings/_packages/openai.index.d.ts +4 -5
- package/umd/typings/_packages/remote-client.index.d.ts +4 -5
- package/umd/typings/_packages/remote-server.index.d.ts +3 -4
- package/umd/typings/_packages/types.index.d.ts +4 -2
- package/umd/typings/_packages/utils.index.d.ts +6 -4
- package/umd/typings/conversion/prettify/prettifyPromptbookString.d.ts +1 -1
- package/umd/typings/conversion/promptbookStringToJson.d.ts +7 -2
- package/umd/typings/execution/ScriptExecutionTools.d.ts +1 -1
- package/umd/typings/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +1 -1
- package/umd/typings/execution/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +1 -1
- package/umd/typings/expectations/drafts/isDomainNameFree.d.ts +6 -0
- package/umd/typings/expectations/drafts/isGithubNameFree.d.ts +6 -0
- package/umd/typings/formats/_common/FormatDefinition.d.ts +69 -0
- package/umd/typings/formats/csv/ListFormatDefinition.d.ts +11 -0
- package/umd/typings/formats/index.d.ts +4 -0
- package/umd/typings/formats/json/JsonFormatDefinition.d.ts +15 -0
- package/umd/typings/formats/list/ListFormatDefinition.d.ts +13 -0
- package/umd/typings/formats/xml/XmlFormatDefinition.d.ts +15 -0
- package/{esm/typings/execution/plugins/user-interface-execution-tools → umd/typings/knowledge/dialogs}/callback/CallbackInterfaceTools.d.ts +2 -2
- package/umd/typings/{execution/plugins/user-interface-execution-tools → knowledge/dialogs}/callback/CallbackInterfaceToolsOptions.d.ts +2 -2
- package/{esm/typings/execution/plugins/user-interface-execution-tools → umd/typings/knowledge/dialogs}/simple-prompt/SimplePromptInterfaceTools.d.ts +4 -4
- package/umd/typings/knowledge/prepare-knowledge/_common/IndexPreparer.d.ts +4 -0
- package/umd/typings/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +7 -0
- package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +6 -6
- package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
- package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/anthropic-claude/anthropic-claude-models.d.ts +2 -2
- package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/azure-openai/AzureOpenAiExecutionTools.d.ts +5 -5
- package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +3 -3
- package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/langtail/LangtailExecutionTools.d.ts +1 -1
- package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/mocked/MockedEchoLlmExecutionTools.d.ts +7 -7
- package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/mocked/MockedFackedLlmExecutionTools.d.ts +7 -7
- package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/fakeTextToExpectations.d.ts +2 -2
- package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/multiple/MultipleLlmExecutionTools.d.ts +5 -5
- package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/multiple/MultipleLlmExecutionToolsOptions.d.ts +3 -3
- package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/openai/OpenAiExecutionTools.d.ts +6 -6
- package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/openai/OpenAiExecutionToolsOptions.d.ts +2 -2
- package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/openai/computeOpenaiUsage.d.ts +3 -3
- package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/openai/openai-models.d.ts +2 -2
- package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/RemoteLlmExecutionTools.d.ts +5 -5
- package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/remote/RemoteLlmExecutionToolsOptions.d.ts +3 -3
- package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/interfaces/Promptbook_Server_Progress.d.ts +1 -1
- package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/remote/interfaces/Promptbook_Server_Request.d.ts +2 -2
- package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/interfaces/Promptbook_Server_Response.d.ts +1 -1
- package/{esm/typings/execution/plugins/llm-execution-tools → umd/typings/llm-providers}/remote/interfaces/RemoteServerOptions.d.ts +5 -5
- package/umd/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromDirectory.d.ts +3 -0
- package/umd/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromPromise.d.ts +3 -0
- package/umd/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromSources.d.ts +4 -1
- package/umd/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromUrl.d.ts +3 -0
- package/umd/typings/scripting/_test/script-execution-errors.test.d.ts +1 -0
- package/umd/typings/scripting/_test/script-execution-tools.test.d.ts +1 -0
- package/umd/typings/{execution/plugins/script-execution-tools → scripting}/javascript/JavascriptEvalExecutionTools.d.ts +2 -2
- package/umd/typings/{execution/plugins/script-execution-tools → scripting}/javascript/JavascriptExecutionToolsOptions.d.ts +2 -2
- package/umd/typings/scripting/python/PythonExecutionTools.d.ts +16 -0
- package/umd/typings/scripting/typescript/TypescriptExecutionTools.d.ts +16 -0
- package/umd/typings/types/Prompt.d.ts +1 -1
- package/umd/typings/types/PromptbookJson/KnowledgeJson.d.ts +6 -0
- package/umd/typings/types/PromptbookJson/MaterialKnowledgePieceJson.d.ts +27 -0
- package/umd/typings/types/PromptbookJson/PromptbookJson.d.ts +8 -6
- package/esm/typings/execution/plugins/script-execution-tools/python/PythonExecutionTools.d.ts +0 -16
- package/esm/typings/execution/plugins/script-execution-tools/typescript/TypescriptExecutionTools.d.ts +0 -16
- package/umd/typings/execution/plugins/script-execution-tools/python/PythonExecutionTools.d.ts +0 -16
- package/umd/typings/execution/plugins/script-execution-tools/typescript/TypescriptExecutionTools.d.ts +0 -16
- /package/esm/typings/{utils → formats/json/utils}/isValidJsonString.d.ts +0 -0
- /package/esm/typings/{utils → formats/json/utils}/isValidJsonString.test.d.ts +0 -0
- /package/esm/typings/{execution/plugins/user-interface-execution-tools → knowledge/dialogs}/user-interface-execution-tools.test.d.ts +0 -0
- /package/esm/typings/{execution/plugins/llm-execution-tools/mocked/fakeTextToExpectations.test.d.ts → knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts} +0 -0
- /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/anthropic-claude/playground/playground.d.ts +0 -0
- /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/azure-openai/playground/playground.d.ts +0 -0
- /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/langtail/LangtailExecutionToolsOptions.d.ts +0 -0
- /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/langtail/playground/playground.d.ts +0 -0
- /package/{umd/typings/execution/plugins/llm-execution-tools → esm/typings/llm-providers}/mocked/fakeTextToExpectations.test.d.ts +0 -0
- /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/faked-completion.test.d.ts +0 -0
- /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/joker.test.d.ts +0 -0
- /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/mocked-chat.test.d.ts +0 -0
- /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/mocked-completion.test.d.ts +0 -0
- /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/multiple/playground/playground.d.ts +0 -0
- /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/openai/computeUsage.d.ts +0 -0
- /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/openai/computeUsage.test.d.ts +0 -0
- /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/openai/playground/playground.d.ts +0 -0
- /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/interfaces/Promptbook_Server_Error.d.ts +0 -0
- /package/esm/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/startRemoteServer.d.ts +0 -0
- /package/esm/typings/{library → promptbook-library}/PromptbookLibrary.d.ts +0 -0
- /package/esm/typings/{library → promptbook-library}/SimplePromptbookLibrary.d.ts +0 -0
- /package/esm/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromDirectory.test.d.ts +0 -0
- /package/esm/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromPromise.test.d.ts +0 -0
- /package/esm/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromSources.test.d.ts +0 -0
- /package/esm/typings/{library → promptbook-library}/constructors/createPromptbookSublibrary.d.ts +0 -0
- /package/esm/typings/{library → promptbook-library}/constructors/justTestFsImport.d.ts +0 -0
- /package/esm/typings/{execution/plugins/script-execution-tools → scripting/_test}/custom-function-async.test.ts.test.d.ts +0 -0
- /package/esm/typings/{execution/plugins/script-execution-tools → scripting/_test}/custom-function-missing.test.d.ts +0 -0
- /package/esm/typings/{execution/plugins/script-execution-tools → scripting/_test}/custom-function-with-dependencies.test.d.ts +0 -0
- /package/esm/typings/{execution/plugins/script-execution-tools → scripting/_test}/custom-function.test.d.ts +0 -0
- /package/esm/typings/{execution/plugins/script-execution-tools → scripting/_test}/postprocessing.test.d.ts +0 -0
- /package/esm/typings/{execution/plugins/script-execution-tools → scripting/_test}/script-execution-errors.test.d.ts +0 -0
- /package/esm/typings/{execution/plugins/script-execution-tools → scripting/_test}/script-execution-tools.test.d.ts +0 -0
- /package/esm/typings/{execution/plugins/script-execution-tools → scripting}/javascript/JavascriptEvalExecutionTools.test.d.ts +0 -0
- /package/esm/typings/{execution/plugins/script-execution-tools → scripting}/javascript/JavascriptExecutionTools.d.ts +0 -0
- /package/esm/typings/{execution/plugins/script-execution-tools → scripting}/javascript/utils/preserve.d.ts +0 -0
- /package/esm/typings/{execution/plugins/script-execution-tools → scripting}/javascript/utils/unknownToString.d.ts +0 -0
- /package/umd/typings/{utils → formats/json/utils}/isValidJsonString.d.ts +0 -0
- /package/umd/typings/{utils → formats/json/utils}/isValidJsonString.test.d.ts +0 -0
- /package/umd/typings/{execution/plugins/user-interface-execution-tools → knowledge/dialogs}/user-interface-execution-tools.test.d.ts +0 -0
- /package/umd/typings/{execution/plugins/llm-execution-tools/mocked/faked-completion.test.d.ts → knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts} +0 -0
- /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/anthropic-claude/playground/playground.d.ts +0 -0
- /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/azure-openai/playground/playground.d.ts +0 -0
- /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/langtail/LangtailExecutionToolsOptions.d.ts +0 -0
- /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/langtail/playground/playground.d.ts +0 -0
- /package/umd/typings/{execution/plugins/llm-execution-tools/openai/computeUsage.test.d.ts → llm-providers/mocked/fakeTextToExpectations.test.d.ts} +0 -0
- /package/umd/typings/{execution/plugins/script-execution-tools/custom-function-async.test.ts.test.d.ts → llm-providers/mocked/faked-completion.test.d.ts} +0 -0
- /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/joker.test.d.ts +0 -0
- /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/mocked-chat.test.d.ts +0 -0
- /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/mocked/mocked-completion.test.d.ts +0 -0
- /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/multiple/playground/playground.d.ts +0 -0
- /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/openai/computeUsage.d.ts +0 -0
- /package/umd/typings/{execution/plugins/script-execution-tools/custom-function-missing.test.d.ts → llm-providers/openai/computeUsage.test.d.ts} +0 -0
- /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/openai/playground/playground.d.ts +0 -0
- /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/interfaces/Promptbook_Server_Error.d.ts +0 -0
- /package/umd/typings/{execution/plugins/llm-execution-tools → llm-providers}/remote/startRemoteServer.d.ts +0 -0
- /package/umd/typings/{library → promptbook-library}/PromptbookLibrary.d.ts +0 -0
- /package/umd/typings/{library → promptbook-library}/SimplePromptbookLibrary.d.ts +0 -0
- /package/umd/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromDirectory.test.d.ts +0 -0
- /package/umd/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromPromise.test.d.ts +0 -0
- /package/umd/typings/{library → promptbook-library}/constructors/createPromptbookLibraryFromSources.test.d.ts +0 -0
- /package/umd/typings/{library → promptbook-library}/constructors/createPromptbookSublibrary.d.ts +0 -0
- /package/umd/typings/{library → promptbook-library}/constructors/justTestFsImport.d.ts +0 -0
- /package/umd/typings/{execution/plugins/script-execution-tools/custom-function-with-dependencies.test.d.ts → scripting/_test/custom-function-async.test.ts.test.d.ts} +0 -0
- /package/umd/typings/{execution/plugins/script-execution-tools/custom-function.test.d.ts → scripting/_test/custom-function-missing.test.d.ts} +0 -0
- /package/umd/typings/{execution/plugins/script-execution-tools/postprocessing.test.d.ts → scripting/_test/custom-function-with-dependencies.test.d.ts} +0 -0
- /package/umd/typings/{execution/plugins/script-execution-tools/script-execution-errors.test.d.ts → scripting/_test/custom-function.test.d.ts} +0 -0
- /package/umd/typings/{execution/plugins/script-execution-tools/script-execution-tools.test.d.ts → scripting/_test/postprocessing.test.d.ts} +0 -0
- /package/umd/typings/{execution/plugins/script-execution-tools → scripting}/javascript/JavascriptEvalExecutionTools.test.d.ts +0 -0
- /package/umd/typings/{execution/plugins/script-execution-tools → scripting}/javascript/JavascriptExecutionTools.d.ts +0 -0
- /package/umd/typings/{execution/plugins/script-execution-tools → scripting}/javascript/utils/preserve.d.ts +0 -0
- /package/umd/typings/{execution/plugins/script-execution-tools → scripting}/javascript/utils/unknownToString.d.ts +0 -0
package/esm/index.es.js
CHANGED
|
@@ -448,7 +448,7 @@ function union() {
|
|
|
448
448
|
/**
|
|
449
449
|
* The version of the Promptbook library
|
|
450
450
|
*/
|
|
451
|
-
var PROMPTBOOK_VERSION = '0.
|
|
451
|
+
var PROMPTBOOK_VERSION = '0.58.0';
|
|
452
452
|
|
|
453
453
|
/**
|
|
454
454
|
* Parses the template and returns the list of all parameter names
|
|
@@ -1319,250 +1319,255 @@ function titleToName(value) {
|
|
|
1319
1319
|
}
|
|
1320
1320
|
|
|
1321
1321
|
/**
|
|
1322
|
-
*
|
|
1322
|
+
* Compile promptbook from string (markdown) format to JSON format
|
|
1323
1323
|
*
|
|
1324
|
+
* @param promptbookString {Promptbook} in string markdown format (.ptbk.md)
|
|
1325
|
+
* @param llmTools {LlmExecutionTools} - tools for processing required for knowledge processing *(not for actual execution)*
|
|
1326
|
+
* @returns {Promptbook} compiled in JSON format (.ptbk.json)
|
|
1324
1327
|
* @throws {PromptbookSyntaxError} if the promptbook string is not valid
|
|
1325
1328
|
*
|
|
1326
1329
|
* Note: This function does not validate logic of the pipeline only the syntax
|
|
1330
|
+
* Note: This function acts as compilation process
|
|
1327
1331
|
*/
|
|
1328
|
-
function promptbookStringToJson(promptbookString) {
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
existingParameter
|
|
1332
|
+
function promptbookStringToJson(promptbookString, llmTools) {
|
|
1333
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1334
|
+
var promptbookJson, addParam, markdownStructure, markdownStructureDeepness, description, defaultModelRequirements, listItems, listItems_1, listItems_1_1, listItem, command, _loop_1, _a, _b, section;
|
|
1335
|
+
var e_1, _c, e_2, _d;
|
|
1336
|
+
return __generator(this, function (_e) {
|
|
1337
|
+
promptbookJson = {
|
|
1338
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1339
|
+
title: undefined /* <- Note: Putting here placeholder to keep `title` on top at final JSON */,
|
|
1340
|
+
promptbookUrl: undefined /* <- Note: Putting here placeholder to keep `promptbookUrl` on top at final JSON */,
|
|
1341
|
+
promptbookVersion: PROMPTBOOK_VERSION,
|
|
1342
|
+
description: undefined /* <- Note: Putting here placeholder to keep `description` on top at final JSON */,
|
|
1343
|
+
parameters: [],
|
|
1344
|
+
promptTemplates: [],
|
|
1345
|
+
knowledge: [],
|
|
1346
|
+
};
|
|
1347
|
+
// =============================================================
|
|
1348
|
+
// Note: 1️⃣ Normalization of the PROMPTBOOK string
|
|
1349
|
+
promptbookString = removeContentComments(promptbookString);
|
|
1350
|
+
promptbookString = promptbookString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
|
|
1351
|
+
promptbookString = promptbookString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
1352
|
+
addParam = function (parameterCommand) {
|
|
1353
|
+
var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
|
|
1354
|
+
var existingParameter = promptbookJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
|
|
1355
|
+
if (existingParameter &&
|
|
1356
|
+
existingParameter.description &&
|
|
1357
|
+
existingParameter.description !== parameterDescription &&
|
|
1358
|
+
parameterDescription) {
|
|
1359
|
+
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 "); }));
|
|
1360
|
+
}
|
|
1361
|
+
if (existingParameter) {
|
|
1362
|
+
if (parameterDescription) {
|
|
1363
|
+
existingParameter.description = parameterDescription;
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
else {
|
|
1367
|
+
promptbookJson.parameters.push({
|
|
1368
|
+
name: parameterName,
|
|
1369
|
+
description: parameterDescription || undefined,
|
|
1370
|
+
isInput: isInput,
|
|
1371
|
+
isOutput: isOutput,
|
|
1372
|
+
});
|
|
1373
|
+
}
|
|
1374
|
+
};
|
|
1375
|
+
markdownStructure = markdownToMarkdownStructure(promptbookString);
|
|
1376
|
+
markdownStructureDeepness = countMarkdownStructureDeepness(markdownStructure);
|
|
1377
|
+
if (markdownStructureDeepness !== 2) {
|
|
1378
|
+
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 ")));
|
|
1358
1379
|
}
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
};
|
|
1369
|
-
// =============================================================
|
|
1370
|
-
// Note: 3️⃣ Parse the dynamic part - the template pipeline
|
|
1371
|
-
var markdownStructure = markdownToMarkdownStructure(promptbookString);
|
|
1372
|
-
var markdownStructureDeepness = countMarkdownStructureDeepness(markdownStructure);
|
|
1373
|
-
if (markdownStructureDeepness !== 2) {
|
|
1374
|
-
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 ")));
|
|
1375
|
-
}
|
|
1376
|
-
promptbookJson.title = markdownStructure.title;
|
|
1377
|
-
// TODO: [1] DRY description
|
|
1378
|
-
var description = markdownStructure.content;
|
|
1379
|
-
// Note: Remove codeblocks
|
|
1380
|
-
description = description.split(/^```.*^```/gms).join('');
|
|
1381
|
-
//Note: Remove lists and return statement
|
|
1382
|
-
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
1383
|
-
description = spaceTrim(description);
|
|
1384
|
-
if (description === '') {
|
|
1385
|
-
description = undefined;
|
|
1386
|
-
}
|
|
1387
|
-
promptbookJson.description = description;
|
|
1388
|
-
var defaultModelRequirements = {};
|
|
1389
|
-
var listItems = extractAllListItemsFromMarkdown(markdownStructure.content);
|
|
1390
|
-
try {
|
|
1391
|
-
for (var listItems_1 = __values(listItems), listItems_1_1 = listItems_1.next(); !listItems_1_1.done; listItems_1_1 = listItems_1.next()) {
|
|
1392
|
-
var listItem = listItems_1_1.value;
|
|
1393
|
-
var command = parseCommand(listItem);
|
|
1394
|
-
switch (command.type) {
|
|
1395
|
-
case 'PROMPTBOOK_URL':
|
|
1396
|
-
promptbookJson.promptbookUrl = command.promptbookUrl.href;
|
|
1397
|
-
break;
|
|
1398
|
-
case 'PROMPTBOOK_VERSION':
|
|
1399
|
-
promptbookJson.promptbookVersion = command.promptbookVersion;
|
|
1400
|
-
break;
|
|
1401
|
-
case 'MODEL':
|
|
1402
|
-
defaultModelRequirements[command.key] = command.value;
|
|
1403
|
-
break;
|
|
1404
|
-
case 'PARAMETER':
|
|
1405
|
-
addParam(command);
|
|
1406
|
-
break;
|
|
1407
|
-
default:
|
|
1408
|
-
throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the prompt template block"));
|
|
1380
|
+
promptbookJson.title = markdownStructure.title;
|
|
1381
|
+
description = markdownStructure.content;
|
|
1382
|
+
// Note: Remove codeblocks
|
|
1383
|
+
description = description.split(/^```.*^```/gms).join('');
|
|
1384
|
+
//Note: Remove lists and return statement
|
|
1385
|
+
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
1386
|
+
description = spaceTrim(description);
|
|
1387
|
+
if (description === '') {
|
|
1388
|
+
description = undefined;
|
|
1409
1389
|
}
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
var listItem = listItems_2_1.value;
|
|
1434
|
-
var command = parseCommand(listItem);
|
|
1435
|
-
switch (command.type) {
|
|
1436
|
-
case 'JOKER':
|
|
1437
|
-
jokers.push(command.parameterName);
|
|
1438
|
-
dependentParameterNames.add(command.parameterName);
|
|
1439
|
-
break;
|
|
1440
|
-
case 'EXECUTE':
|
|
1441
|
-
if (isExecutionTypeChanged) {
|
|
1442
|
-
throw new PromptbookSyntaxError('Execution type is already defined in the prompt template. It can be defined only once.');
|
|
1443
|
-
}
|
|
1444
|
-
executionType = command.executionType;
|
|
1445
|
-
isExecutionTypeChanged = true;
|
|
1446
|
-
break;
|
|
1447
|
-
case 'MODEL':
|
|
1448
|
-
templateModelRequirements[command.key] = command.value;
|
|
1449
|
-
break;
|
|
1450
|
-
case 'PARAMETER':
|
|
1451
|
-
// Note: This is just for detecting resulitng parameter name
|
|
1452
|
-
addParam(command);
|
|
1453
|
-
break;
|
|
1454
|
-
case 'POSTPROCESS':
|
|
1455
|
-
postprocessing.push(command.functionName);
|
|
1456
|
-
break;
|
|
1457
|
-
case 'EXPECT_AMOUNT':
|
|
1458
|
-
// eslint-disable-next-line no-case-declarations
|
|
1459
|
-
var unit = command.unit.toLowerCase();
|
|
1460
|
-
expectAmount[unit] = expectAmount[unit] || {};
|
|
1461
|
-
if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
|
|
1462
|
-
if (expectAmount[unit].min !== undefined) {
|
|
1463
|
-
throw new PromptbookSyntaxError("Already defined minumum ".concat(expectAmount[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
|
|
1464
|
-
}
|
|
1465
|
-
expectAmount[unit].min = command.amount;
|
|
1466
|
-
} /* not else */
|
|
1467
|
-
if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
|
|
1468
|
-
if (expectAmount[unit].max !== undefined) {
|
|
1469
|
-
throw new PromptbookSyntaxError("Already defined maximum ".concat(expectAmount[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
|
|
1470
|
-
}
|
|
1471
|
-
expectAmount[unit].max = command.amount;
|
|
1472
|
-
}
|
|
1473
|
-
break;
|
|
1474
|
-
case 'EXPECT_FORMAT':
|
|
1475
|
-
if (expectFormat !== undefined && command.format !== expectFormat) {
|
|
1476
|
-
throw new PromptbookSyntaxError("Expect format is already defined to \"".concat(expectFormat, "\". Now you try to redefine it by \"").concat(command.format, "\"."));
|
|
1477
|
-
}
|
|
1478
|
-
expectFormat = command.format;
|
|
1479
|
-
break;
|
|
1480
|
-
default:
|
|
1481
|
-
throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the promptbook"));
|
|
1390
|
+
promptbookJson.description = description;
|
|
1391
|
+
defaultModelRequirements = {};
|
|
1392
|
+
listItems = extractAllListItemsFromMarkdown(markdownStructure.content);
|
|
1393
|
+
try {
|
|
1394
|
+
for (listItems_1 = __values(listItems), listItems_1_1 = listItems_1.next(); !listItems_1_1.done; listItems_1_1 = listItems_1.next()) {
|
|
1395
|
+
listItem = listItems_1_1.value;
|
|
1396
|
+
command = parseCommand(listItem);
|
|
1397
|
+
switch (command.type) {
|
|
1398
|
+
case 'PROMPTBOOK_URL':
|
|
1399
|
+
promptbookJson.promptbookUrl = command.promptbookUrl.href;
|
|
1400
|
+
break;
|
|
1401
|
+
case 'PROMPTBOOK_VERSION':
|
|
1402
|
+
promptbookJson.promptbookVersion = command.promptbookVersion;
|
|
1403
|
+
break;
|
|
1404
|
+
case 'MODEL':
|
|
1405
|
+
defaultModelRequirements[command.key] = command.value;
|
|
1406
|
+
break;
|
|
1407
|
+
case 'PARAMETER':
|
|
1408
|
+
addParam(command);
|
|
1409
|
+
break;
|
|
1410
|
+
default:
|
|
1411
|
+
throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the prompt template block"));
|
|
1412
|
+
}
|
|
1482
1413
|
}
|
|
1483
1414
|
}
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1415
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1416
|
+
finally {
|
|
1417
|
+
try {
|
|
1418
|
+
if (listItems_1_1 && !listItems_1_1.done && (_c = listItems_1.return)) _c.call(listItems_1);
|
|
1419
|
+
}
|
|
1420
|
+
finally { if (e_1) throw e_1.error; }
|
|
1489
1421
|
}
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1422
|
+
_loop_1 = function (section) {
|
|
1423
|
+
var e_3, _f;
|
|
1424
|
+
// TODO: Parse prompt template description (the content out of the codeblock and lists)
|
|
1425
|
+
var templateModelRequirements = __assign({}, defaultModelRequirements);
|
|
1426
|
+
var listItems_3 = extractAllListItemsFromMarkdown(section.content);
|
|
1427
|
+
var dependentParameterNames = new Set();
|
|
1428
|
+
var executionType = 'PROMPT_TEMPLATE';
|
|
1429
|
+
var jokers = [];
|
|
1430
|
+
var postprocessing = [];
|
|
1431
|
+
var expectAmount = {};
|
|
1432
|
+
var expectFormat = undefined;
|
|
1433
|
+
var isExecutionTypeChanged = false;
|
|
1434
|
+
try {
|
|
1435
|
+
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()) {
|
|
1436
|
+
var listItem = listItems_2_1.value;
|
|
1437
|
+
var command = parseCommand(listItem);
|
|
1438
|
+
switch (command.type) {
|
|
1439
|
+
case 'JOKER':
|
|
1440
|
+
jokers.push(command.parameterName);
|
|
1441
|
+
dependentParameterNames.add(command.parameterName);
|
|
1442
|
+
break;
|
|
1443
|
+
case 'EXECUTE':
|
|
1444
|
+
if (isExecutionTypeChanged) {
|
|
1445
|
+
throw new PromptbookSyntaxError('Execution type is already defined in the prompt template. It can be defined only once.');
|
|
1446
|
+
}
|
|
1447
|
+
executionType = command.executionType;
|
|
1448
|
+
isExecutionTypeChanged = true;
|
|
1449
|
+
break;
|
|
1450
|
+
case 'MODEL':
|
|
1451
|
+
templateModelRequirements[command.key] = command.value;
|
|
1452
|
+
break;
|
|
1453
|
+
case 'PARAMETER':
|
|
1454
|
+
// Note: This is just for detecting resulitng parameter name
|
|
1455
|
+
addParam(command);
|
|
1456
|
+
break;
|
|
1457
|
+
case 'POSTPROCESS':
|
|
1458
|
+
postprocessing.push(command.functionName);
|
|
1459
|
+
break;
|
|
1460
|
+
case 'EXPECT_AMOUNT':
|
|
1461
|
+
// eslint-disable-next-line no-case-declarations
|
|
1462
|
+
var unit = command.unit.toLowerCase();
|
|
1463
|
+
expectAmount[unit] = expectAmount[unit] || {};
|
|
1464
|
+
if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
|
|
1465
|
+
if (expectAmount[unit].min !== undefined) {
|
|
1466
|
+
throw new PromptbookSyntaxError("Already defined minumum ".concat(expectAmount[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
|
|
1467
|
+
}
|
|
1468
|
+
expectAmount[unit].min = command.amount;
|
|
1469
|
+
} /* not else */
|
|
1470
|
+
if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
|
|
1471
|
+
if (expectAmount[unit].max !== undefined) {
|
|
1472
|
+
throw new PromptbookSyntaxError("Already defined maximum ".concat(expectAmount[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
|
|
1473
|
+
}
|
|
1474
|
+
expectAmount[unit].max = command.amount;
|
|
1475
|
+
}
|
|
1476
|
+
break;
|
|
1477
|
+
case 'EXPECT_FORMAT':
|
|
1478
|
+
if (expectFormat !== undefined && command.format !== expectFormat) {
|
|
1479
|
+
throw new PromptbookSyntaxError("Expect format is already defined to \"".concat(expectFormat, "\". Now you try to redefine it by \"").concat(command.format, "\"."));
|
|
1480
|
+
}
|
|
1481
|
+
expectFormat = command.format;
|
|
1482
|
+
break;
|
|
1483
|
+
default:
|
|
1484
|
+
throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the promptbook"));
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1489
|
+
finally {
|
|
1490
|
+
try {
|
|
1491
|
+
if (listItems_2_1 && !listItems_2_1.done && (_f = listItems_2.return)) _f.call(listItems_2);
|
|
1492
|
+
}
|
|
1493
|
+
finally { if (e_3) throw e_3.error; }
|
|
1494
|
+
}
|
|
1495
|
+
var _g = extractOneBlockFromMarkdown(section.content), language = _g.language, content = _g.content;
|
|
1496
|
+
if (executionType === 'SCRIPT') {
|
|
1497
|
+
if (!language) {
|
|
1498
|
+
throw new PromptbookSyntaxError('You must specify the language of the script in the prompt template');
|
|
1499
|
+
}
|
|
1500
|
+
else if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
|
|
1501
|
+
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 "); }));
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
var lastLine = section.content.split('\n').pop();
|
|
1505
|
+
var match = /^->\s*\{(?<resultingParamName>[a-z0-9_]+)\}/im.exec(lastLine);
|
|
1506
|
+
if (!match || match.groups === undefined || match.groups.resultingParamName === undefined) {
|
|
1507
|
+
throw new PromptbookSyntaxError(spaceTrim(function (block) { return "\n Invalid template - each section must end with \"-> {...}\"\n\n Invalid section:\n ".concat(block(
|
|
1508
|
+
// TODO: Show code of invalid sections each time + DRY
|
|
1509
|
+
section.content
|
|
1510
|
+
.split('\n')
|
|
1511
|
+
.map(function (line) { return "> ".concat(line); })
|
|
1512
|
+
.join('\n')), "\n "); }));
|
|
1513
|
+
}
|
|
1514
|
+
var resultingParameterName = match.groups.resultingParamName;
|
|
1515
|
+
// TODO: [1] DRY description
|
|
1516
|
+
var description_1 = section.content;
|
|
1517
|
+
// Note: Remove codeblocks
|
|
1518
|
+
description_1 = description_1.split(/^```.*^```/gms).join('');
|
|
1519
|
+
//Note: Remove lists and return statement
|
|
1520
|
+
description_1 = description_1.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
1521
|
+
description_1 = spaceTrim(description_1);
|
|
1522
|
+
if (description_1 === '') {
|
|
1523
|
+
description_1 = undefined;
|
|
1524
|
+
}
|
|
1525
|
+
if (Object.keys(jokers).length === 0) {
|
|
1526
|
+
jokers = undefined;
|
|
1527
|
+
}
|
|
1528
|
+
if (Object.keys(expectAmount).length === 0) {
|
|
1529
|
+
expectAmount = undefined;
|
|
1530
|
+
}
|
|
1531
|
+
if (Object.keys(postprocessing).length === 0) {
|
|
1532
|
+
postprocessing = undefined;
|
|
1533
|
+
}
|
|
1534
|
+
dependentParameterNames = union(dependentParameterNames, extractParametersFromPromptTemplate(__assign(__assign({}, section), { description: description_1, executionType: executionType, content: content })));
|
|
1535
|
+
if (templateModelRequirements.modelVariant === undefined) {
|
|
1536
|
+
templateModelRequirements.modelVariant = 'CHAT';
|
|
1537
|
+
}
|
|
1538
|
+
promptbookJson.promptTemplates.push({
|
|
1539
|
+
name: titleToName(section.title),
|
|
1540
|
+
title: section.title,
|
|
1541
|
+
description: description_1,
|
|
1542
|
+
dependentParameterNames: Array.from(dependentParameterNames),
|
|
1543
|
+
executionType: executionType,
|
|
1544
|
+
jokers: jokers,
|
|
1545
|
+
postprocessing: postprocessing,
|
|
1546
|
+
expectations: expectAmount,
|
|
1547
|
+
expectFormat: expectFormat,
|
|
1548
|
+
modelRequirements: templateModelRequirements,
|
|
1549
|
+
contentLanguage: executionType === 'SCRIPT' ? language : undefined,
|
|
1550
|
+
content: content,
|
|
1551
|
+
resultingParameterName: resultingParameterName,
|
|
1552
|
+
});
|
|
1553
|
+
};
|
|
1554
|
+
try {
|
|
1555
|
+
for (_a = __values(markdownStructure.sections), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
1556
|
+
section = _b.value;
|
|
1557
|
+
_loop_1(section);
|
|
1558
|
+
}
|
|
1496
1559
|
}
|
|
1497
|
-
|
|
1498
|
-
|
|
1560
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1561
|
+
finally {
|
|
1562
|
+
try {
|
|
1563
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
1564
|
+
}
|
|
1565
|
+
finally { if (e_2) throw e_2.error; }
|
|
1499
1566
|
}
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
var match = /^->\s*\{(?<resultingParamName>[a-z0-9_]+)\}/im.exec(lastLine);
|
|
1503
|
-
if (!match || match.groups === undefined || match.groups.resultingParamName === undefined) {
|
|
1504
|
-
throw new PromptbookSyntaxError(spaceTrim(function (block) { return "\n Invalid template - each section must end with \"-> {...}\"\n\n Invalid section:\n ".concat(block(
|
|
1505
|
-
// TODO: Show code of invalid sections each time + DRY
|
|
1506
|
-
section.content
|
|
1507
|
-
.split('\n')
|
|
1508
|
-
.map(function (line) { return "> ".concat(line); })
|
|
1509
|
-
.join('\n')), "\n "); }));
|
|
1510
|
-
}
|
|
1511
|
-
var resultingParameterName = match.groups.resultingParamName;
|
|
1512
|
-
// TODO: [1] DRY description
|
|
1513
|
-
var description_1 = section.content;
|
|
1514
|
-
// Note: Remove codeblocks
|
|
1515
|
-
description_1 = description_1.split(/^```.*^```/gms).join('');
|
|
1516
|
-
//Note: Remove lists and return statement
|
|
1517
|
-
description_1 = description_1.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
1518
|
-
description_1 = spaceTrim(description_1);
|
|
1519
|
-
if (description_1 === '') {
|
|
1520
|
-
description_1 = undefined;
|
|
1521
|
-
}
|
|
1522
|
-
if (Object.keys(jokers).length === 0) {
|
|
1523
|
-
jokers = undefined;
|
|
1524
|
-
}
|
|
1525
|
-
if (Object.keys(expectAmount).length === 0) {
|
|
1526
|
-
expectAmount = undefined;
|
|
1527
|
-
}
|
|
1528
|
-
if (Object.keys(postprocessing).length === 0) {
|
|
1529
|
-
postprocessing = undefined;
|
|
1530
|
-
}
|
|
1531
|
-
dependentParameterNames = union(dependentParameterNames, extractParametersFromPromptTemplate(__assign(__assign({}, section), { description: description_1, executionType: executionType, content: content })));
|
|
1532
|
-
if (templateModelRequirements.modelVariant === undefined) {
|
|
1533
|
-
templateModelRequirements.modelVariant = 'CHAT';
|
|
1534
|
-
}
|
|
1535
|
-
promptbookJson.promptTemplates.push({
|
|
1536
|
-
name: titleToName(section.title),
|
|
1537
|
-
title: section.title,
|
|
1538
|
-
description: description_1,
|
|
1539
|
-
dependentParameterNames: Array.from(dependentParameterNames),
|
|
1540
|
-
executionType: executionType,
|
|
1541
|
-
jokers: jokers,
|
|
1542
|
-
postprocessing: postprocessing,
|
|
1543
|
-
expectations: expectAmount,
|
|
1544
|
-
expectFormat: expectFormat,
|
|
1545
|
-
modelRequirements: templateModelRequirements,
|
|
1546
|
-
contentLanguage: executionType === 'SCRIPT' ? language : undefined,
|
|
1547
|
-
content: content,
|
|
1548
|
-
resultingParameterName: resultingParameterName,
|
|
1567
|
+
// =============================================================
|
|
1568
|
+
return [2 /*return*/, promptbookJson];
|
|
1549
1569
|
});
|
|
1550
|
-
};
|
|
1551
|
-
try {
|
|
1552
|
-
for (var _c = __values(markdownStructure.sections), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
1553
|
-
var section = _d.value;
|
|
1554
|
-
_loop_1(section);
|
|
1555
|
-
}
|
|
1556
|
-
}
|
|
1557
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1558
|
-
finally {
|
|
1559
|
-
try {
|
|
1560
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
1561
|
-
}
|
|
1562
|
-
finally { if (e_2) throw e_2.error; }
|
|
1563
|
-
}
|
|
1564
|
-
// =============================================================
|
|
1565
|
-
return promptbookJson;
|
|
1570
|
+
});
|
|
1566
1571
|
}
|
|
1567
1572
|
/**
|
|
1568
1573
|
* TODO: Report here line/column of error
|
|
@@ -2171,36 +2176,61 @@ var SimplePromptbookLibrary = /** @class */ (function () {
|
|
|
2171
2176
|
* @returns PromptbookLibrary
|
|
2172
2177
|
*/
|
|
2173
2178
|
function createPromptbookLibraryFromSources() {
|
|
2174
|
-
var e_1, _a;
|
|
2175
2179
|
var promptbookSources = [];
|
|
2176
2180
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2177
2181
|
promptbookSources[_i] = arguments[_i];
|
|
2178
2182
|
}
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2183
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2184
|
+
var promptbooks, promptbookSources_1, promptbookSources_1_1, source, promptbook, e_1_1;
|
|
2185
|
+
var e_1, _a;
|
|
2186
|
+
return __generator(this, function (_b) {
|
|
2187
|
+
switch (_b.label) {
|
|
2188
|
+
case 0:
|
|
2189
|
+
promptbooks = new Array();
|
|
2190
|
+
_b.label = 1;
|
|
2191
|
+
case 1:
|
|
2192
|
+
_b.trys.push([1, 8, 9, 10]);
|
|
2193
|
+
promptbookSources_1 = __values(promptbookSources), promptbookSources_1_1 = promptbookSources_1.next();
|
|
2194
|
+
_b.label = 2;
|
|
2195
|
+
case 2:
|
|
2196
|
+
if (!!promptbookSources_1_1.done) return [3 /*break*/, 7];
|
|
2197
|
+
source = promptbookSources_1_1.value;
|
|
2198
|
+
promptbook = void 0;
|
|
2199
|
+
if (!(typeof source === 'string')) return [3 /*break*/, 4];
|
|
2200
|
+
return [4 /*yield*/, promptbookStringToJson(source)];
|
|
2201
|
+
case 3:
|
|
2202
|
+
// Note: When directly creating from string, no need to validate the source
|
|
2203
|
+
// The validation is performed always before execution
|
|
2204
|
+
promptbook = _b.sent();
|
|
2205
|
+
return [3 /*break*/, 5];
|
|
2206
|
+
case 4:
|
|
2207
|
+
promptbook = source;
|
|
2208
|
+
_b.label = 5;
|
|
2209
|
+
case 5:
|
|
2210
|
+
promptbooks.push(promptbook);
|
|
2211
|
+
_b.label = 6;
|
|
2212
|
+
case 6:
|
|
2213
|
+
promptbookSources_1_1 = promptbookSources_1.next();
|
|
2214
|
+
return [3 /*break*/, 2];
|
|
2215
|
+
case 7: return [3 /*break*/, 10];
|
|
2216
|
+
case 8:
|
|
2217
|
+
e_1_1 = _b.sent();
|
|
2218
|
+
e_1 = { error: e_1_1 };
|
|
2219
|
+
return [3 /*break*/, 10];
|
|
2220
|
+
case 9:
|
|
2221
|
+
try {
|
|
2222
|
+
if (promptbookSources_1_1 && !promptbookSources_1_1.done && (_a = promptbookSources_1.return)) _a.call(promptbookSources_1);
|
|
2223
|
+
}
|
|
2224
|
+
finally { if (e_1) throw e_1.error; }
|
|
2225
|
+
return [7 /*endfinally*/];
|
|
2226
|
+
case 10: return [2 /*return*/, new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))()];
|
|
2191
2227
|
}
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
}
|
|
2195
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2196
|
-
finally {
|
|
2197
|
-
try {
|
|
2198
|
-
if (promptbookSources_1_1 && !promptbookSources_1_1.done && (_a = promptbookSources_1.return)) _a.call(promptbookSources_1);
|
|
2199
|
-
}
|
|
2200
|
-
finally { if (e_1) throw e_1.error; }
|
|
2201
|
-
}
|
|
2202
|
-
return new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))();
|
|
2228
|
+
});
|
|
2229
|
+
});
|
|
2203
2230
|
}
|
|
2231
|
+
/**
|
|
2232
|
+
* TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
|
|
2233
|
+
*/
|
|
2204
2234
|
|
|
2205
2235
|
/**
|
|
2206
2236
|
* Constructs Promptbook from async sources
|
|
@@ -2236,7 +2266,9 @@ function createPromptbookLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
|
|
|
2236
2266
|
return [4 /*yield*/, promptbookSourcesPromiseOrFactory];
|
|
2237
2267
|
case 1:
|
|
2238
2268
|
promptbookSources = _a.sent();
|
|
2239
|
-
|
|
2269
|
+
return [4 /*yield*/, createPromptbookLibraryFromSources.apply(void 0, __spreadArray([], __read(promptbookSources), false))];
|
|
2270
|
+
case 2:
|
|
2271
|
+
library = _a.sent();
|
|
2240
2272
|
return [2 /*return*/];
|
|
2241
2273
|
}
|
|
2242
2274
|
});
|
|
@@ -2284,6 +2316,9 @@ function createPromptbookLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
|
|
|
2284
2316
|
isResponsibleForPrompt: isResponsibleForPrompt,
|
|
2285
2317
|
};
|
|
2286
2318
|
}
|
|
2319
|
+
/**
|
|
2320
|
+
* TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
|
|
2321
|
+
*/
|
|
2287
2322
|
|
|
2288
2323
|
/**
|
|
2289
2324
|
* Constructs Promptbook from given directory
|
|
@@ -2326,31 +2361,33 @@ function createPromptbookLibraryFromDirectory(path, options) {
|
|
|
2326
2361
|
return __generator(this, function (_e) {
|
|
2327
2362
|
switch (_e.label) {
|
|
2328
2363
|
case 0:
|
|
2329
|
-
_e.trys.push([0,
|
|
2364
|
+
_e.trys.push([0, 7, , 8]);
|
|
2330
2365
|
promptbook = null;
|
|
2331
|
-
if (!fileName.endsWith('.ptbk.md')) return [3 /*break*/,
|
|
2366
|
+
if (!fileName.endsWith('.ptbk.md')) return [3 /*break*/, 3];
|
|
2332
2367
|
return [4 /*yield*/, readFile(fileName, 'utf8')];
|
|
2333
2368
|
case 1:
|
|
2334
2369
|
promptbookString = (_e.sent());
|
|
2335
|
-
|
|
2336
|
-
return [3 /*break*/, 5];
|
|
2370
|
+
return [4 /*yield*/, promptbookStringToJson(promptbookString)];
|
|
2337
2371
|
case 2:
|
|
2338
|
-
|
|
2372
|
+
promptbook = _e.sent();
|
|
2373
|
+
return [3 /*break*/, 6];
|
|
2374
|
+
case 3:
|
|
2375
|
+
if (!fileName.endsWith('.ptbk.json')) return [3 /*break*/, 5];
|
|
2339
2376
|
if (isVerbose) {
|
|
2340
2377
|
console.info("Loading ".concat(fileName));
|
|
2341
2378
|
}
|
|
2342
2379
|
_d = (_c = JSON).parse;
|
|
2343
2380
|
return [4 /*yield*/, readFile(fileName, 'utf8')];
|
|
2344
|
-
case
|
|
2381
|
+
case 4:
|
|
2345
2382
|
// TODO: Handle non-valid JSON files
|
|
2346
2383
|
promptbook = _d.apply(_c, [_e.sent()]);
|
|
2347
|
-
return [3 /*break*/,
|
|
2348
|
-
case
|
|
2384
|
+
return [3 /*break*/, 6];
|
|
2385
|
+
case 5:
|
|
2349
2386
|
if (isVerbose) {
|
|
2350
2387
|
console.info("Skipping file ".concat(fileName));
|
|
2351
2388
|
}
|
|
2352
|
-
_e.label =
|
|
2353
|
-
case
|
|
2389
|
+
_e.label = 6;
|
|
2390
|
+
case 6:
|
|
2354
2391
|
// ---
|
|
2355
2392
|
if (promptbook !== null) {
|
|
2356
2393
|
if (!promptbook.promptbookUrl) {
|
|
@@ -2371,8 +2408,8 @@ function createPromptbookLibraryFromDirectory(path, options) {
|
|
|
2371
2408
|
promptbooks.push(promptbook);
|
|
2372
2409
|
}
|
|
2373
2410
|
}
|
|
2374
|
-
return [3 /*break*/,
|
|
2375
|
-
case
|
|
2411
|
+
return [3 /*break*/, 8];
|
|
2412
|
+
case 7:
|
|
2376
2413
|
error_1 = _e.sent();
|
|
2377
2414
|
if (!(error_1 instanceof Error)) {
|
|
2378
2415
|
throw error_1;
|
|
@@ -2382,8 +2419,8 @@ function createPromptbookLibraryFromDirectory(path, options) {
|
|
|
2382
2419
|
throw new PromptbookLibraryError(wrappedErrorMessage);
|
|
2383
2420
|
}
|
|
2384
2421
|
console.error(wrappedErrorMessage);
|
|
2385
|
-
return [3 /*break*/,
|
|
2386
|
-
case
|
|
2422
|
+
return [3 /*break*/, 8];
|
|
2423
|
+
case 8: return [2 /*return*/];
|
|
2387
2424
|
}
|
|
2388
2425
|
});
|
|
2389
2426
|
};
|
|
@@ -2486,6 +2523,9 @@ function listAllFiles(path, isRecursive) {
|
|
|
2486
2523
|
});
|
|
2487
2524
|
});
|
|
2488
2525
|
}
|
|
2526
|
+
/**
|
|
2527
|
+
* TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
|
|
2528
|
+
*/
|
|
2489
2529
|
|
|
2490
2530
|
export { PROMPTBOOK_VERSION, createPromptbookLibraryFromDirectory };
|
|
2491
2531
|
//# sourceMappingURL=index.es.js.map
|