@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/umd/index.umd.js
CHANGED
|
@@ -453,7 +453,7 @@
|
|
|
453
453
|
/**
|
|
454
454
|
* The version of the Promptbook library
|
|
455
455
|
*/
|
|
456
|
-
var PROMPTBOOK_VERSION = '0.
|
|
456
|
+
var PROMPTBOOK_VERSION = '0.58.0';
|
|
457
457
|
|
|
458
458
|
/**
|
|
459
459
|
* Parses the template and returns the list of all parameter names
|
|
@@ -1324,250 +1324,255 @@
|
|
|
1324
1324
|
}
|
|
1325
1325
|
|
|
1326
1326
|
/**
|
|
1327
|
-
*
|
|
1327
|
+
* Compile promptbook from string (markdown) format to JSON format
|
|
1328
1328
|
*
|
|
1329
|
+
* @param promptbookString {Promptbook} in string markdown format (.ptbk.md)
|
|
1330
|
+
* @param llmTools {LlmExecutionTools} - tools for processing required for knowledge processing *(not for actual execution)*
|
|
1331
|
+
* @returns {Promptbook} compiled in JSON format (.ptbk.json)
|
|
1329
1332
|
* @throws {PromptbookSyntaxError} if the promptbook string is not valid
|
|
1330
1333
|
*
|
|
1331
1334
|
* Note: This function does not validate logic of the pipeline only the syntax
|
|
1335
|
+
* Note: This function acts as compilation process
|
|
1332
1336
|
*/
|
|
1333
|
-
function promptbookStringToJson(promptbookString) {
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
existingParameter
|
|
1337
|
+
function promptbookStringToJson(promptbookString, llmTools) {
|
|
1338
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1339
|
+
var promptbookJson, addParam, markdownStructure, markdownStructureDeepness, description, defaultModelRequirements, listItems, listItems_1, listItems_1_1, listItem, command, _loop_1, _a, _b, section;
|
|
1340
|
+
var e_1, _c, e_2, _d;
|
|
1341
|
+
return __generator(this, function (_e) {
|
|
1342
|
+
promptbookJson = {
|
|
1343
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1344
|
+
title: undefined /* <- Note: Putting here placeholder to keep `title` on top at final JSON */,
|
|
1345
|
+
promptbookUrl: undefined /* <- Note: Putting here placeholder to keep `promptbookUrl` on top at final JSON */,
|
|
1346
|
+
promptbookVersion: PROMPTBOOK_VERSION,
|
|
1347
|
+
description: undefined /* <- Note: Putting here placeholder to keep `description` on top at final JSON */,
|
|
1348
|
+
parameters: [],
|
|
1349
|
+
promptTemplates: [],
|
|
1350
|
+
knowledge: [],
|
|
1351
|
+
};
|
|
1352
|
+
// =============================================================
|
|
1353
|
+
// Note: 1️⃣ Normalization of the PROMPTBOOK string
|
|
1354
|
+
promptbookString = removeContentComments(promptbookString);
|
|
1355
|
+
promptbookString = promptbookString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
|
|
1356
|
+
promptbookString = promptbookString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
1357
|
+
addParam = function (parameterCommand) {
|
|
1358
|
+
var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
|
|
1359
|
+
var existingParameter = promptbookJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
|
|
1360
|
+
if (existingParameter &&
|
|
1361
|
+
existingParameter.description &&
|
|
1362
|
+
existingParameter.description !== parameterDescription &&
|
|
1363
|
+
parameterDescription) {
|
|
1364
|
+
throw new PromptbookSyntaxError(spaceTrim.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 "); }));
|
|
1365
|
+
}
|
|
1366
|
+
if (existingParameter) {
|
|
1367
|
+
if (parameterDescription) {
|
|
1368
|
+
existingParameter.description = parameterDescription;
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
else {
|
|
1372
|
+
promptbookJson.parameters.push({
|
|
1373
|
+
name: parameterName,
|
|
1374
|
+
description: parameterDescription || undefined,
|
|
1375
|
+
isInput: isInput,
|
|
1376
|
+
isOutput: isOutput,
|
|
1377
|
+
});
|
|
1378
|
+
}
|
|
1379
|
+
};
|
|
1380
|
+
markdownStructure = markdownToMarkdownStructure(promptbookString);
|
|
1381
|
+
markdownStructureDeepness = countMarkdownStructureDeepness(markdownStructure);
|
|
1382
|
+
if (markdownStructureDeepness !== 2) {
|
|
1383
|
+
throw new PromptbookSyntaxError(spaceTrim.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 ")));
|
|
1363
1384
|
}
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
};
|
|
1374
|
-
// =============================================================
|
|
1375
|
-
// Note: 3️⃣ Parse the dynamic part - the template pipeline
|
|
1376
|
-
var markdownStructure = markdownToMarkdownStructure(promptbookString);
|
|
1377
|
-
var markdownStructureDeepness = countMarkdownStructureDeepness(markdownStructure);
|
|
1378
|
-
if (markdownStructureDeepness !== 2) {
|
|
1379
|
-
throw new PromptbookSyntaxError(spaceTrim.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 ")));
|
|
1380
|
-
}
|
|
1381
|
-
promptbookJson.title = markdownStructure.title;
|
|
1382
|
-
// TODO: [1] DRY description
|
|
1383
|
-
var description = markdownStructure.content;
|
|
1384
|
-
// Note: Remove codeblocks
|
|
1385
|
-
description = description.split(/^```.*^```/gms).join('');
|
|
1386
|
-
//Note: Remove lists and return statement
|
|
1387
|
-
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
1388
|
-
description = spaceTrim.spaceTrim(description);
|
|
1389
|
-
if (description === '') {
|
|
1390
|
-
description = undefined;
|
|
1391
|
-
}
|
|
1392
|
-
promptbookJson.description = description;
|
|
1393
|
-
var defaultModelRequirements = {};
|
|
1394
|
-
var listItems = extractAllListItemsFromMarkdown(markdownStructure.content);
|
|
1395
|
-
try {
|
|
1396
|
-
for (var listItems_1 = __values(listItems), listItems_1_1 = listItems_1.next(); !listItems_1_1.done; listItems_1_1 = listItems_1.next()) {
|
|
1397
|
-
var listItem = listItems_1_1.value;
|
|
1398
|
-
var command = parseCommand(listItem);
|
|
1399
|
-
switch (command.type) {
|
|
1400
|
-
case 'PROMPTBOOK_URL':
|
|
1401
|
-
promptbookJson.promptbookUrl = command.promptbookUrl.href;
|
|
1402
|
-
break;
|
|
1403
|
-
case 'PROMPTBOOK_VERSION':
|
|
1404
|
-
promptbookJson.promptbookVersion = command.promptbookVersion;
|
|
1405
|
-
break;
|
|
1406
|
-
case 'MODEL':
|
|
1407
|
-
defaultModelRequirements[command.key] = command.value;
|
|
1408
|
-
break;
|
|
1409
|
-
case 'PARAMETER':
|
|
1410
|
-
addParam(command);
|
|
1411
|
-
break;
|
|
1412
|
-
default:
|
|
1413
|
-
throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the prompt template block"));
|
|
1385
|
+
promptbookJson.title = markdownStructure.title;
|
|
1386
|
+
description = markdownStructure.content;
|
|
1387
|
+
// Note: Remove codeblocks
|
|
1388
|
+
description = description.split(/^```.*^```/gms).join('');
|
|
1389
|
+
//Note: Remove lists and return statement
|
|
1390
|
+
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
1391
|
+
description = spaceTrim.spaceTrim(description);
|
|
1392
|
+
if (description === '') {
|
|
1393
|
+
description = undefined;
|
|
1414
1394
|
}
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
var listItem = listItems_2_1.value;
|
|
1439
|
-
var command = parseCommand(listItem);
|
|
1440
|
-
switch (command.type) {
|
|
1441
|
-
case 'JOKER':
|
|
1442
|
-
jokers.push(command.parameterName);
|
|
1443
|
-
dependentParameterNames.add(command.parameterName);
|
|
1444
|
-
break;
|
|
1445
|
-
case 'EXECUTE':
|
|
1446
|
-
if (isExecutionTypeChanged) {
|
|
1447
|
-
throw new PromptbookSyntaxError('Execution type is already defined in the prompt template. It can be defined only once.');
|
|
1448
|
-
}
|
|
1449
|
-
executionType = command.executionType;
|
|
1450
|
-
isExecutionTypeChanged = true;
|
|
1451
|
-
break;
|
|
1452
|
-
case 'MODEL':
|
|
1453
|
-
templateModelRequirements[command.key] = command.value;
|
|
1454
|
-
break;
|
|
1455
|
-
case 'PARAMETER':
|
|
1456
|
-
// Note: This is just for detecting resulitng parameter name
|
|
1457
|
-
addParam(command);
|
|
1458
|
-
break;
|
|
1459
|
-
case 'POSTPROCESS':
|
|
1460
|
-
postprocessing.push(command.functionName);
|
|
1461
|
-
break;
|
|
1462
|
-
case 'EXPECT_AMOUNT':
|
|
1463
|
-
// eslint-disable-next-line no-case-declarations
|
|
1464
|
-
var unit = command.unit.toLowerCase();
|
|
1465
|
-
expectAmount[unit] = expectAmount[unit] || {};
|
|
1466
|
-
if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
|
|
1467
|
-
if (expectAmount[unit].min !== undefined) {
|
|
1468
|
-
throw new PromptbookSyntaxError("Already defined minumum ".concat(expectAmount[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
|
|
1469
|
-
}
|
|
1470
|
-
expectAmount[unit].min = command.amount;
|
|
1471
|
-
} /* not else */
|
|
1472
|
-
if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
|
|
1473
|
-
if (expectAmount[unit].max !== undefined) {
|
|
1474
|
-
throw new PromptbookSyntaxError("Already defined maximum ".concat(expectAmount[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
|
|
1475
|
-
}
|
|
1476
|
-
expectAmount[unit].max = command.amount;
|
|
1477
|
-
}
|
|
1478
|
-
break;
|
|
1479
|
-
case 'EXPECT_FORMAT':
|
|
1480
|
-
if (expectFormat !== undefined && command.format !== expectFormat) {
|
|
1481
|
-
throw new PromptbookSyntaxError("Expect format is already defined to \"".concat(expectFormat, "\". Now you try to redefine it by \"").concat(command.format, "\"."));
|
|
1482
|
-
}
|
|
1483
|
-
expectFormat = command.format;
|
|
1484
|
-
break;
|
|
1485
|
-
default:
|
|
1486
|
-
throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the promptbook"));
|
|
1395
|
+
promptbookJson.description = description;
|
|
1396
|
+
defaultModelRequirements = {};
|
|
1397
|
+
listItems = extractAllListItemsFromMarkdown(markdownStructure.content);
|
|
1398
|
+
try {
|
|
1399
|
+
for (listItems_1 = __values(listItems), listItems_1_1 = listItems_1.next(); !listItems_1_1.done; listItems_1_1 = listItems_1.next()) {
|
|
1400
|
+
listItem = listItems_1_1.value;
|
|
1401
|
+
command = parseCommand(listItem);
|
|
1402
|
+
switch (command.type) {
|
|
1403
|
+
case 'PROMPTBOOK_URL':
|
|
1404
|
+
promptbookJson.promptbookUrl = command.promptbookUrl.href;
|
|
1405
|
+
break;
|
|
1406
|
+
case 'PROMPTBOOK_VERSION':
|
|
1407
|
+
promptbookJson.promptbookVersion = command.promptbookVersion;
|
|
1408
|
+
break;
|
|
1409
|
+
case 'MODEL':
|
|
1410
|
+
defaultModelRequirements[command.key] = command.value;
|
|
1411
|
+
break;
|
|
1412
|
+
case 'PARAMETER':
|
|
1413
|
+
addParam(command);
|
|
1414
|
+
break;
|
|
1415
|
+
default:
|
|
1416
|
+
throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the prompt template block"));
|
|
1417
|
+
}
|
|
1487
1418
|
}
|
|
1488
1419
|
}
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1420
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1421
|
+
finally {
|
|
1422
|
+
try {
|
|
1423
|
+
if (listItems_1_1 && !listItems_1_1.done && (_c = listItems_1.return)) _c.call(listItems_1);
|
|
1424
|
+
}
|
|
1425
|
+
finally { if (e_1) throw e_1.error; }
|
|
1494
1426
|
}
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1427
|
+
_loop_1 = function (section) {
|
|
1428
|
+
var e_3, _f;
|
|
1429
|
+
// TODO: Parse prompt template description (the content out of the codeblock and lists)
|
|
1430
|
+
var templateModelRequirements = __assign({}, defaultModelRequirements);
|
|
1431
|
+
var listItems_3 = extractAllListItemsFromMarkdown(section.content);
|
|
1432
|
+
var dependentParameterNames = new Set();
|
|
1433
|
+
var executionType = 'PROMPT_TEMPLATE';
|
|
1434
|
+
var jokers = [];
|
|
1435
|
+
var postprocessing = [];
|
|
1436
|
+
var expectAmount = {};
|
|
1437
|
+
var expectFormat = undefined;
|
|
1438
|
+
var isExecutionTypeChanged = false;
|
|
1439
|
+
try {
|
|
1440
|
+
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()) {
|
|
1441
|
+
var listItem = listItems_2_1.value;
|
|
1442
|
+
var command = parseCommand(listItem);
|
|
1443
|
+
switch (command.type) {
|
|
1444
|
+
case 'JOKER':
|
|
1445
|
+
jokers.push(command.parameterName);
|
|
1446
|
+
dependentParameterNames.add(command.parameterName);
|
|
1447
|
+
break;
|
|
1448
|
+
case 'EXECUTE':
|
|
1449
|
+
if (isExecutionTypeChanged) {
|
|
1450
|
+
throw new PromptbookSyntaxError('Execution type is already defined in the prompt template. It can be defined only once.');
|
|
1451
|
+
}
|
|
1452
|
+
executionType = command.executionType;
|
|
1453
|
+
isExecutionTypeChanged = true;
|
|
1454
|
+
break;
|
|
1455
|
+
case 'MODEL':
|
|
1456
|
+
templateModelRequirements[command.key] = command.value;
|
|
1457
|
+
break;
|
|
1458
|
+
case 'PARAMETER':
|
|
1459
|
+
// Note: This is just for detecting resulitng parameter name
|
|
1460
|
+
addParam(command);
|
|
1461
|
+
break;
|
|
1462
|
+
case 'POSTPROCESS':
|
|
1463
|
+
postprocessing.push(command.functionName);
|
|
1464
|
+
break;
|
|
1465
|
+
case 'EXPECT_AMOUNT':
|
|
1466
|
+
// eslint-disable-next-line no-case-declarations
|
|
1467
|
+
var unit = command.unit.toLowerCase();
|
|
1468
|
+
expectAmount[unit] = expectAmount[unit] || {};
|
|
1469
|
+
if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
|
|
1470
|
+
if (expectAmount[unit].min !== undefined) {
|
|
1471
|
+
throw new PromptbookSyntaxError("Already defined minumum ".concat(expectAmount[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
|
|
1472
|
+
}
|
|
1473
|
+
expectAmount[unit].min = command.amount;
|
|
1474
|
+
} /* not else */
|
|
1475
|
+
if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
|
|
1476
|
+
if (expectAmount[unit].max !== undefined) {
|
|
1477
|
+
throw new PromptbookSyntaxError("Already defined maximum ".concat(expectAmount[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
|
|
1478
|
+
}
|
|
1479
|
+
expectAmount[unit].max = command.amount;
|
|
1480
|
+
}
|
|
1481
|
+
break;
|
|
1482
|
+
case 'EXPECT_FORMAT':
|
|
1483
|
+
if (expectFormat !== undefined && command.format !== expectFormat) {
|
|
1484
|
+
throw new PromptbookSyntaxError("Expect format is already defined to \"".concat(expectFormat, "\". Now you try to redefine it by \"").concat(command.format, "\"."));
|
|
1485
|
+
}
|
|
1486
|
+
expectFormat = command.format;
|
|
1487
|
+
break;
|
|
1488
|
+
default:
|
|
1489
|
+
throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the promptbook"));
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1494
|
+
finally {
|
|
1495
|
+
try {
|
|
1496
|
+
if (listItems_2_1 && !listItems_2_1.done && (_f = listItems_2.return)) _f.call(listItems_2);
|
|
1497
|
+
}
|
|
1498
|
+
finally { if (e_3) throw e_3.error; }
|
|
1499
|
+
}
|
|
1500
|
+
var _g = extractOneBlockFromMarkdown(section.content), language = _g.language, content = _g.content;
|
|
1501
|
+
if (executionType === 'SCRIPT') {
|
|
1502
|
+
if (!language) {
|
|
1503
|
+
throw new PromptbookSyntaxError('You must specify the language of the script in the prompt template');
|
|
1504
|
+
}
|
|
1505
|
+
else if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
|
|
1506
|
+
throw new PromptbookSyntaxError(spaceTrim.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 "); }));
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
var lastLine = section.content.split('\n').pop();
|
|
1510
|
+
var match = /^->\s*\{(?<resultingParamName>[a-z0-9_]+)\}/im.exec(lastLine);
|
|
1511
|
+
if (!match || match.groups === undefined || match.groups.resultingParamName === undefined) {
|
|
1512
|
+
throw new PromptbookSyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Invalid template - each section must end with \"-> {...}\"\n\n Invalid section:\n ".concat(block(
|
|
1513
|
+
// TODO: Show code of invalid sections each time + DRY
|
|
1514
|
+
section.content
|
|
1515
|
+
.split('\n')
|
|
1516
|
+
.map(function (line) { return "> ".concat(line); })
|
|
1517
|
+
.join('\n')), "\n "); }));
|
|
1518
|
+
}
|
|
1519
|
+
var resultingParameterName = match.groups.resultingParamName;
|
|
1520
|
+
// TODO: [1] DRY description
|
|
1521
|
+
var description_1 = section.content;
|
|
1522
|
+
// Note: Remove codeblocks
|
|
1523
|
+
description_1 = description_1.split(/^```.*^```/gms).join('');
|
|
1524
|
+
//Note: Remove lists and return statement
|
|
1525
|
+
description_1 = description_1.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
1526
|
+
description_1 = spaceTrim.spaceTrim(description_1);
|
|
1527
|
+
if (description_1 === '') {
|
|
1528
|
+
description_1 = undefined;
|
|
1529
|
+
}
|
|
1530
|
+
if (Object.keys(jokers).length === 0) {
|
|
1531
|
+
jokers = undefined;
|
|
1532
|
+
}
|
|
1533
|
+
if (Object.keys(expectAmount).length === 0) {
|
|
1534
|
+
expectAmount = undefined;
|
|
1535
|
+
}
|
|
1536
|
+
if (Object.keys(postprocessing).length === 0) {
|
|
1537
|
+
postprocessing = undefined;
|
|
1538
|
+
}
|
|
1539
|
+
dependentParameterNames = union(dependentParameterNames, extractParametersFromPromptTemplate(__assign(__assign({}, section), { description: description_1, executionType: executionType, content: content })));
|
|
1540
|
+
if (templateModelRequirements.modelVariant === undefined) {
|
|
1541
|
+
templateModelRequirements.modelVariant = 'CHAT';
|
|
1542
|
+
}
|
|
1543
|
+
promptbookJson.promptTemplates.push({
|
|
1544
|
+
name: titleToName(section.title),
|
|
1545
|
+
title: section.title,
|
|
1546
|
+
description: description_1,
|
|
1547
|
+
dependentParameterNames: Array.from(dependentParameterNames),
|
|
1548
|
+
executionType: executionType,
|
|
1549
|
+
jokers: jokers,
|
|
1550
|
+
postprocessing: postprocessing,
|
|
1551
|
+
expectations: expectAmount,
|
|
1552
|
+
expectFormat: expectFormat,
|
|
1553
|
+
modelRequirements: templateModelRequirements,
|
|
1554
|
+
contentLanguage: executionType === 'SCRIPT' ? language : undefined,
|
|
1555
|
+
content: content,
|
|
1556
|
+
resultingParameterName: resultingParameterName,
|
|
1557
|
+
});
|
|
1558
|
+
};
|
|
1559
|
+
try {
|
|
1560
|
+
for (_a = __values(markdownStructure.sections), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
1561
|
+
section = _b.value;
|
|
1562
|
+
_loop_1(section);
|
|
1563
|
+
}
|
|
1501
1564
|
}
|
|
1502
|
-
|
|
1503
|
-
|
|
1565
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1566
|
+
finally {
|
|
1567
|
+
try {
|
|
1568
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
1569
|
+
}
|
|
1570
|
+
finally { if (e_2) throw e_2.error; }
|
|
1504
1571
|
}
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
var match = /^->\s*\{(?<resultingParamName>[a-z0-9_]+)\}/im.exec(lastLine);
|
|
1508
|
-
if (!match || match.groups === undefined || match.groups.resultingParamName === undefined) {
|
|
1509
|
-
throw new PromptbookSyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Invalid template - each section must end with \"-> {...}\"\n\n Invalid section:\n ".concat(block(
|
|
1510
|
-
// TODO: Show code of invalid sections each time + DRY
|
|
1511
|
-
section.content
|
|
1512
|
-
.split('\n')
|
|
1513
|
-
.map(function (line) { return "> ".concat(line); })
|
|
1514
|
-
.join('\n')), "\n "); }));
|
|
1515
|
-
}
|
|
1516
|
-
var resultingParameterName = match.groups.resultingParamName;
|
|
1517
|
-
// TODO: [1] DRY description
|
|
1518
|
-
var description_1 = section.content;
|
|
1519
|
-
// Note: Remove codeblocks
|
|
1520
|
-
description_1 = description_1.split(/^```.*^```/gms).join('');
|
|
1521
|
-
//Note: Remove lists and return statement
|
|
1522
|
-
description_1 = description_1.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
1523
|
-
description_1 = spaceTrim.spaceTrim(description_1);
|
|
1524
|
-
if (description_1 === '') {
|
|
1525
|
-
description_1 = undefined;
|
|
1526
|
-
}
|
|
1527
|
-
if (Object.keys(jokers).length === 0) {
|
|
1528
|
-
jokers = undefined;
|
|
1529
|
-
}
|
|
1530
|
-
if (Object.keys(expectAmount).length === 0) {
|
|
1531
|
-
expectAmount = undefined;
|
|
1532
|
-
}
|
|
1533
|
-
if (Object.keys(postprocessing).length === 0) {
|
|
1534
|
-
postprocessing = undefined;
|
|
1535
|
-
}
|
|
1536
|
-
dependentParameterNames = union(dependentParameterNames, extractParametersFromPromptTemplate(__assign(__assign({}, section), { description: description_1, executionType: executionType, content: content })));
|
|
1537
|
-
if (templateModelRequirements.modelVariant === undefined) {
|
|
1538
|
-
templateModelRequirements.modelVariant = 'CHAT';
|
|
1539
|
-
}
|
|
1540
|
-
promptbookJson.promptTemplates.push({
|
|
1541
|
-
name: titleToName(section.title),
|
|
1542
|
-
title: section.title,
|
|
1543
|
-
description: description_1,
|
|
1544
|
-
dependentParameterNames: Array.from(dependentParameterNames),
|
|
1545
|
-
executionType: executionType,
|
|
1546
|
-
jokers: jokers,
|
|
1547
|
-
postprocessing: postprocessing,
|
|
1548
|
-
expectations: expectAmount,
|
|
1549
|
-
expectFormat: expectFormat,
|
|
1550
|
-
modelRequirements: templateModelRequirements,
|
|
1551
|
-
contentLanguage: executionType === 'SCRIPT' ? language : undefined,
|
|
1552
|
-
content: content,
|
|
1553
|
-
resultingParameterName: resultingParameterName,
|
|
1572
|
+
// =============================================================
|
|
1573
|
+
return [2 /*return*/, promptbookJson];
|
|
1554
1574
|
});
|
|
1555
|
-
};
|
|
1556
|
-
try {
|
|
1557
|
-
for (var _c = __values(markdownStructure.sections), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
1558
|
-
var section = _d.value;
|
|
1559
|
-
_loop_1(section);
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1562
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1563
|
-
finally {
|
|
1564
|
-
try {
|
|
1565
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
1566
|
-
}
|
|
1567
|
-
finally { if (e_2) throw e_2.error; }
|
|
1568
|
-
}
|
|
1569
|
-
// =============================================================
|
|
1570
|
-
return promptbookJson;
|
|
1575
|
+
});
|
|
1571
1576
|
}
|
|
1572
1577
|
/**
|
|
1573
1578
|
* TODO: Report here line/column of error
|
|
@@ -2176,36 +2181,61 @@
|
|
|
2176
2181
|
* @returns PromptbookLibrary
|
|
2177
2182
|
*/
|
|
2178
2183
|
function createPromptbookLibraryFromSources() {
|
|
2179
|
-
var e_1, _a;
|
|
2180
2184
|
var promptbookSources = [];
|
|
2181
2185
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2182
2186
|
promptbookSources[_i] = arguments[_i];
|
|
2183
2187
|
}
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2188
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2189
|
+
var promptbooks, promptbookSources_1, promptbookSources_1_1, source, promptbook, e_1_1;
|
|
2190
|
+
var e_1, _a;
|
|
2191
|
+
return __generator(this, function (_b) {
|
|
2192
|
+
switch (_b.label) {
|
|
2193
|
+
case 0:
|
|
2194
|
+
promptbooks = new Array();
|
|
2195
|
+
_b.label = 1;
|
|
2196
|
+
case 1:
|
|
2197
|
+
_b.trys.push([1, 8, 9, 10]);
|
|
2198
|
+
promptbookSources_1 = __values(promptbookSources), promptbookSources_1_1 = promptbookSources_1.next();
|
|
2199
|
+
_b.label = 2;
|
|
2200
|
+
case 2:
|
|
2201
|
+
if (!!promptbookSources_1_1.done) return [3 /*break*/, 7];
|
|
2202
|
+
source = promptbookSources_1_1.value;
|
|
2203
|
+
promptbook = void 0;
|
|
2204
|
+
if (!(typeof source === 'string')) return [3 /*break*/, 4];
|
|
2205
|
+
return [4 /*yield*/, promptbookStringToJson(source)];
|
|
2206
|
+
case 3:
|
|
2207
|
+
// Note: When directly creating from string, no need to validate the source
|
|
2208
|
+
// The validation is performed always before execution
|
|
2209
|
+
promptbook = _b.sent();
|
|
2210
|
+
return [3 /*break*/, 5];
|
|
2211
|
+
case 4:
|
|
2212
|
+
promptbook = source;
|
|
2213
|
+
_b.label = 5;
|
|
2214
|
+
case 5:
|
|
2215
|
+
promptbooks.push(promptbook);
|
|
2216
|
+
_b.label = 6;
|
|
2217
|
+
case 6:
|
|
2218
|
+
promptbookSources_1_1 = promptbookSources_1.next();
|
|
2219
|
+
return [3 /*break*/, 2];
|
|
2220
|
+
case 7: return [3 /*break*/, 10];
|
|
2221
|
+
case 8:
|
|
2222
|
+
e_1_1 = _b.sent();
|
|
2223
|
+
e_1 = { error: e_1_1 };
|
|
2224
|
+
return [3 /*break*/, 10];
|
|
2225
|
+
case 9:
|
|
2226
|
+
try {
|
|
2227
|
+
if (promptbookSources_1_1 && !promptbookSources_1_1.done && (_a = promptbookSources_1.return)) _a.call(promptbookSources_1);
|
|
2228
|
+
}
|
|
2229
|
+
finally { if (e_1) throw e_1.error; }
|
|
2230
|
+
return [7 /*endfinally*/];
|
|
2231
|
+
case 10: return [2 /*return*/, new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))()];
|
|
2196
2232
|
}
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
}
|
|
2200
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2201
|
-
finally {
|
|
2202
|
-
try {
|
|
2203
|
-
if (promptbookSources_1_1 && !promptbookSources_1_1.done && (_a = promptbookSources_1.return)) _a.call(promptbookSources_1);
|
|
2204
|
-
}
|
|
2205
|
-
finally { if (e_1) throw e_1.error; }
|
|
2206
|
-
}
|
|
2207
|
-
return new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))();
|
|
2233
|
+
});
|
|
2234
|
+
});
|
|
2208
2235
|
}
|
|
2236
|
+
/**
|
|
2237
|
+
* TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
|
|
2238
|
+
*/
|
|
2209
2239
|
|
|
2210
2240
|
/**
|
|
2211
2241
|
* Constructs Promptbook from async sources
|
|
@@ -2241,7 +2271,9 @@
|
|
|
2241
2271
|
return [4 /*yield*/, promptbookSourcesPromiseOrFactory];
|
|
2242
2272
|
case 1:
|
|
2243
2273
|
promptbookSources = _a.sent();
|
|
2244
|
-
|
|
2274
|
+
return [4 /*yield*/, createPromptbookLibraryFromSources.apply(void 0, __spreadArray([], __read(promptbookSources), false))];
|
|
2275
|
+
case 2:
|
|
2276
|
+
library = _a.sent();
|
|
2245
2277
|
return [2 /*return*/];
|
|
2246
2278
|
}
|
|
2247
2279
|
});
|
|
@@ -2289,6 +2321,9 @@
|
|
|
2289
2321
|
isResponsibleForPrompt: isResponsibleForPrompt,
|
|
2290
2322
|
};
|
|
2291
2323
|
}
|
|
2324
|
+
/**
|
|
2325
|
+
* TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
|
|
2326
|
+
*/
|
|
2292
2327
|
|
|
2293
2328
|
/**
|
|
2294
2329
|
* Constructs Promptbook from given directory
|
|
@@ -2331,31 +2366,33 @@
|
|
|
2331
2366
|
return __generator(this, function (_e) {
|
|
2332
2367
|
switch (_e.label) {
|
|
2333
2368
|
case 0:
|
|
2334
|
-
_e.trys.push([0,
|
|
2369
|
+
_e.trys.push([0, 7, , 8]);
|
|
2335
2370
|
promptbook = null;
|
|
2336
|
-
if (!fileName.endsWith('.ptbk.md')) return [3 /*break*/,
|
|
2371
|
+
if (!fileName.endsWith('.ptbk.md')) return [3 /*break*/, 3];
|
|
2337
2372
|
return [4 /*yield*/, promises.readFile(fileName, 'utf8')];
|
|
2338
2373
|
case 1:
|
|
2339
2374
|
promptbookString = (_e.sent());
|
|
2340
|
-
|
|
2341
|
-
return [3 /*break*/, 5];
|
|
2375
|
+
return [4 /*yield*/, promptbookStringToJson(promptbookString)];
|
|
2342
2376
|
case 2:
|
|
2343
|
-
|
|
2377
|
+
promptbook = _e.sent();
|
|
2378
|
+
return [3 /*break*/, 6];
|
|
2379
|
+
case 3:
|
|
2380
|
+
if (!fileName.endsWith('.ptbk.json')) return [3 /*break*/, 5];
|
|
2344
2381
|
if (isVerbose) {
|
|
2345
2382
|
console.info("Loading ".concat(fileName));
|
|
2346
2383
|
}
|
|
2347
2384
|
_d = (_c = JSON).parse;
|
|
2348
2385
|
return [4 /*yield*/, promises.readFile(fileName, 'utf8')];
|
|
2349
|
-
case
|
|
2386
|
+
case 4:
|
|
2350
2387
|
// TODO: Handle non-valid JSON files
|
|
2351
2388
|
promptbook = _d.apply(_c, [_e.sent()]);
|
|
2352
|
-
return [3 /*break*/,
|
|
2353
|
-
case
|
|
2389
|
+
return [3 /*break*/, 6];
|
|
2390
|
+
case 5:
|
|
2354
2391
|
if (isVerbose) {
|
|
2355
2392
|
console.info("Skipping file ".concat(fileName));
|
|
2356
2393
|
}
|
|
2357
|
-
_e.label =
|
|
2358
|
-
case
|
|
2394
|
+
_e.label = 6;
|
|
2395
|
+
case 6:
|
|
2359
2396
|
// ---
|
|
2360
2397
|
if (promptbook !== null) {
|
|
2361
2398
|
if (!promptbook.promptbookUrl) {
|
|
@@ -2376,8 +2413,8 @@
|
|
|
2376
2413
|
promptbooks.push(promptbook);
|
|
2377
2414
|
}
|
|
2378
2415
|
}
|
|
2379
|
-
return [3 /*break*/,
|
|
2380
|
-
case
|
|
2416
|
+
return [3 /*break*/, 8];
|
|
2417
|
+
case 7:
|
|
2381
2418
|
error_1 = _e.sent();
|
|
2382
2419
|
if (!(error_1 instanceof Error)) {
|
|
2383
2420
|
throw error_1;
|
|
@@ -2387,8 +2424,8 @@
|
|
|
2387
2424
|
throw new PromptbookLibraryError(wrappedErrorMessage);
|
|
2388
2425
|
}
|
|
2389
2426
|
console.error(wrappedErrorMessage);
|
|
2390
|
-
return [3 /*break*/,
|
|
2391
|
-
case
|
|
2427
|
+
return [3 /*break*/, 8];
|
|
2428
|
+
case 8: return [2 /*return*/];
|
|
2392
2429
|
}
|
|
2393
2430
|
});
|
|
2394
2431
|
};
|
|
@@ -2491,6 +2528,9 @@
|
|
|
2491
2528
|
});
|
|
2492
2529
|
});
|
|
2493
2530
|
}
|
|
2531
|
+
/**
|
|
2532
|
+
* TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
|
|
2533
|
+
*/
|
|
2494
2534
|
|
|
2495
2535
|
exports.PROMPTBOOK_VERSION = PROMPTBOOK_VERSION;
|
|
2496
2536
|
exports.createPromptbookLibraryFromDirectory = createPromptbookLibraryFromDirectory;
|