@promptbook/markdown-utils 0.103.0-9 → 0.104.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/README.md +59 -35
- package/esm/index.es.js +328 -239
- package/esm/index.es.js.map +1 -1
- package/esm/typings/books/index.d.ts +0 -81
- package/esm/typings/servers.d.ts +9 -7
- package/esm/typings/src/_packages/browser.index.d.ts +6 -0
- package/esm/typings/src/_packages/cli.index.d.ts +4 -0
- package/esm/typings/src/_packages/components.index.d.ts +22 -8
- package/esm/typings/src/_packages/core.index.d.ts +58 -18
- package/esm/typings/src/_packages/node.index.d.ts +2 -2
- package/esm/typings/src/_packages/remote-server.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +70 -8
- package/esm/typings/src/_packages/utils.index.d.ts +6 -0
- package/esm/typings/src/_packages/wizard.index.d.ts +4 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +20 -5
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +17 -1
- package/esm/typings/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +3 -2
- package/esm/typings/src/book-2.0/agent-source/computeAgentHash.d.ts +8 -0
- package/esm/typings/src/book-2.0/agent-source/createCommitmentRegex.d.ts +3 -3
- package/esm/typings/src/book-2.0/agent-source/createDefaultAgentName.d.ts +8 -0
- package/esm/typings/src/book-2.0/agent-source/normalizeAgentName.d.ts +9 -0
- package/esm/typings/src/book-2.0/agent-source/padBook.d.ts +18 -0
- package/esm/typings/src/book-2.0/agent-source/parseAgentSourceWithCommitments.d.ts +1 -1
- package/esm/typings/src/book-2.0/agent-source/string_book.d.ts +3 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +6 -1
- package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +85 -14
- package/esm/typings/src/book-components/BookEditor/BookEditorActionbar.d.ts +18 -0
- package/esm/typings/src/book-components/BookEditor/BookEditorMonaco.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.d.ts +17 -0
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChatProps.d.ts +13 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +16 -0
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +15 -0
- package/esm/typings/src/book-components/Chat/MockedChat/MockedChat.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/save/_common/ChatSaveFormatDefinition.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/save/html/htmlSaveFormatDefinition.d.ts +1 -0
- package/esm/typings/src/book-components/Chat/save/pdf/pdfSaveFormatDefinition.d.ts +4 -0
- package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +1 -1
- package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgentIntegration.d.ts +67 -0
- package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgentSeamlessIntegration.d.ts +23 -0
- package/esm/typings/src/book-components/Qr/BrandedQrCode.d.ts +18 -0
- package/esm/typings/src/book-components/Qr/GenericQrCode.d.ts +10 -0
- package/esm/typings/src/book-components/Qr/PromptbookQrCode.d.ts +18 -0
- package/esm/typings/src/book-components/Qr/useQrCode.d.ts +15 -0
- package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +15 -0
- package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +12 -0
- package/esm/typings/src/book-components/_common/Modal/Modal.d.ts +2 -2
- package/esm/typings/src/book-components/_common/Tooltip/Tooltip.d.ts +47 -0
- package/esm/typings/src/book-components/icons/AboutIcon.d.ts +9 -0
- package/esm/typings/src/book-components/icons/CameraIcon.d.ts +11 -0
- package/esm/typings/src/book-components/icons/CloseIcon.d.ts +4 -8
- package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +9 -0
- package/esm/typings/src/book-components/icons/ExitFullscreenIcon.d.ts +7 -0
- package/esm/typings/src/book-components/icons/FullscreenIcon.d.ts +7 -0
- package/esm/typings/src/book-components/icons/MenuIcon.d.ts +12 -0
- package/esm/typings/src/book-components/icons/MicIcon.d.ts +8 -0
- package/esm/typings/src/book-components/icons/SendIcon.d.ts +3 -0
- package/esm/typings/src/cli/cli-commands/_boilerplate.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/about.d.ts +3 -1
- package/esm/typings/src/cli/cli-commands/hello.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/list-models.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/login.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/make.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/prettify.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/run.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/{start-server.d.ts → start-agents-server.d.ts} +3 -2
- package/esm/typings/src/cli/cli-commands/start-pipelines-server.d.ts +15 -0
- package/esm/typings/src/cli/cli-commands/test-command.d.ts +2 -1
- package/esm/typings/src/cli/common/$addGlobalOptionsToCommand.d.ts +2 -1
- package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +12 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +75 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabaseOptions.d.ts +10 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +154 -0
- package/esm/typings/src/collection/{PipelineCollection.d.ts → pipeline-collection/PipelineCollection.d.ts} +7 -3
- package/esm/typings/src/collection/{SimplePipelineCollection.d.ts → pipeline-collection/SimplePipelineCollection.d.ts} +5 -5
- package/esm/typings/src/collection/{constructors/createCollectionFromDirectory.d.ts → pipeline-collection/constructors/createPipelineCollectionFromDirectory.d.ts} +8 -11
- package/esm/typings/src/collection/pipeline-collection/constructors/createPipelineCollectionFromJson.d.ts +13 -0
- package/esm/typings/src/collection/{constructors/createCollectionFromPromise.d.ts → pipeline-collection/constructors/createPipelineCollectionFromPromise.d.ts} +6 -5
- package/esm/typings/src/collection/pipeline-collection/constructors/createPipelineCollectionFromPromise.test.d.ts +1 -0
- package/esm/typings/src/collection/{constructors/createCollectionFromUrl.d.ts → pipeline-collection/constructors/createPipelineCollectionFromUrl.d.ts} +3 -3
- package/esm/typings/src/collection/{constructors/createSubcollection.d.ts → pipeline-collection/constructors/createPipelineSubcollection.d.ts} +3 -3
- package/esm/typings/src/collection/pipeline-collection/pipelineCollectionToJson.d.ts +13 -0
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +4 -5
- package/esm/typings/src/{book-2.0/commitments → commitments}/ACTION/ACTION.d.ts +5 -1
- package/esm/typings/src/commitments/CLOSED/CLOSED.d.ts +39 -0
- package/esm/typings/src/commitments/CLOSED/CLOSED.test.d.ts +4 -0
- package/esm/typings/src/commitments/COMPONENT/COMPONENT.d.ts +28 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/DELETE/DELETE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/FORMAT/FORMAT.d.ts +5 -1
- package/esm/typings/src/commitments/FROM/FROM.d.ts +34 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/GOAL/GOAL.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/KNOWLEDGE/KNOWLEDGE.d.ts +5 -5
- package/esm/typings/src/commitments/LANGUAGE/LANGUAGE.d.ts +35 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/MEMORY/MEMORY.d.ts +5 -1
- package/esm/typings/src/commitments/MESSAGE/AgentMessageCommitmentDefinition.d.ts +32 -0
- package/esm/typings/src/commitments/MESSAGE/InitialMessageCommitmentDefinition.d.ts +32 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/MESSAGE/MESSAGE.d.ts +5 -1
- package/esm/typings/src/commitments/MESSAGE/UserMessageCommitmentDefinition.d.ts +32 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/META/META.d.ts +5 -1
- package/esm/typings/src/commitments/META_COLOR/META_COLOR.d.ts +48 -0
- package/esm/typings/src/commitments/META_FONT/META_FONT.d.ts +42 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/META_IMAGE/META_IMAGE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/META_LINK/META_LINK.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/MODEL/MODEL.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/NOTE/NOTE.d.ts +5 -1
- package/esm/typings/src/commitments/OPEN/OPEN.d.ts +35 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/PERSONA/PERSONA.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/RULE/RULE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/SAMPLE/SAMPLE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/SCENARIO/SCENARIO.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/STYLE/STYLE.d.ts +5 -1
- package/esm/typings/src/commitments/USE/USE.d.ts +53 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +42 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.test.d.ts +1 -0
- package/esm/typings/src/commitments/USE_MCP/USE_MCP.d.ts +37 -0
- package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +38 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BaseCommitmentDefinition.d.ts +14 -2
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/CommitmentDefinition.d.ts +6 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/NotYetImplementedCommitmentDefinition.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/createEmptyAgentModelRequirements.d.ts +1 -1
- package/esm/typings/src/commitments/index.d.ts +93 -0
- package/esm/typings/src/config.d.ts +24 -3
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +2 -0
- package/esm/typings/src/errors/0-index.d.ts +6 -0
- package/esm/typings/src/errors/DatabaseError.d.ts +12 -0
- package/esm/typings/src/errors/NotAllowed.d.ts +9 -0
- package/esm/typings/src/errors/WrappedError.d.ts +2 -2
- package/esm/typings/src/execution/AvailableModel.d.ts +1 -0
- package/esm/typings/src/execution/Executables.d.ts +3 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +12 -3
- package/esm/typings/src/execution/ExecutionTools.d.ts +5 -0
- package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +26 -2
- package/esm/typings/src/execution/PromptResult.d.ts +7 -1
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +5 -0
- package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +5 -0
- package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +5 -0
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +5 -0
- package/esm/typings/src/execution/utils/usage-constants.d.ts +4 -124
- package/esm/typings/src/execution/utils/validatePromptResult.d.ts +2 -0
- package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +2 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +2 -2
- package/esm/typings/src/llm-providers/_common/register/$registeredLlmToolsMessage.d.ts +2 -1
- package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/assertUniqueModels.d.ts +12 -0
- package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +72 -0
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +26 -4
- package/esm/typings/src/llm-providers/agent/AgentOptions.d.ts +19 -0
- package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +17 -0
- package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +50 -0
- package/esm/typings/src/llm-providers/agent/RemoteAgentOptions.d.ts +11 -0
- package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.d.ts +1 -19
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/ollama/OllamaExecutionTools.d.ts +4 -0
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +60 -2
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +7 -1
- package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +13 -1
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +4 -0
- package/esm/typings/src/llm-providers/openai/createOpenAiCompatibleExecutionTools.d.ts +6 -6
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/openai-models.test.d.ts +4 -0
- package/esm/typings/src/other/templates/getTemplatesPipelineCollection.d.ts +1 -1
- package/esm/typings/src/pipeline/validatePipelineString.d.ts +2 -0
- package/esm/typings/src/playground/permanent/_boilerplate.d.ts +5 -0
- package/esm/typings/src/playground/permanent/agent-with-browser-playground.d.ts +5 -0
- package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +1 -0
- package/esm/typings/src/remote-server/startAgentServer.d.ts +26 -0
- package/esm/typings/src/remote-server/startRemoteServer.d.ts +4 -1
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +3 -8
- package/esm/typings/src/scrapers/_boilerplate/createBoilerplateScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/_boilerplate/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/markitdown/createMarkitdownScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/markitdown/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -9
- package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +1 -0
- package/esm/typings/src/storage/env-storage/$EnvStorage.d.ts +2 -1
- package/esm/typings/src/transpilers/_common/BookTranspiler.d.ts +33 -0
- package/esm/typings/src/transpilers/_common/BookTranspilerOptions.d.ts +18 -0
- package/esm/typings/src/transpilers/_common/register/$bookTranspilersRegister.d.ts +15 -0
- package/esm/typings/src/transpilers/formatted-book-in-markdown/FormattedBookInMarkdownTranspiler.d.ts +16 -0
- package/esm/typings/src/transpilers/formatted-book-in-markdown/register.d.ts +15 -0
- package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.d.ts +16 -0
- package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.test.d.ts +1 -0
- package/esm/typings/src/transpilers/openai-sdk/playground/playground.d.ts +5 -0
- package/esm/typings/src/transpilers/openai-sdk/register.d.ts +15 -0
- package/esm/typings/src/types/LlmCall.d.ts +20 -0
- package/esm/typings/src/types/ModelRequirements.d.ts +13 -1
- package/esm/typings/src/types/ModelVariant.d.ts +1 -1
- package/esm/typings/src/types/Prompt.d.ts +13 -1
- package/esm/typings/src/types/Updatable.d.ts +19 -0
- package/esm/typings/src/types/typeAliases.d.ts +38 -2
- package/esm/typings/src/utils/color/$randomColor.d.ts +1 -0
- package/esm/typings/src/utils/color/Color.d.ts +16 -1
- package/esm/typings/src/utils/color/Color.test.d.ts +1 -0
- package/esm/typings/src/utils/color/css-colors.d.ts +1 -0
- package/esm/typings/src/utils/color/internal-utils/checkChannelValue.d.ts +0 -3
- package/esm/typings/src/utils/color/operators/darken.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/grayscale.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/lighten.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/mixWithColor.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/saturate.d.ts +1 -1
- package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +16 -0
- package/esm/typings/src/utils/environment/$getGlobalScope.d.ts +2 -2
- package/esm/typings/src/utils/execCommand/$execCommand.d.ts +2 -1
- package/esm/typings/src/utils/execCommand/$execCommands.d.ts +2 -1
- package/esm/typings/src/utils/files/$induceBookDownload.d.ts +13 -0
- package/esm/typings/src/utils/files/$induceFileDownload.d.ts +13 -0
- package/esm/typings/src/utils/files/ObjectUrl.d.ts +46 -0
- package/esm/typings/src/utils/files/listAllFiles.d.ts +2 -3
- package/esm/typings/src/utils/misc/aboutPromptbookInformation.d.ts +27 -0
- package/esm/typings/src/utils/misc/computeHash.d.ts +11 -0
- package/esm/typings/src/utils/misc/computeHash.test.d.ts +1 -0
- package/esm/typings/src/utils/misc/injectCssModuleIntoShadowRoot.d.ts +1 -0
- package/esm/typings/src/utils/misc/xAboutPromptbookInformation.d.ts +13 -0
- package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +2 -0
- package/esm/typings/src/utils/normalization/normalizeMessageText.d.ts +9 -0
- package/esm/typings/src/utils/normalization/normalizeMessageText.test.d.ts +1 -0
- package/esm/typings/src/utils/normalization/normalizeTo_PascalCase.d.ts +3 -0
- package/esm/typings/src/utils/normalization/normalizeTo_camelCase.d.ts +2 -0
- package/esm/typings/src/utils/normalization/titleToName.d.ts +2 -0
- package/esm/typings/src/utils/organization/$sideEffect.d.ts +2 -2
- package/esm/typings/src/utils/organization/$side_effect.d.ts +7 -0
- package/esm/typings/src/utils/organization/TODO_USE.d.ts +2 -2
- package/esm/typings/src/utils/organization/keepUnused.d.ts +2 -2
- package/esm/typings/src/utils/organization/preserve.d.ts +3 -3
- package/esm/typings/src/utils/organization/really_any.d.ts +7 -0
- package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +31 -0
- package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +9 -0
- package/esm/typings/src/utils/random/$randomFullnameWithColor.d.ts +13 -0
- package/esm/typings/src/utils/random/$randomItem.d.ts +9 -0
- package/esm/typings/src/utils/random/$randomSeed.d.ts +3 -0
- package/esm/typings/src/utils/random/$randomToken.d.ts +2 -0
- package/esm/typings/src/utils/random/CzechNamePool.d.ts +7 -0
- package/esm/typings/src/utils/random/EnglishNamePool.d.ts +7 -0
- package/esm/typings/src/utils/random/NamePool.d.ts +17 -0
- package/esm/typings/src/utils/random/getNamePool.d.ts +10 -0
- package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +2 -1
- package/esm/typings/src/utils/serialization/asSerializable.d.ts +2 -2
- package/esm/typings/src/utils/serialization/serializeToPromptbookJavascript.d.ts +2 -2
- package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +2 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/esm/typings/src/wizard/$getCompiledBook.d.ts +1 -2
- package/package.json +6 -6
- package/umd/index.umd.js +293 -204
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/book-2.0/commitments/index.d.ts +0 -60
- package/esm/typings/src/book-components/BookEditor/BookEditorInner.d.ts +0 -5
- package/esm/typings/src/book-components/BookEditor/BookEditorWrapper.d.ts +0 -9
- package/esm/typings/src/book-components/BookEditor/config.d.ts +0 -10
- package/esm/typings/src/book-components/Chat/utils/renderMarkdown.d.ts +0 -21
- package/esm/typings/src/collection/collectionToJson.d.ts +0 -13
- package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +0 -13
- /package/esm/typings/src/{book-components/Chat/utils/renderMarkdown.test.d.ts → book-2.0/agent-source/computeAgentHash.test.d.ts} +0 -0
- /package/esm/typings/src/{collection/constructors/createCollectionFromDirectory.test.d.ts → book-2.0/agent-source/normalizeAgentName.test.d.ts} +0 -0
- /package/esm/typings/src/{collection/constructors/createCollectionFromJson.test.d.ts → book-components/Chat/AgentChat/AgentChat.test.d.ts} +0 -0
- /package/esm/typings/src/collection/{constructors/createCollectionFromPromise.test.d.ts → pipeline-collection/constructors/createPipelineCollectionFromDirectory.test.d.ts} +0 -0
- /package/esm/typings/src/{commands/_common/parseCommand.test.d.ts → collection/pipeline-collection/constructors/createPipelineCollectionFromJson.test.d.ts} +0 -0
- /package/esm/typings/src/collection/{collectionToJson.test.d.ts → pipeline-collection/pipelineCollectionToJson.test.d.ts} +0 -0
- /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BookCommitment.d.ts +0 -0
- /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/ParsedCommitment.d.ts +0 -0
package/esm/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import spaceTrim, { spaceTrim as spaceTrim$
|
|
1
|
+
import spaceTrim$1, { spaceTrim as spaceTrim$2 } from 'spacetrim';
|
|
2
2
|
import { randomBytes } from 'crypto';
|
|
3
3
|
import { Subject } from 'rxjs';
|
|
4
4
|
import { forTime } from 'waitasecond';
|
|
@@ -16,14 +16,14 @@ import { parse, unparse } from 'papaparse';
|
|
|
16
16
|
* @generated
|
|
17
17
|
* @see https://github.com/webgptorg/book
|
|
18
18
|
*/
|
|
19
|
-
const BOOK_LANGUAGE_VERSION = '
|
|
19
|
+
const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
20
20
|
/**
|
|
21
21
|
* The version of the Promptbook engine
|
|
22
22
|
*
|
|
23
23
|
* @generated
|
|
24
24
|
* @see https://github.com/webgptorg/promptbook
|
|
25
25
|
*/
|
|
26
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.
|
|
26
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-0';
|
|
27
27
|
/**
|
|
28
28
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
29
29
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -141,7 +141,7 @@ function extractAllBlocksFromMarkdown(markdown) {
|
|
|
141
141
|
function extractOneBlockFromMarkdown(markdown) {
|
|
142
142
|
const codeBlocks = extractAllBlocksFromMarkdown(markdown);
|
|
143
143
|
if (codeBlocks.length !== 1) {
|
|
144
|
-
throw new ParseError(spaceTrim((block) => `
|
|
144
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
145
145
|
There should be exactly 1 code block in task section, found ${codeBlocks.length} code blocks
|
|
146
146
|
|
|
147
147
|
${block(codeBlocks.map((block, i) => `Block ${i + 1}:\n${block.content}`).join('\n\n\n'))}
|
|
@@ -172,6 +172,17 @@ function extractBlock(markdown) {
|
|
|
172
172
|
return content;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
/**
|
|
176
|
+
* Trims string from all 4 sides
|
|
177
|
+
*
|
|
178
|
+
* Note: This is a re-exported function from the `spacetrim` package which is
|
|
179
|
+
* Developed by same author @hejny as this package
|
|
180
|
+
*
|
|
181
|
+
* @public exported from `@promptbook/utils`
|
|
182
|
+
* @see https://github.com/hejny/spacetrim#usage
|
|
183
|
+
*/
|
|
184
|
+
const spaceTrim = spaceTrim$2;
|
|
185
|
+
|
|
175
186
|
/**
|
|
176
187
|
* @private util of `@promptbook/color`
|
|
177
188
|
* @de
|
|
@@ -220,6 +231,7 @@ function take(initialValue) {
|
|
|
220
231
|
* @public exported from `@promptbook/color`
|
|
221
232
|
*/
|
|
222
233
|
const CSS_COLORS = {
|
|
234
|
+
promptbook: '#79EAFD',
|
|
223
235
|
transparent: 'rgba(0,0,0,0)',
|
|
224
236
|
aliceblue: '#f0f8ff',
|
|
225
237
|
antiquewhite: '#faebd7',
|
|
@@ -401,9 +413,6 @@ function checkChannelValue(channelName, value) {
|
|
|
401
413
|
throw new Error(`${channelName} channel is greater than 255, it is ${value}`);
|
|
402
414
|
}
|
|
403
415
|
}
|
|
404
|
-
/**
|
|
405
|
-
* TODO: [🧠][🚓] Is/which combination it better to use asserts/check, validate or is utility function?
|
|
406
|
-
*/
|
|
407
416
|
|
|
408
417
|
/**
|
|
409
418
|
* Color object represents an RGB color with alpha channel
|
|
@@ -423,21 +432,61 @@ class Color {
|
|
|
423
432
|
* @param color
|
|
424
433
|
* @returns Color object
|
|
425
434
|
*/
|
|
426
|
-
static from(color) {
|
|
427
|
-
if (color
|
|
435
|
+
static from(color, _isSingleValue = false) {
|
|
436
|
+
if (color === '') {
|
|
437
|
+
throw new Error(`Can not create color from empty string`);
|
|
438
|
+
}
|
|
439
|
+
else if (color instanceof Color) {
|
|
428
440
|
return take(color);
|
|
429
441
|
}
|
|
430
442
|
else if (Color.isColor(color)) {
|
|
431
443
|
return take(color);
|
|
432
444
|
}
|
|
433
445
|
else if (typeof color === 'string') {
|
|
434
|
-
|
|
446
|
+
try {
|
|
447
|
+
return Color.fromString(color);
|
|
448
|
+
}
|
|
449
|
+
catch (error) {
|
|
450
|
+
// <- Note: Can not use `assertsError(error)` here because it causes circular dependency
|
|
451
|
+
if (_isSingleValue) {
|
|
452
|
+
throw error;
|
|
453
|
+
}
|
|
454
|
+
const parts = color.split(/[\s+,;|]/);
|
|
455
|
+
if (parts.length > 0) {
|
|
456
|
+
return Color.from(parts[0].trim(), true);
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
throw new Error(`Can not create color from given string "${color}"`);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
435
462
|
}
|
|
436
463
|
else {
|
|
437
464
|
console.error({ color });
|
|
438
465
|
throw new Error(`Can not create color from given object`);
|
|
439
466
|
}
|
|
440
467
|
}
|
|
468
|
+
/**
|
|
469
|
+
* Creates a new Color instance from miscellaneous formats
|
|
470
|
+
* It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
|
|
471
|
+
*
|
|
472
|
+
* @param color
|
|
473
|
+
* @returns Color object
|
|
474
|
+
*/
|
|
475
|
+
static fromSafe(color) {
|
|
476
|
+
try {
|
|
477
|
+
return Color.from(color);
|
|
478
|
+
}
|
|
479
|
+
catch (error) {
|
|
480
|
+
// <- Note: Can not use `assertsError(error)` here because it causes circular dependency
|
|
481
|
+
console.warn(spaceTrim((block) => `
|
|
482
|
+
Color.fromSafe error:
|
|
483
|
+
${block(error.message)}
|
|
484
|
+
|
|
485
|
+
Returning default PROMPTBOOK_COLOR.
|
|
486
|
+
`));
|
|
487
|
+
return Color.fromString('promptbook');
|
|
488
|
+
}
|
|
489
|
+
}
|
|
441
490
|
/**
|
|
442
491
|
* Creates a new Color instance from miscellaneous string formats
|
|
443
492
|
*
|
|
@@ -505,6 +554,9 @@ class Color {
|
|
|
505
554
|
if (hex.length === 3) {
|
|
506
555
|
return Color.fromHex3(hex);
|
|
507
556
|
}
|
|
557
|
+
if (hex.length === 4) {
|
|
558
|
+
return Color.fromHex4(hex);
|
|
559
|
+
}
|
|
508
560
|
if (hex.length === 6) {
|
|
509
561
|
return Color.fromHex6(hex);
|
|
510
562
|
}
|
|
@@ -525,6 +577,19 @@ class Color {
|
|
|
525
577
|
const b = parseInt(hex.substr(2, 1), 16) * 16;
|
|
526
578
|
return take(new Color(r, g, b));
|
|
527
579
|
}
|
|
580
|
+
/**
|
|
581
|
+
* Creates a new Color instance from color in hex format with 4 digits (with alpha channel)
|
|
582
|
+
*
|
|
583
|
+
* @param color in hex for example `09df`
|
|
584
|
+
* @returns Color object
|
|
585
|
+
*/
|
|
586
|
+
static fromHex4(hex) {
|
|
587
|
+
const r = parseInt(hex.substr(0, 1), 16) * 16;
|
|
588
|
+
const g = parseInt(hex.substr(1, 1), 16) * 16;
|
|
589
|
+
const b = parseInt(hex.substr(2, 1), 16) * 16;
|
|
590
|
+
const a = parseInt(hex.substr(3, 1), 16) * 16;
|
|
591
|
+
return take(new Color(r, g, b, a));
|
|
592
|
+
}
|
|
528
593
|
/**
|
|
529
594
|
* Creates a new Color instance from color in hex format with 6 color digits (without alpha channel)
|
|
530
595
|
*
|
|
@@ -715,7 +780,8 @@ class Color {
|
|
|
715
780
|
* @returns true if the value is a valid hex color string (e.g., `#009edd`, `#fff`, etc.)
|
|
716
781
|
*/
|
|
717
782
|
static isHexColorString(value) {
|
|
718
|
-
return typeof value === 'string' &&
|
|
783
|
+
return (typeof value === 'string' &&
|
|
784
|
+
/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(value));
|
|
719
785
|
}
|
|
720
786
|
/**
|
|
721
787
|
* Creates new Color object
|
|
@@ -830,6 +896,23 @@ class Color {
|
|
|
830
896
|
* TODO: Maybe connect with textures
|
|
831
897
|
*/
|
|
832
898
|
|
|
899
|
+
/**
|
|
900
|
+
* Makes color transformer which returns a grayscale version of the color
|
|
901
|
+
*
|
|
902
|
+
* @param amount from 0 to 1
|
|
903
|
+
*
|
|
904
|
+
* @public exported from `@promptbook/color`
|
|
905
|
+
*/
|
|
906
|
+
function grayscale(amount) {
|
|
907
|
+
return ({ red, green, blue, alpha }) => {
|
|
908
|
+
const average = (red + green + blue) / 3;
|
|
909
|
+
red = Math.round(average * amount + red * (1 - amount));
|
|
910
|
+
green = Math.round(average * amount + green * (1 - amount));
|
|
911
|
+
blue = Math.round(average * amount + blue * (1 - amount));
|
|
912
|
+
return Color.fromValues(red, green, blue, alpha);
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
|
|
833
916
|
/**
|
|
834
917
|
* Converts HSL values to RGB values
|
|
835
918
|
*
|
|
@@ -945,102 +1028,6 @@ function lighten(amount) {
|
|
|
945
1028
|
* TODO: Maybe implement by mix+hsl
|
|
946
1029
|
*/
|
|
947
1030
|
|
|
948
|
-
/**
|
|
949
|
-
* Calculates distance between two colors
|
|
950
|
-
*
|
|
951
|
-
* @param color1 first color
|
|
952
|
-
* @param color2 second color
|
|
953
|
-
*
|
|
954
|
-
* Note: This function is inefficient. Use colorDistanceSquared instead if possible.
|
|
955
|
-
*
|
|
956
|
-
* @public exported from `@promptbook/color`
|
|
957
|
-
*/
|
|
958
|
-
/**
|
|
959
|
-
* Calculates distance between two colors without square root
|
|
960
|
-
*
|
|
961
|
-
* @param color1 first color
|
|
962
|
-
* @param color2 second color
|
|
963
|
-
*
|
|
964
|
-
* @public exported from `@promptbook/color`
|
|
965
|
-
*/
|
|
966
|
-
function colorDistanceSquared(color1, color2) {
|
|
967
|
-
const rmean = (color1.red + color2.red) / 2;
|
|
968
|
-
const r = color1.red - color2.red;
|
|
969
|
-
const g = color1.green - color2.green;
|
|
970
|
-
const b = color1.blue - color2.blue;
|
|
971
|
-
const weightR = 2 + rmean / 256;
|
|
972
|
-
const weightG = 4.0;
|
|
973
|
-
const weightB = 2 + (255 - rmean) / 256;
|
|
974
|
-
const distance = weightR * r * r + weightG * g * g + weightB * b * b;
|
|
975
|
-
return distance;
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
/**
|
|
979
|
-
* Makes color transformer which finds the nearest color from the given list
|
|
980
|
-
*
|
|
981
|
-
* @param colors array of colors to choose from
|
|
982
|
-
*
|
|
983
|
-
* @public exported from `@promptbook/color`
|
|
984
|
-
*/
|
|
985
|
-
function nearest(...colors) {
|
|
986
|
-
return (color) => {
|
|
987
|
-
const distances = colors.map((c) => colorDistanceSquared(c, color));
|
|
988
|
-
const minDistance = Math.min(...distances);
|
|
989
|
-
const minIndex = distances.indexOf(minDistance);
|
|
990
|
-
const nearestColor = colors[minIndex];
|
|
991
|
-
return nearestColor;
|
|
992
|
-
};
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
/**
|
|
996
|
-
* Color transformer which returns the negative color
|
|
997
|
-
*
|
|
998
|
-
* @public exported from `@promptbook/color`
|
|
999
|
-
*/
|
|
1000
|
-
function negative(color) {
|
|
1001
|
-
const r = 255 - color.red;
|
|
1002
|
-
const g = 255 - color.green;
|
|
1003
|
-
const b = 255 - color.blue;
|
|
1004
|
-
return Color.fromValues(r, g, b, color.alpha);
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
/**
|
|
1008
|
-
* Makes color transformer which finds the furthest color from the given list
|
|
1009
|
-
*
|
|
1010
|
-
* @param colors array of colors to choose from
|
|
1011
|
-
*
|
|
1012
|
-
* @public exported from `@promptbook/color`
|
|
1013
|
-
*/
|
|
1014
|
-
function furthest(...colors) {
|
|
1015
|
-
return (color) => {
|
|
1016
|
-
const furthestColor = negative(nearest(...colors.map(negative))(color));
|
|
1017
|
-
return furthestColor;
|
|
1018
|
-
};
|
|
1019
|
-
}
|
|
1020
|
-
/**
|
|
1021
|
-
* Makes color transformer which finds the best text color (black or white) for the given background color
|
|
1022
|
-
*
|
|
1023
|
-
* @public exported from `@promptbook/color`
|
|
1024
|
-
*/
|
|
1025
|
-
furthest(Color.get('white'), Color.from('black'));
|
|
1026
|
-
|
|
1027
|
-
/**
|
|
1028
|
-
* Makes color transformer which returns a grayscale version of the color
|
|
1029
|
-
*
|
|
1030
|
-
* @param amount from 0 to 1
|
|
1031
|
-
*
|
|
1032
|
-
* @public exported from `@promptbook/color`
|
|
1033
|
-
*/
|
|
1034
|
-
function grayscale(amount) {
|
|
1035
|
-
return ({ red, green, blue, alpha }) => {
|
|
1036
|
-
const average = (red + green + blue) / 3;
|
|
1037
|
-
red = Math.round(average * amount + red * (1 - amount));
|
|
1038
|
-
green = Math.round(average * amount + green * (1 - amount));
|
|
1039
|
-
blue = Math.round(average * amount + blue * (1 - amount));
|
|
1040
|
-
return Color.fromValues(red, green, blue, alpha);
|
|
1041
|
-
};
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
1031
|
/**
|
|
1045
1032
|
* Makes color transformer which saturate the given color
|
|
1046
1033
|
*
|
|
@@ -1115,16 +1102,32 @@ const ADMIN_GITHUB_NAME = 'hejny';
|
|
|
1115
1102
|
*
|
|
1116
1103
|
* @public exported from `@promptbook/core`
|
|
1117
1104
|
*/
|
|
1118
|
-
const PROMPTBOOK_COLOR = Color.
|
|
1119
|
-
// <- TODO: [🧠] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
1105
|
+
const PROMPTBOOK_COLOR = Color.fromString('promptbook');
|
|
1106
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
1120
1107
|
/**
|
|
1121
|
-
*
|
|
1108
|
+
* Colors for syntax highlighting in the `<BookEditor/>`
|
|
1109
|
+
*
|
|
1110
|
+
* TODO: [🗽] Unite branding and make single place for it
|
|
1111
|
+
*
|
|
1112
|
+
* @public exported from `@promptbook/core`
|
|
1113
|
+
*/
|
|
1114
|
+
({
|
|
1115
|
+
TITLE: Color.fromHex('#244EA8'),
|
|
1116
|
+
LINE: Color.fromHex('#eeeeee'),
|
|
1117
|
+
SEPARATOR: Color.fromHex('#cccccc'),
|
|
1118
|
+
COMMITMENT: Color.fromHex('#DA0F78'),
|
|
1119
|
+
PARAMETER: Color.fromHex('#8e44ad'),
|
|
1120
|
+
});
|
|
1121
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
1122
|
+
/**
|
|
1123
|
+
* Chat color of the Promptbook (in chat)
|
|
1122
1124
|
*
|
|
1123
1125
|
* TODO: [🗽] Unite branding and make single place for it
|
|
1124
1126
|
*
|
|
1125
1127
|
* @public exported from `@promptbook/core`
|
|
1126
1128
|
*/
|
|
1127
1129
|
PROMPTBOOK_COLOR.then(lighten(0.1)).then(saturate(0.9)).then(grayscale(0.9));
|
|
1130
|
+
// <- TODO: [🧠][🈵] Using `Color` and `lighten`, `saturate`,... here increases the package size approx 3kb, maybe remove it
|
|
1128
1131
|
/**
|
|
1129
1132
|
* Color of the user (in chat)
|
|
1130
1133
|
*
|
|
@@ -1133,6 +1136,7 @@ PROMPTBOOK_COLOR.then(lighten(0.1)).then(saturate(0.9)).then(grayscale(0.9));
|
|
|
1133
1136
|
* @public exported from `@promptbook/core`
|
|
1134
1137
|
*/
|
|
1135
1138
|
Color.fromHex('#1D4ED8');
|
|
1139
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
1136
1140
|
/**
|
|
1137
1141
|
* When the title is not provided, the default title is used
|
|
1138
1142
|
*
|
|
@@ -1219,7 +1223,7 @@ const DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [🤹♂️]
|
|
|
1219
1223
|
* @public exported from `@promptbook/core`
|
|
1220
1224
|
*/
|
|
1221
1225
|
const DEFAULT_MAX_EXECUTION_ATTEMPTS = 7; // <- TODO: [🤹♂️]
|
|
1222
|
-
// <- TODO: [🕝] Make also `
|
|
1226
|
+
// <- TODO: [🕝] Make also `AGENTS_DIRNAME_ALTERNATIVES`
|
|
1223
1227
|
// TODO: Just `.promptbook` in config, hardcode subfolders like `download-cache` or `execution-cache`
|
|
1224
1228
|
/**
|
|
1225
1229
|
* Where to store the temporary downloads
|
|
@@ -1296,7 +1300,7 @@ true);
|
|
|
1296
1300
|
function getErrorReportUrl(error) {
|
|
1297
1301
|
const report = {
|
|
1298
1302
|
title: `🐜 Error report from ${NAME}`,
|
|
1299
|
-
body: spaceTrim((block) => `
|
|
1303
|
+
body: spaceTrim$1((block) => `
|
|
1300
1304
|
|
|
1301
1305
|
|
|
1302
1306
|
\`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
|
|
@@ -1339,7 +1343,7 @@ function getErrorReportUrl(error) {
|
|
|
1339
1343
|
*/
|
|
1340
1344
|
class UnexpectedError extends Error {
|
|
1341
1345
|
constructor(message) {
|
|
1342
|
-
super(spaceTrim$
|
|
1346
|
+
super(spaceTrim$2((block) => `
|
|
1343
1347
|
${block(message)}
|
|
1344
1348
|
|
|
1345
1349
|
Note: This error should not happen.
|
|
@@ -1365,7 +1369,7 @@ class WrappedError extends Error {
|
|
|
1365
1369
|
constructor(whatWasThrown) {
|
|
1366
1370
|
const tag = `[🤮]`;
|
|
1367
1371
|
console.error(tag, whatWasThrown);
|
|
1368
|
-
super(spaceTrim$
|
|
1372
|
+
super(spaceTrim$2(`
|
|
1369
1373
|
Non-Error object was thrown
|
|
1370
1374
|
|
|
1371
1375
|
Note: Look for ${tag} in the console for more details
|
|
@@ -1479,7 +1483,7 @@ function extractJsonBlock(markdown) {
|
|
|
1479
1483
|
function keepUnused(...valuesToKeep) {
|
|
1480
1484
|
}
|
|
1481
1485
|
|
|
1482
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge from Markdown\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book`\n- INPUT PARAMETER `{knowledgeContent}` Markdown document content\n- OUTPUT PARAMETER `{knowledgePieces}` The knowledge JSON object\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}\n```\n\n`-> {knowledgePieces}`\n"}],sourceFile:"./books/prepare-knowledge-from-markdown.book"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Keywords\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-keywords.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{keywords}` Keywords separated by comma\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}\n```\n\n`-> {keywords}`\n"}],sourceFile:"./books/prepare-knowledge-keywords.book"},{title:"Prepare Knowledge-piece Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge-piece Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-title.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{title}` The title of the document\n\n## Knowledge\n\n- EXPECT MIN 1 WORD\n- EXPECT MAX 8 WORDS\n\n```markdown\nYou are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-knowledge-title.book"},{title:"Prepare Persona",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book",formfactorName:"GENERIC",parameters:[{name:"availableModels",description:"List of available model names together with their descriptions as JSON",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelsRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n```json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpful assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n```\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n```json\n{availableModels}\n```\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelsRequirements",format:"JSON",dependentParameterNames:["availableModels","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Persona\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-persona.book`\n- INPUT PARAMETER `{availableModels}` List of available model names together with their descriptions as JSON\n- INPUT PARAMETER `{personaDescription}` Description of the persona\n- OUTPUT PARAMETER `{modelsRequirements}` Specific requirements for the model\n\n## Make modelRequirements\n\n- FORMAT JSON\n\n```markdown\nYou are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n\\`\\`\\`json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpful assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n\\`\\`\\`\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n\\`\\`\\`json\n{availableModels}\n\\`\\`\\`\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}\n```\n\n`-> {modelsRequirements}`\n"}],sourceFile:"./books/prepare-persona.book"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-title.book",formfactorName:"GENERIC",parameters:[{name:"book",description:"The book to prepare the title for",isInput:true,isOutput:false},{name:"title",description:"Best title for the book",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-title",title:"Make title",content:"Make best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}",resultingParameterName:"title",expectations:{words:{min:1,max:8},lines:{min:1,max:1}},dependentParameterNames:["book"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-title.book`\n- INPUT PARAMETER `{book}` The book to prepare the title for\n- OUTPUT PARAMETER `{title}` Best title for the book\n\n## Make title\n\n- EXPECT MIN 1 Word\n- EXPECT MAX 8 Words\n- EXPECT EXACTLY 1 Line\n\n```markdown\nMake best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-title.book"},{title:"📊 Curriculum Audit",pipelineUrl:"https://promptbook.studio/promptbook//examples/lsvp-asistent.book",formfactorName:"GENERIC",parameters:[{name:"result",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"prompt",title:"Prompt",content:"Asistent pro LŠVP\n\nPERSONA Jsi asistent pro RVP Lyceum v rámci Národního pedagogického institutu České Republiky\nMETA IMAGE https://edulk.cz/getFile/id:475818/type:large/02%20zna%C4%8Dka%20npi.jpg\nRULE Pokud jsi nejsi jistý, napiš nevím\nKNOWLEDGE ./241129_Lyceum_final.pdf\nCONTEXT Obecně dokážeš řešit libovolné ŠVP, aktuálně řešíš {Školní vzdělávací program LYCEUM}\nRULE Z {Porovnání RVP a ŠVP - postup} je nejdůležitější fáze 3\nKNOWLEDGE {Školní vzdělávací program LYCEUM} ./ŠVP Lyceum - Finance v digitální době.pdf\nKNOWLEDGE @Slovník\n\n**Interní slovník - RVP/ŠVP**\n\n**RVP**\n\nRámcový vzdělávací program pro obor vzdělání Lyceum je dokument na národní úrovni, který formuluje požadavky na školní vzdělávací programy ve formě především očekávaných výsledků učení, kterých mají žáci absolvováním tohoto programu na dané škole dosáhnout.\n\n**ŠVP**\n\nŠkolní vzdělávací program pro obor vzdělání Lyceum je dokument každé jednotlivé školy, který popisuje v jakých vyučovacích předmětech/ vzdělávacích modulech a v jakých ročnících budou požadované očekávané výsledky učení naplněny. Zároveň formuluje další očekávané výsledky učení, které naplňují disponibilní část vyučovacího času určeného RVP pro tento obor vzdělání.\n\n**Očekávaný výsledek učení (OVU)**\n\nVyjadřuje jednotlivý požadavek na to, co mají žáci umět na konci vzdělávacího programu, tzn. jejich požadované kompetence. Je vyjádřen formulací, která je uvozena činnostním slovesem a dále obsahuje předmět této činnosti. Formulace je konkretizována resp. doplněna zpravidla formou odrážek vymezením dílčích znalostí, dovedností, postojů, jejichž splnění je předpokladem dosažení OVU jako celku.\n\n_Příklad:_\n\n<div class=\"joplin-table-wrapper\"><table><tbody><tr><th><p><strong>Žák/žákyně řídí realizaci jednoduchého projektu</strong></p></th></tr><tr><td><ul><li>naplánuje aktivity projektu</li></ul></td></tr><tr><td><ul><li>navrhne rozpočet projektu vzhledem k navrženým aktivitám</li></ul></td></tr><tr><td><ul><li>stanoví základní ukazatele a sleduje jejich naplňování</li></ul></td></tr><tr><td><ul><li>vede projektový tým</li></ul></td></tr><tr><td><ul><li>uvede, jak by řešil krizové situace v projektu</li></ul></td></tr><tr><td><ul><li>vyhodnotí úspěšnost projektu</li></ul></td></tr></tbody></table></div>\n\n**Vzdělávací oblasti**\n\nOčekávané výsledky učení jsou v **_RVP členěny do 4 vzdělávacích oblastí_**, které tvoří společný všeobecně vzdělávací základ:\n\n- Osobnostní rozvoj, vzdělávání ke zdraví, bezpečí a produktivnímu pracovnímu životu (kariéře)\n- Komunikační a jazykové vzdělávání\n- Aplikované vzdělávání STEM (Science, Technology, Engeneering, Math), tj. přírodní vědy, informatika, technika, matematika\n- Prakticky orientované vzdělávání společenskovědní a humanitní\n\nKaždá vzdělávací oblast se dále člení na okruhy, v jejichž rámci jsou OVU samostatně číslované.\n\n<div class=\"joplin-table-wrapper\"><table><tbody><tr><th rowspan=\"21\"><ul><li>Prakticky orientované vzdělávání společenskovědní a humanitní</li></ul></th><th rowspan=\"21\"><p><strong>Člověk, ekonomie a podnikání</strong></p></th><th rowspan=\"7\"><p><strong>1</strong></p></th><th><p><strong>zpracuje podklady související s podnikáním</strong></p></th></tr><tr><td><p>připraví podnikatelský záměr</p></td></tr><tr><td><p>sestaví zakladatelský rozpočet</p></td></tr><tr><td><p>zkalkuluje cenu zboží nebo služby</p></td></tr><tr><td><p>vysvětlí na příkladu základní povinnosti podnikatele vůči státu a zaměstnancům</p></td></tr><tr><td><p>vede daňovou evidenci</p></td></tr><tr><td><p>vysvětlí na příkladech etiku v podnikání</p></td></tr><tr><td rowspan=\"7\"><p><strong>2</strong></p></td><td><p><strong>řídí realizaci jednoduchého projektu</strong></p></td></tr><tr><td><p>naplánuje aktivity projektu</p></td></tr><tr><td><p>navrhne rozpočet projektu vzhledem k navrženým aktivitám</p></td></tr><tr><td><p>stanoví základní ukazatele a sleduje jejich naplňování</p></td></tr><tr><td><p>vede projektový tým</p></td></tr><tr><td><p>uvede, jak by řešil krizové situace v projektu</p></td></tr><tr><td><p>vyhodnotí úspěšnost projektu</p></td></tr><tr><td rowspan=\"7\"><p><strong>3</strong></p></td><td><p><strong>aplikuje ekonomické teorie v osobním a profesním životě</strong></p></td></tr><tr><td><p>vysvětlí základní ekonomické otázky</p></td></tr><tr><td><p>vysvětí stanovení rovnovážné ceny na dokonalém i nedokonalém trhu</p></td></tr><tr><td><p>charakterizuje výrobní faktory a vysvětlí hranici produkčních možností a náklady obětované příležitosti</p></td></tr><tr><td><p>uvede nejdůležitější makroekonomické pojmy a vliv jejich výše na kvalitu života a podnikání v daném státě</p></td></tr><tr><td><p>vysvětlí podstatu inflace a její důsledky na finanční situaci obyvatel a na příkladu ukáže jak se bránit jejím nepříznivým důsledkům</p></td></tr><tr><td><p>uvede hlavní výhody a nevýhody mezinárodního obchodu a vliv ochranářských opatření na ekonomickou situaci dané země</p></td></tr><tr><td></td><td></td><td><p><strong>4</strong></p></td><td><p>Atd.</p></td></tr></tbody></table></div>\n\n**Vyučovací předmět / vzdělávací modul**\n\nOčekávané výsledky učení jsou v **ŠVP** členěny do vyučovacích předmětů nebo vzdělávacích modulů, které jsou dále zařazeny do jednoho nebo více ročníků 4letého studia. Vyučovací předmět / vzdělávací modul tvoří vyučovací jednotku, kde jsou očekávané výsledky učení dále rozpracovány pro potřeby výuky podle následující šablony\n\n| **A. VSTUPNÍ ČÁST** |\n| --- |\n| **1\\. Název** |\n| **2\\. Kód** (kódy by měly být navázány na obory vzdělání a výsledky učení) |\n| **2a) Kategorie vzdělání** - v případě, že nebude součástí kódu |\n| **3\\. Typ vyučovací jednotky** (modul, předmět, stáž apod.) |\n| **4\\. Délka** (počet hodin - dělitelný čtyřmi (optimální modul 16, 32 hodin = týden výuky) |\n| **5\\. Platnost** (datum, od kterého platí) |\n| **6\\. Vstupní předpoklady** (vymezení požadované úrovně vstupních vědomostí a dovedností, které jsou předpokladem úspěšného studia) |\n| |\n| **B. JÁDRO VYUČOVACÍ JEDNOTKY** |\n| **1\\. Charakteristika** (stručná anotace popisující obecné cíle a pojetí) |\n| **2\\. Očekávané výsledky učení a jejich indikátory (převzaté z RVP nebo dále konkretizované)** |\n| **3\\. Podpora rozvoje klíčových kompetencí a základních gramotností** (které klíčové kompetence jsou v rozvíjeny) |\n| **4\\. Obsah vzdělávání** (rozpis učiva) |\n| **5\\. Vzdělávací strategie** (strategie výuky, resp. učební činnosti žáků, které jsou doporučené pro dosažení výsledků) |\n| |\n| **C. VÝSTUPNÍ ČÁST** |\n| **1\\. Způsob ověřování dosažených výsledků** (ve vazbě na jednotlivé výsledky učení) |\n| **2\\. Kritéria hodnocení** (co znamená splnění výsledků učení, kdy je splněna celá vyučovací jednotka, kritéria pro známky, příp. procentuální, slovní hodnocení) |\n| **3\\. Doporučená studijní literatura, odkazy na ilustrační zdroje** |\n| **4\\. Poznámky** |\n\n**Soulad OVU RVP a ŠVP**\n\nTento soulad je předmětem zjišťování. Soulad nastává, jestliže jsou očekávané výsledky učení z jednotlivých vzdělávacích oblastí RVP **obsaženy** ve vyučovacích předmětech/ vzdělávacích modulech ŠVP jednotlivých škol, tzn. že v ŠVP se objevuje jejich formulace buď v doslovném nebo podobném znění v jednom nebo více vyučovacích předmětech/ vzdělávacích modulech.\n\n_Příklad souladu:_\n\nRVP ŠVP - komunikace a marketing (SŠ obchodní Č.\n\n| **2** | **řídí realizaci jednoduchého projektu** |\n| --- | --- |\n| naplánuje aktivity projektu |\n| navrhne rozpočet projektu vzhledem k navrženým aktivitám |\n| stanoví základní ukazatele a sleduje jejich naplňování |\n| vede projektový tým |\n| uvede, jak by řešil krizové situace v projektu |\n| vyhodnotí úspěšnost projektu |\n\nKNOWLEDGE {Porovnání RVP a ŠVP - postup}\n\n\n# AUDITNÍ PROTOKOL ŠVP-RVP\n\n# (POPIS KONTROLNÍHO ALGORITMU)\n\nMetodika je určena pro **Kvantifikaci Shody** školního vzdělávacího programu (ŠVP) s Rámcovým vzdělávacím programem (RVP).\n\n## FÁZE 1: VALIDACE DOKUMENTACE\n\n**Cíl:** Ověřit platnost, aktuálnost a strukturu zdrojových dokumentů.\n\n- **RVP Verifikace:** Otevřít aktuální verzi RVP (např. RVP ZV/G/SOŠ).\n- **Typová shoda:** Ověřit, že RVP se vztahuje k danému typu školy.\n- **ŠVP Dimenze:** Identifikovat a izolovat relevantní části ŠVP: Profil absolventa, Klíčové kompetence (KK), Vzdělávací oblasti (VO), případně Učební plán (UP).\n- **Verzování:** Potvrdit, že obě verze (RVP a ŠVP) jsou nejnovější a platné (včetně dodatků RVP).\n\n## FÁZE 2: DATABÁZOVÉ MAPOVÁNÍ VÝSTUPŮ (MASTER MATICE)\n\n**Cíl:** Vytvořit systémovou databázi pro křížové porovnání všech povinných komponent RVP se ŠVP.\n\n- **Dekompozice RVP:** Rozložit RVP na základní povinné komponenty: Klíčové kompetence, Vzdělávací oblasti a obory, Očekávané výstupy (OVU), Průřezová témata (PT).\n- **Přiřazovací mapa:** Vytvořit hlavní kontrolní matici (Master Matice) pro záznam vazeb.\n\n| Oblast RVP | Výstup RVP (OVU) | Odpovídající Část ŠVP (Předmět/Ročník) | Konkrétní Tématický Celek v ŠVP | Stav Shody (Protokol) |\n| --- | --- | --- | --- | --- |\n| ... | ... | ... | ... | ... |\n| --- | --- | --- | --- | --- |\n\n## FÁZE 3: ALGORITMICKÁ KONTROLA POKRYTÍ A HLOUBKY\n\n**Cíl:** Posoudit, zda každý povinný výstup RVP je adekvátně reflektován v obsahu ŠVP, a přidělit bodovou hodnotu pro kvantifikaci.\n\n- **Audit OVU:** Projít každý jednotlivý Očekávaný výstup (OVU) z RVP.\n- **Kódování stavu a bodování:** U každého OVU v matici označit stav pokrytí dle následujícího schématu:\n\n| Kód (Protokol) | Popis (Kvalitativní zjištění) | Bodová hodnota (Kvantifikace) |\n| --- | --- | --- |\n| ✅ | Plná shoda (Výstup pokryt v plném rozsahu, odpovídající úrovni RVP) | 1,0 |\n| --- | --- | --- |\n| ⚠️ | Částečná shoda (Formální pokrytí, omezený rozsah, chybná návaznost) | 0,5 |\n| --- | --- | --- |\n| ❌ | Absence (Výstup zcela chybí v obsahu ŠVP) | 0,0 |\n| --- | --- | --- |\n\n- **Defektologie ŠVP:** Identifikovat a zaznamenat deficity ŠVP: Chybějící výstupy (❌), Sémantické překryvy, Přetížení obsahu.\n- **Kvalitativní posun:** Ověřit, zda je formulace výstupů v ŠVP **aktivní, měřitelná a v souladu** s úrovní RVP.\n\n## FÁZE 4: STRUKTURÁLNÍ VERIFIKACE NÁVAZNOSTI (VERTIKÁLA/HORIZONTÁLA)\n\n**Cíl:** Zkontrolovat logickou posloupnost a provázanost učiva v rámci ŠVP.\n\n- **Vertikální Kontrola:** Ověřit posloupnost OVU a učiva uvnitř jednoho předmětu/oblasti (postup od jednodušších ke složitějším konceptům napříč ročníky).\n- **Horizontální Kontrola:** Zkontrolovat logické provázání napříč vzdělávacími oblastmi a předměty (např. fyzika ↔ matematika).\n- **PT Integrace:** Audit reálné integrace Průřezových témat (PT) do konkrétních částí obsahu, metod a projektů.\n\n## FÁZE 5: ANALÝZA ŠKOLNÍ PROFILACE A ROZŠÍŘENÍ RVP\n\n**Cíl:** Validovat, že profilace školy je **v souladu** s RVP a nejedná se o **rozpor**.\n\n- **Nekonfliktnost:** Porovnat definovaný Profil absolventa školy s Klíčovými kompetencemi RVP. Profil ŠVP musí RVP rozvíjet, nikoli mu odporovat.\n- **Modularita:** Zkontrolovat, zda volitelné předměty a rozšiřující moduly logicky navazují na vzdělávací oblasti RVP.\n- **Implementace specializace:** Popisně uvést, jak je školní profilace (např. STEM zaměření, projektová výuka) integrována do OVU a kompetencí definovaných RVP.\n\n## FÁZE 6: GENERÁTOR ZÁVĚREČNÉ ZPRÁVY A KVANTIFIKACE\n\n**Cíl:** Syntetizovat výsledky, kvantifikovat soulad a generovat závazné návrhy na korekce.\n\n### 6.1 Kvantifikace Souladu\n\nVypočítat Index shody (IS) na základě bodového hodnocení (Fáze 3):\n\n### 6.2 Interpretace Indexu Shody (IS)\n\nKlasifikace souladu pro standardizované vyhodnocení:\n\n| Interval IS | Klasifikace souladu | Popis |\n| --- | --- | --- |\n| 95-100 % | Výborný soulad | ŠVP plně odpovídá RVP, pouze stylistické nebo formální rozdíly. |\n| --- | --- | --- |\n| 85-94 % | Dobrá shoda | ŠVP pokrývá všechny klíčové výstupy, menší korekce nutné. |\n| --- | --- | --- |\n| 70-84 % | Částečná shoda | Významné nedostatky v některých oblastech, nutná revize obsahu. |\n| --- | --- | --- |\n| < 70 % | Kritická neshoda | ŠVP neplní rámcové požadavky, ohrožuje legislativní soulad. |\n| --- | --- | --- |\n\n### 6.3 Doplňkové Indexy\n\nVypočítat následující doplňkové indexy pro detailní kvalitativní analýzu:\n\n- **Index kompetenčního souladu (IKS):** Poměr pokrytí klíčových kompetencí RVP v ŠVP.\n- **Index průřezové integrace (IPI):** Míra reálné integrace průřezových témat do výuky.\n- **Index hloubky pokrytí (IHP):** Procento výstupů, které jsou v ŠVP rozvedeny na konkrétní výukové cíle (měřitelné, aktivní formulace).\n- **Index profilové rozšiřitelnosti (IPR):** Kolik rozšiřujících nebo profilových výstupů přesahuje rámec RVP, aniž by narušily jeho strukturu.\n\n### 6.4 Vizuální výstupy\n\nZajistit generování následujících vizualizací pro Závěrečnou zprávu:\n\n- Graf pokrytí po vzdělávacích oblastech (Sloupcový graf IS pro VO).\n- Pavoukový diagram Klíčových kompetencí (RVP vs. ŠVP).\n- Mapa defektů (Vizualizace ❌ a ⚠️ výstupů).\n\n### 6.5 Struktura Závěrečné Zprávy\n\nZpráva musí být strukturována dle standardizovaného formátu:\n\n| Oddíl | Obsah |\n| --- | --- |\n| A. Identifikace | Název školy, IZO, typ školy, datum revize, zpracovatel, verze ŠVP a RVP. |\n| --- | --- |\n| B. Shrnutí výsledků | Celkový Index Shody (IS), hlavní závěry a doporučení. |\n| --- | --- |\n| C. Kvantitativní analýza | Přehled IS v % dle kategorií OVU / VO / kompetencí. |\n| --- | --- |\n| D. Kvalitativní analýza | Slovní zhodnocení kvality souladu (formulace, obtížnost, integrace PT). |\n| --- | --- |\n| E. Rizikové oblasti | Přehled nalezených defektů (chybějící OVU, přetížení, formální shoda). |\n| --- | --- |\n| F. Návrhy opatření (Korekční plán) | Přesné návrhy změn - **Co, Kde, Kdo** má upravit, včetně termínu. |\n| --- | --- |\n| G. Přílohy | Master Matice (Fáze 2-3), revizní tabulka, výstupní grafy a metriky. |\n| --- | --- |\n\n\n\n\n.",resultingParameterName:"result",dependentParameterNames:[]}],personas:[],preparations:[{id:1,promptbookVersion:"0.103.0-8",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"Asistent pro LŠVP\n\nPERSONA Jsi asistent pro RVP Lyceum v rámci Národního pedagogického institutu České Republiky\nMETA IMAGE https://edulk.cz/getFile/id:475818/type:large/02%20zna%C4%8Dka%20npi.jpg\nRULE Pokud jsi nejsi jistý, napiš nevím\nKNOWLEDGE ./241129_Lyceum_final.pdf\nCONTEXT Obecně dokážeš řešit libovolné ŠVP, aktuálně řešíš {Školní vzdělávací program LYCEUM}\nRULE Z {Porovnání RVP a ŠVP - postup} je nejdůležitější fáze 3\nKNOWLEDGE {Školní vzdělávací program LYCEUM} ./ŠVP Lyceum - Finance v digitální době.pdf\nKNOWLEDGE @Slovník\n\n**Interní slovník - RVP/ŠVP**\n\n**RVP**\n\nRámcový vzdělávací program pro obor vzdělání Lyceum je dokument na národní úrovni, který formuluje požadavky na školní vzdělávací programy ve formě především očekávaných výsledků učení, kterých mají žáci absolvováním tohoto programu na dané škole dosáhnout.\n\n**ŠVP**\n\nŠkolní vzdělávací program pro obor vzdělání Lyceum je dokument každé jednotlivé školy, který popisuje v jakých vyučovacích předmětech/ vzdělávacích modulech a v jakých ročnících budou požadované očekávané výsledky učení naplněny. Zároveň formuluje další očekávané výsledky učení, které naplňují disponibilní část vyučovacího času určeného RVP pro tento obor vzdělání.\n\n**Očekávaný výsledek učení (OVU)**\n\nVyjadřuje jednotlivý požadavek na to, co mají žáci umět na konci vzdělávacího programu, tzn. jejich požadované kompetence. Je vyjádřen formulací, která je uvozena činnostním slovesem a dále obsahuje předmět této činnosti. Formulace je konkretizována resp. doplněna zpravidla formou odrážek vymezením dílčích znalostí, dovedností, postojů, jejichž splnění je předpokladem dosažení OVU jako celku.\n\n_Příklad:_\n\n<div class=\"joplin-table-wrapper\"><table><tbody><tr><th><p><strong>Žák/žákyně řídí realizaci jednoduchého projektu</strong></p></th></tr><tr><td><ul><li>naplánuje aktivity projektu</li></ul></td></tr><tr><td><ul><li>navrhne rozpočet projektu vzhledem k navrženým aktivitám</li></ul></td></tr><tr><td><ul><li>stanoví základní ukazatele a sleduje jejich naplňování</li></ul></td></tr><tr><td><ul><li>vede projektový tým</li></ul></td></tr><tr><td><ul><li>uvede, jak by řešil krizové situace v projektu</li></ul></td></tr><tr><td><ul><li>vyhodnotí úspěšnost projektu</li></ul></td></tr></tbody></table></div>\n\n**Vzdělávací oblasti**\n\nOčekávané výsledky učení jsou v **_RVP členěny do 4 vzdělávacích oblastí_**, které tvoří společný všeobecně vzdělávací základ:\n\n- Osobnostní rozvoj, vzdělávání ke zdraví, bezpečí a produktivnímu pracovnímu životu (kariéře)\n- Komunikační a jazykové vzdělávání\n- Aplikované vzdělávání STEM (Science, Technology, Engeneering, Math), tj. přírodní vědy, informatika, technika, matematika\n- Prakticky orientované vzdělávání společenskovědní a humanitní\n\nKaždá vzdělávací oblast se dále člení na okruhy, v jejichž rámci jsou OVU samostatně číslované.\n\n<div class=\"joplin-table-wrapper\"><table><tbody><tr><th rowspan=\"21\"><ul><li>Prakticky orientované vzdělávání společenskovědní a humanitní</li></ul></th><th rowspan=\"21\"><p><strong>Člověk, ekonomie a podnikání</strong></p></th><th rowspan=\"7\"><p><strong>1</strong></p></th><th><p><strong>zpracuje podklady související s podnikáním</strong></p></th></tr><tr><td><p>připraví podnikatelský záměr</p></td></tr><tr><td><p>sestaví zakladatelský rozpočet</p></td></tr><tr><td><p>zkalkuluje cenu zboží nebo služby</p></td></tr><tr><td><p>vysvětlí na příkladu základní povinnosti podnikatele vůči státu a zaměstnancům</p></td></tr><tr><td><p>vede daňovou evidenci</p></td></tr><tr><td><p>vysvětlí na příkladech etiku v podnikání</p></td></tr><tr><td rowspan=\"7\"><p><strong>2</strong></p></td><td><p><strong>řídí realizaci jednoduchého projektu</strong></p></td></tr><tr><td><p>naplánuje aktivity projektu</p></td></tr><tr><td><p>navrhne rozpočet projektu vzhledem k navrženým aktivitám</p></td></tr><tr><td><p>stanoví základní ukazatele a sleduje jejich naplňování</p></td></tr><tr><td><p>vede projektový tým</p></td></tr><tr><td><p>uvede, jak by řešil krizové situace v projektu</p></td></tr><tr><td><p>vyhodnotí úspěšnost projektu</p></td></tr><tr><td rowspan=\"7\"><p><strong>3</strong></p></td><td><p><strong>aplikuje ekonomické teorie v osobním a profesním životě</strong></p></td></tr><tr><td><p>vysvětlí základní ekonomické otázky</p></td></tr><tr><td><p>vysvětí stanovení rovnovážné ceny na dokonalém i nedokonalém trhu</p></td></tr><tr><td><p>charakterizuje výrobní faktory a vysvětlí hranici produkčních možností a náklady obětované příležitosti</p></td></tr><tr><td><p>uvede nejdůležitější makroekonomické pojmy a vliv jejich výše na kvalitu života a podnikání v daném státě</p></td></tr><tr><td><p>vysvětlí podstatu inflace a její důsledky na finanční situaci obyvatel a na příkladu ukáže jak se bránit jejím nepříznivým důsledkům</p></td></tr><tr><td><p>uvede hlavní výhody a nevýhody mezinárodního obchodu a vliv ochranářských opatření na ekonomickou situaci dané země</p></td></tr><tr><td></td><td></td><td><p><strong>4</strong></p></td><td><p>Atd.</p></td></tr></tbody></table></div>\n\n**Vyučovací předmět / vzdělávací modul**\n\nOčekávané výsledky učení jsou v **ŠVP** členěny do vyučovacích předmětů nebo vzdělávacích modulů, které jsou dále zařazeny do jednoho nebo více ročníků 4letého studia. Vyučovací předmět / vzdělávací modul tvoří vyučovací jednotku, kde jsou očekávané výsledky učení dále rozpracovány pro potřeby výuky podle následující šablony\n\n| **A. VSTUPNÍ ČÁST** |\n| --- |\n| **1\\. Název** |\n| **2\\. Kód** (kódy by měly být navázány na obory vzdělání a výsledky učení) |\n| **2a) Kategorie vzdělání** - v případě, že nebude součástí kódu |\n| **3\\. Typ vyučovací jednotky** (modul, předmět, stáž apod.) |\n| **4\\. Délka** (počet hodin - dělitelný čtyřmi (optimální modul 16, 32 hodin = týden výuky) |\n| **5\\. Platnost** (datum, od kterého platí) |\n| **6\\. Vstupní předpoklady** (vymezení požadované úrovně vstupních vědomostí a dovedností, které jsou předpokladem úspěšného studia) |\n| |\n| **B. JÁDRO VYUČOVACÍ JEDNOTKY** |\n| **1\\. Charakteristika** (stručná anotace popisující obecné cíle a pojetí) |\n| **2\\. Očekávané výsledky učení a jejich indikátory (převzaté z RVP nebo dále konkretizované)** |\n| **3\\. Podpora rozvoje klíčových kompetencí a základních gramotností** (které klíčové kompetence jsou v rozvíjeny) |\n| **4\\. Obsah vzdělávání** (rozpis učiva) |\n| **5\\. Vzdělávací strategie** (strategie výuky, resp. učební činnosti žáků, které jsou doporučené pro dosažení výsledků) |\n| |\n| **C. VÝSTUPNÍ ČÁST** |\n| **1\\. Způsob ověřování dosažených výsledků** (ve vazbě na jednotlivé výsledky učení) |\n| **2\\. Kritéria hodnocení** (co znamená splnění výsledků učení, kdy je splněna celá vyučovací jednotka, kritéria pro známky, příp. procentuální, slovní hodnocení) |\n| **3\\. Doporučená studijní literatura, odkazy na ilustrační zdroje** |\n| **4\\. Poznámky** |\n\n**Soulad OVU RVP a ŠVP**\n\nTento soulad je předmětem zjišťování. Soulad nastává, jestliže jsou očekávané výsledky učení z jednotlivých vzdělávacích oblastí RVP **obsaženy** ve vyučovacích předmětech/ vzdělávacích modulech ŠVP jednotlivých škol, tzn. že v ŠVP se objevuje jejich formulace buď v doslovném nebo podobném znění v jednom nebo více vyučovacích předmětech/ vzdělávacích modulech.\n\n_Příklad souladu:_\n\nRVP ŠVP - komunikace a marketing (SŠ obchodní Č.\n\n| **2** | **řídí realizaci jednoduchého projektu** |\n| --- | --- |\n| naplánuje aktivity projektu |\n| navrhne rozpočet projektu vzhledem k navrženým aktivitám |\n| stanoví základní ukazatele a sleduje jejich naplňování |\n| vede projektový tým |\n| uvede, jak by řešil krizové situace v projektu |\n| vyhodnotí úspěšnost projektu |\n\nKNOWLEDGE {Porovnání RVP a ŠVP - postup}\n\n\n# AUDITNÍ PROTOKOL ŠVP-RVP\n\n# (POPIS KONTROLNÍHO ALGORITMU)\n\nMetodika je určena pro **Kvantifikaci Shody** školního vzdělávacího programu (ŠVP) s Rámcovým vzdělávacím programem (RVP).\n\n## FÁZE 1: VALIDACE DOKUMENTACE\n\n**Cíl:** Ověřit platnost, aktuálnost a strukturu zdrojových dokumentů.\n\n- **RVP Verifikace:** Otevřít aktuální verzi RVP (např. RVP ZV/G/SOŠ).\n- **Typová shoda:** Ověřit, že RVP se vztahuje k danému typu školy.\n- **ŠVP Dimenze:** Identifikovat a izolovat relevantní části ŠVP: Profil absolventa, Klíčové kompetence (KK), Vzdělávací oblasti (VO), případně Učební plán (UP).\n- **Verzování:** Potvrdit, že obě verze (RVP a ŠVP) jsou nejnovější a platné (včetně dodatků RVP).\n\n## FÁZE 2: DATABÁZOVÉ MAPOVÁNÍ VÝSTUPŮ (MASTER MATICE)\n\n**Cíl:** Vytvořit systémovou databázi pro křížové porovnání všech povinných komponent RVP se ŠVP.\n\n- **Dekompozice RVP:** Rozložit RVP na základní povinné komponenty: Klíčové kompetence, Vzdělávací oblasti a obory, Očekávané výstupy (OVU), Průřezová témata (PT).\n- **Přiřazovací mapa:** Vytvořit hlavní kontrolní matici (Master Matice) pro záznam vazeb.\n\n| Oblast RVP | Výstup RVP (OVU) | Odpovídající Část ŠVP (Předmět/Ročník) | Konkrétní Tématický Celek v ŠVP | Stav Shody (Protokol) |\n| --- | --- | --- | --- | --- |\n| ... | ... | ... | ... | ... |\n| --- | --- | --- | --- | --- |\n\n## FÁZE 3: ALGORITMICKÁ KONTROLA POKRYTÍ A HLOUBKY\n\n**Cíl:** Posoudit, zda každý povinný výstup RVP je adekvátně reflektován v obsahu ŠVP, a přidělit bodovou hodnotu pro kvantifikaci.\n\n- **Audit OVU:** Projít každý jednotlivý Očekávaný výstup (OVU) z RVP.\n- **Kódování stavu a bodování:** U každého OVU v matici označit stav pokrytí dle následujícího schématu:\n\n| Kód (Protokol) | Popis (Kvalitativní zjištění) | Bodová hodnota (Kvantifikace) |\n| --- | --- | --- |\n| ✅ | Plná shoda (Výstup pokryt v plném rozsahu, odpovídající úrovni RVP) | 1,0 |\n| --- | --- | --- |\n| ⚠️ | Částečná shoda (Formální pokrytí, omezený rozsah, chybná návaznost) | 0,5 |\n| --- | --- | --- |\n| ❌ | Absence (Výstup zcela chybí v obsahu ŠVP) | 0,0 |\n| --- | --- | --- |\n\n- **Defektologie ŠVP:** Identifikovat a zaznamenat deficity ŠVP: Chybějící výstupy (❌), Sémantické překryvy, Přetížení obsahu.\n- **Kvalitativní posun:** Ověřit, zda je formulace výstupů v ŠVP **aktivní, měřitelná a v souladu** s úrovní RVP.\n\n## FÁZE 4: STRUKTURÁLNÍ VERIFIKACE NÁVAZNOSTI (VERTIKÁLA/HORIZONTÁLA)\n\n**Cíl:** Zkontrolovat logickou posloupnost a provázanost učiva v rámci ŠVP.\n\n- **Vertikální Kontrola:** Ověřit posloupnost OVU a učiva uvnitř jednoho předmětu/oblasti (postup od jednodušších ke složitějším konceptům napříč ročníky).\n- **Horizontální Kontrola:** Zkontrolovat logické provázání napříč vzdělávacími oblastmi a předměty (např. fyzika ↔ matematika).\n- **PT Integrace:** Audit reálné integrace Průřezových témat (PT) do konkrétních částí obsahu, metod a projektů.\n\n## FÁZE 5: ANALÝZA ŠKOLNÍ PROFILACE A ROZŠÍŘENÍ RVP\n\n**Cíl:** Validovat, že profilace školy je **v souladu** s RVP a nejedná se o **rozpor**.\n\n- **Nekonfliktnost:** Porovnat definovaný Profil absolventa školy s Klíčovými kompetencemi RVP. Profil ŠVP musí RVP rozvíjet, nikoli mu odporovat.\n- **Modularita:** Zkontrolovat, zda volitelné předměty a rozšiřující moduly logicky navazují na vzdělávací oblasti RVP.\n- **Implementace specializace:** Popisně uvést, jak je školní profilace (např. STEM zaměření, projektová výuka) integrována do OVU a kompetencí definovaných RVP.\n\n## FÁZE 6: GENERÁTOR ZÁVĚREČNÉ ZPRÁVY A KVANTIFIKACE\n\n**Cíl:** Syntetizovat výsledky, kvantifikovat soulad a generovat závazné návrhy na korekce.\n\n### 6.1 Kvantifikace Souladu\n\nVypočítat Index shody (IS) na základě bodového hodnocení (Fáze 3):\n\n### 6.2 Interpretace Indexu Shody (IS)\n\nKlasifikace souladu pro standardizované vyhodnocení:\n\n| Interval IS | Klasifikace souladu | Popis |\n| --- | --- | --- |\n| 95-100 % | Výborný soulad | ŠVP plně odpovídá RVP, pouze stylistické nebo formální rozdíly. |\n| --- | --- | --- |\n| 85-94 % | Dobrá shoda | ŠVP pokrývá všechny klíčové výstupy, menší korekce nutné. |\n| --- | --- | --- |\n| 70-84 % | Částečná shoda | Významné nedostatky v některých oblastech, nutná revize obsahu. |\n| --- | --- | --- |\n| < 70 % | Kritická neshoda | ŠVP neplní rámcové požadavky, ohrožuje legislativní soulad. |\n| --- | --- | --- |\n\n### 6.3 Doplňkové Indexy\n\nVypočítat následující doplňkové indexy pro detailní kvalitativní analýzu:\n\n- **Index kompetenčního souladu (IKS):** Poměr pokrytí klíčových kompetencí RVP v ŠVP.\n- **Index průřezové integrace (IPI):** Míra reálné integrace průřezových témat do výuky.\n- **Index hloubky pokrytí (IHP):** Procento výstupů, které jsou v ŠVP rozvedeny na konkrétní výukové cíle (měřitelné, aktivní formulace).\n- **Index profilové rozšiřitelnosti (IPR):** Kolik rozšiřujících nebo profilových výstupů přesahuje rámec RVP, aniž by narušily jeho strukturu.\n\n### 6.4 Vizuální výstupy\n\nZajistit generování následujících vizualizací pro Závěrečnou zprávu:\n\n- Graf pokrytí po vzdělávacích oblastech (Sloupcový graf IS pro VO).\n- Pavoukový diagram Klíčových kompetencí (RVP vs. ŠVP).\n- Mapa defektů (Vizualizace ❌ a ⚠️ výstupů).\n\n### 6.5 Struktura Závěrečné Zprávy\n\nZpráva musí být strukturována dle standardizovaného formátu:\n\n| Oddíl | Obsah |\n| --- | --- |\n| A. Identifikace | Název školy, IZO, typ školy, datum revize, zpracovatel, verze ŠVP a RVP. |\n| --- | --- |\n| B. Shrnutí výsledků | Celkový Index Shody (IS), hlavní závěry a doporučení. |\n| --- | --- |\n| C. Kvantitativní analýza | Přehled IS v % dle kategorií OVU / VO / kompetencí. |\n| --- | --- |\n| D. Kvalitativní analýza | Slovní zhodnocení kvality souladu (formulace, obtížnost, integrace PT). |\n| --- | --- |\n| E. Rizikové oblasti | Přehled nalezených defektů (chybějící OVU, přetížení, formální shoda). |\n| --- | --- |\n| F. Návrhy opatření (Korekční plán) | Přesné návrhy změn - **Co, Kde, Kdo** má upravit, včetně termínu. |\n| --- | --- |\n| G. Přílohy | Master Matice (Fáze 2-3), revizní tabulka, výstupní grafy a metriky. |\n| --- | --- |\n\n\n\n\n.\n"}],sourceFile:"./books/examples/lsvp-asistent.book"}];
|
|
1486
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge from Markdown\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book`\n- INPUT PARAMETER `{knowledgeContent}` Markdown document content\n- OUTPUT PARAMETER `{knowledgePieces}` The knowledge JSON object\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}\n```\n\n`-> {knowledgePieces}`\n"}],sourceFile:"./books/prepare-knowledge-from-markdown.book"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Keywords\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-keywords.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{keywords}` Keywords separated by comma\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}\n```\n\n`-> {keywords}`\n"}],sourceFile:"./books/prepare-knowledge-keywords.book"},{title:"Prepare Knowledge-piece Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge-piece Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-title.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{title}` The title of the document\n\n## Knowledge\n\n- EXPECT MIN 1 WORD\n- EXPECT MAX 8 WORDS\n\n```markdown\nYou are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-knowledge-title.book"},{title:"Prepare Persona",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book",formfactorName:"GENERIC",parameters:[{name:"availableModels",description:"List of available model names together with their descriptions as JSON",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelsRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n```json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpful assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n```\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n```json\n{availableModels}\n```\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelsRequirements",format:"JSON",dependentParameterNames:["availableModels","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Persona\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-persona.book`\n- INPUT PARAMETER `{availableModels}` List of available model names together with their descriptions as JSON\n- INPUT PARAMETER `{personaDescription}` Description of the persona\n- OUTPUT PARAMETER `{modelsRequirements}` Specific requirements for the model\n\n## Make modelRequirements\n\n- FORMAT JSON\n\n```markdown\nYou are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n\\`\\`\\`json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpful assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n\\`\\`\\`\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n\\`\\`\\`json\n{availableModels}\n\\`\\`\\`\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}\n```\n\n`-> {modelsRequirements}`\n"}],sourceFile:"./books/prepare-persona.book"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-title.book",formfactorName:"GENERIC",parameters:[{name:"book",description:"The book to prepare the title for",isInput:true,isOutput:false},{name:"title",description:"Best title for the book",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-title",title:"Make title",content:"Make best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}",resultingParameterName:"title",expectations:{words:{min:1,max:8},lines:{min:1,max:1}},dependentParameterNames:["book"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-title.book`\n- INPUT PARAMETER `{book}` The book to prepare the title for\n- OUTPUT PARAMETER `{title}` Best title for the book\n\n## Make title\n\n- EXPECT MIN 1 Word\n- EXPECT MAX 8 Words\n- EXPECT EXACTLY 1 Line\n\n```markdown\nMake best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-title.book"}];
|
|
1483
1487
|
|
|
1484
1488
|
/**
|
|
1485
1489
|
* Checks if value is valid email
|
|
@@ -1586,6 +1590,8 @@ function isValidUrl(url) {
|
|
|
1586
1590
|
* Function `validatePipelineString` will validate the if the string is a valid pipeline string
|
|
1587
1591
|
* It does not check if the string is fully logically correct, but if it is a string that can be a pipeline string or the string looks completely different.
|
|
1588
1592
|
*
|
|
1593
|
+
* Note: [🔂] This function is idempotent.
|
|
1594
|
+
*
|
|
1589
1595
|
* @param {string} pipelineString the candidate for a pipeline string
|
|
1590
1596
|
* @returns {PipelineString} the same string as input, but validated as valid
|
|
1591
1597
|
* @throws {ParseError} if the string is not a valid pipeline string
|
|
@@ -1734,7 +1740,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
1734
1740
|
pipelineString += '\n\n';
|
|
1735
1741
|
pipelineString += '```' + contentLanguage;
|
|
1736
1742
|
pipelineString += '\n';
|
|
1737
|
-
pipelineString += spaceTrim(content);
|
|
1743
|
+
pipelineString += spaceTrim$1(content);
|
|
1738
1744
|
// <- TODO: [main] !!3 Escape
|
|
1739
1745
|
// <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
|
|
1740
1746
|
pipelineString += '\n';
|
|
@@ -1855,7 +1861,7 @@ function checkSerializableAsJson(options) {
|
|
|
1855
1861
|
}
|
|
1856
1862
|
else if (typeof value === 'object') {
|
|
1857
1863
|
if (value instanceof Date) {
|
|
1858
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
1864
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
1859
1865
|
\`${name}\` is Date
|
|
1860
1866
|
|
|
1861
1867
|
Use \`string_date_iso8601\` instead
|
|
@@ -1874,7 +1880,7 @@ function checkSerializableAsJson(options) {
|
|
|
1874
1880
|
throw new UnexpectedError(`${name} is RegExp`);
|
|
1875
1881
|
}
|
|
1876
1882
|
else if (value instanceof Error) {
|
|
1877
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
1883
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
1878
1884
|
\`${name}\` is unserialized Error
|
|
1879
1885
|
|
|
1880
1886
|
Use function \`serializeError\`
|
|
@@ -1897,7 +1903,7 @@ function checkSerializableAsJson(options) {
|
|
|
1897
1903
|
}
|
|
1898
1904
|
catch (error) {
|
|
1899
1905
|
assertsError(error);
|
|
1900
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
1906
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
1901
1907
|
\`${name}\` is not serializable
|
|
1902
1908
|
|
|
1903
1909
|
${block(error.stack || error.message)}
|
|
@@ -1929,7 +1935,7 @@ function checkSerializableAsJson(options) {
|
|
|
1929
1935
|
}
|
|
1930
1936
|
}
|
|
1931
1937
|
else {
|
|
1932
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
1938
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
1933
1939
|
\`${name}\` is unknown type
|
|
1934
1940
|
|
|
1935
1941
|
Additional message for \`${name}\`:
|
|
@@ -1959,7 +1965,7 @@ function deepClone(objectValue) {
|
|
|
1959
1965
|
TODO: [🧠] Is there a better implementation?
|
|
1960
1966
|
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
1961
1967
|
> for (const propertyName of propertyNames) {
|
|
1962
|
-
> const value = (objectValue as
|
|
1968
|
+
> const value = (objectValue as chococake)[propertyName];
|
|
1963
1969
|
> if (value && typeof value === 'object') {
|
|
1964
1970
|
> deepClone(value);
|
|
1965
1971
|
> }
|
|
@@ -2164,6 +2170,8 @@ function isValidPipelineUrl(url) {
|
|
|
2164
2170
|
* - if it is valid json
|
|
2165
2171
|
* - if it is meaningful
|
|
2166
2172
|
*
|
|
2173
|
+
* Note: [🔂] This function is idempotent.
|
|
2174
|
+
*
|
|
2167
2175
|
* @param pipeline valid or invalid PipelineJson
|
|
2168
2176
|
* @returns the same pipeline if it is logically valid
|
|
2169
2177
|
* @throws {PipelineLogicError} on logical error in the pipeline
|
|
@@ -2181,7 +2189,7 @@ function validatePipeline(pipeline) {
|
|
|
2181
2189
|
if (!(error instanceof PipelineLogicError)) {
|
|
2182
2190
|
throw error;
|
|
2183
2191
|
}
|
|
2184
|
-
console.error(spaceTrim$
|
|
2192
|
+
console.error(spaceTrim$2((block) => `
|
|
2185
2193
|
Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
|
|
2186
2194
|
|
|
2187
2195
|
${block(error.message)}
|
|
@@ -2208,7 +2216,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2208
2216
|
})();
|
|
2209
2217
|
if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
|
|
2210
2218
|
// <- Note: [🚲]
|
|
2211
|
-
throw new PipelineLogicError(spaceTrim$
|
|
2219
|
+
throw new PipelineLogicError(spaceTrim$2((block) => `
|
|
2212
2220
|
Invalid promptbook URL "${pipeline.pipelineUrl}"
|
|
2213
2221
|
|
|
2214
2222
|
${block(pipelineIdentification)}
|
|
@@ -2216,7 +2224,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2216
2224
|
}
|
|
2217
2225
|
if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
|
|
2218
2226
|
// <- Note: [🚲]
|
|
2219
|
-
throw new PipelineLogicError(spaceTrim$
|
|
2227
|
+
throw new PipelineLogicError(spaceTrim$2((block) => `
|
|
2220
2228
|
Invalid Promptbook Version "${pipeline.bookVersion}"
|
|
2221
2229
|
|
|
2222
2230
|
${block(pipelineIdentification)}
|
|
@@ -2225,7 +2233,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2225
2233
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
2226
2234
|
if (!Array.isArray(pipeline.parameters)) {
|
|
2227
2235
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
2228
|
-
throw new ParseError(spaceTrim$
|
|
2236
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
2229
2237
|
Pipeline is valid JSON but with wrong structure
|
|
2230
2238
|
|
|
2231
2239
|
\`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
|
|
@@ -2236,7 +2244,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2236
2244
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
2237
2245
|
if (!Array.isArray(pipeline.tasks)) {
|
|
2238
2246
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
2239
|
-
throw new ParseError(spaceTrim$
|
|
2247
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
2240
2248
|
Pipeline is valid JSON but with wrong structure
|
|
2241
2249
|
|
|
2242
2250
|
\`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
|
|
@@ -2262,7 +2270,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2262
2270
|
// Note: Check each parameter individually
|
|
2263
2271
|
for (const parameter of pipeline.parameters) {
|
|
2264
2272
|
if (parameter.isInput && parameter.isOutput) {
|
|
2265
|
-
throw new PipelineLogicError(spaceTrim$
|
|
2273
|
+
throw new PipelineLogicError(spaceTrim$2((block) => `
|
|
2266
2274
|
|
|
2267
2275
|
Parameter \`{${parameter.name}}\` can not be both input and output
|
|
2268
2276
|
|
|
@@ -2273,7 +2281,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2273
2281
|
if (!parameter.isInput &&
|
|
2274
2282
|
!parameter.isOutput &&
|
|
2275
2283
|
!pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
|
|
2276
|
-
throw new PipelineLogicError(spaceTrim$
|
|
2284
|
+
throw new PipelineLogicError(spaceTrim$2((block) => `
|
|
2277
2285
|
Parameter \`{${parameter.name}}\` is created but not used
|
|
2278
2286
|
|
|
2279
2287
|
You can declare {${parameter.name}} as output parameter by adding in the header:
|
|
@@ -2285,7 +2293,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2285
2293
|
}
|
|
2286
2294
|
// Note: Testing that parameter is either input or result of some task
|
|
2287
2295
|
if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
|
|
2288
|
-
throw new PipelineLogicError(spaceTrim$
|
|
2296
|
+
throw new PipelineLogicError(spaceTrim$2((block) => `
|
|
2289
2297
|
Parameter \`{${parameter.name}}\` is declared but not defined
|
|
2290
2298
|
|
|
2291
2299
|
You can do one of these:
|
|
@@ -2301,14 +2309,14 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2301
2309
|
// Note: Checking each task individually
|
|
2302
2310
|
for (const task of pipeline.tasks) {
|
|
2303
2311
|
if (definedParameters.has(task.resultingParameterName)) {
|
|
2304
|
-
throw new PipelineLogicError(spaceTrim$
|
|
2312
|
+
throw new PipelineLogicError(spaceTrim$2((block) => `
|
|
2305
2313
|
Parameter \`{${task.resultingParameterName}}\` is defined multiple times
|
|
2306
2314
|
|
|
2307
2315
|
${block(pipelineIdentification)}
|
|
2308
2316
|
`));
|
|
2309
2317
|
}
|
|
2310
2318
|
if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
|
|
2311
|
-
throw new PipelineLogicError(spaceTrim$
|
|
2319
|
+
throw new PipelineLogicError(spaceTrim$2((block) => `
|
|
2312
2320
|
Parameter name {${task.resultingParameterName}} is reserved, please use different name
|
|
2313
2321
|
|
|
2314
2322
|
${block(pipelineIdentification)}
|
|
@@ -2318,7 +2326,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2318
2326
|
if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
|
|
2319
2327
|
if (!task.format &&
|
|
2320
2328
|
!task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
|
|
2321
|
-
throw new PipelineLogicError(spaceTrim$
|
|
2329
|
+
throw new PipelineLogicError(spaceTrim$2((block) => `
|
|
2322
2330
|
Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
|
|
2323
2331
|
|
|
2324
2332
|
${block(pipelineIdentification)}
|
|
@@ -2326,7 +2334,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2326
2334
|
}
|
|
2327
2335
|
for (const joker of task.jokerParameterNames) {
|
|
2328
2336
|
if (!task.dependentParameterNames.includes(joker)) {
|
|
2329
|
-
throw new PipelineLogicError(spaceTrim$
|
|
2337
|
+
throw new PipelineLogicError(spaceTrim$2((block) => `
|
|
2330
2338
|
Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
|
|
2331
2339
|
|
|
2332
2340
|
${block(pipelineIdentification)}
|
|
@@ -2337,21 +2345,21 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2337
2345
|
if (task.expectations) {
|
|
2338
2346
|
for (const [unit, { min, max }] of Object.entries(task.expectations)) {
|
|
2339
2347
|
if (min !== undefined && max !== undefined && min > max) {
|
|
2340
|
-
throw new PipelineLogicError(spaceTrim$
|
|
2348
|
+
throw new PipelineLogicError(spaceTrim$2((block) => `
|
|
2341
2349
|
Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
|
|
2342
2350
|
|
|
2343
2351
|
${block(pipelineIdentification)}
|
|
2344
2352
|
`));
|
|
2345
2353
|
}
|
|
2346
2354
|
if (min !== undefined && min < 0) {
|
|
2347
|
-
throw new PipelineLogicError(spaceTrim$
|
|
2355
|
+
throw new PipelineLogicError(spaceTrim$2((block) => `
|
|
2348
2356
|
Min expectation of ${unit} must be zero or positive
|
|
2349
2357
|
|
|
2350
2358
|
${block(pipelineIdentification)}
|
|
2351
2359
|
`));
|
|
2352
2360
|
}
|
|
2353
2361
|
if (max !== undefined && max <= 0) {
|
|
2354
|
-
throw new PipelineLogicError(spaceTrim$
|
|
2362
|
+
throw new PipelineLogicError(spaceTrim$2((block) => `
|
|
2355
2363
|
Max expectation of ${unit} must be positive
|
|
2356
2364
|
|
|
2357
2365
|
${block(pipelineIdentification)}
|
|
@@ -2373,7 +2381,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2373
2381
|
while (unresovedTasks.length > 0) {
|
|
2374
2382
|
if (loopLimit-- < 0) {
|
|
2375
2383
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
2376
|
-
throw new UnexpectedError(spaceTrim$
|
|
2384
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2377
2385
|
Loop limit reached during detection of circular dependencies in \`validatePipeline\`
|
|
2378
2386
|
|
|
2379
2387
|
${block(pipelineIdentification)}
|
|
@@ -2383,7 +2391,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2383
2391
|
if (currentlyResovedTasks.length === 0) {
|
|
2384
2392
|
throw new PipelineLogicError(
|
|
2385
2393
|
// TODO: [🐎] DRY
|
|
2386
|
-
spaceTrim$
|
|
2394
|
+
spaceTrim$2((block) => `
|
|
2387
2395
|
|
|
2388
2396
|
Can not resolve some parameters:
|
|
2389
2397
|
Either you are using a parameter that is not defined, or there are some circular dependencies.
|
|
@@ -2530,7 +2538,7 @@ function unpreparePipeline(pipeline) {
|
|
|
2530
2538
|
* Library of pipelines that groups together pipelines for an application.
|
|
2531
2539
|
* This implementation is a very thin wrapper around the Array / Map of pipelines.
|
|
2532
2540
|
*
|
|
2533
|
-
* @private internal function of `
|
|
2541
|
+
* @private internal function of `createPipelineCollectionFromJson`, use `createPipelineCollectionFromJson` instead
|
|
2534
2542
|
* @see https://github.com/webgptorg/pipeline#pipeline-collection
|
|
2535
2543
|
*/
|
|
2536
2544
|
class SimplePipelineCollection {
|
|
@@ -2540,14 +2548,14 @@ class SimplePipelineCollection {
|
|
|
2540
2548
|
* @param pipelines Array of pipeline JSON objects to include in the collection
|
|
2541
2549
|
*
|
|
2542
2550
|
* Note: During the construction logic of all pipelines are validated
|
|
2543
|
-
* Note: It is not recommended to use this constructor directly, use `
|
|
2551
|
+
* Note: It is not recommended to use this constructor directly, use `createPipelineCollectionFromJson` *(or other variant)* instead
|
|
2544
2552
|
*/
|
|
2545
2553
|
constructor(...pipelines) {
|
|
2546
2554
|
this.collection = new Map();
|
|
2547
2555
|
for (const pipeline of pipelines) {
|
|
2548
2556
|
// TODO: [👠] DRY
|
|
2549
2557
|
if (pipeline.pipelineUrl === undefined) {
|
|
2550
|
-
throw new PipelineUrlError(spaceTrim$
|
|
2558
|
+
throw new PipelineUrlError(spaceTrim$2(`
|
|
2551
2559
|
Pipeline with name "${pipeline.title}" does not have defined URL
|
|
2552
2560
|
|
|
2553
2561
|
File:
|
|
@@ -2569,7 +2577,7 @@ class SimplePipelineCollection {
|
|
|
2569
2577
|
pipelineJsonToString(unpreparePipeline(pipeline)) !==
|
|
2570
2578
|
pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
|
|
2571
2579
|
const existing = this.collection.get(pipeline.pipelineUrl);
|
|
2572
|
-
throw new PipelineUrlError(spaceTrim$
|
|
2580
|
+
throw new PipelineUrlError(spaceTrim$2(`
|
|
2573
2581
|
Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍎
|
|
2574
2582
|
|
|
2575
2583
|
Conflicting files:
|
|
@@ -2601,13 +2609,13 @@ class SimplePipelineCollection {
|
|
|
2601
2609
|
const pipeline = this.collection.get(url);
|
|
2602
2610
|
if (!pipeline) {
|
|
2603
2611
|
if (this.listPipelines().length === 0) {
|
|
2604
|
-
throw new NotFoundError(spaceTrim$
|
|
2612
|
+
throw new NotFoundError(spaceTrim$2(`
|
|
2605
2613
|
Pipeline with url "${url}" not found
|
|
2606
2614
|
|
|
2607
2615
|
No pipelines available
|
|
2608
2616
|
`));
|
|
2609
2617
|
}
|
|
2610
|
-
throw new NotFoundError(spaceTrim$
|
|
2618
|
+
throw new NotFoundError(spaceTrim$2((block) => `
|
|
2611
2619
|
Pipeline with url "${url}" not found
|
|
2612
2620
|
|
|
2613
2621
|
Available pipelines:
|
|
@@ -2628,16 +2636,16 @@ class SimplePipelineCollection {
|
|
|
2628
2636
|
}
|
|
2629
2637
|
|
|
2630
2638
|
/**
|
|
2631
|
-
* Creates PipelineCollection from array of PipelineJson or PipelineString
|
|
2639
|
+
* Creates `PipelineCollection` from array of PipelineJson or PipelineString
|
|
2632
2640
|
*
|
|
2633
|
-
* Note: Functions `
|
|
2641
|
+
* Note: Functions `pipelineCollectionToJson` and `createPipelineCollectionFromJson` are complementary
|
|
2634
2642
|
* Note: Syntax, parsing, and logic consistency checks are performed on all sources during build
|
|
2635
2643
|
*
|
|
2636
2644
|
* @param promptbookSources
|
|
2637
2645
|
* @returns PipelineCollection
|
|
2638
2646
|
* @public exported from `@promptbook/core`
|
|
2639
2647
|
*/
|
|
2640
|
-
function
|
|
2648
|
+
function createPipelineCollectionFromJson(...promptbooks) {
|
|
2641
2649
|
return new SimplePipelineCollection(...promptbooks);
|
|
2642
2650
|
}
|
|
2643
2651
|
|
|
@@ -2648,7 +2656,7 @@ function createCollectionFromJson(...promptbooks) {
|
|
|
2648
2656
|
*/
|
|
2649
2657
|
class MissingToolsError extends Error {
|
|
2650
2658
|
constructor(message) {
|
|
2651
|
-
super(spaceTrim$
|
|
2659
|
+
super(spaceTrim$2((block) => `
|
|
2652
2660
|
${block(message)}
|
|
2653
2661
|
|
|
2654
2662
|
Note: You have probably forgot to provide some tools for pipeline execution or preparation
|
|
@@ -2662,6 +2670,7 @@ class MissingToolsError extends Error {
|
|
|
2662
2670
|
/**
|
|
2663
2671
|
* Generates random token
|
|
2664
2672
|
*
|
|
2673
|
+
* Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
|
|
2665
2674
|
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
2666
2675
|
*
|
|
2667
2676
|
* @private internal helper function
|
|
@@ -2671,6 +2680,7 @@ function $randomToken(randomness) {
|
|
|
2671
2680
|
return randomBytes(randomness).toString('hex');
|
|
2672
2681
|
}
|
|
2673
2682
|
/**
|
|
2683
|
+
* TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
|
|
2674
2684
|
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
2675
2685
|
*/
|
|
2676
2686
|
|
|
@@ -2789,6 +2799,22 @@ class CollectionError extends Error {
|
|
|
2789
2799
|
}
|
|
2790
2800
|
}
|
|
2791
2801
|
|
|
2802
|
+
/**
|
|
2803
|
+
* This error indicates error from the database
|
|
2804
|
+
*
|
|
2805
|
+
* @public exported from `@promptbook/core`
|
|
2806
|
+
*/
|
|
2807
|
+
class DatabaseError extends Error {
|
|
2808
|
+
constructor(message) {
|
|
2809
|
+
super(message);
|
|
2810
|
+
this.name = 'DatabaseError';
|
|
2811
|
+
Object.setPrototypeOf(this, DatabaseError.prototype);
|
|
2812
|
+
}
|
|
2813
|
+
}
|
|
2814
|
+
/**
|
|
2815
|
+
* TODO: [🐱🚀] Explain that NotFoundError ([🐱🚀] and other specific errors) has priority over DatabaseError in some contexts
|
|
2816
|
+
*/
|
|
2817
|
+
|
|
2792
2818
|
/**
|
|
2793
2819
|
* This error type indicates that you try to use a feature that is not available in the current environment
|
|
2794
2820
|
*
|
|
@@ -2844,6 +2870,19 @@ class LimitReachedError extends Error {
|
|
|
2844
2870
|
}
|
|
2845
2871
|
}
|
|
2846
2872
|
|
|
2873
|
+
/**
|
|
2874
|
+
* This error indicates that promptbook operation is not allowed
|
|
2875
|
+
*
|
|
2876
|
+
* @public exported from `@promptbook/core`
|
|
2877
|
+
*/
|
|
2878
|
+
class NotAllowed extends Error {
|
|
2879
|
+
constructor(message) {
|
|
2880
|
+
super(message);
|
|
2881
|
+
this.name = 'NotAllowed';
|
|
2882
|
+
Object.setPrototypeOf(this, NotAllowed.prototype);
|
|
2883
|
+
}
|
|
2884
|
+
}
|
|
2885
|
+
|
|
2847
2886
|
/**
|
|
2848
2887
|
* This error type indicates that some part of the code is not implemented yet
|
|
2849
2888
|
*
|
|
@@ -2851,7 +2890,7 @@ class LimitReachedError extends Error {
|
|
|
2851
2890
|
*/
|
|
2852
2891
|
class NotYetImplementedError extends Error {
|
|
2853
2892
|
constructor(message) {
|
|
2854
|
-
super(spaceTrim$
|
|
2893
|
+
super(spaceTrim$2((block) => `
|
|
2855
2894
|
${block(message)}
|
|
2856
2895
|
|
|
2857
2896
|
Note: This feature is not implemented yet but it will be soon.
|
|
@@ -2904,6 +2943,8 @@ const PROMPTBOOK_ERRORS = {
|
|
|
2904
2943
|
PromptbookFetchError,
|
|
2905
2944
|
UnexpectedError,
|
|
2906
2945
|
WrappedError,
|
|
2946
|
+
NotAllowed,
|
|
2947
|
+
DatabaseError,
|
|
2907
2948
|
// TODO: [🪑]> VersionMismatchError,
|
|
2908
2949
|
};
|
|
2909
2950
|
/**
|
|
@@ -2951,7 +2992,7 @@ function serializeError(error) {
|
|
|
2951
2992
|
const { name, message, stack } = error;
|
|
2952
2993
|
const { id } = error;
|
|
2953
2994
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
2954
|
-
console.error(spaceTrim((block) => `
|
|
2995
|
+
console.error(spaceTrim$1((block) => `
|
|
2955
2996
|
|
|
2956
2997
|
Cannot serialize error with name "${name}"
|
|
2957
2998
|
|
|
@@ -2984,7 +3025,7 @@ function jsonParse(value) {
|
|
|
2984
3025
|
}
|
|
2985
3026
|
else if (typeof value !== 'string') {
|
|
2986
3027
|
console.error('Can not parse JSON from non-string value.', { text: value });
|
|
2987
|
-
throw new Error(spaceTrim(`
|
|
3028
|
+
throw new Error(spaceTrim$1(`
|
|
2988
3029
|
Can not parse JSON from non-string value.
|
|
2989
3030
|
|
|
2990
3031
|
The value type: ${typeof value}
|
|
@@ -2998,7 +3039,7 @@ function jsonParse(value) {
|
|
|
2998
3039
|
if (!(error instanceof Error)) {
|
|
2999
3040
|
throw error;
|
|
3000
3041
|
}
|
|
3001
|
-
throw new Error(spaceTrim((block) => `
|
|
3042
|
+
throw new Error(spaceTrim$1((block) => `
|
|
3002
3043
|
${block(error.message)}
|
|
3003
3044
|
|
|
3004
3045
|
The expected JSON text:
|
|
@@ -3051,7 +3092,7 @@ function deserializeError(error) {
|
|
|
3051
3092
|
message = `${name}: ${message}`;
|
|
3052
3093
|
}
|
|
3053
3094
|
if (stack !== undefined && stack !== '') {
|
|
3054
|
-
message = spaceTrim((block) => `
|
|
3095
|
+
message = spaceTrim$1((block) => `
|
|
3055
3096
|
${block(message)}
|
|
3056
3097
|
|
|
3057
3098
|
Original stack trace:
|
|
@@ -3088,11 +3129,11 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
3088
3129
|
throw deserializeError(errors[0]);
|
|
3089
3130
|
}
|
|
3090
3131
|
else {
|
|
3091
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
3132
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
3092
3133
|
Multiple errors occurred during Promptbook execution
|
|
3093
3134
|
|
|
3094
3135
|
${block(errors
|
|
3095
|
-
.map(({ name, stack, message }, index) => spaceTrim$
|
|
3136
|
+
.map(({ name, stack, message }, index) => spaceTrim$2((block) => `
|
|
3096
3137
|
${name} ${index + 1}:
|
|
3097
3138
|
${block(stack || message)}
|
|
3098
3139
|
`))
|
|
@@ -3119,6 +3160,7 @@ function createTask(options) {
|
|
|
3119
3160
|
let updatedAt = createdAt;
|
|
3120
3161
|
const errors = [];
|
|
3121
3162
|
const warnings = [];
|
|
3163
|
+
const llmCalls = [];
|
|
3122
3164
|
let currentValue = {};
|
|
3123
3165
|
let customTldr = null;
|
|
3124
3166
|
const partialResultSubject = new Subject();
|
|
@@ -3134,6 +3176,9 @@ function createTask(options) {
|
|
|
3134
3176
|
}, (tldrInfo) => {
|
|
3135
3177
|
customTldr = tldrInfo;
|
|
3136
3178
|
updatedAt = new Date();
|
|
3179
|
+
}, (llmCall) => {
|
|
3180
|
+
llmCalls.push(llmCall);
|
|
3181
|
+
updatedAt = new Date();
|
|
3137
3182
|
});
|
|
3138
3183
|
finalResultPromise
|
|
3139
3184
|
.catch((error) => {
|
|
@@ -3256,7 +3301,7 @@ function createTask(options) {
|
|
|
3256
3301
|
}
|
|
3257
3302
|
return {
|
|
3258
3303
|
percent: percent,
|
|
3259
|
-
message,
|
|
3304
|
+
message: message + ' (!!!fallback)',
|
|
3260
3305
|
};
|
|
3261
3306
|
},
|
|
3262
3307
|
get createdAt() {
|
|
@@ -3279,6 +3324,10 @@ function createTask(options) {
|
|
|
3279
3324
|
return warnings;
|
|
3280
3325
|
// <- Note: [1] --||--
|
|
3281
3326
|
},
|
|
3327
|
+
get llmCalls() {
|
|
3328
|
+
return [...llmCalls, { foo: '!!! bar' }];
|
|
3329
|
+
// <- Note: [1] --||--
|
|
3330
|
+
},
|
|
3282
3331
|
get currentValue() {
|
|
3283
3332
|
return currentValue;
|
|
3284
3333
|
// <- Note: [1] --||--
|
|
@@ -3555,14 +3604,14 @@ class MultipleLlmExecutionTools {
|
|
|
3555
3604
|
if (description === undefined) {
|
|
3556
3605
|
return headLine;
|
|
3557
3606
|
}
|
|
3558
|
-
return spaceTrim((block) => `
|
|
3607
|
+
return spaceTrim$1((block) => `
|
|
3559
3608
|
${headLine}
|
|
3560
3609
|
|
|
3561
3610
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
3562
3611
|
`);
|
|
3563
3612
|
})
|
|
3564
3613
|
.join('\n\n');
|
|
3565
|
-
return spaceTrim((block) => `
|
|
3614
|
+
return spaceTrim$1((block) => `
|
|
3566
3615
|
Multiple LLM Providers:
|
|
3567
3616
|
|
|
3568
3617
|
${block(innerModelsTitlesAndDescriptions)}
|
|
@@ -3653,7 +3702,7 @@ class MultipleLlmExecutionTools {
|
|
|
3653
3702
|
// 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
3654
3703
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
3655
3704
|
// 3) ...
|
|
3656
|
-
spaceTrim((block) => `
|
|
3705
|
+
spaceTrim$1((block) => `
|
|
3657
3706
|
All execution tools of ${this.title} failed:
|
|
3658
3707
|
|
|
3659
3708
|
${block(errors
|
|
@@ -3666,7 +3715,7 @@ class MultipleLlmExecutionTools {
|
|
|
3666
3715
|
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
|
|
3667
3716
|
}
|
|
3668
3717
|
else {
|
|
3669
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
3718
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
3670
3719
|
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
|
|
3671
3720
|
|
|
3672
3721
|
Available \`LlmExecutionTools\`:
|
|
@@ -3699,7 +3748,7 @@ class MultipleLlmExecutionTools {
|
|
|
3699
3748
|
*/
|
|
3700
3749
|
function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
3701
3750
|
if (llmExecutionTools.length === 0) {
|
|
3702
|
-
const warningMessage = spaceTrim(`
|
|
3751
|
+
const warningMessage = spaceTrim$1(`
|
|
3703
3752
|
You have not provided any \`LlmExecutionTools\`
|
|
3704
3753
|
This means that you won't be able to execute any prompts that require large language models like GPT-4 or Anthropic's Claude.
|
|
3705
3754
|
|
|
@@ -3732,6 +3781,7 @@ function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
|
3732
3781
|
return new MultipleLlmExecutionTools(title || 'Multiple LLM Providers joined by `joinLlmExecutionTools`', ...llmExecutionTools);
|
|
3733
3782
|
}
|
|
3734
3783
|
/**
|
|
3784
|
+
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
3735
3785
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
3736
3786
|
*/
|
|
3737
3787
|
|
|
@@ -3748,6 +3798,7 @@ function getSingleLlmExecutionTools(oneOrMoreLlmExecutionTools) {
|
|
|
3748
3798
|
return llmTools;
|
|
3749
3799
|
}
|
|
3750
3800
|
/**
|
|
3801
|
+
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
3751
3802
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
3752
3803
|
*/
|
|
3753
3804
|
|
|
@@ -3763,7 +3814,7 @@ async function preparePersona(personaDescription, tools, options) {
|
|
|
3763
3814
|
throw new MissingToolsError('LLM tools are required for preparing persona');
|
|
3764
3815
|
}
|
|
3765
3816
|
// TODO: [🌼] In future use `ptbk make` and made getPipelineCollection
|
|
3766
|
-
const collection =
|
|
3817
|
+
const collection = createPipelineCollectionFromJson(...PipelineCollection);
|
|
3767
3818
|
const preparePersonaExecutor = createPipelineExecutor({
|
|
3768
3819
|
pipeline: await collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book'),
|
|
3769
3820
|
tools,
|
|
@@ -4014,14 +4065,14 @@ function $registeredScrapersMessage(availableScrapers) {
|
|
|
4014
4065
|
return { ...metadata, isMetadataAviailable, isInstalled, isAvailableInTools };
|
|
4015
4066
|
});
|
|
4016
4067
|
if (metadata.length === 0) {
|
|
4017
|
-
return spaceTrim(`
|
|
4068
|
+
return spaceTrim$1(`
|
|
4018
4069
|
**No scrapers are available**
|
|
4019
4070
|
|
|
4020
4071
|
This is a unexpected behavior, you are probably using some broken version of Promptbook
|
|
4021
4072
|
At least there should be available the metadata of the scrapers
|
|
4022
4073
|
`);
|
|
4023
4074
|
}
|
|
4024
|
-
return spaceTrim((block) => `
|
|
4075
|
+
return spaceTrim$1((block) => `
|
|
4025
4076
|
Available scrapers are:
|
|
4026
4077
|
${block(metadata
|
|
4027
4078
|
.map(({ packageName, className, isMetadataAviailable, isInstalled, mimeTypes, isAvailableInBrowser, isAvailableInTools, }, i) => {
|
|
@@ -4329,6 +4380,8 @@ function removeDiacritics(input) {
|
|
|
4329
4380
|
/**
|
|
4330
4381
|
* Converts a given text to kebab-case format.
|
|
4331
4382
|
*
|
|
4383
|
+
* Note: [🔂] This function is idempotent.
|
|
4384
|
+
*
|
|
4332
4385
|
* @param text The text to be converted.
|
|
4333
4386
|
* @returns The kebab-case formatted string.
|
|
4334
4387
|
* @example 'hello-world'
|
|
@@ -4484,6 +4537,8 @@ function removeEmojis(text) {
|
|
|
4484
4537
|
/**
|
|
4485
4538
|
* Converts a title string into a normalized name.
|
|
4486
4539
|
*
|
|
4540
|
+
* Note: [🔂] This function is idempotent.
|
|
4541
|
+
*
|
|
4487
4542
|
* @param value The title string to be converted to a name.
|
|
4488
4543
|
* @returns A normalized name derived from the input title.
|
|
4489
4544
|
* @example 'Hello World!' -> 'hello-world'
|
|
@@ -4523,7 +4578,7 @@ const promptbookFetch = async (urlOrRequest, init) => {
|
|
|
4523
4578
|
else if (urlOrRequest instanceof Request) {
|
|
4524
4579
|
url = urlOrRequest.url;
|
|
4525
4580
|
}
|
|
4526
|
-
throw new PromptbookFetchError(spaceTrim((block) => `
|
|
4581
|
+
throw new PromptbookFetchError(spaceTrim$1((block) => `
|
|
4527
4582
|
Can not fetch "${url}"
|
|
4528
4583
|
|
|
4529
4584
|
Fetch error:
|
|
@@ -4684,7 +4739,7 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
4684
4739
|
const fileExtension = getFileExtension(filename);
|
|
4685
4740
|
const mimeType = extensionToMimeType(fileExtension || '');
|
|
4686
4741
|
if (!(await isFileExisting(filename, tools.fs))) {
|
|
4687
|
-
throw new NotFoundError(spaceTrim((block) => `
|
|
4742
|
+
throw new NotFoundError(spaceTrim$1((block) => `
|
|
4688
4743
|
Can not make source handler for file which does not exist:
|
|
4689
4744
|
|
|
4690
4745
|
File:
|
|
@@ -4777,7 +4832,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
4777
4832
|
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
4778
4833
|
break;
|
|
4779
4834
|
}
|
|
4780
|
-
console.warn(spaceTrim((block) => `
|
|
4835
|
+
console.warn(spaceTrim$1((block) => `
|
|
4781
4836
|
Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
|
|
4782
4837
|
|
|
4783
4838
|
The source:
|
|
@@ -4793,7 +4848,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
4793
4848
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
4794
4849
|
}
|
|
4795
4850
|
if (partialPieces === null) {
|
|
4796
|
-
throw new KnowledgeScrapeError(spaceTrim((block) => `
|
|
4851
|
+
throw new KnowledgeScrapeError(spaceTrim$1((block) => `
|
|
4797
4852
|
Cannot scrape knowledge
|
|
4798
4853
|
|
|
4799
4854
|
The source:
|
|
@@ -4872,7 +4927,7 @@ async function prepareTasks(pipeline, tools, options) {
|
|
|
4872
4927
|
if (task.taskType === 'PROMPT_TASK' &&
|
|
4873
4928
|
knowledgePiecesCount > 0 &&
|
|
4874
4929
|
!dependentParameterNames.includes('knowledge')) {
|
|
4875
|
-
preparedContent = spaceTrim$
|
|
4930
|
+
preparedContent = spaceTrim$2(`
|
|
4876
4931
|
{content}
|
|
4877
4932
|
|
|
4878
4933
|
## Knowledge
|
|
@@ -4958,7 +5013,7 @@ async function preparePipeline(pipeline, tools, options) {
|
|
|
4958
5013
|
let title = pipeline.title;
|
|
4959
5014
|
if (title === undefined || title === '' || title === DEFAULT_BOOK_TITLE) {
|
|
4960
5015
|
// TODO: [🌼] In future use `ptbk make` and made getPipelineCollection
|
|
4961
|
-
const collection =
|
|
5016
|
+
const collection = createPipelineCollectionFromJson(...PipelineCollection);
|
|
4962
5017
|
const prepareTitleExecutor = createPipelineExecutor({
|
|
4963
5018
|
pipeline: await collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-title.book'),
|
|
4964
5019
|
tools,
|
|
@@ -5185,7 +5240,7 @@ function extractVariablesFromJavascript(script) {
|
|
|
5185
5240
|
}
|
|
5186
5241
|
catch (error) {
|
|
5187
5242
|
assertsError(error);
|
|
5188
|
-
throw new ParseError(spaceTrim$
|
|
5243
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
5189
5244
|
Can not extract variables from the script
|
|
5190
5245
|
${block(error.stack || error.message)}
|
|
5191
5246
|
|
|
@@ -5368,7 +5423,7 @@ const CsvFormatParser = {
|
|
|
5368
5423
|
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
5369
5424
|
const csv = csvParse(value, settings);
|
|
5370
5425
|
if (csv.errors.length !== 0) {
|
|
5371
|
-
throw new CsvFormatError(spaceTrim((block) => `
|
|
5426
|
+
throw new CsvFormatError(spaceTrim$1((block) => `
|
|
5372
5427
|
CSV parsing error
|
|
5373
5428
|
|
|
5374
5429
|
Error(s) from CSV parsing:
|
|
@@ -5413,7 +5468,7 @@ const CsvFormatParser = {
|
|
|
5413
5468
|
const { value, settings, mapCallback, onProgress } = options;
|
|
5414
5469
|
const csv = csvParse(value, settings);
|
|
5415
5470
|
if (csv.errors.length !== 0) {
|
|
5416
|
-
throw new CsvFormatError(spaceTrim((block) => `
|
|
5471
|
+
throw new CsvFormatError(spaceTrim$1((block) => `
|
|
5417
5472
|
CSV parsing error
|
|
5418
5473
|
|
|
5419
5474
|
Error(s) from CSV parsing:
|
|
@@ -5623,7 +5678,7 @@ function mapAvailableToExpectedParameters(options) {
|
|
|
5623
5678
|
}
|
|
5624
5679
|
// Phase 2️⃣: Non-matching mapping
|
|
5625
5680
|
if (expectedParameterNames.size !== availableParametersNames.size) {
|
|
5626
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
5681
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
5627
5682
|
Can not map available parameters to expected parameters
|
|
5628
5683
|
|
|
5629
5684
|
Mapped parameters:
|
|
@@ -5768,10 +5823,13 @@ const LINES_PER_STANDARD_PAGE = 44;
|
|
|
5768
5823
|
* @public exported from `@promptbook/utils`
|
|
5769
5824
|
*/
|
|
5770
5825
|
function countLines(text) {
|
|
5826
|
+
if (text === '') {
|
|
5827
|
+
return 0;
|
|
5828
|
+
}
|
|
5771
5829
|
text = text.replace('\r\n', '\n');
|
|
5772
5830
|
text = text.replace('\r', '\n');
|
|
5773
5831
|
const lines = text.split('\n');
|
|
5774
|
-
return lines.reduce((count, line) => count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 0);
|
|
5832
|
+
return lines.reduce((count, line) => count + Math.max(Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 1), 0);
|
|
5775
5833
|
}
|
|
5776
5834
|
/**
|
|
5777
5835
|
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
@@ -5896,6 +5954,8 @@ function checkExpectations(expectations, value) {
|
|
|
5896
5954
|
* This function provides a common abstraction for result validation that can be used
|
|
5897
5955
|
* by both execution logic and caching logic to ensure consistency.
|
|
5898
5956
|
*
|
|
5957
|
+
* Note: [🔂] This function is idempotent.
|
|
5958
|
+
*
|
|
5899
5959
|
* @param options - The validation options including result string, expectations, and format
|
|
5900
5960
|
* @returns Validation result with processed string and validity status
|
|
5901
5961
|
* @private internal function of `createPipelineExecutor` and `cacheLlmTools`
|
|
@@ -5915,7 +5975,7 @@ function validatePromptResult(options) {
|
|
|
5915
5975
|
}
|
|
5916
5976
|
catch (error) {
|
|
5917
5977
|
keepUnused(error);
|
|
5918
|
-
throw new ExpectError(spaceTrim$
|
|
5978
|
+
throw new ExpectError(spaceTrim$2((block) => `
|
|
5919
5979
|
Expected valid JSON string
|
|
5920
5980
|
|
|
5921
5981
|
The expected JSON text:
|
|
@@ -5964,7 +6024,7 @@ function validatePromptResult(options) {
|
|
|
5964
6024
|
*/
|
|
5965
6025
|
async function executeAttempts(options) {
|
|
5966
6026
|
const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
|
|
5967
|
-
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, } = options;
|
|
6027
|
+
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall, } = options;
|
|
5968
6028
|
const $ongoingTaskResult = {
|
|
5969
6029
|
$result: null,
|
|
5970
6030
|
$resultString: null,
|
|
@@ -5978,7 +6038,7 @@ async function executeAttempts(options) {
|
|
|
5978
6038
|
const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
|
|
5979
6039
|
// TODO: [🧠][🍭] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
|
|
5980
6040
|
if (isJokerAttempt && !jokerParameterName) {
|
|
5981
|
-
throw new UnexpectedError(spaceTrim$
|
|
6041
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
5982
6042
|
Joker not found in attempt ${attemptIndex}
|
|
5983
6043
|
|
|
5984
6044
|
${block(pipelineIdentification)}
|
|
@@ -5989,7 +6049,7 @@ async function executeAttempts(options) {
|
|
|
5989
6049
|
$ongoingTaskResult.$expectError = null;
|
|
5990
6050
|
if (isJokerAttempt) {
|
|
5991
6051
|
if (parameters[jokerParameterName] === undefined) {
|
|
5992
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
6052
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
5993
6053
|
Joker parameter {${jokerParameterName}} not defined
|
|
5994
6054
|
|
|
5995
6055
|
${block(pipelineIdentification)}
|
|
@@ -6047,7 +6107,7 @@ async function executeAttempts(options) {
|
|
|
6047
6107
|
$ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
|
|
6048
6108
|
break variant;
|
|
6049
6109
|
case 'EMBEDDING':
|
|
6050
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
6110
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
6051
6111
|
Embedding model can not be used in pipeline
|
|
6052
6112
|
|
|
6053
6113
|
This should be catched during parsing
|
|
@@ -6058,7 +6118,7 @@ async function executeAttempts(options) {
|
|
|
6058
6118
|
break variant;
|
|
6059
6119
|
// <- case [🤖]:
|
|
6060
6120
|
default:
|
|
6061
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
6121
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
6062
6122
|
Unknown model variant "${task.modelRequirements.modelVariant}"
|
|
6063
6123
|
|
|
6064
6124
|
${block(pipelineIdentification)}
|
|
@@ -6069,14 +6129,14 @@ async function executeAttempts(options) {
|
|
|
6069
6129
|
break;
|
|
6070
6130
|
case 'SCRIPT_TASK':
|
|
6071
6131
|
if (arrayableToArray(tools.script).length === 0) {
|
|
6072
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
6132
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
6073
6133
|
No script execution tools are available
|
|
6074
6134
|
|
|
6075
6135
|
${block(pipelineIdentification)}
|
|
6076
6136
|
`));
|
|
6077
6137
|
}
|
|
6078
6138
|
if (!task.contentLanguage) {
|
|
6079
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
6139
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
6080
6140
|
Script language is not defined for SCRIPT TASK "${task.name}"
|
|
6081
6141
|
|
|
6082
6142
|
${block(pipelineIdentification)}
|
|
@@ -6107,7 +6167,7 @@ async function executeAttempts(options) {
|
|
|
6107
6167
|
throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
|
|
6108
6168
|
}
|
|
6109
6169
|
else {
|
|
6110
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
6170
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
6111
6171
|
Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
|
|
6112
6172
|
|
|
6113
6173
|
${block(pipelineIdentification)}
|
|
@@ -6121,7 +6181,7 @@ async function executeAttempts(options) {
|
|
|
6121
6181
|
break taskType;
|
|
6122
6182
|
case 'DIALOG_TASK':
|
|
6123
6183
|
if (tools.userInterface === undefined) {
|
|
6124
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
6184
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
6125
6185
|
User interface tools are not available
|
|
6126
6186
|
|
|
6127
6187
|
${block(pipelineIdentification)}
|
|
@@ -6139,7 +6199,7 @@ async function executeAttempts(options) {
|
|
|
6139
6199
|
break taskType;
|
|
6140
6200
|
// <- case: [🅱]
|
|
6141
6201
|
default:
|
|
6142
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
6202
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
6143
6203
|
Unknown execution type "${task.taskType}"
|
|
6144
6204
|
|
|
6145
6205
|
${block(pipelineIdentification)}
|
|
@@ -6212,14 +6272,10 @@ async function executeAttempts(options) {
|
|
|
6212
6272
|
});
|
|
6213
6273
|
}
|
|
6214
6274
|
finally {
|
|
6215
|
-
if (!isJokerAttempt &&
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
// In that case we don’t want to make a report about it because it’s not a llm execution error
|
|
6220
|
-
) {
|
|
6221
|
-
// TODO: [🧠] Maybe put other taskTypes into report
|
|
6222
|
-
$executionReport.promptExecutions.push({
|
|
6275
|
+
if (!isJokerAttempt && task.taskType === 'PROMPT_TASK' && $ongoingTaskResult.$prompt) {
|
|
6276
|
+
// Note: [2] When some expected parameter is not defined, error will occur in templateParameters
|
|
6277
|
+
// In that case we don’t want to make a report about it because it’s not a llm execution error
|
|
6278
|
+
const executionPromptReport = {
|
|
6223
6279
|
prompt: {
|
|
6224
6280
|
...$ongoingTaskResult.$prompt,
|
|
6225
6281
|
// <- TODO: [🧠] How to pick everyhing except `pipelineUrl`
|
|
@@ -6228,13 +6284,20 @@ async function executeAttempts(options) {
|
|
|
6228
6284
|
error: $ongoingTaskResult.$expectError === null
|
|
6229
6285
|
? undefined
|
|
6230
6286
|
: serializeError($ongoingTaskResult.$expectError),
|
|
6231
|
-
}
|
|
6287
|
+
};
|
|
6288
|
+
$executionReport.promptExecutions.push(executionPromptReport);
|
|
6289
|
+
if (logLlmCall) {
|
|
6290
|
+
logLlmCall({
|
|
6291
|
+
modelName: 'model' /* <- TODO: How to get model name from the report */,
|
|
6292
|
+
report: executionPromptReport,
|
|
6293
|
+
});
|
|
6294
|
+
}
|
|
6232
6295
|
}
|
|
6233
6296
|
}
|
|
6234
6297
|
if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
|
|
6235
6298
|
// Note: Create a summary of all failures
|
|
6236
6299
|
const failuresSummary = $ongoingTaskResult.$failedResults
|
|
6237
|
-
.map((failure) => spaceTrim$
|
|
6300
|
+
.map((failure) => spaceTrim$2((block) => {
|
|
6238
6301
|
var _a, _b;
|
|
6239
6302
|
return `
|
|
6240
6303
|
Attempt ${failure.attemptIndex + 1}:
|
|
@@ -6244,14 +6307,14 @@ async function executeAttempts(options) {
|
|
|
6244
6307
|
Result:
|
|
6245
6308
|
${block(failure.result === null
|
|
6246
6309
|
? 'null'
|
|
6247
|
-
: spaceTrim$
|
|
6310
|
+
: spaceTrim$2(failure.result)
|
|
6248
6311
|
.split('\n')
|
|
6249
6312
|
.map((line) => `> ${line}`)
|
|
6250
6313
|
.join('\n'))}
|
|
6251
6314
|
`;
|
|
6252
6315
|
}))
|
|
6253
6316
|
.join('\n\n---\n\n');
|
|
6254
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
6317
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => {
|
|
6255
6318
|
var _a;
|
|
6256
6319
|
return `
|
|
6257
6320
|
LLM execution failed ${maxExecutionAttempts}x
|
|
@@ -6271,7 +6334,7 @@ async function executeAttempts(options) {
|
|
|
6271
6334
|
}
|
|
6272
6335
|
}
|
|
6273
6336
|
if ($ongoingTaskResult.$resultString === null) {
|
|
6274
|
-
throw new UnexpectedError(spaceTrim$
|
|
6337
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
6275
6338
|
Something went wrong and prompt result is null
|
|
6276
6339
|
|
|
6277
6340
|
${block(pipelineIdentification)}
|
|
@@ -6293,12 +6356,12 @@ async function executeAttempts(options) {
|
|
|
6293
6356
|
* @private internal utility of `createPipelineExecutor`
|
|
6294
6357
|
*/
|
|
6295
6358
|
async function executeFormatSubvalues(options) {
|
|
6296
|
-
const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, pipelineIdentification } = options;
|
|
6359
|
+
const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, logLlmCall, pipelineIdentification, } = options;
|
|
6297
6360
|
if (task.foreach === undefined) {
|
|
6298
|
-
return /* not await */ executeAttempts(options);
|
|
6361
|
+
return /* not await */ executeAttempts({ ...options, logLlmCall });
|
|
6299
6362
|
}
|
|
6300
6363
|
if (jokerParameterNames.length !== 0) {
|
|
6301
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
6364
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6302
6365
|
JOKER parameters are not supported together with FOREACH command
|
|
6303
6366
|
|
|
6304
6367
|
[🧞♀️] This should be prevented in \`validatePipeline\`
|
|
@@ -6311,7 +6374,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6311
6374
|
if (formatDefinition === undefined) {
|
|
6312
6375
|
throw new UnexpectedError(
|
|
6313
6376
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
6314
|
-
spaceTrim((block) => `
|
|
6377
|
+
spaceTrim$1((block) => `
|
|
6315
6378
|
Unsupported format "${task.foreach.formatName}"
|
|
6316
6379
|
|
|
6317
6380
|
Available formats:
|
|
@@ -6328,7 +6391,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6328
6391
|
if (subvalueParser === undefined) {
|
|
6329
6392
|
throw new UnexpectedError(
|
|
6330
6393
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
6331
|
-
spaceTrim((block) => `
|
|
6394
|
+
spaceTrim$1((block) => `
|
|
6332
6395
|
Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
|
|
6333
6396
|
|
|
6334
6397
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -6368,7 +6431,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6368
6431
|
if (!(error instanceof PipelineExecutionError)) {
|
|
6369
6432
|
throw error;
|
|
6370
6433
|
}
|
|
6371
|
-
const highLevelError = new PipelineExecutionError(spaceTrim((block) => `
|
|
6434
|
+
const highLevelError = new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6372
6435
|
${error.message}
|
|
6373
6436
|
|
|
6374
6437
|
This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -6392,7 +6455,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6392
6455
|
...options,
|
|
6393
6456
|
priority: priority + index,
|
|
6394
6457
|
parameters: allSubparameters,
|
|
6395
|
-
pipelineIdentification: spaceTrim((block) => `
|
|
6458
|
+
pipelineIdentification: spaceTrim$1((block) => `
|
|
6396
6459
|
${block(pipelineIdentification)}
|
|
6397
6460
|
Subparameter index: ${index}
|
|
6398
6461
|
`),
|
|
@@ -6401,7 +6464,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6401
6464
|
}
|
|
6402
6465
|
catch (error) {
|
|
6403
6466
|
if (length > BIG_DATASET_TRESHOLD) {
|
|
6404
|
-
console.error(spaceTrim((block) => `
|
|
6467
|
+
console.error(spaceTrim$1((block) => `
|
|
6405
6468
|
${error.message}
|
|
6406
6469
|
|
|
6407
6470
|
This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -6501,7 +6564,7 @@ async function getKnowledgeForTask(options) {
|
|
|
6501
6564
|
},
|
|
6502
6565
|
content: task.content,
|
|
6503
6566
|
parameters,
|
|
6504
|
-
};
|
|
6567
|
+
}; /* <- Note: [🤛] */
|
|
6505
6568
|
const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
|
|
6506
6569
|
const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
|
|
6507
6570
|
const { index } = knowledgePiece;
|
|
@@ -6577,7 +6640,7 @@ async function getReservedParametersForTask(options) {
|
|
|
6577
6640
|
// Note: Doublecheck that ALL reserved parameters are defined:
|
|
6578
6641
|
for (const parameterName of RESERVED_PARAMETER_NAMES) {
|
|
6579
6642
|
if (reservedParameters[parameterName] === undefined) {
|
|
6580
|
-
throw new UnexpectedError(spaceTrim$
|
|
6643
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
6581
6644
|
Reserved parameter {${parameterName}} is not defined
|
|
6582
6645
|
|
|
6583
6646
|
${block(pipelineIdentification)}
|
|
@@ -6596,14 +6659,14 @@ async function getReservedParametersForTask(options) {
|
|
|
6596
6659
|
* @private internal utility of `createPipelineExecutor`
|
|
6597
6660
|
*/
|
|
6598
6661
|
async function executeTask(options) {
|
|
6599
|
-
const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSuppressed, } = options;
|
|
6662
|
+
const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, logLlmCall, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSuppressed, } = options;
|
|
6600
6663
|
const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
|
|
6601
6664
|
// Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but it’s good to doublecheck
|
|
6602
6665
|
const usedParameterNames = extractParameterNamesFromTask(currentTask);
|
|
6603
6666
|
const dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
6604
6667
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
6605
6668
|
if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
|
|
6606
|
-
throw new UnexpectedError(spaceTrim$
|
|
6669
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
6607
6670
|
Dependent parameters are not consistent with used parameters:
|
|
6608
6671
|
|
|
6609
6672
|
Dependent parameters:
|
|
@@ -6647,7 +6710,7 @@ async function executeTask(options) {
|
|
|
6647
6710
|
else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
|
|
6648
6711
|
// Houston, we have a problem
|
|
6649
6712
|
// Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
|
|
6650
|
-
throw new UnexpectedError(spaceTrim$
|
|
6713
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
6651
6714
|
Parameter \`{${parameterName}}\` is NOT defined
|
|
6652
6715
|
BUT used in task "${currentTask.title || currentTask.name}"
|
|
6653
6716
|
|
|
@@ -6675,6 +6738,7 @@ async function executeTask(options) {
|
|
|
6675
6738
|
tools,
|
|
6676
6739
|
$executionReport,
|
|
6677
6740
|
onProgress,
|
|
6741
|
+
logLlmCall,
|
|
6678
6742
|
pipelineIdentification,
|
|
6679
6743
|
maxExecutionAttempts,
|
|
6680
6744
|
maxParallelCount,
|
|
@@ -6715,9 +6779,32 @@ function filterJustOutputParameters(options) {
|
|
|
6715
6779
|
for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
|
|
6716
6780
|
if (parametersToPass[parameter.name] === undefined) {
|
|
6717
6781
|
// [4]
|
|
6718
|
-
$warnings.push(new PipelineExecutionError(spaceTrim$
|
|
6782
|
+
$warnings.push(new PipelineExecutionError(spaceTrim$2((block) => `
|
|
6719
6783
|
Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
|
|
6720
6784
|
|
|
6785
|
+
Note: This is a warning which happened after the pipeline was executed, and \`{${parameter.name}}\` was not for some reason defined in output parameters
|
|
6786
|
+
|
|
6787
|
+
All parameters:
|
|
6788
|
+
${block(preparedPipeline.parameters
|
|
6789
|
+
.map(({ name, isInput, isOutput, description }) => {
|
|
6790
|
+
let line = `\`{${name}}\``;
|
|
6791
|
+
if (isInput) {
|
|
6792
|
+
line += ' `[input parameter]`';
|
|
6793
|
+
}
|
|
6794
|
+
if (isOutput) {
|
|
6795
|
+
line += ' `[output parameter]`';
|
|
6796
|
+
}
|
|
6797
|
+
if (parametersToPass[name] === undefined) {
|
|
6798
|
+
line += ` <- Warning: Should be in the output but its not |`;
|
|
6799
|
+
}
|
|
6800
|
+
if (description) {
|
|
6801
|
+
line += ` ${description}`;
|
|
6802
|
+
}
|
|
6803
|
+
return line;
|
|
6804
|
+
})
|
|
6805
|
+
.map((line, index) => `${index + 1}) ${line}`)
|
|
6806
|
+
.join('\n'))}
|
|
6807
|
+
|
|
6721
6808
|
${block(pipelineIdentification)}
|
|
6722
6809
|
`)));
|
|
6723
6810
|
continue;
|
|
@@ -6738,7 +6825,7 @@ function filterJustOutputParameters(options) {
|
|
|
6738
6825
|
* @private internal utility of `createPipelineExecutor`
|
|
6739
6826
|
*/
|
|
6740
6827
|
async function executePipeline(options) {
|
|
6741
|
-
const { inputParameters, tools, onProgress, pipeline, setPreparedPipeline, pipelineIdentification, maxParallelCount, rootDirname, isVerbose, } = options;
|
|
6828
|
+
const { inputParameters, tools, onProgress, logLlmCall, pipeline, setPreparedPipeline, pipelineIdentification, maxParallelCount, rootDirname, isVerbose, } = options;
|
|
6742
6829
|
let { preparedPipeline } = options;
|
|
6743
6830
|
if (preparedPipeline === undefined) {
|
|
6744
6831
|
preparedPipeline = await preparePipeline(pipeline, tools, {
|
|
@@ -6800,7 +6887,7 @@ async function executePipeline(options) {
|
|
|
6800
6887
|
for (const parameterName of Object.keys(inputParameters)) {
|
|
6801
6888
|
const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
|
|
6802
6889
|
if (parameter === undefined) {
|
|
6803
|
-
warnings.push(new PipelineExecutionError(spaceTrim$
|
|
6890
|
+
warnings.push(new PipelineExecutionError(spaceTrim$2((block) => `
|
|
6804
6891
|
Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
|
|
6805
6892
|
|
|
6806
6893
|
${block(pipelineIdentification)}
|
|
@@ -6815,7 +6902,7 @@ async function executePipeline(options) {
|
|
|
6815
6902
|
// TODO: [🧠] This should be also non-critical error
|
|
6816
6903
|
return exportJson({
|
|
6817
6904
|
name: 'pipelineExecutorResult',
|
|
6818
|
-
message: spaceTrim$
|
|
6905
|
+
message: spaceTrim$2((block) => `
|
|
6819
6906
|
Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
|
|
6820
6907
|
|
|
6821
6908
|
${block(pipelineIdentification)}
|
|
@@ -6824,7 +6911,7 @@ async function executePipeline(options) {
|
|
|
6824
6911
|
value: {
|
|
6825
6912
|
isSuccessful: false,
|
|
6826
6913
|
errors: [
|
|
6827
|
-
new PipelineExecutionError(spaceTrim$
|
|
6914
|
+
new PipelineExecutionError(spaceTrim$2((block) => `
|
|
6828
6915
|
Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
|
|
6829
6916
|
|
|
6830
6917
|
${block(pipelineIdentification)}
|
|
@@ -6851,7 +6938,7 @@ async function executePipeline(options) {
|
|
|
6851
6938
|
while (unresovedTasks.length > 0) {
|
|
6852
6939
|
if (loopLimit-- < 0) {
|
|
6853
6940
|
// Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
|
|
6854
|
-
throw new UnexpectedError(spaceTrim$
|
|
6941
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
6855
6942
|
Loop limit reached during resolving parameters pipeline execution
|
|
6856
6943
|
|
|
6857
6944
|
${block(pipelineIdentification)}
|
|
@@ -6861,7 +6948,7 @@ async function executePipeline(options) {
|
|
|
6861
6948
|
if (!currentTask && resolving.length === 0) {
|
|
6862
6949
|
throw new UnexpectedError(
|
|
6863
6950
|
// TODO: [🐎] DRY
|
|
6864
|
-
spaceTrim$
|
|
6951
|
+
spaceTrim$2((block) => `
|
|
6865
6952
|
Can not resolve some parameters:
|
|
6866
6953
|
|
|
6867
6954
|
${block(pipelineIdentification)}
|
|
@@ -6901,7 +6988,7 @@ async function executePipeline(options) {
|
|
|
6901
6988
|
tools,
|
|
6902
6989
|
onProgress(newOngoingResult) {
|
|
6903
6990
|
if (isReturned) {
|
|
6904
|
-
throw new UnexpectedError(spaceTrim$
|
|
6991
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
6905
6992
|
Can not call \`onProgress\` after pipeline execution is finished
|
|
6906
6993
|
|
|
6907
6994
|
${block(pipelineIdentification)}
|
|
@@ -6916,8 +7003,9 @@ async function executePipeline(options) {
|
|
|
6916
7003
|
onProgress(newOngoingResult);
|
|
6917
7004
|
}
|
|
6918
7005
|
},
|
|
7006
|
+
logLlmCall,
|
|
6919
7007
|
$executionReport: executionReport,
|
|
6920
|
-
pipelineIdentification: spaceTrim$
|
|
7008
|
+
pipelineIdentification: spaceTrim$2((block) => `
|
|
6921
7009
|
${block(pipelineIdentification)}
|
|
6922
7010
|
Task name: ${currentTask.name}
|
|
6923
7011
|
Task title: ${currentTask.title}
|
|
@@ -7026,7 +7114,7 @@ function createPipelineExecutor(options) {
|
|
|
7026
7114
|
preparedPipeline = pipeline;
|
|
7027
7115
|
}
|
|
7028
7116
|
else if (isNotPreparedWarningSuppressed !== true) {
|
|
7029
|
-
console.warn(spaceTrim$
|
|
7117
|
+
console.warn(spaceTrim$2((block) => `
|
|
7030
7118
|
Pipeline is not prepared
|
|
7031
7119
|
|
|
7032
7120
|
${block(pipelineIdentification)}
|
|
@@ -7039,7 +7127,7 @@ function createPipelineExecutor(options) {
|
|
|
7039
7127
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
7040
7128
|
}
|
|
7041
7129
|
let runCount = 0;
|
|
7042
|
-
const pipelineExecutorWithCallback = async (inputParameters, onProgress) => {
|
|
7130
|
+
const pipelineExecutorWithCallback = async (inputParameters, onProgress, logLlmCall) => {
|
|
7043
7131
|
runCount++;
|
|
7044
7132
|
return /* not await */ executePipeline({
|
|
7045
7133
|
pipeline,
|
|
@@ -7050,7 +7138,8 @@ function createPipelineExecutor(options) {
|
|
|
7050
7138
|
inputParameters,
|
|
7051
7139
|
tools,
|
|
7052
7140
|
onProgress,
|
|
7053
|
-
|
|
7141
|
+
logLlmCall,
|
|
7142
|
+
pipelineIdentification: spaceTrim$2((block) => `
|
|
7054
7143
|
${block(pipelineIdentification)}
|
|
7055
7144
|
${runCount === 1 ? '' : `Run #${runCount}`}
|
|
7056
7145
|
`),
|
|
@@ -7211,7 +7300,7 @@ class MarkdownScraper {
|
|
|
7211
7300
|
}
|
|
7212
7301
|
const llmTools = getSingleLlmExecutionTools(llm);
|
|
7213
7302
|
// TODO: [🌼] In future use `ptbk make` and made getPipelineCollection
|
|
7214
|
-
const collection =
|
|
7303
|
+
const collection = createPipelineCollectionFromJson(...PipelineCollection);
|
|
7215
7304
|
const prepareKnowledgeFromMarkdownExecutor = createPipelineExecutor({
|
|
7216
7305
|
pipeline: await collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book'),
|
|
7217
7306
|
tools: {
|
|
@@ -7247,8 +7336,8 @@ class MarkdownScraper {
|
|
|
7247
7336
|
knowledgeTextPieces.map(async (knowledgeTextPiece, i) => {
|
|
7248
7337
|
// Note: These are just default values, they will be overwritten by the actual values:
|
|
7249
7338
|
let name = `piece-${i}`;
|
|
7250
|
-
let title = spaceTrim(knowledgeTextPiece.substring(0, 100));
|
|
7251
|
-
const knowledgePieceContent = spaceTrim(knowledgeTextPiece);
|
|
7339
|
+
let title = spaceTrim$1(knowledgeTextPiece.substring(0, 100));
|
|
7340
|
+
const knowledgePieceContent = spaceTrim$1(knowledgeTextPiece);
|
|
7252
7341
|
let keywords = [];
|
|
7253
7342
|
const index = [];
|
|
7254
7343
|
/*
|
|
@@ -7261,7 +7350,7 @@ class MarkdownScraper {
|
|
|
7261
7350
|
isCrashedOnError: true,
|
|
7262
7351
|
});
|
|
7263
7352
|
const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
|
|
7264
|
-
title = spaceTrim(titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
7353
|
+
title = spaceTrim$1(titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
7265
7354
|
name = titleToName(title);
|
|
7266
7355
|
// --- Keywords
|
|
7267
7356
|
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
|
|
@@ -7358,7 +7447,7 @@ const _MarkdownScraperRegistration = $scrapersRegister.register(createMarkdownSc
|
|
|
7358
7447
|
* @public exported from `@promptbook/markdown-utils`
|
|
7359
7448
|
*/
|
|
7360
7449
|
function removeMarkdownComments(content) {
|
|
7361
|
-
return spaceTrim$
|
|
7450
|
+
return spaceTrim$2(content.replace(/<!--(.*?)-->/gs, ''));
|
|
7362
7451
|
}
|
|
7363
7452
|
|
|
7364
7453
|
/**
|
|
@@ -7371,7 +7460,7 @@ function addAutoGeneratedSection(content, options) {
|
|
|
7371
7460
|
const warningLine = `<!-- ${GENERATOR_WARNING} -->`;
|
|
7372
7461
|
const sectionRegex = new RegExp(`<!--${sectionName}-->([\\s\\S]*?)<!--/${sectionName}-->`, 'g');
|
|
7373
7462
|
const sectionMatch = content.match(sectionRegex);
|
|
7374
|
-
const contentToInsert = spaceTrim$
|
|
7463
|
+
const contentToInsert = spaceTrim$2((block) => `
|
|
7375
7464
|
<!--${sectionName}-->
|
|
7376
7465
|
${block(warningLine)}
|
|
7377
7466
|
${block(sectionContent)}
|
|
@@ -7384,7 +7473,7 @@ function addAutoGeneratedSection(content, options) {
|
|
|
7384
7473
|
const placeForSection = removeMarkdownComments(content).match(/^##.*$/im);
|
|
7385
7474
|
if (placeForSection !== null) {
|
|
7386
7475
|
const [heading] = placeForSection;
|
|
7387
|
-
return content.replace(heading, spaceTrim$
|
|
7476
|
+
return content.replace(heading, spaceTrim$2((block) => `
|
|
7388
7477
|
${block(contentToInsert)}
|
|
7389
7478
|
|
|
7390
7479
|
${block(heading)}
|
|
@@ -7393,7 +7482,7 @@ function addAutoGeneratedSection(content, options) {
|
|
|
7393
7482
|
console.warn(`No place where to put the section <!--${sectionName}-->, using the end of the file`);
|
|
7394
7483
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
7395
7484
|
// <- TODO: [🏮] Some better way how to get warnings from pipeline parsing / logic
|
|
7396
|
-
return spaceTrim$
|
|
7485
|
+
return spaceTrim$2((block) => `
|
|
7397
7486
|
${block(content)}
|
|
7398
7487
|
|
|
7399
7488
|
${block(contentToInsert)}
|
|
@@ -7514,7 +7603,7 @@ function parseMarkdownSection(value) {
|
|
|
7514
7603
|
}
|
|
7515
7604
|
const title = lines[0].replace(/^#+\s*/, '');
|
|
7516
7605
|
const level = (_b = (_a = lines[0].match(/^#+/)) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
|
|
7517
|
-
const content = spaceTrim(lines.slice(1).join('\n'));
|
|
7606
|
+
const content = spaceTrim$1(lines.slice(1).join('\n'));
|
|
7518
7607
|
if (level < 1 || level > 6) {
|
|
7519
7608
|
throw new ParseError('Markdown section must have heading level between 1 and 6');
|
|
7520
7609
|
}
|
|
@@ -7542,7 +7631,7 @@ function splitMarkdownIntoSections(markdown) {
|
|
|
7542
7631
|
if (buffer.length === 0) {
|
|
7543
7632
|
return;
|
|
7544
7633
|
}
|
|
7545
|
-
let section = spaceTrim(buffer.join('\n'));
|
|
7634
|
+
let section = spaceTrim$1(buffer.join('\n'));
|
|
7546
7635
|
if (section === '') {
|
|
7547
7636
|
return;
|
|
7548
7637
|
}
|
|
@@ -7617,7 +7706,7 @@ function flattenMarkdown(markdown) {
|
|
|
7617
7706
|
flattenedMarkdown += `## ${title}` + `\n\n`;
|
|
7618
7707
|
flattenedMarkdown += content + `\n\n`; // <- [🧠] Maybe 3 new lines?
|
|
7619
7708
|
}
|
|
7620
|
-
return spaceTrim(flattenedMarkdown);
|
|
7709
|
+
return spaceTrim$1(flattenedMarkdown);
|
|
7621
7710
|
}
|
|
7622
7711
|
/**
|
|
7623
7712
|
* TODO: [🏛] This can be part of markdown builder
|
|
@@ -7808,13 +7897,13 @@ function removeMarkdownLinks(str) {
|
|
|
7808
7897
|
* @public exported from `@promptbook/markdown-utils`
|
|
7809
7898
|
*/
|
|
7810
7899
|
function trimCodeBlock(value) {
|
|
7811
|
-
value = spaceTrim$
|
|
7900
|
+
value = spaceTrim$2(value);
|
|
7812
7901
|
if (!/^```[a-z]*(.*)```$/is.test(value)) {
|
|
7813
7902
|
return value;
|
|
7814
7903
|
}
|
|
7815
7904
|
value = value.replace(/^```[a-z]*/i, '');
|
|
7816
7905
|
value = value.replace(/```$/i, '');
|
|
7817
|
-
value = spaceTrim$
|
|
7906
|
+
value = spaceTrim$2(value);
|
|
7818
7907
|
return value;
|
|
7819
7908
|
}
|
|
7820
7909
|
|
|
@@ -7827,9 +7916,9 @@ function trimCodeBlock(value) {
|
|
|
7827
7916
|
* @public exported from `@promptbook/markdown-utils`
|
|
7828
7917
|
*/
|
|
7829
7918
|
function trimEndOfCodeBlock(value) {
|
|
7830
|
-
value = spaceTrim$
|
|
7919
|
+
value = spaceTrim$2(value);
|
|
7831
7920
|
value = value.replace(/```$/g, '');
|
|
7832
|
-
value = spaceTrim$
|
|
7921
|
+
value = spaceTrim$2(value);
|
|
7833
7922
|
return value;
|
|
7834
7923
|
}
|
|
7835
7924
|
|