@promptbook/documents 0.103.0-10 → 0.103.0-100
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 +299 -228
- 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 +20 -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 +58 -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 +19 -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 +77 -7
- package/esm/typings/src/book-components/BookEditor/BookEditorActionbar.d.ts +14 -0
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.d.ts +14 -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 +10 -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/PromptbookAgent.d.ts +29 -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/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/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 +35 -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 +38 -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 +8 -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 +21 -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 +70 -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/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/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/Updatable.d.ts +19 -0
- package/esm/typings/src/types/typeAliases.d.ts +32 -2
- package/esm/typings/src/utils/color/$randomColor.d.ts +1 -0
- package/esm/typings/src/utils/color/Color.d.ts +15 -0
- 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/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 +25 -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/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 +267 -196
- 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/config.d.ts +0 -11
- 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,5 +1,5 @@
|
|
|
1
1
|
import { mkdir, rm, readFile } from 'fs/promises';
|
|
2
|
-
import spaceTrim$
|
|
2
|
+
import spaceTrim$2, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
3
3
|
import { spawn } from 'child_process';
|
|
4
4
|
import colors from 'colors';
|
|
5
5
|
import { forTime } from 'waitasecond';
|
|
@@ -19,14 +19,14 @@ import { parse, unparse } from 'papaparse';
|
|
|
19
19
|
* @generated
|
|
20
20
|
* @see https://github.com/webgptorg/book
|
|
21
21
|
*/
|
|
22
|
-
const BOOK_LANGUAGE_VERSION = '
|
|
22
|
+
const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
23
23
|
/**
|
|
24
24
|
* The version of the Promptbook engine
|
|
25
25
|
*
|
|
26
26
|
* @generated
|
|
27
27
|
* @see https://github.com/webgptorg/promptbook
|
|
28
28
|
*/
|
|
29
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-
|
|
29
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-100';
|
|
30
30
|
/**
|
|
31
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
32
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -49,6 +49,17 @@ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-10';
|
|
|
49
49
|
function keepUnused(...valuesToKeep) {
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Trims string from all 4 sides
|
|
54
|
+
*
|
|
55
|
+
* Note: This is a re-exported function from the `spacetrim` package which is
|
|
56
|
+
* Developed by same author @hejny as this package
|
|
57
|
+
*
|
|
58
|
+
* @public exported from `@promptbook/utils`
|
|
59
|
+
* @see https://github.com/hejny/spacetrim#usage
|
|
60
|
+
*/
|
|
61
|
+
const spaceTrim = spaceTrim$1;
|
|
62
|
+
|
|
52
63
|
/**
|
|
53
64
|
* @private util of `@promptbook/color`
|
|
54
65
|
* @de
|
|
@@ -97,6 +108,7 @@ function take(initialValue) {
|
|
|
97
108
|
* @public exported from `@promptbook/color`
|
|
98
109
|
*/
|
|
99
110
|
const CSS_COLORS = {
|
|
111
|
+
promptbook: '#79EAFD',
|
|
100
112
|
transparent: 'rgba(0,0,0,0)',
|
|
101
113
|
aliceblue: '#f0f8ff',
|
|
102
114
|
antiquewhite: '#faebd7',
|
|
@@ -278,9 +290,6 @@ function checkChannelValue(channelName, value) {
|
|
|
278
290
|
throw new Error(`${channelName} channel is greater than 255, it is ${value}`);
|
|
279
291
|
}
|
|
280
292
|
}
|
|
281
|
-
/**
|
|
282
|
-
* TODO: [🧠][🚓] Is/which combination it better to use asserts/check, validate or is utility function?
|
|
283
|
-
*/
|
|
284
293
|
|
|
285
294
|
/**
|
|
286
295
|
* Color object represents an RGB color with alpha channel
|
|
@@ -315,6 +324,28 @@ class Color {
|
|
|
315
324
|
throw new Error(`Can not create color from given object`);
|
|
316
325
|
}
|
|
317
326
|
}
|
|
327
|
+
/**
|
|
328
|
+
* Creates a new Color instance from miscellaneous formats
|
|
329
|
+
* It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
|
|
330
|
+
*
|
|
331
|
+
* @param color
|
|
332
|
+
* @returns Color object
|
|
333
|
+
*/
|
|
334
|
+
static fromSafe(color) {
|
|
335
|
+
try {
|
|
336
|
+
return Color.from(color);
|
|
337
|
+
}
|
|
338
|
+
catch (error) {
|
|
339
|
+
// <- Note: Can not use `assertsError(error)` here because it causes circular dependency
|
|
340
|
+
console.warn(spaceTrim((block) => `
|
|
341
|
+
Color.fromSafe error:
|
|
342
|
+
${block(error.message)}
|
|
343
|
+
|
|
344
|
+
Returning default PROMPTBOOK_COLOR.
|
|
345
|
+
`));
|
|
346
|
+
return Color.fromString('promptbook');
|
|
347
|
+
}
|
|
348
|
+
}
|
|
318
349
|
/**
|
|
319
350
|
* Creates a new Color instance from miscellaneous string formats
|
|
320
351
|
*
|
|
@@ -382,6 +413,9 @@ class Color {
|
|
|
382
413
|
if (hex.length === 3) {
|
|
383
414
|
return Color.fromHex3(hex);
|
|
384
415
|
}
|
|
416
|
+
if (hex.length === 4) {
|
|
417
|
+
return Color.fromHex4(hex);
|
|
418
|
+
}
|
|
385
419
|
if (hex.length === 6) {
|
|
386
420
|
return Color.fromHex6(hex);
|
|
387
421
|
}
|
|
@@ -402,6 +436,19 @@ class Color {
|
|
|
402
436
|
const b = parseInt(hex.substr(2, 1), 16) * 16;
|
|
403
437
|
return take(new Color(r, g, b));
|
|
404
438
|
}
|
|
439
|
+
/**
|
|
440
|
+
* Creates a new Color instance from color in hex format with 4 digits (with alpha channel)
|
|
441
|
+
*
|
|
442
|
+
* @param color in hex for example `09df`
|
|
443
|
+
* @returns Color object
|
|
444
|
+
*/
|
|
445
|
+
static fromHex4(hex) {
|
|
446
|
+
const r = parseInt(hex.substr(0, 1), 16) * 16;
|
|
447
|
+
const g = parseInt(hex.substr(1, 1), 16) * 16;
|
|
448
|
+
const b = parseInt(hex.substr(2, 1), 16) * 16;
|
|
449
|
+
const a = parseInt(hex.substr(3, 1), 16) * 16;
|
|
450
|
+
return take(new Color(r, g, b, a));
|
|
451
|
+
}
|
|
405
452
|
/**
|
|
406
453
|
* Creates a new Color instance from color in hex format with 6 color digits (without alpha channel)
|
|
407
454
|
*
|
|
@@ -592,7 +639,8 @@ class Color {
|
|
|
592
639
|
* @returns true if the value is a valid hex color string (e.g., `#009edd`, `#fff`, etc.)
|
|
593
640
|
*/
|
|
594
641
|
static isHexColorString(value) {
|
|
595
|
-
return typeof value === 'string' &&
|
|
642
|
+
return (typeof value === 'string' &&
|
|
643
|
+
/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(value));
|
|
596
644
|
}
|
|
597
645
|
/**
|
|
598
646
|
* Creates new Color object
|
|
@@ -707,6 +755,23 @@ class Color {
|
|
|
707
755
|
* TODO: Maybe connect with textures
|
|
708
756
|
*/
|
|
709
757
|
|
|
758
|
+
/**
|
|
759
|
+
* Makes color transformer which returns a grayscale version of the color
|
|
760
|
+
*
|
|
761
|
+
* @param amount from 0 to 1
|
|
762
|
+
*
|
|
763
|
+
* @public exported from `@promptbook/color`
|
|
764
|
+
*/
|
|
765
|
+
function grayscale(amount) {
|
|
766
|
+
return ({ red, green, blue, alpha }) => {
|
|
767
|
+
const average = (red + green + blue) / 3;
|
|
768
|
+
red = Math.round(average * amount + red * (1 - amount));
|
|
769
|
+
green = Math.round(average * amount + green * (1 - amount));
|
|
770
|
+
blue = Math.round(average * amount + blue * (1 - amount));
|
|
771
|
+
return Color.fromValues(red, green, blue, alpha);
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
|
|
710
775
|
/**
|
|
711
776
|
* Converts HSL values to RGB values
|
|
712
777
|
*
|
|
@@ -822,102 +887,6 @@ function lighten(amount) {
|
|
|
822
887
|
* TODO: Maybe implement by mix+hsl
|
|
823
888
|
*/
|
|
824
889
|
|
|
825
|
-
/**
|
|
826
|
-
* Calculates distance between two colors
|
|
827
|
-
*
|
|
828
|
-
* @param color1 first color
|
|
829
|
-
* @param color2 second color
|
|
830
|
-
*
|
|
831
|
-
* Note: This function is inefficient. Use colorDistanceSquared instead if possible.
|
|
832
|
-
*
|
|
833
|
-
* @public exported from `@promptbook/color`
|
|
834
|
-
*/
|
|
835
|
-
/**
|
|
836
|
-
* Calculates distance between two colors without square root
|
|
837
|
-
*
|
|
838
|
-
* @param color1 first color
|
|
839
|
-
* @param color2 second color
|
|
840
|
-
*
|
|
841
|
-
* @public exported from `@promptbook/color`
|
|
842
|
-
*/
|
|
843
|
-
function colorDistanceSquared(color1, color2) {
|
|
844
|
-
const rmean = (color1.red + color2.red) / 2;
|
|
845
|
-
const r = color1.red - color2.red;
|
|
846
|
-
const g = color1.green - color2.green;
|
|
847
|
-
const b = color1.blue - color2.blue;
|
|
848
|
-
const weightR = 2 + rmean / 256;
|
|
849
|
-
const weightG = 4.0;
|
|
850
|
-
const weightB = 2 + (255 - rmean) / 256;
|
|
851
|
-
const distance = weightR * r * r + weightG * g * g + weightB * b * b;
|
|
852
|
-
return distance;
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
/**
|
|
856
|
-
* Makes color transformer which finds the nearest color from the given list
|
|
857
|
-
*
|
|
858
|
-
* @param colors array of colors to choose from
|
|
859
|
-
*
|
|
860
|
-
* @public exported from `@promptbook/color`
|
|
861
|
-
*/
|
|
862
|
-
function nearest(...colors) {
|
|
863
|
-
return (color) => {
|
|
864
|
-
const distances = colors.map((c) => colorDistanceSquared(c, color));
|
|
865
|
-
const minDistance = Math.min(...distances);
|
|
866
|
-
const minIndex = distances.indexOf(minDistance);
|
|
867
|
-
const nearestColor = colors[minIndex];
|
|
868
|
-
return nearestColor;
|
|
869
|
-
};
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
/**
|
|
873
|
-
* Color transformer which returns the negative color
|
|
874
|
-
*
|
|
875
|
-
* @public exported from `@promptbook/color`
|
|
876
|
-
*/
|
|
877
|
-
function negative(color) {
|
|
878
|
-
const r = 255 - color.red;
|
|
879
|
-
const g = 255 - color.green;
|
|
880
|
-
const b = 255 - color.blue;
|
|
881
|
-
return Color.fromValues(r, g, b, color.alpha);
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
/**
|
|
885
|
-
* Makes color transformer which finds the furthest color from the given list
|
|
886
|
-
*
|
|
887
|
-
* @param colors array of colors to choose from
|
|
888
|
-
*
|
|
889
|
-
* @public exported from `@promptbook/color`
|
|
890
|
-
*/
|
|
891
|
-
function furthest(...colors) {
|
|
892
|
-
return (color) => {
|
|
893
|
-
const furthestColor = negative(nearest(...colors.map(negative))(color));
|
|
894
|
-
return furthestColor;
|
|
895
|
-
};
|
|
896
|
-
}
|
|
897
|
-
/**
|
|
898
|
-
* Makes color transformer which finds the best text color (black or white) for the given background color
|
|
899
|
-
*
|
|
900
|
-
* @public exported from `@promptbook/color`
|
|
901
|
-
*/
|
|
902
|
-
furthest(Color.get('white'), Color.from('black'));
|
|
903
|
-
|
|
904
|
-
/**
|
|
905
|
-
* Makes color transformer which returns a grayscale version of the color
|
|
906
|
-
*
|
|
907
|
-
* @param amount from 0 to 1
|
|
908
|
-
*
|
|
909
|
-
* @public exported from `@promptbook/color`
|
|
910
|
-
*/
|
|
911
|
-
function grayscale(amount) {
|
|
912
|
-
return ({ red, green, blue, alpha }) => {
|
|
913
|
-
const average = (red + green + blue) / 3;
|
|
914
|
-
red = Math.round(average * amount + red * (1 - amount));
|
|
915
|
-
green = Math.round(average * amount + green * (1 - amount));
|
|
916
|
-
blue = Math.round(average * amount + blue * (1 - amount));
|
|
917
|
-
return Color.fromValues(red, green, blue, alpha);
|
|
918
|
-
};
|
|
919
|
-
}
|
|
920
|
-
|
|
921
890
|
/**
|
|
922
891
|
* Makes color transformer which saturate the given color
|
|
923
892
|
*
|
|
@@ -986,16 +955,32 @@ const ADMIN_GITHUB_NAME = 'hejny';
|
|
|
986
955
|
*
|
|
987
956
|
* @public exported from `@promptbook/core`
|
|
988
957
|
*/
|
|
989
|
-
const PROMPTBOOK_COLOR = Color.
|
|
990
|
-
// <- TODO: [🧠] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
958
|
+
const PROMPTBOOK_COLOR = Color.fromString('promptbook');
|
|
959
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
991
960
|
/**
|
|
992
|
-
*
|
|
961
|
+
* Colors for syntax highlighting in the `<BookEditor/>`
|
|
962
|
+
*
|
|
963
|
+
* TODO: [🗽] Unite branding and make single place for it
|
|
964
|
+
*
|
|
965
|
+
* @public exported from `@promptbook/core`
|
|
966
|
+
*/
|
|
967
|
+
({
|
|
968
|
+
TITLE: Color.fromHex('#244EA8'),
|
|
969
|
+
LINE: Color.fromHex('#eeeeee'),
|
|
970
|
+
SEPARATOR: Color.fromHex('#cccccc'),
|
|
971
|
+
COMMITMENT: Color.fromHex('#DA0F78'),
|
|
972
|
+
PARAMETER: Color.fromHex('#8e44ad'),
|
|
973
|
+
});
|
|
974
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
975
|
+
/**
|
|
976
|
+
* Chat color of the Promptbook (in chat)
|
|
993
977
|
*
|
|
994
978
|
* TODO: [🗽] Unite branding and make single place for it
|
|
995
979
|
*
|
|
996
980
|
* @public exported from `@promptbook/core`
|
|
997
981
|
*/
|
|
998
982
|
PROMPTBOOK_COLOR.then(lighten(0.1)).then(saturate(0.9)).then(grayscale(0.9));
|
|
983
|
+
// <- TODO: [🧠][🈵] Using `Color` and `lighten`, `saturate`,... here increases the package size approx 3kb, maybe remove it
|
|
999
984
|
/**
|
|
1000
985
|
* Color of the user (in chat)
|
|
1001
986
|
*
|
|
@@ -1004,6 +989,7 @@ PROMPTBOOK_COLOR.then(lighten(0.1)).then(saturate(0.9)).then(grayscale(0.9));
|
|
|
1004
989
|
* @public exported from `@promptbook/core`
|
|
1005
990
|
*/
|
|
1006
991
|
Color.fromHex('#1D4ED8');
|
|
992
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
1007
993
|
/**
|
|
1008
994
|
* When the title is not provided, the default title is used
|
|
1009
995
|
*
|
|
@@ -1090,7 +1076,7 @@ const DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [🤹♂️]
|
|
|
1090
1076
|
* @public exported from `@promptbook/core`
|
|
1091
1077
|
*/
|
|
1092
1078
|
const DEFAULT_MAX_EXECUTION_ATTEMPTS = 7; // <- TODO: [🤹♂️]
|
|
1093
|
-
// <- TODO: [🕝] Make also `
|
|
1079
|
+
// <- TODO: [🕝] Make also `AGENTS_DIRNAME_ALTERNATIVES`
|
|
1094
1080
|
// TODO: Just `.promptbook` in config, hardcode subfolders like `download-cache` or `execution-cache`
|
|
1095
1081
|
/**
|
|
1096
1082
|
* Where to store the temporary downloads
|
|
@@ -1192,7 +1178,7 @@ class KnowledgeScrapeError extends Error {
|
|
|
1192
1178
|
*/
|
|
1193
1179
|
class MissingToolsError extends Error {
|
|
1194
1180
|
constructor(message) {
|
|
1195
|
-
super(spaceTrim((block) => `
|
|
1181
|
+
super(spaceTrim$1((block) => `
|
|
1196
1182
|
${block(message)}
|
|
1197
1183
|
|
|
1198
1184
|
Note: You have probably forgot to provide some tools for pipeline execution or preparation
|
|
@@ -1211,7 +1197,7 @@ class MissingToolsError extends Error {
|
|
|
1211
1197
|
function getErrorReportUrl(error) {
|
|
1212
1198
|
const report = {
|
|
1213
1199
|
title: `🐜 Error report from ${NAME}`,
|
|
1214
|
-
body: spaceTrim$
|
|
1200
|
+
body: spaceTrim$2((block) => `
|
|
1215
1201
|
|
|
1216
1202
|
|
|
1217
1203
|
\`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
|
|
@@ -1254,7 +1240,7 @@ function getErrorReportUrl(error) {
|
|
|
1254
1240
|
*/
|
|
1255
1241
|
class UnexpectedError extends Error {
|
|
1256
1242
|
constructor(message) {
|
|
1257
|
-
super(spaceTrim((block) => `
|
|
1243
|
+
super(spaceTrim$1((block) => `
|
|
1258
1244
|
${block(message)}
|
|
1259
1245
|
|
|
1260
1246
|
Note: This error should not happen.
|
|
@@ -1415,11 +1401,11 @@ function $execCommand(options) {
|
|
|
1415
1401
|
console.warn(`Command "${humanReadableCommand}" exited with code ${code}`);
|
|
1416
1402
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
1417
1403
|
}
|
|
1418
|
-
resolve(spaceTrim(output.join('\n')));
|
|
1404
|
+
resolve(spaceTrim$1(output.join('\n')));
|
|
1419
1405
|
}
|
|
1420
1406
|
}
|
|
1421
1407
|
else {
|
|
1422
|
-
resolve(spaceTrim(output.join('\n')));
|
|
1408
|
+
resolve(spaceTrim$1(output.join('\n')));
|
|
1423
1409
|
}
|
|
1424
1410
|
};
|
|
1425
1411
|
commandProcess.on('close', finishWithCode);
|
|
@@ -1437,7 +1423,7 @@ function $execCommand(options) {
|
|
|
1437
1423
|
console.warn(error);
|
|
1438
1424
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
1439
1425
|
}
|
|
1440
|
-
resolve(spaceTrim(output.join('\n')));
|
|
1426
|
+
resolve(spaceTrim$1(output.join('\n')));
|
|
1441
1427
|
}
|
|
1442
1428
|
});
|
|
1443
1429
|
}
|
|
@@ -1762,6 +1748,8 @@ function removeDiacritics(input) {
|
|
|
1762
1748
|
/**
|
|
1763
1749
|
* Converts a given text to kebab-case format.
|
|
1764
1750
|
*
|
|
1751
|
+
* Note: [🔂] This function is idempotent.
|
|
1752
|
+
*
|
|
1765
1753
|
* @param text The text to be converted.
|
|
1766
1754
|
* @returns The kebab-case formatted string.
|
|
1767
1755
|
* @example 'hello-world'
|
|
@@ -1917,6 +1905,8 @@ function removeEmojis(text) {
|
|
|
1917
1905
|
/**
|
|
1918
1906
|
* Converts a title string into a normalized name.
|
|
1919
1907
|
*
|
|
1908
|
+
* Note: [🔂] This function is idempotent.
|
|
1909
|
+
*
|
|
1920
1910
|
* @param value The title string to be converted to a name.
|
|
1921
1911
|
* @returns A normalized name derived from the input title.
|
|
1922
1912
|
* @example 'Hello World!' -> 'hello-world'
|
|
@@ -2008,7 +1998,7 @@ async function getScraperIntermediateSource(source, options) {
|
|
|
2008
1998
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
2009
1999
|
*/
|
|
2010
2000
|
|
|
2011
|
-
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-9",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"}];
|
|
2001
|
+
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"}];
|
|
2012
2002
|
|
|
2013
2003
|
/**
|
|
2014
2004
|
* Checks if value is valid email
|
|
@@ -2050,7 +2040,7 @@ class WrappedError extends Error {
|
|
|
2050
2040
|
constructor(whatWasThrown) {
|
|
2051
2041
|
const tag = `[🤮]`;
|
|
2052
2042
|
console.error(tag, whatWasThrown);
|
|
2053
|
-
super(spaceTrim(`
|
|
2043
|
+
super(spaceTrim$1(`
|
|
2054
2044
|
Non-Error object was thrown
|
|
2055
2045
|
|
|
2056
2046
|
Note: Look for ${tag} in the console for more details
|
|
@@ -2115,6 +2105,8 @@ function isValidJsonString(value /* <- [👨⚖️] */) {
|
|
|
2115
2105
|
* Function `validatePipelineString` will validate the if the string is a valid pipeline string
|
|
2116
2106
|
* 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.
|
|
2117
2107
|
*
|
|
2108
|
+
* Note: [🔂] This function is idempotent.
|
|
2109
|
+
*
|
|
2118
2110
|
* @param {string} pipelineString the candidate for a pipeline string
|
|
2119
2111
|
* @returns {PipelineString} the same string as input, but validated as valid
|
|
2120
2112
|
* @throws {ParseError} if the string is not a valid pipeline string
|
|
@@ -2274,7 +2266,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
2274
2266
|
pipelineString += '\n\n';
|
|
2275
2267
|
pipelineString += '```' + contentLanguage;
|
|
2276
2268
|
pipelineString += '\n';
|
|
2277
|
-
pipelineString += spaceTrim$
|
|
2269
|
+
pipelineString += spaceTrim$2(content);
|
|
2278
2270
|
// <- TODO: [main] !!3 Escape
|
|
2279
2271
|
// <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
|
|
2280
2272
|
pipelineString += '\n';
|
|
@@ -2395,7 +2387,7 @@ function checkSerializableAsJson(options) {
|
|
|
2395
2387
|
}
|
|
2396
2388
|
else if (typeof value === 'object') {
|
|
2397
2389
|
if (value instanceof Date) {
|
|
2398
|
-
throw new UnexpectedError(spaceTrim$
|
|
2390
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2399
2391
|
\`${name}\` is Date
|
|
2400
2392
|
|
|
2401
2393
|
Use \`string_date_iso8601\` instead
|
|
@@ -2414,7 +2406,7 @@ function checkSerializableAsJson(options) {
|
|
|
2414
2406
|
throw new UnexpectedError(`${name} is RegExp`);
|
|
2415
2407
|
}
|
|
2416
2408
|
else if (value instanceof Error) {
|
|
2417
|
-
throw new UnexpectedError(spaceTrim$
|
|
2409
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2418
2410
|
\`${name}\` is unserialized Error
|
|
2419
2411
|
|
|
2420
2412
|
Use function \`serializeError\`
|
|
@@ -2437,7 +2429,7 @@ function checkSerializableAsJson(options) {
|
|
|
2437
2429
|
}
|
|
2438
2430
|
catch (error) {
|
|
2439
2431
|
assertsError(error);
|
|
2440
|
-
throw new UnexpectedError(spaceTrim$
|
|
2432
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2441
2433
|
\`${name}\` is not serializable
|
|
2442
2434
|
|
|
2443
2435
|
${block(error.stack || error.message)}
|
|
@@ -2469,7 +2461,7 @@ function checkSerializableAsJson(options) {
|
|
|
2469
2461
|
}
|
|
2470
2462
|
}
|
|
2471
2463
|
else {
|
|
2472
|
-
throw new UnexpectedError(spaceTrim$
|
|
2464
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2473
2465
|
\`${name}\` is unknown type
|
|
2474
2466
|
|
|
2475
2467
|
Additional message for \`${name}\`:
|
|
@@ -2499,7 +2491,7 @@ function deepClone(objectValue) {
|
|
|
2499
2491
|
TODO: [🧠] Is there a better implementation?
|
|
2500
2492
|
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
2501
2493
|
> for (const propertyName of propertyNames) {
|
|
2502
|
-
> const value = (objectValue as
|
|
2494
|
+
> const value = (objectValue as chococake)[propertyName];
|
|
2503
2495
|
> if (value && typeof value === 'object') {
|
|
2504
2496
|
> deepClone(value);
|
|
2505
2497
|
> }
|
|
@@ -2704,6 +2696,8 @@ function isValidPipelineUrl(url) {
|
|
|
2704
2696
|
* - if it is valid json
|
|
2705
2697
|
* - if it is meaningful
|
|
2706
2698
|
*
|
|
2699
|
+
* Note: [🔂] This function is idempotent.
|
|
2700
|
+
*
|
|
2707
2701
|
* @param pipeline valid or invalid PipelineJson
|
|
2708
2702
|
* @returns the same pipeline if it is logically valid
|
|
2709
2703
|
* @throws {PipelineLogicError} on logical error in the pipeline
|
|
@@ -2721,7 +2715,7 @@ function validatePipeline(pipeline) {
|
|
|
2721
2715
|
if (!(error instanceof PipelineLogicError)) {
|
|
2722
2716
|
throw error;
|
|
2723
2717
|
}
|
|
2724
|
-
console.error(spaceTrim((block) => `
|
|
2718
|
+
console.error(spaceTrim$1((block) => `
|
|
2725
2719
|
Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
|
|
2726
2720
|
|
|
2727
2721
|
${block(error.message)}
|
|
@@ -2748,7 +2742,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2748
2742
|
})();
|
|
2749
2743
|
if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
|
|
2750
2744
|
// <- Note: [🚲]
|
|
2751
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2745
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2752
2746
|
Invalid promptbook URL "${pipeline.pipelineUrl}"
|
|
2753
2747
|
|
|
2754
2748
|
${block(pipelineIdentification)}
|
|
@@ -2756,7 +2750,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2756
2750
|
}
|
|
2757
2751
|
if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
|
|
2758
2752
|
// <- Note: [🚲]
|
|
2759
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2753
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2760
2754
|
Invalid Promptbook Version "${pipeline.bookVersion}"
|
|
2761
2755
|
|
|
2762
2756
|
${block(pipelineIdentification)}
|
|
@@ -2765,7 +2759,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2765
2759
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
2766
2760
|
if (!Array.isArray(pipeline.parameters)) {
|
|
2767
2761
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
2768
|
-
throw new ParseError(spaceTrim((block) => `
|
|
2762
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
2769
2763
|
Pipeline is valid JSON but with wrong structure
|
|
2770
2764
|
|
|
2771
2765
|
\`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
|
|
@@ -2776,7 +2770,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2776
2770
|
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
2777
2771
|
if (!Array.isArray(pipeline.tasks)) {
|
|
2778
2772
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
2779
|
-
throw new ParseError(spaceTrim((block) => `
|
|
2773
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
2780
2774
|
Pipeline is valid JSON but with wrong structure
|
|
2781
2775
|
|
|
2782
2776
|
\`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
|
|
@@ -2802,7 +2796,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2802
2796
|
// Note: Check each parameter individually
|
|
2803
2797
|
for (const parameter of pipeline.parameters) {
|
|
2804
2798
|
if (parameter.isInput && parameter.isOutput) {
|
|
2805
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2799
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2806
2800
|
|
|
2807
2801
|
Parameter \`{${parameter.name}}\` can not be both input and output
|
|
2808
2802
|
|
|
@@ -2813,7 +2807,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2813
2807
|
if (!parameter.isInput &&
|
|
2814
2808
|
!parameter.isOutput &&
|
|
2815
2809
|
!pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
|
|
2816
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2810
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2817
2811
|
Parameter \`{${parameter.name}}\` is created but not used
|
|
2818
2812
|
|
|
2819
2813
|
You can declare {${parameter.name}} as output parameter by adding in the header:
|
|
@@ -2825,7 +2819,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2825
2819
|
}
|
|
2826
2820
|
// Note: Testing that parameter is either input or result of some task
|
|
2827
2821
|
if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
|
|
2828
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2822
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2829
2823
|
Parameter \`{${parameter.name}}\` is declared but not defined
|
|
2830
2824
|
|
|
2831
2825
|
You can do one of these:
|
|
@@ -2841,14 +2835,14 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2841
2835
|
// Note: Checking each task individually
|
|
2842
2836
|
for (const task of pipeline.tasks) {
|
|
2843
2837
|
if (definedParameters.has(task.resultingParameterName)) {
|
|
2844
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2838
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2845
2839
|
Parameter \`{${task.resultingParameterName}}\` is defined multiple times
|
|
2846
2840
|
|
|
2847
2841
|
${block(pipelineIdentification)}
|
|
2848
2842
|
`));
|
|
2849
2843
|
}
|
|
2850
2844
|
if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
|
|
2851
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2845
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2852
2846
|
Parameter name {${task.resultingParameterName}} is reserved, please use different name
|
|
2853
2847
|
|
|
2854
2848
|
${block(pipelineIdentification)}
|
|
@@ -2858,7 +2852,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2858
2852
|
if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
|
|
2859
2853
|
if (!task.format &&
|
|
2860
2854
|
!task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
|
|
2861
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2855
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2862
2856
|
Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
|
|
2863
2857
|
|
|
2864
2858
|
${block(pipelineIdentification)}
|
|
@@ -2866,7 +2860,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2866
2860
|
}
|
|
2867
2861
|
for (const joker of task.jokerParameterNames) {
|
|
2868
2862
|
if (!task.dependentParameterNames.includes(joker)) {
|
|
2869
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2863
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2870
2864
|
Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
|
|
2871
2865
|
|
|
2872
2866
|
${block(pipelineIdentification)}
|
|
@@ -2877,21 +2871,21 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2877
2871
|
if (task.expectations) {
|
|
2878
2872
|
for (const [unit, { min, max }] of Object.entries(task.expectations)) {
|
|
2879
2873
|
if (min !== undefined && max !== undefined && min > max) {
|
|
2880
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2874
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2881
2875
|
Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
|
|
2882
2876
|
|
|
2883
2877
|
${block(pipelineIdentification)}
|
|
2884
2878
|
`));
|
|
2885
2879
|
}
|
|
2886
2880
|
if (min !== undefined && min < 0) {
|
|
2887
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2881
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2888
2882
|
Min expectation of ${unit} must be zero or positive
|
|
2889
2883
|
|
|
2890
2884
|
${block(pipelineIdentification)}
|
|
2891
2885
|
`));
|
|
2892
2886
|
}
|
|
2893
2887
|
if (max !== undefined && max <= 0) {
|
|
2894
|
-
throw new PipelineLogicError(spaceTrim((block) => `
|
|
2888
|
+
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
2895
2889
|
Max expectation of ${unit} must be positive
|
|
2896
2890
|
|
|
2897
2891
|
${block(pipelineIdentification)}
|
|
@@ -2913,7 +2907,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2913
2907
|
while (unresovedTasks.length > 0) {
|
|
2914
2908
|
if (loopLimit-- < 0) {
|
|
2915
2909
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
2916
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
2910
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
2917
2911
|
Loop limit reached during detection of circular dependencies in \`validatePipeline\`
|
|
2918
2912
|
|
|
2919
2913
|
${block(pipelineIdentification)}
|
|
@@ -2923,7 +2917,7 @@ function validatePipeline_InnerFunction(pipeline) {
|
|
|
2923
2917
|
if (currentlyResovedTasks.length === 0) {
|
|
2924
2918
|
throw new PipelineLogicError(
|
|
2925
2919
|
// TODO: [🐎] DRY
|
|
2926
|
-
spaceTrim((block) => `
|
|
2920
|
+
spaceTrim$1((block) => `
|
|
2927
2921
|
|
|
2928
2922
|
Can not resolve some parameters:
|
|
2929
2923
|
Either you are using a parameter that is not defined, or there are some circular dependencies.
|
|
@@ -3070,7 +3064,7 @@ function unpreparePipeline(pipeline) {
|
|
|
3070
3064
|
* Library of pipelines that groups together pipelines for an application.
|
|
3071
3065
|
* This implementation is a very thin wrapper around the Array / Map of pipelines.
|
|
3072
3066
|
*
|
|
3073
|
-
* @private internal function of `
|
|
3067
|
+
* @private internal function of `createPipelineCollectionFromJson`, use `createPipelineCollectionFromJson` instead
|
|
3074
3068
|
* @see https://github.com/webgptorg/pipeline#pipeline-collection
|
|
3075
3069
|
*/
|
|
3076
3070
|
class SimplePipelineCollection {
|
|
@@ -3080,14 +3074,14 @@ class SimplePipelineCollection {
|
|
|
3080
3074
|
* @param pipelines Array of pipeline JSON objects to include in the collection
|
|
3081
3075
|
*
|
|
3082
3076
|
* Note: During the construction logic of all pipelines are validated
|
|
3083
|
-
* Note: It is not recommended to use this constructor directly, use `
|
|
3077
|
+
* Note: It is not recommended to use this constructor directly, use `createPipelineCollectionFromJson` *(or other variant)* instead
|
|
3084
3078
|
*/
|
|
3085
3079
|
constructor(...pipelines) {
|
|
3086
3080
|
this.collection = new Map();
|
|
3087
3081
|
for (const pipeline of pipelines) {
|
|
3088
3082
|
// TODO: [👠] DRY
|
|
3089
3083
|
if (pipeline.pipelineUrl === undefined) {
|
|
3090
|
-
throw new PipelineUrlError(spaceTrim(`
|
|
3084
|
+
throw new PipelineUrlError(spaceTrim$1(`
|
|
3091
3085
|
Pipeline with name "${pipeline.title}" does not have defined URL
|
|
3092
3086
|
|
|
3093
3087
|
File:
|
|
@@ -3109,7 +3103,7 @@ class SimplePipelineCollection {
|
|
|
3109
3103
|
pipelineJsonToString(unpreparePipeline(pipeline)) !==
|
|
3110
3104
|
pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
|
|
3111
3105
|
const existing = this.collection.get(pipeline.pipelineUrl);
|
|
3112
|
-
throw new PipelineUrlError(spaceTrim(`
|
|
3106
|
+
throw new PipelineUrlError(spaceTrim$1(`
|
|
3113
3107
|
Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍎
|
|
3114
3108
|
|
|
3115
3109
|
Conflicting files:
|
|
@@ -3141,13 +3135,13 @@ class SimplePipelineCollection {
|
|
|
3141
3135
|
const pipeline = this.collection.get(url);
|
|
3142
3136
|
if (!pipeline) {
|
|
3143
3137
|
if (this.listPipelines().length === 0) {
|
|
3144
|
-
throw new NotFoundError(spaceTrim(`
|
|
3138
|
+
throw new NotFoundError(spaceTrim$1(`
|
|
3145
3139
|
Pipeline with url "${url}" not found
|
|
3146
3140
|
|
|
3147
3141
|
No pipelines available
|
|
3148
3142
|
`));
|
|
3149
3143
|
}
|
|
3150
|
-
throw new NotFoundError(spaceTrim((block) => `
|
|
3144
|
+
throw new NotFoundError(spaceTrim$1((block) => `
|
|
3151
3145
|
Pipeline with url "${url}" not found
|
|
3152
3146
|
|
|
3153
3147
|
Available pipelines:
|
|
@@ -3168,22 +3162,23 @@ class SimplePipelineCollection {
|
|
|
3168
3162
|
}
|
|
3169
3163
|
|
|
3170
3164
|
/**
|
|
3171
|
-
* Creates PipelineCollection from array of PipelineJson or PipelineString
|
|
3165
|
+
* Creates `PipelineCollection` from array of PipelineJson or PipelineString
|
|
3172
3166
|
*
|
|
3173
|
-
* Note: Functions `
|
|
3167
|
+
* Note: Functions `pipelineCollectionToJson` and `createPipelineCollectionFromJson` are complementary
|
|
3174
3168
|
* Note: Syntax, parsing, and logic consistency checks are performed on all sources during build
|
|
3175
3169
|
*
|
|
3176
3170
|
* @param promptbookSources
|
|
3177
3171
|
* @returns PipelineCollection
|
|
3178
3172
|
* @public exported from `@promptbook/core`
|
|
3179
3173
|
*/
|
|
3180
|
-
function
|
|
3174
|
+
function createPipelineCollectionFromJson(...promptbooks) {
|
|
3181
3175
|
return new SimplePipelineCollection(...promptbooks);
|
|
3182
3176
|
}
|
|
3183
3177
|
|
|
3184
3178
|
/**
|
|
3185
3179
|
* Generates random token
|
|
3186
3180
|
*
|
|
3181
|
+
* Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
|
|
3187
3182
|
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
3188
3183
|
*
|
|
3189
3184
|
* @private internal helper function
|
|
@@ -3193,6 +3188,7 @@ function $randomToken(randomness) {
|
|
|
3193
3188
|
return randomBytes(randomness).toString('hex');
|
|
3194
3189
|
}
|
|
3195
3190
|
/**
|
|
3191
|
+
* TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
|
|
3196
3192
|
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
3197
3193
|
*/
|
|
3198
3194
|
|
|
@@ -3311,6 +3307,22 @@ class CollectionError extends Error {
|
|
|
3311
3307
|
}
|
|
3312
3308
|
}
|
|
3313
3309
|
|
|
3310
|
+
/**
|
|
3311
|
+
* This error indicates error from the database
|
|
3312
|
+
*
|
|
3313
|
+
* @public exported from `@promptbook/core`
|
|
3314
|
+
*/
|
|
3315
|
+
class DatabaseError extends Error {
|
|
3316
|
+
constructor(message) {
|
|
3317
|
+
super(message);
|
|
3318
|
+
this.name = 'DatabaseError';
|
|
3319
|
+
Object.setPrototypeOf(this, DatabaseError.prototype);
|
|
3320
|
+
}
|
|
3321
|
+
}
|
|
3322
|
+
/**
|
|
3323
|
+
* TODO: [🐱🚀] Explain that NotFoundError ([🐱🚀] and other specific errors) has priority over DatabaseError in some contexts
|
|
3324
|
+
*/
|
|
3325
|
+
|
|
3314
3326
|
/**
|
|
3315
3327
|
* This error occurs when some expectation is not met in the execution of the pipeline
|
|
3316
3328
|
*
|
|
@@ -3340,6 +3352,19 @@ class LimitReachedError extends Error {
|
|
|
3340
3352
|
}
|
|
3341
3353
|
}
|
|
3342
3354
|
|
|
3355
|
+
/**
|
|
3356
|
+
* This error indicates that promptbook operation is not allowed
|
|
3357
|
+
*
|
|
3358
|
+
* @public exported from `@promptbook/core`
|
|
3359
|
+
*/
|
|
3360
|
+
class NotAllowed extends Error {
|
|
3361
|
+
constructor(message) {
|
|
3362
|
+
super(message);
|
|
3363
|
+
this.name = 'NotAllowed';
|
|
3364
|
+
Object.setPrototypeOf(this, NotAllowed.prototype);
|
|
3365
|
+
}
|
|
3366
|
+
}
|
|
3367
|
+
|
|
3343
3368
|
/**
|
|
3344
3369
|
* This error type indicates that some part of the code is not implemented yet
|
|
3345
3370
|
*
|
|
@@ -3347,7 +3372,7 @@ class LimitReachedError extends Error {
|
|
|
3347
3372
|
*/
|
|
3348
3373
|
class NotYetImplementedError extends Error {
|
|
3349
3374
|
constructor(message) {
|
|
3350
|
-
super(spaceTrim((block) => `
|
|
3375
|
+
super(spaceTrim$1((block) => `
|
|
3351
3376
|
${block(message)}
|
|
3352
3377
|
|
|
3353
3378
|
Note: This feature is not implemented yet but it will be soon.
|
|
@@ -3400,6 +3425,8 @@ const PROMPTBOOK_ERRORS = {
|
|
|
3400
3425
|
PromptbookFetchError,
|
|
3401
3426
|
UnexpectedError,
|
|
3402
3427
|
WrappedError,
|
|
3428
|
+
NotAllowed,
|
|
3429
|
+
DatabaseError,
|
|
3403
3430
|
// TODO: [🪑]> VersionMismatchError,
|
|
3404
3431
|
};
|
|
3405
3432
|
/**
|
|
@@ -3447,7 +3474,7 @@ function serializeError(error) {
|
|
|
3447
3474
|
const { name, message, stack } = error;
|
|
3448
3475
|
const { id } = error;
|
|
3449
3476
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
3450
|
-
console.error(spaceTrim$
|
|
3477
|
+
console.error(spaceTrim$2((block) => `
|
|
3451
3478
|
|
|
3452
3479
|
Cannot serialize error with name "${name}"
|
|
3453
3480
|
|
|
@@ -3480,7 +3507,7 @@ function jsonParse(value) {
|
|
|
3480
3507
|
}
|
|
3481
3508
|
else if (typeof value !== 'string') {
|
|
3482
3509
|
console.error('Can not parse JSON from non-string value.', { text: value });
|
|
3483
|
-
throw new Error(spaceTrim$
|
|
3510
|
+
throw new Error(spaceTrim$2(`
|
|
3484
3511
|
Can not parse JSON from non-string value.
|
|
3485
3512
|
|
|
3486
3513
|
The value type: ${typeof value}
|
|
@@ -3494,7 +3521,7 @@ function jsonParse(value) {
|
|
|
3494
3521
|
if (!(error instanceof Error)) {
|
|
3495
3522
|
throw error;
|
|
3496
3523
|
}
|
|
3497
|
-
throw new Error(spaceTrim$
|
|
3524
|
+
throw new Error(spaceTrim$2((block) => `
|
|
3498
3525
|
${block(error.message)}
|
|
3499
3526
|
|
|
3500
3527
|
The expected JSON text:
|
|
@@ -3547,7 +3574,7 @@ function deserializeError(error) {
|
|
|
3547
3574
|
message = `${name}: ${message}`;
|
|
3548
3575
|
}
|
|
3549
3576
|
if (stack !== undefined && stack !== '') {
|
|
3550
|
-
message = spaceTrim$
|
|
3577
|
+
message = spaceTrim$2((block) => `
|
|
3551
3578
|
${block(message)}
|
|
3552
3579
|
|
|
3553
3580
|
Original stack trace:
|
|
@@ -3584,11 +3611,11 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
3584
3611
|
throw deserializeError(errors[0]);
|
|
3585
3612
|
}
|
|
3586
3613
|
else {
|
|
3587
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
3614
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
3588
3615
|
Multiple errors occurred during Promptbook execution
|
|
3589
3616
|
|
|
3590
3617
|
${block(errors
|
|
3591
|
-
.map(({ name, stack, message }, index) => spaceTrim((block) => `
|
|
3618
|
+
.map(({ name, stack, message }, index) => spaceTrim$1((block) => `
|
|
3592
3619
|
${name} ${index + 1}:
|
|
3593
3620
|
${block(stack || message)}
|
|
3594
3621
|
`))
|
|
@@ -3615,6 +3642,7 @@ function createTask(options) {
|
|
|
3615
3642
|
let updatedAt = createdAt;
|
|
3616
3643
|
const errors = [];
|
|
3617
3644
|
const warnings = [];
|
|
3645
|
+
const llmCalls = [];
|
|
3618
3646
|
let currentValue = {};
|
|
3619
3647
|
let customTldr = null;
|
|
3620
3648
|
const partialResultSubject = new Subject();
|
|
@@ -3630,6 +3658,9 @@ function createTask(options) {
|
|
|
3630
3658
|
}, (tldrInfo) => {
|
|
3631
3659
|
customTldr = tldrInfo;
|
|
3632
3660
|
updatedAt = new Date();
|
|
3661
|
+
}, (llmCall) => {
|
|
3662
|
+
llmCalls.push(llmCall);
|
|
3663
|
+
updatedAt = new Date();
|
|
3633
3664
|
});
|
|
3634
3665
|
finalResultPromise
|
|
3635
3666
|
.catch((error) => {
|
|
@@ -3752,7 +3783,7 @@ function createTask(options) {
|
|
|
3752
3783
|
}
|
|
3753
3784
|
return {
|
|
3754
3785
|
percent: percent,
|
|
3755
|
-
message,
|
|
3786
|
+
message: message + ' (!!!fallback)',
|
|
3756
3787
|
};
|
|
3757
3788
|
},
|
|
3758
3789
|
get createdAt() {
|
|
@@ -3775,6 +3806,10 @@ function createTask(options) {
|
|
|
3775
3806
|
return warnings;
|
|
3776
3807
|
// <- Note: [1] --||--
|
|
3777
3808
|
},
|
|
3809
|
+
get llmCalls() {
|
|
3810
|
+
return [...llmCalls, { foo: '!!! bar' }];
|
|
3811
|
+
// <- Note: [1] --||--
|
|
3812
|
+
},
|
|
3778
3813
|
get currentValue() {
|
|
3779
3814
|
return currentValue;
|
|
3780
3815
|
// <- Note: [1] --||--
|
|
@@ -4051,14 +4086,14 @@ class MultipleLlmExecutionTools {
|
|
|
4051
4086
|
if (description === undefined) {
|
|
4052
4087
|
return headLine;
|
|
4053
4088
|
}
|
|
4054
|
-
return spaceTrim$
|
|
4089
|
+
return spaceTrim$2((block) => `
|
|
4055
4090
|
${headLine}
|
|
4056
4091
|
|
|
4057
4092
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
4058
4093
|
`);
|
|
4059
4094
|
})
|
|
4060
4095
|
.join('\n\n');
|
|
4061
|
-
return spaceTrim$
|
|
4096
|
+
return spaceTrim$2((block) => `
|
|
4062
4097
|
Multiple LLM Providers:
|
|
4063
4098
|
|
|
4064
4099
|
${block(innerModelsTitlesAndDescriptions)}
|
|
@@ -4149,7 +4184,7 @@ class MultipleLlmExecutionTools {
|
|
|
4149
4184
|
// 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
4150
4185
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
4151
4186
|
// 3) ...
|
|
4152
|
-
spaceTrim$
|
|
4187
|
+
spaceTrim$2((block) => `
|
|
4153
4188
|
All execution tools of ${this.title} failed:
|
|
4154
4189
|
|
|
4155
4190
|
${block(errors
|
|
@@ -4162,7 +4197,7 @@ class MultipleLlmExecutionTools {
|
|
|
4162
4197
|
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
|
|
4163
4198
|
}
|
|
4164
4199
|
else {
|
|
4165
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
4200
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
4166
4201
|
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
|
|
4167
4202
|
|
|
4168
4203
|
Available \`LlmExecutionTools\`:
|
|
@@ -4195,7 +4230,7 @@ class MultipleLlmExecutionTools {
|
|
|
4195
4230
|
*/
|
|
4196
4231
|
function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
4197
4232
|
if (llmExecutionTools.length === 0) {
|
|
4198
|
-
const warningMessage = spaceTrim$
|
|
4233
|
+
const warningMessage = spaceTrim$2(`
|
|
4199
4234
|
You have not provided any \`LlmExecutionTools\`
|
|
4200
4235
|
This means that you won't be able to execute any prompts that require large language models like GPT-4 or Anthropic's Claude.
|
|
4201
4236
|
|
|
@@ -4228,6 +4263,7 @@ function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
|
4228
4263
|
return new MultipleLlmExecutionTools(title || 'Multiple LLM Providers joined by `joinLlmExecutionTools`', ...llmExecutionTools);
|
|
4229
4264
|
}
|
|
4230
4265
|
/**
|
|
4266
|
+
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
4231
4267
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
4232
4268
|
*/
|
|
4233
4269
|
|
|
@@ -4244,6 +4280,7 @@ function getSingleLlmExecutionTools(oneOrMoreLlmExecutionTools) {
|
|
|
4244
4280
|
return llmTools;
|
|
4245
4281
|
}
|
|
4246
4282
|
/**
|
|
4283
|
+
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
4247
4284
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
4248
4285
|
*/
|
|
4249
4286
|
|
|
@@ -4259,7 +4296,7 @@ async function preparePersona(personaDescription, tools, options) {
|
|
|
4259
4296
|
throw new MissingToolsError('LLM tools are required for preparing persona');
|
|
4260
4297
|
}
|
|
4261
4298
|
// TODO: [🌼] In future use `ptbk make` and made getPipelineCollection
|
|
4262
|
-
const collection =
|
|
4299
|
+
const collection = createPipelineCollectionFromJson(...PipelineCollection);
|
|
4263
4300
|
const preparePersonaExecutor = createPipelineExecutor({
|
|
4264
4301
|
pipeline: await collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book'),
|
|
4265
4302
|
tools,
|
|
@@ -4510,14 +4547,14 @@ function $registeredScrapersMessage(availableScrapers) {
|
|
|
4510
4547
|
return { ...metadata, isMetadataAviailable, isInstalled, isAvailableInTools };
|
|
4511
4548
|
});
|
|
4512
4549
|
if (metadata.length === 0) {
|
|
4513
|
-
return spaceTrim$
|
|
4550
|
+
return spaceTrim$2(`
|
|
4514
4551
|
**No scrapers are available**
|
|
4515
4552
|
|
|
4516
4553
|
This is a unexpected behavior, you are probably using some broken version of Promptbook
|
|
4517
4554
|
At least there should be available the metadata of the scrapers
|
|
4518
4555
|
`);
|
|
4519
4556
|
}
|
|
4520
|
-
return spaceTrim$
|
|
4557
|
+
return spaceTrim$2((block) => `
|
|
4521
4558
|
Available scrapers are:
|
|
4522
4559
|
${block(metadata
|
|
4523
4560
|
.map(({ packageName, className, isMetadataAviailable, isInstalled, mimeTypes, isAvailableInBrowser, isAvailableInTools, }, i) => {
|
|
@@ -4618,7 +4655,7 @@ const promptbookFetch = async (urlOrRequest, init) => {
|
|
|
4618
4655
|
else if (urlOrRequest instanceof Request) {
|
|
4619
4656
|
url = urlOrRequest.url;
|
|
4620
4657
|
}
|
|
4621
|
-
throw new PromptbookFetchError(spaceTrim$
|
|
4658
|
+
throw new PromptbookFetchError(spaceTrim$2((block) => `
|
|
4622
4659
|
Can not fetch "${url}"
|
|
4623
4660
|
|
|
4624
4661
|
Fetch error:
|
|
@@ -4779,7 +4816,7 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
4779
4816
|
const fileExtension = getFileExtension(filename);
|
|
4780
4817
|
const mimeType = extensionToMimeType(fileExtension || '');
|
|
4781
4818
|
if (!(await isFileExisting(filename, tools.fs))) {
|
|
4782
|
-
throw new NotFoundError(spaceTrim$
|
|
4819
|
+
throw new NotFoundError(spaceTrim$2((block) => `
|
|
4783
4820
|
Can not make source handler for file which does not exist:
|
|
4784
4821
|
|
|
4785
4822
|
File:
|
|
@@ -4872,7 +4909,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
4872
4909
|
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
4873
4910
|
break;
|
|
4874
4911
|
}
|
|
4875
|
-
console.warn(spaceTrim$
|
|
4912
|
+
console.warn(spaceTrim$2((block) => `
|
|
4876
4913
|
Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
|
|
4877
4914
|
|
|
4878
4915
|
The source:
|
|
@@ -4888,7 +4925,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
4888
4925
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
4889
4926
|
}
|
|
4890
4927
|
if (partialPieces === null) {
|
|
4891
|
-
throw new KnowledgeScrapeError(spaceTrim$
|
|
4928
|
+
throw new KnowledgeScrapeError(spaceTrim$2((block) => `
|
|
4892
4929
|
Cannot scrape knowledge
|
|
4893
4930
|
|
|
4894
4931
|
The source:
|
|
@@ -4967,7 +5004,7 @@ async function prepareTasks(pipeline, tools, options) {
|
|
|
4967
5004
|
if (task.taskType === 'PROMPT_TASK' &&
|
|
4968
5005
|
knowledgePiecesCount > 0 &&
|
|
4969
5006
|
!dependentParameterNames.includes('knowledge')) {
|
|
4970
|
-
preparedContent = spaceTrim(`
|
|
5007
|
+
preparedContent = spaceTrim$1(`
|
|
4971
5008
|
{content}
|
|
4972
5009
|
|
|
4973
5010
|
## Knowledge
|
|
@@ -5053,7 +5090,7 @@ async function preparePipeline(pipeline, tools, options) {
|
|
|
5053
5090
|
let title = pipeline.title;
|
|
5054
5091
|
if (title === undefined || title === '' || title === DEFAULT_BOOK_TITLE) {
|
|
5055
5092
|
// TODO: [🌼] In future use `ptbk make` and made getPipelineCollection
|
|
5056
|
-
const collection =
|
|
5093
|
+
const collection = createPipelineCollectionFromJson(...PipelineCollection);
|
|
5057
5094
|
const prepareTitleExecutor = createPipelineExecutor({
|
|
5058
5095
|
pipeline: await collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-title.book'),
|
|
5059
5096
|
tools,
|
|
@@ -5280,7 +5317,7 @@ function extractVariablesFromJavascript(script) {
|
|
|
5280
5317
|
}
|
|
5281
5318
|
catch (error) {
|
|
5282
5319
|
assertsError(error);
|
|
5283
|
-
throw new ParseError(spaceTrim((block) => `
|
|
5320
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
5284
5321
|
Can not extract variables from the script
|
|
5285
5322
|
${block(error.stack || error.message)}
|
|
5286
5323
|
|
|
@@ -5463,7 +5500,7 @@ const CsvFormatParser = {
|
|
|
5463
5500
|
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
5464
5501
|
const csv = csvParse(value, settings);
|
|
5465
5502
|
if (csv.errors.length !== 0) {
|
|
5466
|
-
throw new CsvFormatError(spaceTrim$
|
|
5503
|
+
throw new CsvFormatError(spaceTrim$2((block) => `
|
|
5467
5504
|
CSV parsing error
|
|
5468
5505
|
|
|
5469
5506
|
Error(s) from CSV parsing:
|
|
@@ -5508,7 +5545,7 @@ const CsvFormatParser = {
|
|
|
5508
5545
|
const { value, settings, mapCallback, onProgress } = options;
|
|
5509
5546
|
const csv = csvParse(value, settings);
|
|
5510
5547
|
if (csv.errors.length !== 0) {
|
|
5511
|
-
throw new CsvFormatError(spaceTrim$
|
|
5548
|
+
throw new CsvFormatError(spaceTrim$2((block) => `
|
|
5512
5549
|
CSV parsing error
|
|
5513
5550
|
|
|
5514
5551
|
Error(s) from CSV parsing:
|
|
@@ -5718,7 +5755,7 @@ function mapAvailableToExpectedParameters(options) {
|
|
|
5718
5755
|
}
|
|
5719
5756
|
// Phase 2️⃣: Non-matching mapping
|
|
5720
5757
|
if (expectedParameterNames.size !== availableParametersNames.size) {
|
|
5721
|
-
throw new PipelineExecutionError(spaceTrim$
|
|
5758
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
5722
5759
|
Can not map available parameters to expected parameters
|
|
5723
5760
|
|
|
5724
5761
|
Mapped parameters:
|
|
@@ -5965,10 +6002,13 @@ const LINES_PER_STANDARD_PAGE = 44;
|
|
|
5965
6002
|
* @public exported from `@promptbook/utils`
|
|
5966
6003
|
*/
|
|
5967
6004
|
function countLines(text) {
|
|
6005
|
+
if (text === '') {
|
|
6006
|
+
return 0;
|
|
6007
|
+
}
|
|
5968
6008
|
text = text.replace('\r\n', '\n');
|
|
5969
6009
|
text = text.replace('\r', '\n');
|
|
5970
6010
|
const lines = text.split('\n');
|
|
5971
|
-
return lines.reduce((count, line) => count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 0);
|
|
6011
|
+
return lines.reduce((count, line) => count + Math.max(Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 1), 0);
|
|
5972
6012
|
}
|
|
5973
6013
|
/**
|
|
5974
6014
|
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
@@ -6093,6 +6133,8 @@ function checkExpectations(expectations, value) {
|
|
|
6093
6133
|
* This function provides a common abstraction for result validation that can be used
|
|
6094
6134
|
* by both execution logic and caching logic to ensure consistency.
|
|
6095
6135
|
*
|
|
6136
|
+
* Note: [🔂] This function is idempotent.
|
|
6137
|
+
*
|
|
6096
6138
|
* @param options - The validation options including result string, expectations, and format
|
|
6097
6139
|
* @returns Validation result with processed string and validity status
|
|
6098
6140
|
* @private internal function of `createPipelineExecutor` and `cacheLlmTools`
|
|
@@ -6112,7 +6154,7 @@ function validatePromptResult(options) {
|
|
|
6112
6154
|
}
|
|
6113
6155
|
catch (error) {
|
|
6114
6156
|
keepUnused(error);
|
|
6115
|
-
throw new ExpectError(spaceTrim((block) => `
|
|
6157
|
+
throw new ExpectError(spaceTrim$1((block) => `
|
|
6116
6158
|
Expected valid JSON string
|
|
6117
6159
|
|
|
6118
6160
|
The expected JSON text:
|
|
@@ -6161,7 +6203,7 @@ function validatePromptResult(options) {
|
|
|
6161
6203
|
*/
|
|
6162
6204
|
async function executeAttempts(options) {
|
|
6163
6205
|
const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
|
|
6164
|
-
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, } = options;
|
|
6206
|
+
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall, } = options;
|
|
6165
6207
|
const $ongoingTaskResult = {
|
|
6166
6208
|
$result: null,
|
|
6167
6209
|
$resultString: null,
|
|
@@ -6175,7 +6217,7 @@ async function executeAttempts(options) {
|
|
|
6175
6217
|
const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
|
|
6176
6218
|
// TODO: [🧠][🍭] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
|
|
6177
6219
|
if (isJokerAttempt && !jokerParameterName) {
|
|
6178
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
6220
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6179
6221
|
Joker not found in attempt ${attemptIndex}
|
|
6180
6222
|
|
|
6181
6223
|
${block(pipelineIdentification)}
|
|
@@ -6186,7 +6228,7 @@ async function executeAttempts(options) {
|
|
|
6186
6228
|
$ongoingTaskResult.$expectError = null;
|
|
6187
6229
|
if (isJokerAttempt) {
|
|
6188
6230
|
if (parameters[jokerParameterName] === undefined) {
|
|
6189
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6231
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6190
6232
|
Joker parameter {${jokerParameterName}} not defined
|
|
6191
6233
|
|
|
6192
6234
|
${block(pipelineIdentification)}
|
|
@@ -6244,7 +6286,7 @@ async function executeAttempts(options) {
|
|
|
6244
6286
|
$ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
|
|
6245
6287
|
break variant;
|
|
6246
6288
|
case 'EMBEDDING':
|
|
6247
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6289
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6248
6290
|
Embedding model can not be used in pipeline
|
|
6249
6291
|
|
|
6250
6292
|
This should be catched during parsing
|
|
@@ -6255,7 +6297,7 @@ async function executeAttempts(options) {
|
|
|
6255
6297
|
break variant;
|
|
6256
6298
|
// <- case [🤖]:
|
|
6257
6299
|
default:
|
|
6258
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6300
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6259
6301
|
Unknown model variant "${task.modelRequirements.modelVariant}"
|
|
6260
6302
|
|
|
6261
6303
|
${block(pipelineIdentification)}
|
|
@@ -6266,14 +6308,14 @@ async function executeAttempts(options) {
|
|
|
6266
6308
|
break;
|
|
6267
6309
|
case 'SCRIPT_TASK':
|
|
6268
6310
|
if (arrayableToArray(tools.script).length === 0) {
|
|
6269
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6311
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6270
6312
|
No script execution tools are available
|
|
6271
6313
|
|
|
6272
6314
|
${block(pipelineIdentification)}
|
|
6273
6315
|
`));
|
|
6274
6316
|
}
|
|
6275
6317
|
if (!task.contentLanguage) {
|
|
6276
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6318
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6277
6319
|
Script language is not defined for SCRIPT TASK "${task.name}"
|
|
6278
6320
|
|
|
6279
6321
|
${block(pipelineIdentification)}
|
|
@@ -6304,7 +6346,7 @@ async function executeAttempts(options) {
|
|
|
6304
6346
|
throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
|
|
6305
6347
|
}
|
|
6306
6348
|
else {
|
|
6307
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6349
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6308
6350
|
Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
|
|
6309
6351
|
|
|
6310
6352
|
${block(pipelineIdentification)}
|
|
@@ -6318,7 +6360,7 @@ async function executeAttempts(options) {
|
|
|
6318
6360
|
break taskType;
|
|
6319
6361
|
case 'DIALOG_TASK':
|
|
6320
6362
|
if (tools.userInterface === undefined) {
|
|
6321
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6363
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6322
6364
|
User interface tools are not available
|
|
6323
6365
|
|
|
6324
6366
|
${block(pipelineIdentification)}
|
|
@@ -6336,7 +6378,7 @@ async function executeAttempts(options) {
|
|
|
6336
6378
|
break taskType;
|
|
6337
6379
|
// <- case: [🅱]
|
|
6338
6380
|
default:
|
|
6339
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
6381
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6340
6382
|
Unknown execution type "${task.taskType}"
|
|
6341
6383
|
|
|
6342
6384
|
${block(pipelineIdentification)}
|
|
@@ -6409,14 +6451,10 @@ async function executeAttempts(options) {
|
|
|
6409
6451
|
});
|
|
6410
6452
|
}
|
|
6411
6453
|
finally {
|
|
6412
|
-
if (!isJokerAttempt &&
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
// In that case we don’t want to make a report about it because it’s not a llm execution error
|
|
6417
|
-
) {
|
|
6418
|
-
// TODO: [🧠] Maybe put other taskTypes into report
|
|
6419
|
-
$executionReport.promptExecutions.push({
|
|
6454
|
+
if (!isJokerAttempt && task.taskType === 'PROMPT_TASK' && $ongoingTaskResult.$prompt) {
|
|
6455
|
+
// Note: [2] When some expected parameter is not defined, error will occur in templateParameters
|
|
6456
|
+
// In that case we don’t want to make a report about it because it’s not a llm execution error
|
|
6457
|
+
const executionPromptReport = {
|
|
6420
6458
|
prompt: {
|
|
6421
6459
|
...$ongoingTaskResult.$prompt,
|
|
6422
6460
|
// <- TODO: [🧠] How to pick everyhing except `pipelineUrl`
|
|
@@ -6425,13 +6463,20 @@ async function executeAttempts(options) {
|
|
|
6425
6463
|
error: $ongoingTaskResult.$expectError === null
|
|
6426
6464
|
? undefined
|
|
6427
6465
|
: serializeError($ongoingTaskResult.$expectError),
|
|
6428
|
-
}
|
|
6466
|
+
};
|
|
6467
|
+
$executionReport.promptExecutions.push(executionPromptReport);
|
|
6468
|
+
if (logLlmCall) {
|
|
6469
|
+
logLlmCall({
|
|
6470
|
+
modelName: 'model' /* <- TODO: How to get model name from the report */,
|
|
6471
|
+
report: executionPromptReport,
|
|
6472
|
+
});
|
|
6473
|
+
}
|
|
6429
6474
|
}
|
|
6430
6475
|
}
|
|
6431
6476
|
if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
|
|
6432
6477
|
// Note: Create a summary of all failures
|
|
6433
6478
|
const failuresSummary = $ongoingTaskResult.$failedResults
|
|
6434
|
-
.map((failure) => spaceTrim((block) => {
|
|
6479
|
+
.map((failure) => spaceTrim$1((block) => {
|
|
6435
6480
|
var _a, _b;
|
|
6436
6481
|
return `
|
|
6437
6482
|
Attempt ${failure.attemptIndex + 1}:
|
|
@@ -6441,14 +6486,14 @@ async function executeAttempts(options) {
|
|
|
6441
6486
|
Result:
|
|
6442
6487
|
${block(failure.result === null
|
|
6443
6488
|
? 'null'
|
|
6444
|
-
: spaceTrim(failure.result)
|
|
6489
|
+
: spaceTrim$1(failure.result)
|
|
6445
6490
|
.split('\n')
|
|
6446
6491
|
.map((line) => `> ${line}`)
|
|
6447
6492
|
.join('\n'))}
|
|
6448
6493
|
`;
|
|
6449
6494
|
}))
|
|
6450
6495
|
.join('\n\n---\n\n');
|
|
6451
|
-
throw new PipelineExecutionError(spaceTrim((block) => {
|
|
6496
|
+
throw new PipelineExecutionError(spaceTrim$1((block) => {
|
|
6452
6497
|
var _a;
|
|
6453
6498
|
return `
|
|
6454
6499
|
LLM execution failed ${maxExecutionAttempts}x
|
|
@@ -6468,7 +6513,7 @@ async function executeAttempts(options) {
|
|
|
6468
6513
|
}
|
|
6469
6514
|
}
|
|
6470
6515
|
if ($ongoingTaskResult.$resultString === null) {
|
|
6471
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
6516
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6472
6517
|
Something went wrong and prompt result is null
|
|
6473
6518
|
|
|
6474
6519
|
${block(pipelineIdentification)}
|
|
@@ -6490,12 +6535,12 @@ async function executeAttempts(options) {
|
|
|
6490
6535
|
* @private internal utility of `createPipelineExecutor`
|
|
6491
6536
|
*/
|
|
6492
6537
|
async function executeFormatSubvalues(options) {
|
|
6493
|
-
const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, pipelineIdentification } = options;
|
|
6538
|
+
const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, logLlmCall, pipelineIdentification, } = options;
|
|
6494
6539
|
if (task.foreach === undefined) {
|
|
6495
|
-
return /* not await */ executeAttempts(options);
|
|
6540
|
+
return /* not await */ executeAttempts({ ...options, logLlmCall });
|
|
6496
6541
|
}
|
|
6497
6542
|
if (jokerParameterNames.length !== 0) {
|
|
6498
|
-
throw new UnexpectedError(spaceTrim$
|
|
6543
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
6499
6544
|
JOKER parameters are not supported together with FOREACH command
|
|
6500
6545
|
|
|
6501
6546
|
[🧞♀️] This should be prevented in \`validatePipeline\`
|
|
@@ -6508,7 +6553,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6508
6553
|
if (formatDefinition === undefined) {
|
|
6509
6554
|
throw new UnexpectedError(
|
|
6510
6555
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
6511
|
-
spaceTrim$
|
|
6556
|
+
spaceTrim$2((block) => `
|
|
6512
6557
|
Unsupported format "${task.foreach.formatName}"
|
|
6513
6558
|
|
|
6514
6559
|
Available formats:
|
|
@@ -6525,7 +6570,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6525
6570
|
if (subvalueParser === undefined) {
|
|
6526
6571
|
throw new UnexpectedError(
|
|
6527
6572
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
6528
|
-
spaceTrim$
|
|
6573
|
+
spaceTrim$2((block) => `
|
|
6529
6574
|
Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
|
|
6530
6575
|
|
|
6531
6576
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -6565,7 +6610,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6565
6610
|
if (!(error instanceof PipelineExecutionError)) {
|
|
6566
6611
|
throw error;
|
|
6567
6612
|
}
|
|
6568
|
-
const highLevelError = new PipelineExecutionError(spaceTrim$
|
|
6613
|
+
const highLevelError = new PipelineExecutionError(spaceTrim$2((block) => `
|
|
6569
6614
|
${error.message}
|
|
6570
6615
|
|
|
6571
6616
|
This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -6589,7 +6634,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6589
6634
|
...options,
|
|
6590
6635
|
priority: priority + index,
|
|
6591
6636
|
parameters: allSubparameters,
|
|
6592
|
-
pipelineIdentification: spaceTrim$
|
|
6637
|
+
pipelineIdentification: spaceTrim$2((block) => `
|
|
6593
6638
|
${block(pipelineIdentification)}
|
|
6594
6639
|
Subparameter index: ${index}
|
|
6595
6640
|
`),
|
|
@@ -6598,7 +6643,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6598
6643
|
}
|
|
6599
6644
|
catch (error) {
|
|
6600
6645
|
if (length > BIG_DATASET_TRESHOLD) {
|
|
6601
|
-
console.error(spaceTrim$
|
|
6646
|
+
console.error(spaceTrim$2((block) => `
|
|
6602
6647
|
${error.message}
|
|
6603
6648
|
|
|
6604
6649
|
This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -6698,7 +6743,7 @@ async function getKnowledgeForTask(options) {
|
|
|
6698
6743
|
},
|
|
6699
6744
|
content: task.content,
|
|
6700
6745
|
parameters,
|
|
6701
|
-
};
|
|
6746
|
+
}; /* <- Note: [🤛] */
|
|
6702
6747
|
const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
|
|
6703
6748
|
const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
|
|
6704
6749
|
const { index } = knowledgePiece;
|
|
@@ -6774,7 +6819,7 @@ async function getReservedParametersForTask(options) {
|
|
|
6774
6819
|
// Note: Doublecheck that ALL reserved parameters are defined:
|
|
6775
6820
|
for (const parameterName of RESERVED_PARAMETER_NAMES) {
|
|
6776
6821
|
if (reservedParameters[parameterName] === undefined) {
|
|
6777
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
6822
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6778
6823
|
Reserved parameter {${parameterName}} is not defined
|
|
6779
6824
|
|
|
6780
6825
|
${block(pipelineIdentification)}
|
|
@@ -6793,14 +6838,14 @@ async function getReservedParametersForTask(options) {
|
|
|
6793
6838
|
* @private internal utility of `createPipelineExecutor`
|
|
6794
6839
|
*/
|
|
6795
6840
|
async function executeTask(options) {
|
|
6796
|
-
const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSuppressed, } = options;
|
|
6841
|
+
const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, logLlmCall, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSuppressed, } = options;
|
|
6797
6842
|
const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
|
|
6798
6843
|
// Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but it’s good to doublecheck
|
|
6799
6844
|
const usedParameterNames = extractParameterNamesFromTask(currentTask);
|
|
6800
6845
|
const dependentParameterNames = new Set(currentTask.dependentParameterNames);
|
|
6801
6846
|
// TODO: [👩🏾🤝👩🏻] Use here `mapAvailableToExpectedParameters`
|
|
6802
6847
|
if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
|
|
6803
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
6848
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6804
6849
|
Dependent parameters are not consistent with used parameters:
|
|
6805
6850
|
|
|
6806
6851
|
Dependent parameters:
|
|
@@ -6844,7 +6889,7 @@ async function executeTask(options) {
|
|
|
6844
6889
|
else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
|
|
6845
6890
|
// Houston, we have a problem
|
|
6846
6891
|
// Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
|
|
6847
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
6892
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6848
6893
|
Parameter \`{${parameterName}}\` is NOT defined
|
|
6849
6894
|
BUT used in task "${currentTask.title || currentTask.name}"
|
|
6850
6895
|
|
|
@@ -6872,6 +6917,7 @@ async function executeTask(options) {
|
|
|
6872
6917
|
tools,
|
|
6873
6918
|
$executionReport,
|
|
6874
6919
|
onProgress,
|
|
6920
|
+
logLlmCall,
|
|
6875
6921
|
pipelineIdentification,
|
|
6876
6922
|
maxExecutionAttempts,
|
|
6877
6923
|
maxParallelCount,
|
|
@@ -6912,9 +6958,32 @@ function filterJustOutputParameters(options) {
|
|
|
6912
6958
|
for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
|
|
6913
6959
|
if (parametersToPass[parameter.name] === undefined) {
|
|
6914
6960
|
// [4]
|
|
6915
|
-
$warnings.push(new PipelineExecutionError(spaceTrim((block) => `
|
|
6961
|
+
$warnings.push(new PipelineExecutionError(spaceTrim$1((block) => `
|
|
6916
6962
|
Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
|
|
6917
6963
|
|
|
6964
|
+
Note: This is a warning which happened after the pipeline was executed, and \`{${parameter.name}}\` was not for some reason defined in output parameters
|
|
6965
|
+
|
|
6966
|
+
All parameters:
|
|
6967
|
+
${block(preparedPipeline.parameters
|
|
6968
|
+
.map(({ name, isInput, isOutput, description }) => {
|
|
6969
|
+
let line = `\`{${name}}\``;
|
|
6970
|
+
if (isInput) {
|
|
6971
|
+
line += ' `[input parameter]`';
|
|
6972
|
+
}
|
|
6973
|
+
if (isOutput) {
|
|
6974
|
+
line += ' `[output parameter]`';
|
|
6975
|
+
}
|
|
6976
|
+
if (parametersToPass[name] === undefined) {
|
|
6977
|
+
line += ` <- Warning: Should be in the output but its not |`;
|
|
6978
|
+
}
|
|
6979
|
+
if (description) {
|
|
6980
|
+
line += ` ${description}`;
|
|
6981
|
+
}
|
|
6982
|
+
return line;
|
|
6983
|
+
})
|
|
6984
|
+
.map((line, index) => `${index + 1}) ${line}`)
|
|
6985
|
+
.join('\n'))}
|
|
6986
|
+
|
|
6918
6987
|
${block(pipelineIdentification)}
|
|
6919
6988
|
`)));
|
|
6920
6989
|
continue;
|
|
@@ -6935,7 +7004,7 @@ function filterJustOutputParameters(options) {
|
|
|
6935
7004
|
* @private internal utility of `createPipelineExecutor`
|
|
6936
7005
|
*/
|
|
6937
7006
|
async function executePipeline(options) {
|
|
6938
|
-
const { inputParameters, tools, onProgress, pipeline, setPreparedPipeline, pipelineIdentification, maxParallelCount, rootDirname, isVerbose, } = options;
|
|
7007
|
+
const { inputParameters, tools, onProgress, logLlmCall, pipeline, setPreparedPipeline, pipelineIdentification, maxParallelCount, rootDirname, isVerbose, } = options;
|
|
6939
7008
|
let { preparedPipeline } = options;
|
|
6940
7009
|
if (preparedPipeline === undefined) {
|
|
6941
7010
|
preparedPipeline = await preparePipeline(pipeline, tools, {
|
|
@@ -6997,7 +7066,7 @@ async function executePipeline(options) {
|
|
|
6997
7066
|
for (const parameterName of Object.keys(inputParameters)) {
|
|
6998
7067
|
const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
|
|
6999
7068
|
if (parameter === undefined) {
|
|
7000
|
-
warnings.push(new PipelineExecutionError(spaceTrim((block) => `
|
|
7069
|
+
warnings.push(new PipelineExecutionError(spaceTrim$1((block) => `
|
|
7001
7070
|
Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
|
|
7002
7071
|
|
|
7003
7072
|
${block(pipelineIdentification)}
|
|
@@ -7012,7 +7081,7 @@ async function executePipeline(options) {
|
|
|
7012
7081
|
// TODO: [🧠] This should be also non-critical error
|
|
7013
7082
|
return exportJson({
|
|
7014
7083
|
name: 'pipelineExecutorResult',
|
|
7015
|
-
message: spaceTrim((block) => `
|
|
7084
|
+
message: spaceTrim$1((block) => `
|
|
7016
7085
|
Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
|
|
7017
7086
|
|
|
7018
7087
|
${block(pipelineIdentification)}
|
|
@@ -7021,7 +7090,7 @@ async function executePipeline(options) {
|
|
|
7021
7090
|
value: {
|
|
7022
7091
|
isSuccessful: false,
|
|
7023
7092
|
errors: [
|
|
7024
|
-
new PipelineExecutionError(spaceTrim((block) => `
|
|
7093
|
+
new PipelineExecutionError(spaceTrim$1((block) => `
|
|
7025
7094
|
Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
|
|
7026
7095
|
|
|
7027
7096
|
${block(pipelineIdentification)}
|
|
@@ -7048,7 +7117,7 @@ async function executePipeline(options) {
|
|
|
7048
7117
|
while (unresovedTasks.length > 0) {
|
|
7049
7118
|
if (loopLimit-- < 0) {
|
|
7050
7119
|
// Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
|
|
7051
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
7120
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
7052
7121
|
Loop limit reached during resolving parameters pipeline execution
|
|
7053
7122
|
|
|
7054
7123
|
${block(pipelineIdentification)}
|
|
@@ -7058,7 +7127,7 @@ async function executePipeline(options) {
|
|
|
7058
7127
|
if (!currentTask && resolving.length === 0) {
|
|
7059
7128
|
throw new UnexpectedError(
|
|
7060
7129
|
// TODO: [🐎] DRY
|
|
7061
|
-
spaceTrim((block) => `
|
|
7130
|
+
spaceTrim$1((block) => `
|
|
7062
7131
|
Can not resolve some parameters:
|
|
7063
7132
|
|
|
7064
7133
|
${block(pipelineIdentification)}
|
|
@@ -7098,7 +7167,7 @@ async function executePipeline(options) {
|
|
|
7098
7167
|
tools,
|
|
7099
7168
|
onProgress(newOngoingResult) {
|
|
7100
7169
|
if (isReturned) {
|
|
7101
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
7170
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
7102
7171
|
Can not call \`onProgress\` after pipeline execution is finished
|
|
7103
7172
|
|
|
7104
7173
|
${block(pipelineIdentification)}
|
|
@@ -7113,8 +7182,9 @@ async function executePipeline(options) {
|
|
|
7113
7182
|
onProgress(newOngoingResult);
|
|
7114
7183
|
}
|
|
7115
7184
|
},
|
|
7185
|
+
logLlmCall,
|
|
7116
7186
|
$executionReport: executionReport,
|
|
7117
|
-
pipelineIdentification: spaceTrim((block) => `
|
|
7187
|
+
pipelineIdentification: spaceTrim$1((block) => `
|
|
7118
7188
|
${block(pipelineIdentification)}
|
|
7119
7189
|
Task name: ${currentTask.name}
|
|
7120
7190
|
Task title: ${currentTask.title}
|
|
@@ -7223,7 +7293,7 @@ function createPipelineExecutor(options) {
|
|
|
7223
7293
|
preparedPipeline = pipeline;
|
|
7224
7294
|
}
|
|
7225
7295
|
else if (isNotPreparedWarningSuppressed !== true) {
|
|
7226
|
-
console.warn(spaceTrim((block) => `
|
|
7296
|
+
console.warn(spaceTrim$1((block) => `
|
|
7227
7297
|
Pipeline is not prepared
|
|
7228
7298
|
|
|
7229
7299
|
${block(pipelineIdentification)}
|
|
@@ -7236,7 +7306,7 @@ function createPipelineExecutor(options) {
|
|
|
7236
7306
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
7237
7307
|
}
|
|
7238
7308
|
let runCount = 0;
|
|
7239
|
-
const pipelineExecutorWithCallback = async (inputParameters, onProgress) => {
|
|
7309
|
+
const pipelineExecutorWithCallback = async (inputParameters, onProgress, logLlmCall) => {
|
|
7240
7310
|
runCount++;
|
|
7241
7311
|
return /* not await */ executePipeline({
|
|
7242
7312
|
pipeline,
|
|
@@ -7247,7 +7317,8 @@ function createPipelineExecutor(options) {
|
|
|
7247
7317
|
inputParameters,
|
|
7248
7318
|
tools,
|
|
7249
7319
|
onProgress,
|
|
7250
|
-
|
|
7320
|
+
logLlmCall,
|
|
7321
|
+
pipelineIdentification: spaceTrim$1((block) => `
|
|
7251
7322
|
${block(pipelineIdentification)}
|
|
7252
7323
|
${runCount === 1 ? '' : `Run #${runCount}`}
|
|
7253
7324
|
`),
|
|
@@ -7408,7 +7479,7 @@ class MarkdownScraper {
|
|
|
7408
7479
|
}
|
|
7409
7480
|
const llmTools = getSingleLlmExecutionTools(llm);
|
|
7410
7481
|
// TODO: [🌼] In future use `ptbk make` and made getPipelineCollection
|
|
7411
|
-
const collection =
|
|
7482
|
+
const collection = createPipelineCollectionFromJson(...PipelineCollection);
|
|
7412
7483
|
const prepareKnowledgeFromMarkdownExecutor = createPipelineExecutor({
|
|
7413
7484
|
pipeline: await collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book'),
|
|
7414
7485
|
tools: {
|
|
@@ -7444,8 +7515,8 @@ class MarkdownScraper {
|
|
|
7444
7515
|
knowledgeTextPieces.map(async (knowledgeTextPiece, i) => {
|
|
7445
7516
|
// Note: These are just default values, they will be overwritten by the actual values:
|
|
7446
7517
|
let name = `piece-${i}`;
|
|
7447
|
-
let title = spaceTrim$
|
|
7448
|
-
const knowledgePieceContent = spaceTrim$
|
|
7518
|
+
let title = spaceTrim$2(knowledgeTextPiece.substring(0, 100));
|
|
7519
|
+
const knowledgePieceContent = spaceTrim$2(knowledgeTextPiece);
|
|
7449
7520
|
let keywords = [];
|
|
7450
7521
|
const index = [];
|
|
7451
7522
|
/*
|
|
@@ -7458,7 +7529,7 @@ class MarkdownScraper {
|
|
|
7458
7529
|
isCrashedOnError: true,
|
|
7459
7530
|
});
|
|
7460
7531
|
const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
|
|
7461
|
-
title = spaceTrim$
|
|
7532
|
+
title = spaceTrim$2(titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
7462
7533
|
name = titleToName(title);
|
|
7463
7534
|
// --- Keywords
|
|
7464
7535
|
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
|
|
@@ -7604,7 +7675,7 @@ class DocumentScraper {
|
|
|
7604
7675
|
await $execCommand(command);
|
|
7605
7676
|
// Note: [0]
|
|
7606
7677
|
if (!(await isFileExisting(cacheFilehandler.filename, this.tools.fs))) {
|
|
7607
|
-
throw new UnexpectedError(spaceTrim$
|
|
7678
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
7608
7679
|
File that was supposed to be created by Pandoc does not exist for unknown reason
|
|
7609
7680
|
|
|
7610
7681
|
Expected file:
|