@promptbook/cli 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 +349 -331
- 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 +4 -4
- package/umd/index.umd.js +349 -331
- 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
|
@@ -146,7 +146,70 @@
|
|
|
146
146
|
/**
|
|
147
147
|
* The version of the Promptbook library
|
|
148
148
|
*/
|
|
149
|
-
var PROMPTBOOK_VERSION = '0.
|
|
149
|
+
var PROMPTBOOK_VERSION = '0.58.0';
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Removes HTML or Markdown comments from a string.
|
|
153
|
+
*
|
|
154
|
+
* @param {string} content - The string to remove comments from.
|
|
155
|
+
* @returns {string} The input string with all comments removed.
|
|
156
|
+
*/
|
|
157
|
+
function removeContentComments(content) {
|
|
158
|
+
return spacetrim.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Add or modify an auto-generated section in a markdown file
|
|
163
|
+
*
|
|
164
|
+
* @private within the library
|
|
165
|
+
*/
|
|
166
|
+
function addAutoGeneratedSection(content, options) {
|
|
167
|
+
var sectionName = options.sectionName, sectionContent = options.sectionContent;
|
|
168
|
+
var warningLine = "<!-- \u26A0\uFE0F WARNING: This section was auto-generated -->";
|
|
169
|
+
var sectionRegex = new RegExp("<!--".concat(sectionName, "-->([\\s\\S]*?)<!--/").concat(sectionName, "-->"), 'g');
|
|
170
|
+
var sectionMatch = content.match(sectionRegex);
|
|
171
|
+
if (sectionMatch) {
|
|
172
|
+
return content.replace(sectionRegex, spacetrim.spaceTrim(function (block) { return "\n <!--".concat(sectionName, "-->\n ").concat(block(warningLine), "\n ").concat(block(sectionContent), "\n <!--/").concat(sectionName, "-->\n "); }));
|
|
173
|
+
}
|
|
174
|
+
var placeForSection = removeContentComments(content).match(/^##.*$/im);
|
|
175
|
+
if (!placeForSection) {
|
|
176
|
+
throw new Error("No place where to put the section <!--".concat(sectionName, "-->"));
|
|
177
|
+
}
|
|
178
|
+
var _a = __read(placeForSection, 1), heading = _a[0];
|
|
179
|
+
return content.replace(heading, "<!--".concat(sectionName, "-->\n").concat(warningLine, "\n").concat(sectionContent, "\n<!--/").concat(sectionName, "-->\n\n").concat(heading));
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Prettify the html code
|
|
184
|
+
*
|
|
185
|
+
* @param content raw html code
|
|
186
|
+
* @returns formatted html code
|
|
187
|
+
*/
|
|
188
|
+
function prettifyMarkdown(content) {
|
|
189
|
+
try {
|
|
190
|
+
return prettier.format(content, {
|
|
191
|
+
parser: 'markdown',
|
|
192
|
+
plugins: [parserHtml__default["default"]],
|
|
193
|
+
// TODO: DRY - make some import or auto-copy of .prettierrc
|
|
194
|
+
endOfLine: 'lf',
|
|
195
|
+
tabWidth: 4,
|
|
196
|
+
singleQuote: true,
|
|
197
|
+
trailingComma: 'all',
|
|
198
|
+
arrowParens: 'always',
|
|
199
|
+
printWidth: 120,
|
|
200
|
+
htmlWhitespaceSensitivity: 'ignore',
|
|
201
|
+
jsxBracketSameLine: false,
|
|
202
|
+
bracketSpacing: true,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
console.error('There was an error with prettifying the markdown, using the original as the fallback', {
|
|
207
|
+
error: error,
|
|
208
|
+
html: content,
|
|
209
|
+
});
|
|
210
|
+
return content;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
150
213
|
|
|
151
214
|
/**
|
|
152
215
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -422,16 +485,6 @@
|
|
|
422
485
|
* TODO: [🍓][🌻] !!! Decide of this is internal util, external util OR validator/postprocessor
|
|
423
486
|
*/
|
|
424
487
|
|
|
425
|
-
/**
|
|
426
|
-
* Removes HTML or Markdown comments from a string.
|
|
427
|
-
*
|
|
428
|
-
* @param {string} content - The string to remove comments from.
|
|
429
|
-
* @returns {string} The input string with all comments removed.
|
|
430
|
-
*/
|
|
431
|
-
function removeContentComments(content) {
|
|
432
|
-
return spacetrim.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
|
|
433
|
-
}
|
|
434
|
-
|
|
435
488
|
/**
|
|
436
489
|
* Creates a new set with all elements that are present in either set
|
|
437
490
|
*/
|
|
@@ -1339,250 +1392,255 @@
|
|
|
1339
1392
|
}
|
|
1340
1393
|
|
|
1341
1394
|
/**
|
|
1342
|
-
*
|
|
1395
|
+
* Compile promptbook from string (markdown) format to JSON format
|
|
1343
1396
|
*
|
|
1397
|
+
* @param promptbookString {Promptbook} in string markdown format (.ptbk.md)
|
|
1398
|
+
* @param llmTools {LlmExecutionTools} - tools for processing required for knowledge processing *(not for actual execution)*
|
|
1399
|
+
* @returns {Promptbook} compiled in JSON format (.ptbk.json)
|
|
1344
1400
|
* @throws {PromptbookSyntaxError} if the promptbook string is not valid
|
|
1345
1401
|
*
|
|
1346
1402
|
* Note: This function does not validate logic of the pipeline only the syntax
|
|
1403
|
+
* Note: This function acts as compilation process
|
|
1347
1404
|
*/
|
|
1348
|
-
function promptbookStringToJson(promptbookString) {
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
existingParameter
|
|
1405
|
+
function promptbookStringToJson(promptbookString, llmTools) {
|
|
1406
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1407
|
+
var promptbookJson, addParam, markdownStructure, markdownStructureDeepness, description, defaultModelRequirements, listItems, listItems_1, listItems_1_1, listItem, command, _loop_1, _a, _b, section;
|
|
1408
|
+
var e_1, _c, e_2, _d;
|
|
1409
|
+
return __generator(this, function (_e) {
|
|
1410
|
+
promptbookJson = {
|
|
1411
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1412
|
+
title: undefined /* <- Note: Putting here placeholder to keep `title` on top at final JSON */,
|
|
1413
|
+
promptbookUrl: undefined /* <- Note: Putting here placeholder to keep `promptbookUrl` on top at final JSON */,
|
|
1414
|
+
promptbookVersion: PROMPTBOOK_VERSION,
|
|
1415
|
+
description: undefined /* <- Note: Putting here placeholder to keep `description` on top at final JSON */,
|
|
1416
|
+
parameters: [],
|
|
1417
|
+
promptTemplates: [],
|
|
1418
|
+
knowledge: [],
|
|
1419
|
+
};
|
|
1420
|
+
// =============================================================
|
|
1421
|
+
// Note: 1️⃣ Normalization of the PROMPTBOOK string
|
|
1422
|
+
promptbookString = removeContentComments(promptbookString);
|
|
1423
|
+
promptbookString = promptbookString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
|
|
1424
|
+
promptbookString = promptbookString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
1425
|
+
addParam = function (parameterCommand) {
|
|
1426
|
+
var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
|
|
1427
|
+
var existingParameter = promptbookJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
|
|
1428
|
+
if (existingParameter &&
|
|
1429
|
+
existingParameter.description &&
|
|
1430
|
+
existingParameter.description !== parameterDescription &&
|
|
1431
|
+
parameterDescription) {
|
|
1432
|
+
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 "); }));
|
|
1433
|
+
}
|
|
1434
|
+
if (existingParameter) {
|
|
1435
|
+
if (parameterDescription) {
|
|
1436
|
+
existingParameter.description = parameterDescription;
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
else {
|
|
1440
|
+
promptbookJson.parameters.push({
|
|
1441
|
+
name: parameterName,
|
|
1442
|
+
description: parameterDescription || undefined,
|
|
1443
|
+
isInput: isInput,
|
|
1444
|
+
isOutput: isOutput,
|
|
1445
|
+
});
|
|
1446
|
+
}
|
|
1447
|
+
};
|
|
1448
|
+
markdownStructure = markdownToMarkdownStructure(promptbookString);
|
|
1449
|
+
markdownStructureDeepness = countMarkdownStructureDeepness(markdownStructure);
|
|
1450
|
+
if (markdownStructureDeepness !== 2) {
|
|
1451
|
+
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 ")));
|
|
1378
1452
|
}
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
};
|
|
1389
|
-
// =============================================================
|
|
1390
|
-
// Note: 3️⃣ Parse the dynamic part - the template pipeline
|
|
1391
|
-
var markdownStructure = markdownToMarkdownStructure(promptbookString);
|
|
1392
|
-
var markdownStructureDeepness = countMarkdownStructureDeepness(markdownStructure);
|
|
1393
|
-
if (markdownStructureDeepness !== 2) {
|
|
1394
|
-
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 ")));
|
|
1395
|
-
}
|
|
1396
|
-
promptbookJson.title = markdownStructure.title;
|
|
1397
|
-
// TODO: [1] DRY description
|
|
1398
|
-
var description = markdownStructure.content;
|
|
1399
|
-
// Note: Remove codeblocks
|
|
1400
|
-
description = description.split(/^```.*^```/gms).join('');
|
|
1401
|
-
//Note: Remove lists and return statement
|
|
1402
|
-
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
1403
|
-
description = spacetrim.spaceTrim(description);
|
|
1404
|
-
if (description === '') {
|
|
1405
|
-
description = undefined;
|
|
1406
|
-
}
|
|
1407
|
-
promptbookJson.description = description;
|
|
1408
|
-
var defaultModelRequirements = {};
|
|
1409
|
-
var listItems = extractAllListItemsFromMarkdown(markdownStructure.content);
|
|
1410
|
-
try {
|
|
1411
|
-
for (var listItems_1 = __values(listItems), listItems_1_1 = listItems_1.next(); !listItems_1_1.done; listItems_1_1 = listItems_1.next()) {
|
|
1412
|
-
var listItem = listItems_1_1.value;
|
|
1413
|
-
var command = parseCommand(listItem);
|
|
1414
|
-
switch (command.type) {
|
|
1415
|
-
case 'PROMPTBOOK_URL':
|
|
1416
|
-
promptbookJson.promptbookUrl = command.promptbookUrl.href;
|
|
1417
|
-
break;
|
|
1418
|
-
case 'PROMPTBOOK_VERSION':
|
|
1419
|
-
promptbookJson.promptbookVersion = command.promptbookVersion;
|
|
1420
|
-
break;
|
|
1421
|
-
case 'MODEL':
|
|
1422
|
-
defaultModelRequirements[command.key] = command.value;
|
|
1423
|
-
break;
|
|
1424
|
-
case 'PARAMETER':
|
|
1425
|
-
addParam(command);
|
|
1426
|
-
break;
|
|
1427
|
-
default:
|
|
1428
|
-
throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the prompt template block"));
|
|
1453
|
+
promptbookJson.title = markdownStructure.title;
|
|
1454
|
+
description = markdownStructure.content;
|
|
1455
|
+
// Note: Remove codeblocks
|
|
1456
|
+
description = description.split(/^```.*^```/gms).join('');
|
|
1457
|
+
//Note: Remove lists and return statement
|
|
1458
|
+
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
1459
|
+
description = spacetrim.spaceTrim(description);
|
|
1460
|
+
if (description === '') {
|
|
1461
|
+
description = undefined;
|
|
1429
1462
|
}
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
var listItem = listItems_2_1.value;
|
|
1454
|
-
var command = parseCommand(listItem);
|
|
1455
|
-
switch (command.type) {
|
|
1456
|
-
case 'JOKER':
|
|
1457
|
-
jokers.push(command.parameterName);
|
|
1458
|
-
dependentParameterNames.add(command.parameterName);
|
|
1459
|
-
break;
|
|
1460
|
-
case 'EXECUTE':
|
|
1461
|
-
if (isExecutionTypeChanged) {
|
|
1462
|
-
throw new PromptbookSyntaxError('Execution type is already defined in the prompt template. It can be defined only once.');
|
|
1463
|
-
}
|
|
1464
|
-
executionType = command.executionType;
|
|
1465
|
-
isExecutionTypeChanged = true;
|
|
1466
|
-
break;
|
|
1467
|
-
case 'MODEL':
|
|
1468
|
-
templateModelRequirements[command.key] = command.value;
|
|
1469
|
-
break;
|
|
1470
|
-
case 'PARAMETER':
|
|
1471
|
-
// Note: This is just for detecting resulitng parameter name
|
|
1472
|
-
addParam(command);
|
|
1473
|
-
break;
|
|
1474
|
-
case 'POSTPROCESS':
|
|
1475
|
-
postprocessing.push(command.functionName);
|
|
1476
|
-
break;
|
|
1477
|
-
case 'EXPECT_AMOUNT':
|
|
1478
|
-
// eslint-disable-next-line no-case-declarations
|
|
1479
|
-
var unit = command.unit.toLowerCase();
|
|
1480
|
-
expectAmount[unit] = expectAmount[unit] || {};
|
|
1481
|
-
if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
|
|
1482
|
-
if (expectAmount[unit].min !== undefined) {
|
|
1483
|
-
throw new PromptbookSyntaxError("Already defined minumum ".concat(expectAmount[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
|
|
1484
|
-
}
|
|
1485
|
-
expectAmount[unit].min = command.amount;
|
|
1486
|
-
} /* not else */
|
|
1487
|
-
if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
|
|
1488
|
-
if (expectAmount[unit].max !== undefined) {
|
|
1489
|
-
throw new PromptbookSyntaxError("Already defined maximum ".concat(expectAmount[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
|
|
1490
|
-
}
|
|
1491
|
-
expectAmount[unit].max = command.amount;
|
|
1492
|
-
}
|
|
1493
|
-
break;
|
|
1494
|
-
case 'EXPECT_FORMAT':
|
|
1495
|
-
if (expectFormat !== undefined && command.format !== expectFormat) {
|
|
1496
|
-
throw new PromptbookSyntaxError("Expect format is already defined to \"".concat(expectFormat, "\". Now you try to redefine it by \"").concat(command.format, "\"."));
|
|
1497
|
-
}
|
|
1498
|
-
expectFormat = command.format;
|
|
1499
|
-
break;
|
|
1500
|
-
default:
|
|
1501
|
-
throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the promptbook"));
|
|
1463
|
+
promptbookJson.description = description;
|
|
1464
|
+
defaultModelRequirements = {};
|
|
1465
|
+
listItems = extractAllListItemsFromMarkdown(markdownStructure.content);
|
|
1466
|
+
try {
|
|
1467
|
+
for (listItems_1 = __values(listItems), listItems_1_1 = listItems_1.next(); !listItems_1_1.done; listItems_1_1 = listItems_1.next()) {
|
|
1468
|
+
listItem = listItems_1_1.value;
|
|
1469
|
+
command = parseCommand(listItem);
|
|
1470
|
+
switch (command.type) {
|
|
1471
|
+
case 'PROMPTBOOK_URL':
|
|
1472
|
+
promptbookJson.promptbookUrl = command.promptbookUrl.href;
|
|
1473
|
+
break;
|
|
1474
|
+
case 'PROMPTBOOK_VERSION':
|
|
1475
|
+
promptbookJson.promptbookVersion = command.promptbookVersion;
|
|
1476
|
+
break;
|
|
1477
|
+
case 'MODEL':
|
|
1478
|
+
defaultModelRequirements[command.key] = command.value;
|
|
1479
|
+
break;
|
|
1480
|
+
case 'PARAMETER':
|
|
1481
|
+
addParam(command);
|
|
1482
|
+
break;
|
|
1483
|
+
default:
|
|
1484
|
+
throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the prompt template block"));
|
|
1485
|
+
}
|
|
1502
1486
|
}
|
|
1503
1487
|
}
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1488
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1489
|
+
finally {
|
|
1490
|
+
try {
|
|
1491
|
+
if (listItems_1_1 && !listItems_1_1.done && (_c = listItems_1.return)) _c.call(listItems_1);
|
|
1492
|
+
}
|
|
1493
|
+
finally { if (e_1) throw e_1.error; }
|
|
1509
1494
|
}
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1495
|
+
_loop_1 = function (section) {
|
|
1496
|
+
var e_3, _f;
|
|
1497
|
+
// TODO: Parse prompt template description (the content out of the codeblock and lists)
|
|
1498
|
+
var templateModelRequirements = __assign({}, defaultModelRequirements);
|
|
1499
|
+
var listItems_3 = extractAllListItemsFromMarkdown(section.content);
|
|
1500
|
+
var dependentParameterNames = new Set();
|
|
1501
|
+
var executionType = 'PROMPT_TEMPLATE';
|
|
1502
|
+
var jokers = [];
|
|
1503
|
+
var postprocessing = [];
|
|
1504
|
+
var expectAmount = {};
|
|
1505
|
+
var expectFormat = undefined;
|
|
1506
|
+
var isExecutionTypeChanged = false;
|
|
1507
|
+
try {
|
|
1508
|
+
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()) {
|
|
1509
|
+
var listItem = listItems_2_1.value;
|
|
1510
|
+
var command = parseCommand(listItem);
|
|
1511
|
+
switch (command.type) {
|
|
1512
|
+
case 'JOKER':
|
|
1513
|
+
jokers.push(command.parameterName);
|
|
1514
|
+
dependentParameterNames.add(command.parameterName);
|
|
1515
|
+
break;
|
|
1516
|
+
case 'EXECUTE':
|
|
1517
|
+
if (isExecutionTypeChanged) {
|
|
1518
|
+
throw new PromptbookSyntaxError('Execution type is already defined in the prompt template. It can be defined only once.');
|
|
1519
|
+
}
|
|
1520
|
+
executionType = command.executionType;
|
|
1521
|
+
isExecutionTypeChanged = true;
|
|
1522
|
+
break;
|
|
1523
|
+
case 'MODEL':
|
|
1524
|
+
templateModelRequirements[command.key] = command.value;
|
|
1525
|
+
break;
|
|
1526
|
+
case 'PARAMETER':
|
|
1527
|
+
// Note: This is just for detecting resulitng parameter name
|
|
1528
|
+
addParam(command);
|
|
1529
|
+
break;
|
|
1530
|
+
case 'POSTPROCESS':
|
|
1531
|
+
postprocessing.push(command.functionName);
|
|
1532
|
+
break;
|
|
1533
|
+
case 'EXPECT_AMOUNT':
|
|
1534
|
+
// eslint-disable-next-line no-case-declarations
|
|
1535
|
+
var unit = command.unit.toLowerCase();
|
|
1536
|
+
expectAmount[unit] = expectAmount[unit] || {};
|
|
1537
|
+
if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
|
|
1538
|
+
if (expectAmount[unit].min !== undefined) {
|
|
1539
|
+
throw new PromptbookSyntaxError("Already defined minumum ".concat(expectAmount[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
|
|
1540
|
+
}
|
|
1541
|
+
expectAmount[unit].min = command.amount;
|
|
1542
|
+
} /* not else */
|
|
1543
|
+
if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
|
|
1544
|
+
if (expectAmount[unit].max !== undefined) {
|
|
1545
|
+
throw new PromptbookSyntaxError("Already defined maximum ".concat(expectAmount[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
|
|
1546
|
+
}
|
|
1547
|
+
expectAmount[unit].max = command.amount;
|
|
1548
|
+
}
|
|
1549
|
+
break;
|
|
1550
|
+
case 'EXPECT_FORMAT':
|
|
1551
|
+
if (expectFormat !== undefined && command.format !== expectFormat) {
|
|
1552
|
+
throw new PromptbookSyntaxError("Expect format is already defined to \"".concat(expectFormat, "\". Now you try to redefine it by \"").concat(command.format, "\"."));
|
|
1553
|
+
}
|
|
1554
|
+
expectFormat = command.format;
|
|
1555
|
+
break;
|
|
1556
|
+
default:
|
|
1557
|
+
throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the promptbook"));
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
1562
|
+
finally {
|
|
1563
|
+
try {
|
|
1564
|
+
if (listItems_2_1 && !listItems_2_1.done && (_f = listItems_2.return)) _f.call(listItems_2);
|
|
1565
|
+
}
|
|
1566
|
+
finally { if (e_3) throw e_3.error; }
|
|
1567
|
+
}
|
|
1568
|
+
var _g = extractOneBlockFromMarkdown(section.content), language = _g.language, content = _g.content;
|
|
1569
|
+
if (executionType === 'SCRIPT') {
|
|
1570
|
+
if (!language) {
|
|
1571
|
+
throw new PromptbookSyntaxError('You must specify the language of the script in the prompt template');
|
|
1572
|
+
}
|
|
1573
|
+
else if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
|
|
1574
|
+
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 "); }));
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
var lastLine = section.content.split('\n').pop();
|
|
1578
|
+
var match = /^->\s*\{(?<resultingParamName>[a-z0-9_]+)\}/im.exec(lastLine);
|
|
1579
|
+
if (!match || match.groups === undefined || match.groups.resultingParamName === undefined) {
|
|
1580
|
+
throw new PromptbookSyntaxError(spacetrim.spaceTrim(function (block) { return "\n Invalid template - each section must end with \"-> {...}\"\n\n Invalid section:\n ".concat(block(
|
|
1581
|
+
// TODO: Show code of invalid sections each time + DRY
|
|
1582
|
+
section.content
|
|
1583
|
+
.split('\n')
|
|
1584
|
+
.map(function (line) { return "> ".concat(line); })
|
|
1585
|
+
.join('\n')), "\n "); }));
|
|
1586
|
+
}
|
|
1587
|
+
var resultingParameterName = match.groups.resultingParamName;
|
|
1588
|
+
// TODO: [1] DRY description
|
|
1589
|
+
var description_1 = section.content;
|
|
1590
|
+
// Note: Remove codeblocks
|
|
1591
|
+
description_1 = description_1.split(/^```.*^```/gms).join('');
|
|
1592
|
+
//Note: Remove lists and return statement
|
|
1593
|
+
description_1 = description_1.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
1594
|
+
description_1 = spacetrim.spaceTrim(description_1);
|
|
1595
|
+
if (description_1 === '') {
|
|
1596
|
+
description_1 = undefined;
|
|
1597
|
+
}
|
|
1598
|
+
if (Object.keys(jokers).length === 0) {
|
|
1599
|
+
jokers = undefined;
|
|
1600
|
+
}
|
|
1601
|
+
if (Object.keys(expectAmount).length === 0) {
|
|
1602
|
+
expectAmount = undefined;
|
|
1603
|
+
}
|
|
1604
|
+
if (Object.keys(postprocessing).length === 0) {
|
|
1605
|
+
postprocessing = undefined;
|
|
1606
|
+
}
|
|
1607
|
+
dependentParameterNames = union(dependentParameterNames, extractParametersFromPromptTemplate(__assign(__assign({}, section), { description: description_1, executionType: executionType, content: content })));
|
|
1608
|
+
if (templateModelRequirements.modelVariant === undefined) {
|
|
1609
|
+
templateModelRequirements.modelVariant = 'CHAT';
|
|
1610
|
+
}
|
|
1611
|
+
promptbookJson.promptTemplates.push({
|
|
1612
|
+
name: titleToName(section.title),
|
|
1613
|
+
title: section.title,
|
|
1614
|
+
description: description_1,
|
|
1615
|
+
dependentParameterNames: Array.from(dependentParameterNames),
|
|
1616
|
+
executionType: executionType,
|
|
1617
|
+
jokers: jokers,
|
|
1618
|
+
postprocessing: postprocessing,
|
|
1619
|
+
expectations: expectAmount,
|
|
1620
|
+
expectFormat: expectFormat,
|
|
1621
|
+
modelRequirements: templateModelRequirements,
|
|
1622
|
+
contentLanguage: executionType === 'SCRIPT' ? language : undefined,
|
|
1623
|
+
content: content,
|
|
1624
|
+
resultingParameterName: resultingParameterName,
|
|
1625
|
+
});
|
|
1626
|
+
};
|
|
1627
|
+
try {
|
|
1628
|
+
for (_a = __values(markdownStructure.sections), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
1629
|
+
section = _b.value;
|
|
1630
|
+
_loop_1(section);
|
|
1631
|
+
}
|
|
1516
1632
|
}
|
|
1517
|
-
|
|
1518
|
-
|
|
1633
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1634
|
+
finally {
|
|
1635
|
+
try {
|
|
1636
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
1637
|
+
}
|
|
1638
|
+
finally { if (e_2) throw e_2.error; }
|
|
1519
1639
|
}
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
var match = /^->\s*\{(?<resultingParamName>[a-z0-9_]+)\}/im.exec(lastLine);
|
|
1523
|
-
if (!match || match.groups === undefined || match.groups.resultingParamName === undefined) {
|
|
1524
|
-
throw new PromptbookSyntaxError(spacetrim.spaceTrim(function (block) { return "\n Invalid template - each section must end with \"-> {...}\"\n\n Invalid section:\n ".concat(block(
|
|
1525
|
-
// TODO: Show code of invalid sections each time + DRY
|
|
1526
|
-
section.content
|
|
1527
|
-
.split('\n')
|
|
1528
|
-
.map(function (line) { return "> ".concat(line); })
|
|
1529
|
-
.join('\n')), "\n "); }));
|
|
1530
|
-
}
|
|
1531
|
-
var resultingParameterName = match.groups.resultingParamName;
|
|
1532
|
-
// TODO: [1] DRY description
|
|
1533
|
-
var description_1 = section.content;
|
|
1534
|
-
// Note: Remove codeblocks
|
|
1535
|
-
description_1 = description_1.split(/^```.*^```/gms).join('');
|
|
1536
|
-
//Note: Remove lists and return statement
|
|
1537
|
-
description_1 = description_1.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
1538
|
-
description_1 = spacetrim.spaceTrim(description_1);
|
|
1539
|
-
if (description_1 === '') {
|
|
1540
|
-
description_1 = undefined;
|
|
1541
|
-
}
|
|
1542
|
-
if (Object.keys(jokers).length === 0) {
|
|
1543
|
-
jokers = undefined;
|
|
1544
|
-
}
|
|
1545
|
-
if (Object.keys(expectAmount).length === 0) {
|
|
1546
|
-
expectAmount = undefined;
|
|
1547
|
-
}
|
|
1548
|
-
if (Object.keys(postprocessing).length === 0) {
|
|
1549
|
-
postprocessing = undefined;
|
|
1550
|
-
}
|
|
1551
|
-
dependentParameterNames = union(dependentParameterNames, extractParametersFromPromptTemplate(__assign(__assign({}, section), { description: description_1, executionType: executionType, content: content })));
|
|
1552
|
-
if (templateModelRequirements.modelVariant === undefined) {
|
|
1553
|
-
templateModelRequirements.modelVariant = 'CHAT';
|
|
1554
|
-
}
|
|
1555
|
-
promptbookJson.promptTemplates.push({
|
|
1556
|
-
name: titleToName(section.title),
|
|
1557
|
-
title: section.title,
|
|
1558
|
-
description: description_1,
|
|
1559
|
-
dependentParameterNames: Array.from(dependentParameterNames),
|
|
1560
|
-
executionType: executionType,
|
|
1561
|
-
jokers: jokers,
|
|
1562
|
-
postprocessing: postprocessing,
|
|
1563
|
-
expectations: expectAmount,
|
|
1564
|
-
expectFormat: expectFormat,
|
|
1565
|
-
modelRequirements: templateModelRequirements,
|
|
1566
|
-
contentLanguage: executionType === 'SCRIPT' ? language : undefined,
|
|
1567
|
-
content: content,
|
|
1568
|
-
resultingParameterName: resultingParameterName,
|
|
1640
|
+
// =============================================================
|
|
1641
|
+
return [2 /*return*/, promptbookJson];
|
|
1569
1642
|
});
|
|
1570
|
-
};
|
|
1571
|
-
try {
|
|
1572
|
-
for (var _c = __values(markdownStructure.sections), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
1573
|
-
var section = _d.value;
|
|
1574
|
-
_loop_1(section);
|
|
1575
|
-
}
|
|
1576
|
-
}
|
|
1577
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1578
|
-
finally {
|
|
1579
|
-
try {
|
|
1580
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
1581
|
-
}
|
|
1582
|
-
finally { if (e_2) throw e_2.error; }
|
|
1583
|
-
}
|
|
1584
|
-
// =============================================================
|
|
1585
|
-
return promptbookJson;
|
|
1643
|
+
});
|
|
1586
1644
|
}
|
|
1587
1645
|
/**
|
|
1588
1646
|
* TODO: Report here line/column of error
|
|
@@ -1590,59 +1648,6 @@
|
|
|
1590
1648
|
* TODO: [🧠] Parameter flags - isInput, isOutput, isInternal
|
|
1591
1649
|
*/
|
|
1592
1650
|
|
|
1593
|
-
/**
|
|
1594
|
-
* Add or modify an auto-generated section in a markdown file
|
|
1595
|
-
*
|
|
1596
|
-
* @private within the library
|
|
1597
|
-
*/
|
|
1598
|
-
function addAutoGeneratedSection(content, options) {
|
|
1599
|
-
var sectionName = options.sectionName, sectionContent = options.sectionContent;
|
|
1600
|
-
var warningLine = "<!-- \u26A0\uFE0F WARNING: This section was auto-generated -->";
|
|
1601
|
-
var sectionRegex = new RegExp("<!--".concat(sectionName, "-->([\\s\\S]*?)<!--/").concat(sectionName, "-->"), 'g');
|
|
1602
|
-
var sectionMatch = content.match(sectionRegex);
|
|
1603
|
-
if (sectionMatch) {
|
|
1604
|
-
return content.replace(sectionRegex, spacetrim.spaceTrim(function (block) { return "\n <!--".concat(sectionName, "-->\n ").concat(block(warningLine), "\n ").concat(block(sectionContent), "\n <!--/").concat(sectionName, "-->\n "); }));
|
|
1605
|
-
}
|
|
1606
|
-
var placeForSection = removeContentComments(content).match(/^##.*$/im);
|
|
1607
|
-
if (!placeForSection) {
|
|
1608
|
-
throw new Error("No place where to put the section <!--".concat(sectionName, "-->"));
|
|
1609
|
-
}
|
|
1610
|
-
var _a = __read(placeForSection, 1), heading = _a[0];
|
|
1611
|
-
return content.replace(heading, "<!--".concat(sectionName, "-->\n").concat(warningLine, "\n").concat(sectionContent, "\n<!--/").concat(sectionName, "-->\n\n").concat(heading));
|
|
1612
|
-
}
|
|
1613
|
-
|
|
1614
|
-
/**
|
|
1615
|
-
* Prettify the html code
|
|
1616
|
-
*
|
|
1617
|
-
* @param content raw html code
|
|
1618
|
-
* @returns formatted html code
|
|
1619
|
-
*/
|
|
1620
|
-
function prettifyMarkdown(content) {
|
|
1621
|
-
try {
|
|
1622
|
-
return prettier.format(content, {
|
|
1623
|
-
parser: 'markdown',
|
|
1624
|
-
plugins: [parserHtml__default["default"]],
|
|
1625
|
-
// TODO: DRY - make some import or auto-copy of .prettierrc
|
|
1626
|
-
endOfLine: 'lf',
|
|
1627
|
-
tabWidth: 4,
|
|
1628
|
-
singleQuote: true,
|
|
1629
|
-
trailingComma: 'all',
|
|
1630
|
-
arrowParens: 'always',
|
|
1631
|
-
printWidth: 120,
|
|
1632
|
-
htmlWhitespaceSensitivity: 'ignore',
|
|
1633
|
-
jsxBracketSameLine: false,
|
|
1634
|
-
bracketSpacing: true,
|
|
1635
|
-
});
|
|
1636
|
-
}
|
|
1637
|
-
catch (error) {
|
|
1638
|
-
console.error('There was an error with prettifying the markdown, using the original as the fallback', {
|
|
1639
|
-
error: error,
|
|
1640
|
-
html: content,
|
|
1641
|
-
});
|
|
1642
|
-
return content;
|
|
1643
|
-
}
|
|
1644
|
-
}
|
|
1645
|
-
|
|
1646
1651
|
/* tslint:disable */
|
|
1647
1652
|
function normalizeTo_camelCase(sentence, __firstLetterCapital) {
|
|
1648
1653
|
var e_1, _a;
|
|
@@ -1760,24 +1765,35 @@
|
|
|
1760
1765
|
* Prettyfies Promptbook string and adds Mermaid graph
|
|
1761
1766
|
*/
|
|
1762
1767
|
function prettifyPromptbookString(promptbookString, options) {
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1768
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1769
|
+
var isGraphAdded, isPrettifyed, promptbookJson, promptbookMermaid_1, promptbookMermaidBlock;
|
|
1770
|
+
return __generator(this, function (_a) {
|
|
1771
|
+
switch (_a.label) {
|
|
1772
|
+
case 0:
|
|
1773
|
+
isGraphAdded = options.isGraphAdded, isPrettifyed = options.isPrettifyed;
|
|
1774
|
+
if (!isGraphAdded) return [3 /*break*/, 2];
|
|
1775
|
+
return [4 /*yield*/, promptbookStringToJson(promptbookString /* , {!!!!} */)];
|
|
1776
|
+
case 1:
|
|
1777
|
+
promptbookJson = _a.sent();
|
|
1778
|
+
promptbookMermaid_1 = renderPromptbookMermaid(promptbookJson, {
|
|
1779
|
+
linkPromptTemplate: function (promptTemplate) {
|
|
1780
|
+
return { href: "#".concat(promptTemplate.name), title: promptTemplate.title };
|
|
1781
|
+
},
|
|
1782
|
+
});
|
|
1783
|
+
promptbookMermaidBlock = spacetrim.spaceTrim(function (block) { return "\n ```mermaid\n ".concat(block(promptbookMermaid_1), "\n ```\n "); });
|
|
1784
|
+
promptbookString = addAutoGeneratedSection(promptbookString, {
|
|
1785
|
+
sectionName: 'Graph',
|
|
1786
|
+
sectionContent: promptbookMermaidBlock,
|
|
1787
|
+
});
|
|
1788
|
+
_a.label = 2;
|
|
1789
|
+
case 2:
|
|
1790
|
+
if (isPrettifyed) {
|
|
1791
|
+
promptbookString = prettifyMarkdown(promptbookString);
|
|
1792
|
+
}
|
|
1793
|
+
return [2 /*return*/, promptbookString];
|
|
1794
|
+
}
|
|
1775
1795
|
});
|
|
1776
|
-
}
|
|
1777
|
-
if (isPrettifyed) {
|
|
1778
|
-
promptbookString = prettifyMarkdown(promptbookString);
|
|
1779
|
-
}
|
|
1780
|
-
return promptbookString;
|
|
1796
|
+
});
|
|
1781
1797
|
}
|
|
1782
1798
|
/**
|
|
1783
1799
|
* TODO: Maybe use some Mermaid library instead of string templating
|
|
@@ -1815,33 +1831,35 @@
|
|
|
1815
1831
|
filePaths = _c.sent();
|
|
1816
1832
|
_c.label = 2;
|
|
1817
1833
|
case 2:
|
|
1818
|
-
_c.trys.push([2,
|
|
1834
|
+
_c.trys.push([2, 11, 12, 13]);
|
|
1819
1835
|
filePaths_1 = __values(filePaths), filePaths_1_1 = filePaths_1.next();
|
|
1820
1836
|
_c.label = 3;
|
|
1821
1837
|
case 3:
|
|
1822
|
-
if (!!filePaths_1_1.done) return [3 /*break*/,
|
|
1838
|
+
if (!!filePaths_1_1.done) return [3 /*break*/, 10];
|
|
1823
1839
|
filePath = filePaths_1_1.value;
|
|
1824
1840
|
if (!filePath.endsWith('.ptbk.md')) {
|
|
1825
1841
|
console.warn(colors__default["default"].yellow("Skipping prettify of non-promptbook ".concat(filePath)));
|
|
1826
|
-
return [3 /*break*/,
|
|
1842
|
+
return [3 /*break*/, 9];
|
|
1827
1843
|
}
|
|
1828
1844
|
return [4 /*yield*/, promises.readFile(filePath, 'utf-8')];
|
|
1829
1845
|
case 4:
|
|
1830
1846
|
promptbookMarkdown = (_c.sent());
|
|
1831
1847
|
_c.label = 5;
|
|
1832
1848
|
case 5:
|
|
1833
|
-
_c.trys.push([5,
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
return [4 /*yield*/, promises.writeFile(filePath, promptbookMarkdown)];
|
|
1849
|
+
_c.trys.push([5, 8, , 9]);
|
|
1850
|
+
return [4 /*yield*/, prettifyPromptbookString(promptbookMarkdown, {
|
|
1851
|
+
isGraphAdded: true,
|
|
1852
|
+
isPrettifyed: true,
|
|
1853
|
+
// <- [🕌]
|
|
1854
|
+
})];
|
|
1840
1855
|
case 6:
|
|
1856
|
+
promptbookMarkdown = _c.sent();
|
|
1857
|
+
return [4 /*yield*/, promises.writeFile(filePath, promptbookMarkdown)];
|
|
1858
|
+
case 7:
|
|
1841
1859
|
_c.sent();
|
|
1842
1860
|
console.info(colors__default["default"].green("Prettify ".concat(filePath)));
|
|
1843
|
-
return [3 /*break*/,
|
|
1844
|
-
case
|
|
1861
|
+
return [3 /*break*/, 9];
|
|
1862
|
+
case 8:
|
|
1845
1863
|
error_1 = _c.sent();
|
|
1846
1864
|
if (!(error_1 instanceof Error)) {
|
|
1847
1865
|
throw error_1;
|
|
@@ -1850,22 +1868,22 @@
|
|
|
1850
1868
|
console.error(colors__default["default"].bgRed(error_1.name));
|
|
1851
1869
|
console.error(error_1);
|
|
1852
1870
|
process.exit(1);
|
|
1853
|
-
return [3 /*break*/,
|
|
1854
|
-
case
|
|
1871
|
+
return [3 /*break*/, 9];
|
|
1872
|
+
case 9:
|
|
1855
1873
|
filePaths_1_1 = filePaths_1.next();
|
|
1856
1874
|
return [3 /*break*/, 3];
|
|
1857
|
-
case
|
|
1858
|
-
case
|
|
1875
|
+
case 10: return [3 /*break*/, 13];
|
|
1876
|
+
case 11:
|
|
1859
1877
|
e_1_1 = _c.sent();
|
|
1860
1878
|
e_1 = { error: e_1_1 };
|
|
1861
|
-
return [3 /*break*/,
|
|
1862
|
-
case
|
|
1879
|
+
return [3 /*break*/, 13];
|
|
1880
|
+
case 12:
|
|
1863
1881
|
try {
|
|
1864
1882
|
if (filePaths_1_1 && !filePaths_1_1.done && (_b = filePaths_1.return)) _b.call(filePaths_1);
|
|
1865
1883
|
}
|
|
1866
1884
|
finally { if (e_1) throw e_1.error; }
|
|
1867
1885
|
return [7 /*endfinally*/];
|
|
1868
|
-
case
|
|
1886
|
+
case 13:
|
|
1869
1887
|
process.exit(0);
|
|
1870
1888
|
return [2 /*return*/];
|
|
1871
1889
|
}
|