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