@promptbook/remote-server 0.103.0-9 → 0.104.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -35
- package/esm/index.es.js +524 -389
- package/esm/index.es.js.map +1 -1
- package/esm/typings/books/index.d.ts +0 -81
- package/esm/typings/servers.d.ts +9 -7
- package/esm/typings/src/_packages/browser.index.d.ts +6 -0
- package/esm/typings/src/_packages/cli.index.d.ts +4 -0
- package/esm/typings/src/_packages/components.index.d.ts +22 -8
- package/esm/typings/src/_packages/core.index.d.ts +58 -18
- package/esm/typings/src/_packages/node.index.d.ts +2 -2
- package/esm/typings/src/_packages/remote-server.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +70 -8
- package/esm/typings/src/_packages/utils.index.d.ts +6 -0
- package/esm/typings/src/_packages/wizard.index.d.ts +4 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +20 -5
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +17 -1
- package/esm/typings/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +3 -2
- package/esm/typings/src/book-2.0/agent-source/computeAgentHash.d.ts +8 -0
- package/esm/typings/src/book-2.0/agent-source/createCommitmentRegex.d.ts +3 -3
- package/esm/typings/src/book-2.0/agent-source/createDefaultAgentName.d.ts +8 -0
- package/esm/typings/src/book-2.0/agent-source/normalizeAgentName.d.ts +9 -0
- package/esm/typings/src/book-2.0/agent-source/padBook.d.ts +18 -0
- package/esm/typings/src/book-2.0/agent-source/parseAgentSourceWithCommitments.d.ts +1 -1
- package/esm/typings/src/book-2.0/agent-source/string_book.d.ts +3 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +6 -1
- package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +85 -14
- package/esm/typings/src/book-components/BookEditor/BookEditorActionbar.d.ts +18 -0
- package/esm/typings/src/book-components/BookEditor/BookEditorMonaco.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.d.ts +17 -0
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChatProps.d.ts +13 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +16 -0
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +15 -0
- package/esm/typings/src/book-components/Chat/MockedChat/MockedChat.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/save/_common/ChatSaveFormatDefinition.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/save/html/htmlSaveFormatDefinition.d.ts +1 -0
- package/esm/typings/src/book-components/Chat/save/pdf/pdfSaveFormatDefinition.d.ts +4 -0
- package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +1 -1
- package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgentIntegration.d.ts +67 -0
- package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgentSeamlessIntegration.d.ts +23 -0
- package/esm/typings/src/book-components/Qr/BrandedQrCode.d.ts +18 -0
- package/esm/typings/src/book-components/Qr/GenericQrCode.d.ts +10 -0
- package/esm/typings/src/book-components/Qr/PromptbookQrCode.d.ts +18 -0
- package/esm/typings/src/book-components/Qr/useQrCode.d.ts +15 -0
- package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +15 -0
- package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +12 -0
- package/esm/typings/src/book-components/_common/Modal/Modal.d.ts +2 -2
- package/esm/typings/src/book-components/_common/Tooltip/Tooltip.d.ts +47 -0
- package/esm/typings/src/book-components/icons/AboutIcon.d.ts +9 -0
- package/esm/typings/src/book-components/icons/CameraIcon.d.ts +11 -0
- package/esm/typings/src/book-components/icons/CloseIcon.d.ts +4 -8
- package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +9 -0
- package/esm/typings/src/book-components/icons/ExitFullscreenIcon.d.ts +7 -0
- package/esm/typings/src/book-components/icons/FullscreenIcon.d.ts +7 -0
- package/esm/typings/src/book-components/icons/MenuIcon.d.ts +12 -0
- package/esm/typings/src/book-components/icons/MicIcon.d.ts +8 -0
- package/esm/typings/src/book-components/icons/SendIcon.d.ts +3 -0
- package/esm/typings/src/cli/cli-commands/_boilerplate.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/about.d.ts +3 -1
- package/esm/typings/src/cli/cli-commands/hello.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/list-models.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/login.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/make.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/prettify.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/run.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/{start-server.d.ts → start-agents-server.d.ts} +3 -2
- package/esm/typings/src/cli/cli-commands/start-pipelines-server.d.ts +15 -0
- package/esm/typings/src/cli/cli-commands/test-command.d.ts +2 -1
- package/esm/typings/src/cli/common/$addGlobalOptionsToCommand.d.ts +2 -1
- package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +12 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +75 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabaseOptions.d.ts +10 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +154 -0
- package/esm/typings/src/collection/{PipelineCollection.d.ts → pipeline-collection/PipelineCollection.d.ts} +7 -3
- package/esm/typings/src/collection/{SimplePipelineCollection.d.ts → pipeline-collection/SimplePipelineCollection.d.ts} +5 -5
- package/esm/typings/src/collection/{constructors/createCollectionFromDirectory.d.ts → pipeline-collection/constructors/createPipelineCollectionFromDirectory.d.ts} +8 -11
- package/esm/typings/src/collection/pipeline-collection/constructors/createPipelineCollectionFromJson.d.ts +13 -0
- package/esm/typings/src/collection/{constructors/createCollectionFromPromise.d.ts → pipeline-collection/constructors/createPipelineCollectionFromPromise.d.ts} +6 -5
- package/esm/typings/src/collection/pipeline-collection/constructors/createPipelineCollectionFromPromise.test.d.ts +1 -0
- package/esm/typings/src/collection/{constructors/createCollectionFromUrl.d.ts → pipeline-collection/constructors/createPipelineCollectionFromUrl.d.ts} +3 -3
- package/esm/typings/src/collection/{constructors/createSubcollection.d.ts → pipeline-collection/constructors/createPipelineSubcollection.d.ts} +3 -3
- package/esm/typings/src/collection/pipeline-collection/pipelineCollectionToJson.d.ts +13 -0
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +4 -5
- package/esm/typings/src/{book-2.0/commitments → commitments}/ACTION/ACTION.d.ts +5 -1
- package/esm/typings/src/commitments/CLOSED/CLOSED.d.ts +39 -0
- package/esm/typings/src/commitments/CLOSED/CLOSED.test.d.ts +4 -0
- package/esm/typings/src/commitments/COMPONENT/COMPONENT.d.ts +28 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/DELETE/DELETE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/FORMAT/FORMAT.d.ts +5 -1
- package/esm/typings/src/commitments/FROM/FROM.d.ts +34 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/GOAL/GOAL.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/KNOWLEDGE/KNOWLEDGE.d.ts +5 -5
- package/esm/typings/src/commitments/LANGUAGE/LANGUAGE.d.ts +35 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/MEMORY/MEMORY.d.ts +5 -1
- package/esm/typings/src/commitments/MESSAGE/AgentMessageCommitmentDefinition.d.ts +32 -0
- package/esm/typings/src/commitments/MESSAGE/InitialMessageCommitmentDefinition.d.ts +32 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/MESSAGE/MESSAGE.d.ts +5 -1
- package/esm/typings/src/commitments/MESSAGE/UserMessageCommitmentDefinition.d.ts +32 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/META/META.d.ts +5 -1
- package/esm/typings/src/commitments/META_COLOR/META_COLOR.d.ts +48 -0
- package/esm/typings/src/commitments/META_FONT/META_FONT.d.ts +42 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/META_IMAGE/META_IMAGE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/META_LINK/META_LINK.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/MODEL/MODEL.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/NOTE/NOTE.d.ts +5 -1
- package/esm/typings/src/commitments/OPEN/OPEN.d.ts +35 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/PERSONA/PERSONA.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/RULE/RULE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/SAMPLE/SAMPLE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/SCENARIO/SCENARIO.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/STYLE/STYLE.d.ts +5 -1
- package/esm/typings/src/commitments/USE/USE.d.ts +53 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +42 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.test.d.ts +1 -0
- package/esm/typings/src/commitments/USE_MCP/USE_MCP.d.ts +37 -0
- package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +38 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BaseCommitmentDefinition.d.ts +14 -2
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/CommitmentDefinition.d.ts +6 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/NotYetImplementedCommitmentDefinition.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/createEmptyAgentModelRequirements.d.ts +1 -1
- package/esm/typings/src/commitments/index.d.ts +93 -0
- package/esm/typings/src/config.d.ts +24 -3
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +2 -0
- package/esm/typings/src/errors/0-index.d.ts +6 -0
- package/esm/typings/src/errors/DatabaseError.d.ts +12 -0
- package/esm/typings/src/errors/NotAllowed.d.ts +9 -0
- package/esm/typings/src/errors/WrappedError.d.ts +2 -2
- package/esm/typings/src/execution/AvailableModel.d.ts +1 -0
- package/esm/typings/src/execution/Executables.d.ts +3 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +12 -3
- package/esm/typings/src/execution/ExecutionTools.d.ts +5 -0
- package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +26 -2
- package/esm/typings/src/execution/PromptResult.d.ts +7 -1
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +5 -0
- package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +5 -0
- package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +5 -0
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +5 -0
- package/esm/typings/src/execution/utils/usage-constants.d.ts +4 -124
- package/esm/typings/src/execution/utils/validatePromptResult.d.ts +2 -0
- package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +2 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +2 -2
- package/esm/typings/src/llm-providers/_common/register/$registeredLlmToolsMessage.d.ts +2 -1
- package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/assertUniqueModels.d.ts +12 -0
- package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +72 -0
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +26 -4
- package/esm/typings/src/llm-providers/agent/AgentOptions.d.ts +19 -0
- package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +17 -0
- package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +50 -0
- package/esm/typings/src/llm-providers/agent/RemoteAgentOptions.d.ts +11 -0
- package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.d.ts +1 -19
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/ollama/OllamaExecutionTools.d.ts +4 -0
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +60 -2
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +7 -1
- package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +13 -1
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +4 -0
- package/esm/typings/src/llm-providers/openai/createOpenAiCompatibleExecutionTools.d.ts +6 -6
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/openai-models.test.d.ts +4 -0
- package/esm/typings/src/other/templates/getTemplatesPipelineCollection.d.ts +1 -1
- package/esm/typings/src/pipeline/validatePipelineString.d.ts +2 -0
- package/esm/typings/src/playground/permanent/_boilerplate.d.ts +5 -0
- package/esm/typings/src/playground/permanent/agent-with-browser-playground.d.ts +5 -0
- package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +1 -0
- package/esm/typings/src/remote-server/startAgentServer.d.ts +26 -0
- package/esm/typings/src/remote-server/startRemoteServer.d.ts +4 -1
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +3 -8
- package/esm/typings/src/scrapers/_boilerplate/createBoilerplateScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/_boilerplate/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/markitdown/createMarkitdownScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/markitdown/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -9
- package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +1 -0
- package/esm/typings/src/storage/env-storage/$EnvStorage.d.ts +2 -1
- package/esm/typings/src/transpilers/_common/BookTranspiler.d.ts +33 -0
- package/esm/typings/src/transpilers/_common/BookTranspilerOptions.d.ts +18 -0
- package/esm/typings/src/transpilers/_common/register/$bookTranspilersRegister.d.ts +15 -0
- package/esm/typings/src/transpilers/formatted-book-in-markdown/FormattedBookInMarkdownTranspiler.d.ts +16 -0
- package/esm/typings/src/transpilers/formatted-book-in-markdown/register.d.ts +15 -0
- package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.d.ts +16 -0
- package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.test.d.ts +1 -0
- package/esm/typings/src/transpilers/openai-sdk/playground/playground.d.ts +5 -0
- package/esm/typings/src/transpilers/openai-sdk/register.d.ts +15 -0
- package/esm/typings/src/types/LlmCall.d.ts +20 -0
- package/esm/typings/src/types/ModelRequirements.d.ts +13 -1
- package/esm/typings/src/types/ModelVariant.d.ts +1 -1
- package/esm/typings/src/types/Prompt.d.ts +13 -1
- package/esm/typings/src/types/Updatable.d.ts +19 -0
- package/esm/typings/src/types/typeAliases.d.ts +38 -2
- package/esm/typings/src/utils/color/$randomColor.d.ts +1 -0
- package/esm/typings/src/utils/color/Color.d.ts +16 -1
- package/esm/typings/src/utils/color/Color.test.d.ts +1 -0
- package/esm/typings/src/utils/color/css-colors.d.ts +1 -0
- package/esm/typings/src/utils/color/internal-utils/checkChannelValue.d.ts +0 -3
- package/esm/typings/src/utils/color/operators/darken.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/grayscale.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/lighten.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/mixWithColor.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/saturate.d.ts +1 -1
- package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +16 -0
- package/esm/typings/src/utils/environment/$getGlobalScope.d.ts +2 -2
- package/esm/typings/src/utils/execCommand/$execCommand.d.ts +2 -1
- package/esm/typings/src/utils/execCommand/$execCommands.d.ts +2 -1
- package/esm/typings/src/utils/files/$induceBookDownload.d.ts +13 -0
- package/esm/typings/src/utils/files/$induceFileDownload.d.ts +13 -0
- package/esm/typings/src/utils/files/ObjectUrl.d.ts +46 -0
- package/esm/typings/src/utils/files/listAllFiles.d.ts +2 -3
- package/esm/typings/src/utils/misc/aboutPromptbookInformation.d.ts +27 -0
- package/esm/typings/src/utils/misc/computeHash.d.ts +11 -0
- package/esm/typings/src/utils/misc/computeHash.test.d.ts +1 -0
- package/esm/typings/src/utils/misc/injectCssModuleIntoShadowRoot.d.ts +1 -0
- package/esm/typings/src/utils/misc/xAboutPromptbookInformation.d.ts +13 -0
- package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +2 -0
- package/esm/typings/src/utils/normalization/normalizeMessageText.d.ts +9 -0
- package/esm/typings/src/utils/normalization/normalizeMessageText.test.d.ts +1 -0
- package/esm/typings/src/utils/normalization/normalizeTo_PascalCase.d.ts +3 -0
- package/esm/typings/src/utils/normalization/normalizeTo_camelCase.d.ts +2 -0
- package/esm/typings/src/utils/normalization/titleToName.d.ts +2 -0
- package/esm/typings/src/utils/organization/$sideEffect.d.ts +2 -2
- package/esm/typings/src/utils/organization/$side_effect.d.ts +7 -0
- package/esm/typings/src/utils/organization/TODO_USE.d.ts +2 -2
- package/esm/typings/src/utils/organization/keepUnused.d.ts +2 -2
- package/esm/typings/src/utils/organization/preserve.d.ts +3 -3
- package/esm/typings/src/utils/organization/really_any.d.ts +7 -0
- package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +31 -0
- package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +9 -0
- package/esm/typings/src/utils/random/$randomFullnameWithColor.d.ts +13 -0
- package/esm/typings/src/utils/random/$randomItem.d.ts +9 -0
- package/esm/typings/src/utils/random/$randomSeed.d.ts +3 -0
- package/esm/typings/src/utils/random/$randomToken.d.ts +2 -0
- package/esm/typings/src/utils/random/CzechNamePool.d.ts +7 -0
- package/esm/typings/src/utils/random/EnglishNamePool.d.ts +7 -0
- package/esm/typings/src/utils/random/NamePool.d.ts +17 -0
- package/esm/typings/src/utils/random/getNamePool.d.ts +10 -0
- package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +2 -1
- package/esm/typings/src/utils/serialization/asSerializable.d.ts +2 -2
- package/esm/typings/src/utils/serialization/serializeToPromptbookJavascript.d.ts +2 -2
- package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +2 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/esm/typings/src/wizard/$getCompiledBook.d.ts +1 -2
- package/package.json +8 -8
- package/umd/index.umd.js +545 -409
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/book-2.0/commitments/index.d.ts +0 -60
- package/esm/typings/src/book-components/BookEditor/BookEditorInner.d.ts +0 -5
- package/esm/typings/src/book-components/BookEditor/BookEditorWrapper.d.ts +0 -9
- package/esm/typings/src/book-components/BookEditor/config.d.ts +0 -10
- package/esm/typings/src/book-components/Chat/utils/renderMarkdown.d.ts +0 -21
- package/esm/typings/src/collection/collectionToJson.d.ts +0 -13
- package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +0 -13
- /package/esm/typings/src/{book-components/Chat/utils/renderMarkdown.test.d.ts → book-2.0/agent-source/computeAgentHash.test.d.ts} +0 -0
- /package/esm/typings/src/{collection/constructors/createCollectionFromDirectory.test.d.ts → book-2.0/agent-source/normalizeAgentName.test.d.ts} +0 -0
- /package/esm/typings/src/{collection/constructors/createCollectionFromJson.test.d.ts → book-components/Chat/AgentChat/AgentChat.test.d.ts} +0 -0
- /package/esm/typings/src/collection/{constructors/createCollectionFromPromise.test.d.ts → pipeline-collection/constructors/createPipelineCollectionFromDirectory.test.d.ts} +0 -0
- /package/esm/typings/src/{commands/_common/parseCommand.test.d.ts → collection/pipeline-collection/constructors/createPipelineCollectionFromJson.test.d.ts} +0 -0
- /package/esm/typings/src/collection/{collectionToJson.test.d.ts → pipeline-collection/pipelineCollectionToJson.test.d.ts} +0 -0
- /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BookCommitment.d.ts +0 -0
- /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/ParsedCommitment.d.ts +0 -0
package/esm/index.es.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import { join, basename, dirname, isAbsolute } from 'path';
|
|
2
|
+
import { spawn } from 'child_process';
|
|
1
3
|
import colors from 'colors';
|
|
4
|
+
import spaceTrim$2, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
5
|
+
import { forTime } from 'waitasecond';
|
|
2
6
|
import express from 'express';
|
|
3
7
|
import * as OpenApiValidator from 'express-openapi-validator';
|
|
4
8
|
import http from 'http';
|
|
5
9
|
import { Server } from 'socket.io';
|
|
6
|
-
import spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
7
10
|
import swaggerUi from 'swagger-ui-express';
|
|
8
|
-
import { forTime } from 'waitasecond';
|
|
9
11
|
import { randomBytes } from 'crypto';
|
|
10
|
-
import {
|
|
11
|
-
import { stat, access, constants, readFile, writeFile, readdir, mkdir } from 'fs/promises';
|
|
12
|
-
import { join, basename, dirname, isAbsolute } from 'path';
|
|
12
|
+
import { stat, access, constants, readFile, writeFile, readdir, mkdir, watch } from 'fs/promises';
|
|
13
13
|
import { Subject } from 'rxjs';
|
|
14
14
|
import hexEncoder from 'crypto-js/enc-hex';
|
|
15
15
|
import sha256 from 'crypto-js/sha256';
|
|
@@ -26,19 +26,30 @@ import { renderToStaticMarkup } from 'react-dom/server';
|
|
|
26
26
|
* @generated
|
|
27
27
|
* @see https://github.com/webgptorg/book
|
|
28
28
|
*/
|
|
29
|
-
const BOOK_LANGUAGE_VERSION = '
|
|
29
|
+
const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
30
30
|
/**
|
|
31
31
|
* The version of the Promptbook engine
|
|
32
32
|
*
|
|
33
33
|
* @generated
|
|
34
34
|
* @see https://github.com/webgptorg/promptbook
|
|
35
35
|
*/
|
|
36
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.
|
|
36
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-0';
|
|
37
37
|
/**
|
|
38
38
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
39
39
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
40
40
|
*/
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Trims string from all 4 sides
|
|
44
|
+
*
|
|
45
|
+
* Note: This is a re-exported function from the `spacetrim` package which is
|
|
46
|
+
* Developed by same author @hejny as this package
|
|
47
|
+
*
|
|
48
|
+
* @public exported from `@promptbook/utils`
|
|
49
|
+
* @see https://github.com/hejny/spacetrim#usage
|
|
50
|
+
*/
|
|
51
|
+
const spaceTrim = spaceTrim$1;
|
|
52
|
+
|
|
42
53
|
/**
|
|
43
54
|
* @private util of `@promptbook/color`
|
|
44
55
|
* @de
|
|
@@ -87,6 +98,7 @@ function take(initialValue) {
|
|
|
87
98
|
* @public exported from `@promptbook/color`
|
|
88
99
|
*/
|
|
89
100
|
const CSS_COLORS = {
|
|
101
|
+
promptbook: '#79EAFD',
|
|
90
102
|
transparent: 'rgba(0,0,0,0)',
|
|
91
103
|
aliceblue: '#f0f8ff',
|
|
92
104
|
antiquewhite: '#faebd7',
|
|
@@ -268,9 +280,6 @@ function checkChannelValue(channelName, value) {
|
|
|
268
280
|
throw new Error(`${channelName} channel is greater than 255, it is ${value}`);
|
|
269
281
|
}
|
|
270
282
|
}
|
|
271
|
-
/**
|
|
272
|
-
* TODO: [🧠][🚓] Is/which combination it better to use asserts/check, validate or is utility function?
|
|
273
|
-
*/
|
|
274
283
|
|
|
275
284
|
/**
|
|
276
285
|
* Color object represents an RGB color with alpha channel
|
|
@@ -290,21 +299,61 @@ class Color {
|
|
|
290
299
|
* @param color
|
|
291
300
|
* @returns Color object
|
|
292
301
|
*/
|
|
293
|
-
static from(color) {
|
|
294
|
-
if (color
|
|
302
|
+
static from(color, _isSingleValue = false) {
|
|
303
|
+
if (color === '') {
|
|
304
|
+
throw new Error(`Can not create color from empty string`);
|
|
305
|
+
}
|
|
306
|
+
else if (color instanceof Color) {
|
|
295
307
|
return take(color);
|
|
296
308
|
}
|
|
297
309
|
else if (Color.isColor(color)) {
|
|
298
310
|
return take(color);
|
|
299
311
|
}
|
|
300
312
|
else if (typeof color === 'string') {
|
|
301
|
-
|
|
313
|
+
try {
|
|
314
|
+
return Color.fromString(color);
|
|
315
|
+
}
|
|
316
|
+
catch (error) {
|
|
317
|
+
// <- Note: Can not use `assertsError(error)` here because it causes circular dependency
|
|
318
|
+
if (_isSingleValue) {
|
|
319
|
+
throw error;
|
|
320
|
+
}
|
|
321
|
+
const parts = color.split(/[\s+,;|]/);
|
|
322
|
+
if (parts.length > 0) {
|
|
323
|
+
return Color.from(parts[0].trim(), true);
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
throw new Error(`Can not create color from given string "${color}"`);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
302
329
|
}
|
|
303
330
|
else {
|
|
304
331
|
console.error({ color });
|
|
305
332
|
throw new Error(`Can not create color from given object`);
|
|
306
333
|
}
|
|
307
334
|
}
|
|
335
|
+
/**
|
|
336
|
+
* Creates a new Color instance from miscellaneous formats
|
|
337
|
+
* It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
|
|
338
|
+
*
|
|
339
|
+
* @param color
|
|
340
|
+
* @returns Color object
|
|
341
|
+
*/
|
|
342
|
+
static fromSafe(color) {
|
|
343
|
+
try {
|
|
344
|
+
return Color.from(color);
|
|
345
|
+
}
|
|
346
|
+
catch (error) {
|
|
347
|
+
// <- Note: Can not use `assertsError(error)` here because it causes circular dependency
|
|
348
|
+
console.warn(spaceTrim((block) => `
|
|
349
|
+
Color.fromSafe error:
|
|
350
|
+
${block(error.message)}
|
|
351
|
+
|
|
352
|
+
Returning default PROMPTBOOK_COLOR.
|
|
353
|
+
`));
|
|
354
|
+
return Color.fromString('promptbook');
|
|
355
|
+
}
|
|
356
|
+
}
|
|
308
357
|
/**
|
|
309
358
|
* Creates a new Color instance from miscellaneous string formats
|
|
310
359
|
*
|
|
@@ -372,6 +421,9 @@ class Color {
|
|
|
372
421
|
if (hex.length === 3) {
|
|
373
422
|
return Color.fromHex3(hex);
|
|
374
423
|
}
|
|
424
|
+
if (hex.length === 4) {
|
|
425
|
+
return Color.fromHex4(hex);
|
|
426
|
+
}
|
|
375
427
|
if (hex.length === 6) {
|
|
376
428
|
return Color.fromHex6(hex);
|
|
377
429
|
}
|
|
@@ -392,6 +444,19 @@ class Color {
|
|
|
392
444
|
const b = parseInt(hex.substr(2, 1), 16) * 16;
|
|
393
445
|
return take(new Color(r, g, b));
|
|
394
446
|
}
|
|
447
|
+
/**
|
|
448
|
+
* Creates a new Color instance from color in hex format with 4 digits (with alpha channel)
|
|
449
|
+
*
|
|
450
|
+
* @param color in hex for example `09df`
|
|
451
|
+
* @returns Color object
|
|
452
|
+
*/
|
|
453
|
+
static fromHex4(hex) {
|
|
454
|
+
const r = parseInt(hex.substr(0, 1), 16) * 16;
|
|
455
|
+
const g = parseInt(hex.substr(1, 1), 16) * 16;
|
|
456
|
+
const b = parseInt(hex.substr(2, 1), 16) * 16;
|
|
457
|
+
const a = parseInt(hex.substr(3, 1), 16) * 16;
|
|
458
|
+
return take(new Color(r, g, b, a));
|
|
459
|
+
}
|
|
395
460
|
/**
|
|
396
461
|
* Creates a new Color instance from color in hex format with 6 color digits (without alpha channel)
|
|
397
462
|
*
|
|
@@ -582,7 +647,8 @@ class Color {
|
|
|
582
647
|
* @returns true if the value is a valid hex color string (e.g., `#009edd`, `#fff`, etc.)
|
|
583
648
|
*/
|
|
584
649
|
static isHexColorString(value) {
|
|
585
|
-
return typeof value === 'string' &&
|
|
650
|
+
return (typeof value === 'string' &&
|
|
651
|
+
/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(value));
|
|
586
652
|
}
|
|
587
653
|
/**
|
|
588
654
|
* Creates new Color object
|
|
@@ -697,6 +763,23 @@ class Color {
|
|
|
697
763
|
* TODO: Maybe connect with textures
|
|
698
764
|
*/
|
|
699
765
|
|
|
766
|
+
/**
|
|
767
|
+
* Makes color transformer which returns a grayscale version of the color
|
|
768
|
+
*
|
|
769
|
+
* @param amount from 0 to 1
|
|
770
|
+
*
|
|
771
|
+
* @public exported from `@promptbook/color`
|
|
772
|
+
*/
|
|
773
|
+
function grayscale(amount) {
|
|
774
|
+
return ({ red, green, blue, alpha }) => {
|
|
775
|
+
const average = (red + green + blue) / 3;
|
|
776
|
+
red = Math.round(average * amount + red * (1 - amount));
|
|
777
|
+
green = Math.round(average * amount + green * (1 - amount));
|
|
778
|
+
blue = Math.round(average * amount + blue * (1 - amount));
|
|
779
|
+
return Color.fromValues(red, green, blue, alpha);
|
|
780
|
+
};
|
|
781
|
+
}
|
|
782
|
+
|
|
700
783
|
/**
|
|
701
784
|
* Converts HSL values to RGB values
|
|
702
785
|
*
|
|
@@ -812,102 +895,6 @@ function lighten(amount) {
|
|
|
812
895
|
* TODO: Maybe implement by mix+hsl
|
|
813
896
|
*/
|
|
814
897
|
|
|
815
|
-
/**
|
|
816
|
-
* Calculates distance between two colors
|
|
817
|
-
*
|
|
818
|
-
* @param color1 first color
|
|
819
|
-
* @param color2 second color
|
|
820
|
-
*
|
|
821
|
-
* Note: This function is inefficient. Use colorDistanceSquared instead if possible.
|
|
822
|
-
*
|
|
823
|
-
* @public exported from `@promptbook/color`
|
|
824
|
-
*/
|
|
825
|
-
/**
|
|
826
|
-
* Calculates distance between two colors without square root
|
|
827
|
-
*
|
|
828
|
-
* @param color1 first color
|
|
829
|
-
* @param color2 second color
|
|
830
|
-
*
|
|
831
|
-
* @public exported from `@promptbook/color`
|
|
832
|
-
*/
|
|
833
|
-
function colorDistanceSquared(color1, color2) {
|
|
834
|
-
const rmean = (color1.red + color2.red) / 2;
|
|
835
|
-
const r = color1.red - color2.red;
|
|
836
|
-
const g = color1.green - color2.green;
|
|
837
|
-
const b = color1.blue - color2.blue;
|
|
838
|
-
const weightR = 2 + rmean / 256;
|
|
839
|
-
const weightG = 4.0;
|
|
840
|
-
const weightB = 2 + (255 - rmean) / 256;
|
|
841
|
-
const distance = weightR * r * r + weightG * g * g + weightB * b * b;
|
|
842
|
-
return distance;
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
/**
|
|
846
|
-
* Makes color transformer which finds the nearest color from the given list
|
|
847
|
-
*
|
|
848
|
-
* @param colors array of colors to choose from
|
|
849
|
-
*
|
|
850
|
-
* @public exported from `@promptbook/color`
|
|
851
|
-
*/
|
|
852
|
-
function nearest(...colors) {
|
|
853
|
-
return (color) => {
|
|
854
|
-
const distances = colors.map((c) => colorDistanceSquared(c, color));
|
|
855
|
-
const minDistance = Math.min(...distances);
|
|
856
|
-
const minIndex = distances.indexOf(minDistance);
|
|
857
|
-
const nearestColor = colors[minIndex];
|
|
858
|
-
return nearestColor;
|
|
859
|
-
};
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
/**
|
|
863
|
-
* Color transformer which returns the negative color
|
|
864
|
-
*
|
|
865
|
-
* @public exported from `@promptbook/color`
|
|
866
|
-
*/
|
|
867
|
-
function negative(color) {
|
|
868
|
-
const r = 255 - color.red;
|
|
869
|
-
const g = 255 - color.green;
|
|
870
|
-
const b = 255 - color.blue;
|
|
871
|
-
return Color.fromValues(r, g, b, color.alpha);
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
/**
|
|
875
|
-
* Makes color transformer which finds the furthest color from the given list
|
|
876
|
-
*
|
|
877
|
-
* @param colors array of colors to choose from
|
|
878
|
-
*
|
|
879
|
-
* @public exported from `@promptbook/color`
|
|
880
|
-
*/
|
|
881
|
-
function furthest(...colors) {
|
|
882
|
-
return (color) => {
|
|
883
|
-
const furthestColor = negative(nearest(...colors.map(negative))(color));
|
|
884
|
-
return furthestColor;
|
|
885
|
-
};
|
|
886
|
-
}
|
|
887
|
-
/**
|
|
888
|
-
* Makes color transformer which finds the best text color (black or white) for the given background color
|
|
889
|
-
*
|
|
890
|
-
* @public exported from `@promptbook/color`
|
|
891
|
-
*/
|
|
892
|
-
furthest(Color.get('white'), Color.from('black'));
|
|
893
|
-
|
|
894
|
-
/**
|
|
895
|
-
* Makes color transformer which returns a grayscale version of the color
|
|
896
|
-
*
|
|
897
|
-
* @param amount from 0 to 1
|
|
898
|
-
*
|
|
899
|
-
* @public exported from `@promptbook/color`
|
|
900
|
-
*/
|
|
901
|
-
function grayscale(amount) {
|
|
902
|
-
return ({ red, green, blue, alpha }) => {
|
|
903
|
-
const average = (red + green + blue) / 3;
|
|
904
|
-
red = Math.round(average * amount + red * (1 - amount));
|
|
905
|
-
green = Math.round(average * amount + green * (1 - amount));
|
|
906
|
-
blue = Math.round(average * amount + blue * (1 - amount));
|
|
907
|
-
return Color.fromValues(red, green, blue, alpha);
|
|
908
|
-
};
|
|
909
|
-
}
|
|
910
|
-
|
|
911
898
|
/**
|
|
912
899
|
* Makes color transformer which saturate the given color
|
|
913
900
|
*
|
|
@@ -984,16 +971,32 @@ const CLAIM = `Turn your company's scattered knowledge into AI ready books`;
|
|
|
984
971
|
*
|
|
985
972
|
* @public exported from `@promptbook/core`
|
|
986
973
|
*/
|
|
987
|
-
const PROMPTBOOK_COLOR = Color.
|
|
988
|
-
// <- TODO: [🧠] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
974
|
+
const PROMPTBOOK_COLOR = Color.fromString('promptbook');
|
|
975
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
976
|
+
/**
|
|
977
|
+
* Colors for syntax highlighting in the `<BookEditor/>`
|
|
978
|
+
*
|
|
979
|
+
* TODO: [🗽] Unite branding and make single place for it
|
|
980
|
+
*
|
|
981
|
+
* @public exported from `@promptbook/core`
|
|
982
|
+
*/
|
|
983
|
+
({
|
|
984
|
+
TITLE: Color.fromHex('#244EA8'),
|
|
985
|
+
LINE: Color.fromHex('#eeeeee'),
|
|
986
|
+
SEPARATOR: Color.fromHex('#cccccc'),
|
|
987
|
+
COMMITMENT: Color.fromHex('#DA0F78'),
|
|
988
|
+
PARAMETER: Color.fromHex('#8e44ad'),
|
|
989
|
+
});
|
|
990
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
989
991
|
/**
|
|
990
|
-
*
|
|
992
|
+
* Chat color of the Promptbook (in chat)
|
|
991
993
|
*
|
|
992
994
|
* TODO: [🗽] Unite branding and make single place for it
|
|
993
995
|
*
|
|
994
996
|
* @public exported from `@promptbook/core`
|
|
995
997
|
*/
|
|
996
998
|
PROMPTBOOK_COLOR.then(lighten(0.1)).then(saturate(0.9)).then(grayscale(0.9));
|
|
999
|
+
// <- TODO: [🧠][🈵] Using `Color` and `lighten`, `saturate`,... here increases the package size approx 3kb, maybe remove it
|
|
997
1000
|
/**
|
|
998
1001
|
* Color of the user (in chat)
|
|
999
1002
|
*
|
|
@@ -1002,6 +1005,7 @@ PROMPTBOOK_COLOR.then(lighten(0.1)).then(saturate(0.9)).then(grayscale(0.9));
|
|
|
1002
1005
|
* @public exported from `@promptbook/core`
|
|
1003
1006
|
*/
|
|
1004
1007
|
Color.fromHex('#1D4ED8');
|
|
1008
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
1005
1009
|
/**
|
|
1006
1010
|
* When the title is not provided, the default title is used
|
|
1007
1011
|
*
|
|
@@ -1088,7 +1092,7 @@ const DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [🤹♂️]
|
|
|
1088
1092
|
* @public exported from `@promptbook/core`
|
|
1089
1093
|
*/
|
|
1090
1094
|
const DEFAULT_MAX_EXECUTION_ATTEMPTS = 7; // <- TODO: [🤹♂️]
|
|
1091
|
-
// <- TODO: [🕝] Make also `
|
|
1095
|
+
// <- TODO: [🕝] Make also `AGENTS_DIRNAME_ALTERNATIVES`
|
|
1092
1096
|
// TODO: Just `.promptbook` in config, hardcode subfolders like `download-cache` or `execution-cache`
|
|
1093
1097
|
/**
|
|
1094
1098
|
* Where to store the temporary downloads
|
|
@@ -1137,24 +1141,246 @@ const DEFAULT_IS_AUTO_INSTALLED = false;
|
|
|
1137
1141
|
*/
|
|
1138
1142
|
const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
|
|
1139
1143
|
/**
|
|
1140
|
-
* API request timeout in milliseconds
|
|
1141
|
-
* Can be overridden via API_REQUEST_TIMEOUT environment variable
|
|
1142
|
-
*
|
|
1143
|
-
* @public exported from `@promptbook/core`
|
|
1144
|
+
* API request timeout in milliseconds
|
|
1145
|
+
* Can be overridden via API_REQUEST_TIMEOUT environment variable
|
|
1146
|
+
*
|
|
1147
|
+
* @public exported from `@promptbook/core`
|
|
1148
|
+
*/
|
|
1149
|
+
parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
|
|
1150
|
+
/**
|
|
1151
|
+
* Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
|
|
1152
|
+
*
|
|
1153
|
+
* @private within the repository
|
|
1154
|
+
*/
|
|
1155
|
+
const IS_PIPELINE_LOGIC_VALIDATED = just(
|
|
1156
|
+
/**/
|
|
1157
|
+
// Note: In normal situations, we check the pipeline logic:
|
|
1158
|
+
true);
|
|
1159
|
+
/**
|
|
1160
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
1161
|
+
* TODO: [🧠][🧜♂️] Maybe join remoteServerUrl and path into single value
|
|
1162
|
+
*/
|
|
1163
|
+
|
|
1164
|
+
/**
|
|
1165
|
+
* This error type indicates that you try to use a feature that is not available in the current environment
|
|
1166
|
+
*
|
|
1167
|
+
* @public exported from `@promptbook/core`
|
|
1168
|
+
*/
|
|
1169
|
+
class EnvironmentMismatchError extends Error {
|
|
1170
|
+
constructor(message) {
|
|
1171
|
+
super(message);
|
|
1172
|
+
this.name = 'EnvironmentMismatchError';
|
|
1173
|
+
Object.setPrototypeOf(this, EnvironmentMismatchError.prototype);
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
/**
|
|
1178
|
+
* Detects if the code is running in a Node.js environment
|
|
1179
|
+
*
|
|
1180
|
+
* Note: `$` is used to indicate that this function is not a pure function - it looks at the global object to determine the environment
|
|
1181
|
+
*
|
|
1182
|
+
* @public exported from `@promptbook/utils`
|
|
1183
|
+
*/
|
|
1184
|
+
const $isRunningInNode = new Function(`
|
|
1185
|
+
try {
|
|
1186
|
+
return this === global;
|
|
1187
|
+
} catch (e) {
|
|
1188
|
+
return false;
|
|
1189
|
+
}
|
|
1190
|
+
`);
|
|
1191
|
+
/**
|
|
1192
|
+
* TODO: [🎺]
|
|
1193
|
+
*/
|
|
1194
|
+
|
|
1195
|
+
/**
|
|
1196
|
+
* Normalize options for `execCommand` and `execCommands`
|
|
1197
|
+
*
|
|
1198
|
+
* Note: `$` is used to indicate that this function behaves differently according to `process.platform`
|
|
1199
|
+
*
|
|
1200
|
+
* @private internal utility of `execCommand` and `execCommands`
|
|
1201
|
+
*/
|
|
1202
|
+
function $execCommandNormalizeOptions(options) {
|
|
1203
|
+
var _a, _b, _c, _d;
|
|
1204
|
+
let command;
|
|
1205
|
+
let cwd;
|
|
1206
|
+
let crashOnError;
|
|
1207
|
+
let args = [];
|
|
1208
|
+
let timeout;
|
|
1209
|
+
let isVerbose;
|
|
1210
|
+
if (typeof options === 'string') {
|
|
1211
|
+
// TODO: [1] DRY default values
|
|
1212
|
+
command = options;
|
|
1213
|
+
cwd = process.cwd();
|
|
1214
|
+
crashOnError = true;
|
|
1215
|
+
timeout = Infinity; // <- TODO: [⏳]
|
|
1216
|
+
isVerbose = DEFAULT_IS_VERBOSE;
|
|
1217
|
+
}
|
|
1218
|
+
else {
|
|
1219
|
+
/*
|
|
1220
|
+
TODO:
|
|
1221
|
+
if ((options as any).commands !== undefined) {
|
|
1222
|
+
commands = (options as any).commands;
|
|
1223
|
+
} else {
|
|
1224
|
+
commands = [(options as any).command];
|
|
1225
|
+
}
|
|
1226
|
+
*/
|
|
1227
|
+
// TODO: [1] DRY default values
|
|
1228
|
+
command = options.command;
|
|
1229
|
+
cwd = (_a = options.cwd) !== null && _a !== void 0 ? _a : process.cwd();
|
|
1230
|
+
crashOnError = (_b = options.crashOnError) !== null && _b !== void 0 ? _b : true;
|
|
1231
|
+
timeout = (_c = options.timeout) !== null && _c !== void 0 ? _c : Infinity;
|
|
1232
|
+
isVerbose = (_d = options.isVerbose) !== null && _d !== void 0 ? _d : DEFAULT_IS_VERBOSE;
|
|
1233
|
+
}
|
|
1234
|
+
// TODO: /(-[a-zA-Z0-9-]+\s+[^\s]*)|[^\s]*/g
|
|
1235
|
+
const _ = Array.from(command.matchAll(/(".*")|([^\s]*)/g))
|
|
1236
|
+
.map(([match]) => match)
|
|
1237
|
+
.filter((arg) => arg !== '');
|
|
1238
|
+
if (_.length > 1) {
|
|
1239
|
+
[command, ...args] = _;
|
|
1240
|
+
}
|
|
1241
|
+
if (options.args) {
|
|
1242
|
+
args = [...args, ...options.args];
|
|
1243
|
+
}
|
|
1244
|
+
let humanReadableCommand = !['npx', 'npm'].includes(command) ? command : args[0];
|
|
1245
|
+
if (['ts-node'].includes(humanReadableCommand)) {
|
|
1246
|
+
humanReadableCommand += ` ${args[1]}`;
|
|
1247
|
+
}
|
|
1248
|
+
if (/^win/.test(process.platform) && ['npm', 'npx'].includes(command)) {
|
|
1249
|
+
command = `${command}.cmd`;
|
|
1250
|
+
}
|
|
1251
|
+
return { command, humanReadableCommand, args, cwd, crashOnError, timeout, isVerbose };
|
|
1252
|
+
}
|
|
1253
|
+
// TODO: This should show type error> execCommandNormalizeOptions({ command: '', commands: [''] });
|
|
1254
|
+
|
|
1255
|
+
/**
|
|
1256
|
+
* Run one command in a shell
|
|
1257
|
+
*
|
|
1258
|
+
*
|
|
1259
|
+
* Note: There are 2 similar functions in the codebase:
|
|
1260
|
+
* - `$execCommand` which runs a single command
|
|
1261
|
+
* - `$execCommands` which runs multiple commands
|
|
1262
|
+
* Note: `$` is used to indicate that this function is not a pure function - it runs a command in a shell
|
|
1263
|
+
*
|
|
1264
|
+
* @public exported from `@promptbook/node`
|
|
1265
|
+
*/
|
|
1266
|
+
function $execCommand(options) {
|
|
1267
|
+
if (!$isRunningInNode()) {
|
|
1268
|
+
throw new EnvironmentMismatchError('Function `$execCommand` can run only in Node environment.js');
|
|
1269
|
+
}
|
|
1270
|
+
return new Promise((resolve, reject) => {
|
|
1271
|
+
// eslint-disable-next-line prefer-const
|
|
1272
|
+
const { command, humanReadableCommand, args, cwd, crashOnError, timeout, isVerbose = DEFAULT_IS_VERBOSE, } = $execCommandNormalizeOptions(options);
|
|
1273
|
+
if (timeout !== Infinity) {
|
|
1274
|
+
// TODO: In waitasecond forTime(Infinity) should be equivalent to forEver()
|
|
1275
|
+
forTime(timeout).then(() => {
|
|
1276
|
+
if (crashOnError) {
|
|
1277
|
+
reject(new Error(`Command "${humanReadableCommand}" exceeded time limit of ${timeout}ms`));
|
|
1278
|
+
}
|
|
1279
|
+
else {
|
|
1280
|
+
console.warn(`Command "${humanReadableCommand}" exceeded time limit of ${timeout}ms but continues running`);
|
|
1281
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
1282
|
+
resolve('Command exceeded time limit');
|
|
1283
|
+
}
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
if (isVerbose) {
|
|
1287
|
+
console.info(colors.yellow(cwd) + ' ' + colors.green(command) + ' ' + colors.blue(args.join(' ')));
|
|
1288
|
+
}
|
|
1289
|
+
try {
|
|
1290
|
+
const commandProcess = spawn(command, args, { cwd, shell: true });
|
|
1291
|
+
if (isVerbose) {
|
|
1292
|
+
commandProcess.on('message', (message) => {
|
|
1293
|
+
console.info({ message });
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1296
|
+
const output = [];
|
|
1297
|
+
commandProcess.stdout.on('data', (stdout) => {
|
|
1298
|
+
output.push(stdout.toString());
|
|
1299
|
+
if (isVerbose) {
|
|
1300
|
+
console.info(stdout.toString());
|
|
1301
|
+
}
|
|
1302
|
+
});
|
|
1303
|
+
commandProcess.stderr.on('data', (stderr) => {
|
|
1304
|
+
output.push(stderr.toString());
|
|
1305
|
+
if (isVerbose && stderr.toString().trim()) {
|
|
1306
|
+
console.warn(stderr.toString());
|
|
1307
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
1308
|
+
}
|
|
1309
|
+
});
|
|
1310
|
+
const finishWithCode = (code) => {
|
|
1311
|
+
if (code !== 0) {
|
|
1312
|
+
if (crashOnError) {
|
|
1313
|
+
reject(new Error(output.join('\n').trim() ||
|
|
1314
|
+
`Command "${humanReadableCommand}" exited with code ${code}`));
|
|
1315
|
+
}
|
|
1316
|
+
else {
|
|
1317
|
+
if (isVerbose) {
|
|
1318
|
+
console.warn(`Command "${humanReadableCommand}" exited with code ${code}`);
|
|
1319
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
1320
|
+
}
|
|
1321
|
+
resolve(spaceTrim$1(output.join('\n')));
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
else {
|
|
1325
|
+
resolve(spaceTrim$1(output.join('\n')));
|
|
1326
|
+
}
|
|
1327
|
+
};
|
|
1328
|
+
commandProcess.on('close', finishWithCode);
|
|
1329
|
+
commandProcess.on('exit', finishWithCode);
|
|
1330
|
+
commandProcess.on('disconnect', () => {
|
|
1331
|
+
// Note: Unexpected disconnection should always result in rejection
|
|
1332
|
+
reject(new Error(`Command "${humanReadableCommand}" disconnected`));
|
|
1333
|
+
});
|
|
1334
|
+
commandProcess.on('error', (error) => {
|
|
1335
|
+
if (crashOnError) {
|
|
1336
|
+
reject(new Error(`Command "${humanReadableCommand}" failed: \n${error.message}`));
|
|
1337
|
+
}
|
|
1338
|
+
else {
|
|
1339
|
+
if (isVerbose) {
|
|
1340
|
+
console.warn(error);
|
|
1341
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
1342
|
+
}
|
|
1343
|
+
resolve(spaceTrim$1(output.join('\n')));
|
|
1344
|
+
}
|
|
1345
|
+
});
|
|
1346
|
+
}
|
|
1347
|
+
catch (error) {
|
|
1348
|
+
// Note: Unexpected error in sync code should always result in rejection
|
|
1349
|
+
reject(error);
|
|
1350
|
+
}
|
|
1351
|
+
});
|
|
1352
|
+
}
|
|
1353
|
+
/**
|
|
1354
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
1144
1355
|
*/
|
|
1145
|
-
|
|
1356
|
+
|
|
1146
1357
|
/**
|
|
1147
|
-
*
|
|
1358
|
+
* [🐱🚀]
|
|
1359
|
+
* Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
|
|
1148
1360
|
*
|
|
1149
|
-
*
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1361
|
+
* You can simply use `RemoteExecutionTools` on client-side javascript and connect to your remote server.
|
|
1362
|
+
* This is useful to make all logic on browser side but not expose your API keys or no need to use customer's GPU.
|
|
1363
|
+
*
|
|
1364
|
+
* @see https://github.com/webgptorg/promptbook#remote-server
|
|
1365
|
+
* @public exported from `@promptbook/remote-server`
|
|
1366
|
+
* <- TODO: [🐱🚀] Change to `@promptbook/agent-server`
|
|
1367
|
+
*/
|
|
1368
|
+
async function startAgentServer(options) {
|
|
1369
|
+
const { port = 4440 } = options;
|
|
1370
|
+
// TODO: [🐱🚀] [🌕]
|
|
1371
|
+
const agentsServerRoot = join(__dirname, '../apps/agents-server');
|
|
1372
|
+
console.trace(`!!! Starting agents server on port ${port}...`);
|
|
1373
|
+
console.log(`!!! cwd`, process.cwd());
|
|
1374
|
+
console.log(`!!! __dirname`, __dirname);
|
|
1375
|
+
console.log(`!!! agentsServerRoot`, agentsServerRoot);
|
|
1376
|
+
await $execCommand({
|
|
1377
|
+
cwd: agentsServerRoot,
|
|
1378
|
+
command: `next dev --port ${port} `,
|
|
1379
|
+
isVerbose: true,
|
|
1380
|
+
});
|
|
1381
|
+
}
|
|
1155
1382
|
/**
|
|
1156
|
-
* Note: [
|
|
1157
|
-
* TODO: [🧠][🧜♂️] Maybe join remoteServerUrl and path into single value
|
|
1383
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
1158
1384
|
*/
|
|
1159
1385
|
|
|
1160
1386
|
/**
|
|
@@ -1165,7 +1391,7 @@ true);
|
|
|
1165
1391
|
function getErrorReportUrl(error) {
|
|
1166
1392
|
const report = {
|
|
1167
1393
|
title: `🐜 Error report from ${NAME}`,
|
|
1168
|
-
body: spaceTrim((block) => `
|
|
1394
|
+
body: spaceTrim$2((block) => `
|
|
1169
1395
|
|
|
1170
1396
|
|
|
1171
1397
|
\`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
|
|
@@ -1289,6 +1515,7 @@ class AuthenticationError extends Error {
|
|
|
1289
1515
|
/**
|
|
1290
1516
|
* Generates random token
|
|
1291
1517
|
*
|
|
1518
|
+
* Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
|
|
1292
1519
|
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
1293
1520
|
*
|
|
1294
1521
|
* @private internal helper function
|
|
@@ -1298,6 +1525,7 @@ function $randomToken(randomness) {
|
|
|
1298
1525
|
return randomBytes(randomness).toString('hex');
|
|
1299
1526
|
}
|
|
1300
1527
|
/**
|
|
1528
|
+
* TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
|
|
1301
1529
|
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
1302
1530
|
*/
|
|
1303
1531
|
|
|
@@ -1364,17 +1592,20 @@ class CollectionError extends Error {
|
|
|
1364
1592
|
}
|
|
1365
1593
|
|
|
1366
1594
|
/**
|
|
1367
|
-
* This error
|
|
1595
|
+
* This error indicates error from the database
|
|
1368
1596
|
*
|
|
1369
1597
|
* @public exported from `@promptbook/core`
|
|
1370
1598
|
*/
|
|
1371
|
-
class
|
|
1599
|
+
class DatabaseError extends Error {
|
|
1372
1600
|
constructor(message) {
|
|
1373
1601
|
super(message);
|
|
1374
|
-
this.name = '
|
|
1375
|
-
Object.setPrototypeOf(this,
|
|
1602
|
+
this.name = 'DatabaseError';
|
|
1603
|
+
Object.setPrototypeOf(this, DatabaseError.prototype);
|
|
1376
1604
|
}
|
|
1377
1605
|
}
|
|
1606
|
+
/**
|
|
1607
|
+
* TODO: [🐱🚀] Explain that NotFoundError ([🐱🚀] and other specific errors) has priority over DatabaseError in some contexts
|
|
1608
|
+
*/
|
|
1378
1609
|
|
|
1379
1610
|
/**
|
|
1380
1611
|
* This error occurs when some expectation is not met in the execution of the pipeline
|
|
@@ -1436,6 +1667,19 @@ class MissingToolsError extends Error {
|
|
|
1436
1667
|
}
|
|
1437
1668
|
}
|
|
1438
1669
|
|
|
1670
|
+
/**
|
|
1671
|
+
* This error indicates that promptbook operation is not allowed
|
|
1672
|
+
*
|
|
1673
|
+
* @public exported from `@promptbook/core`
|
|
1674
|
+
*/
|
|
1675
|
+
class NotAllowed extends Error {
|
|
1676
|
+
constructor(message) {
|
|
1677
|
+
super(message);
|
|
1678
|
+
this.name = 'NotAllowed';
|
|
1679
|
+
Object.setPrototypeOf(this, NotAllowed.prototype);
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1439
1683
|
/**
|
|
1440
1684
|
* This error indicates that promptbook not found in the collection
|
|
1441
1685
|
*
|
|
@@ -1551,6 +1795,8 @@ const PROMPTBOOK_ERRORS = {
|
|
|
1551
1795
|
PromptbookFetchError,
|
|
1552
1796
|
UnexpectedError,
|
|
1553
1797
|
WrappedError,
|
|
1798
|
+
NotAllowed,
|
|
1799
|
+
DatabaseError,
|
|
1554
1800
|
// TODO: [🪑]> VersionMismatchError,
|
|
1555
1801
|
};
|
|
1556
1802
|
/**
|
|
@@ -1598,7 +1844,7 @@ function serializeError(error) {
|
|
|
1598
1844
|
const { name, message, stack } = error;
|
|
1599
1845
|
const { id } = error;
|
|
1600
1846
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
1601
|
-
console.error(spaceTrim((block) => `
|
|
1847
|
+
console.error(spaceTrim$2((block) => `
|
|
1602
1848
|
|
|
1603
1849
|
Cannot serialize error with name "${name}"
|
|
1604
1850
|
|
|
@@ -1618,186 +1864,6 @@ function serializeError(error) {
|
|
|
1618
1864
|
};
|
|
1619
1865
|
}
|
|
1620
1866
|
|
|
1621
|
-
/**
|
|
1622
|
-
* Detects if the code is running in a Node.js environment
|
|
1623
|
-
*
|
|
1624
|
-
* Note: `$` is used to indicate that this function is not a pure function - it looks at the global object to determine the environment
|
|
1625
|
-
*
|
|
1626
|
-
* @public exported from `@promptbook/utils`
|
|
1627
|
-
*/
|
|
1628
|
-
const $isRunningInNode = new Function(`
|
|
1629
|
-
try {
|
|
1630
|
-
return this === global;
|
|
1631
|
-
} catch (e) {
|
|
1632
|
-
return false;
|
|
1633
|
-
}
|
|
1634
|
-
`);
|
|
1635
|
-
/**
|
|
1636
|
-
* TODO: [🎺]
|
|
1637
|
-
*/
|
|
1638
|
-
|
|
1639
|
-
/**
|
|
1640
|
-
* Normalize options for `execCommand` and `execCommands`
|
|
1641
|
-
*
|
|
1642
|
-
* Note: `$` is used to indicate that this function behaves differently according to `process.platform`
|
|
1643
|
-
*
|
|
1644
|
-
* @private internal utility of `execCommand` and `execCommands`
|
|
1645
|
-
*/
|
|
1646
|
-
function $execCommandNormalizeOptions(options) {
|
|
1647
|
-
var _a, _b, _c, _d;
|
|
1648
|
-
let command;
|
|
1649
|
-
let cwd;
|
|
1650
|
-
let crashOnError;
|
|
1651
|
-
let args = [];
|
|
1652
|
-
let timeout;
|
|
1653
|
-
let isVerbose;
|
|
1654
|
-
if (typeof options === 'string') {
|
|
1655
|
-
// TODO: [1] DRY default values
|
|
1656
|
-
command = options;
|
|
1657
|
-
cwd = process.cwd();
|
|
1658
|
-
crashOnError = true;
|
|
1659
|
-
timeout = Infinity; // <- TODO: [⏳]
|
|
1660
|
-
isVerbose = DEFAULT_IS_VERBOSE;
|
|
1661
|
-
}
|
|
1662
|
-
else {
|
|
1663
|
-
/*
|
|
1664
|
-
TODO:
|
|
1665
|
-
if ((options as any).commands !== undefined) {
|
|
1666
|
-
commands = (options as any).commands;
|
|
1667
|
-
} else {
|
|
1668
|
-
commands = [(options as any).command];
|
|
1669
|
-
}
|
|
1670
|
-
*/
|
|
1671
|
-
// TODO: [1] DRY default values
|
|
1672
|
-
command = options.command;
|
|
1673
|
-
cwd = (_a = options.cwd) !== null && _a !== void 0 ? _a : process.cwd();
|
|
1674
|
-
crashOnError = (_b = options.crashOnError) !== null && _b !== void 0 ? _b : true;
|
|
1675
|
-
timeout = (_c = options.timeout) !== null && _c !== void 0 ? _c : Infinity;
|
|
1676
|
-
isVerbose = (_d = options.isVerbose) !== null && _d !== void 0 ? _d : DEFAULT_IS_VERBOSE;
|
|
1677
|
-
}
|
|
1678
|
-
// TODO: /(-[a-zA-Z0-9-]+\s+[^\s]*)|[^\s]*/g
|
|
1679
|
-
const _ = Array.from(command.matchAll(/(".*")|([^\s]*)/g))
|
|
1680
|
-
.map(([match]) => match)
|
|
1681
|
-
.filter((arg) => arg !== '');
|
|
1682
|
-
if (_.length > 1) {
|
|
1683
|
-
[command, ...args] = _;
|
|
1684
|
-
}
|
|
1685
|
-
if (options.args) {
|
|
1686
|
-
args = [...args, ...options.args];
|
|
1687
|
-
}
|
|
1688
|
-
let humanReadableCommand = !['npx', 'npm'].includes(command) ? command : args[0];
|
|
1689
|
-
if (['ts-node'].includes(humanReadableCommand)) {
|
|
1690
|
-
humanReadableCommand += ` ${args[1]}`;
|
|
1691
|
-
}
|
|
1692
|
-
if (/^win/.test(process.platform) && ['npm', 'npx'].includes(command)) {
|
|
1693
|
-
command = `${command}.cmd`;
|
|
1694
|
-
}
|
|
1695
|
-
return { command, humanReadableCommand, args, cwd, crashOnError, timeout, isVerbose };
|
|
1696
|
-
}
|
|
1697
|
-
// TODO: This should show type error> execCommandNormalizeOptions({ command: '', commands: [''] });
|
|
1698
|
-
|
|
1699
|
-
/**
|
|
1700
|
-
* Run one command in a shell
|
|
1701
|
-
*
|
|
1702
|
-
*
|
|
1703
|
-
* Note: There are 2 similar functions in the codebase:
|
|
1704
|
-
* - `$execCommand` which runs a single command
|
|
1705
|
-
* - `$execCommands` which runs multiple commands
|
|
1706
|
-
* Note: `$` is used to indicate that this function is not a pure function - it runs a command in a shell
|
|
1707
|
-
*
|
|
1708
|
-
* @public exported from `@promptbook/node`
|
|
1709
|
-
*/
|
|
1710
|
-
function $execCommand(options) {
|
|
1711
|
-
if (!$isRunningInNode()) {
|
|
1712
|
-
throw new EnvironmentMismatchError('Function `$execCommand` can run only in Node environment.js');
|
|
1713
|
-
}
|
|
1714
|
-
return new Promise((resolve, reject) => {
|
|
1715
|
-
// eslint-disable-next-line prefer-const
|
|
1716
|
-
const { command, humanReadableCommand, args, cwd, crashOnError, timeout, isVerbose = DEFAULT_IS_VERBOSE, } = $execCommandNormalizeOptions(options);
|
|
1717
|
-
if (timeout !== Infinity) {
|
|
1718
|
-
// TODO: In waitasecond forTime(Infinity) should be equivalent to forEver()
|
|
1719
|
-
forTime(timeout).then(() => {
|
|
1720
|
-
if (crashOnError) {
|
|
1721
|
-
reject(new Error(`Command "${humanReadableCommand}" exceeded time limit of ${timeout}ms`));
|
|
1722
|
-
}
|
|
1723
|
-
else {
|
|
1724
|
-
console.warn(`Command "${humanReadableCommand}" exceeded time limit of ${timeout}ms but continues running`);
|
|
1725
|
-
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
1726
|
-
resolve('Command exceeded time limit');
|
|
1727
|
-
}
|
|
1728
|
-
});
|
|
1729
|
-
}
|
|
1730
|
-
if (isVerbose) {
|
|
1731
|
-
console.info(colors.yellow(cwd) + ' ' + colors.green(command) + ' ' + colors.blue(args.join(' ')));
|
|
1732
|
-
}
|
|
1733
|
-
try {
|
|
1734
|
-
const commandProcess = spawn(command, args, { cwd, shell: true });
|
|
1735
|
-
if (isVerbose) {
|
|
1736
|
-
commandProcess.on('message', (message) => {
|
|
1737
|
-
console.info({ message });
|
|
1738
|
-
});
|
|
1739
|
-
}
|
|
1740
|
-
const output = [];
|
|
1741
|
-
commandProcess.stdout.on('data', (stdout) => {
|
|
1742
|
-
output.push(stdout.toString());
|
|
1743
|
-
if (isVerbose) {
|
|
1744
|
-
console.info(stdout.toString());
|
|
1745
|
-
}
|
|
1746
|
-
});
|
|
1747
|
-
commandProcess.stderr.on('data', (stderr) => {
|
|
1748
|
-
output.push(stderr.toString());
|
|
1749
|
-
if (isVerbose && stderr.toString().trim()) {
|
|
1750
|
-
console.warn(stderr.toString());
|
|
1751
|
-
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
1752
|
-
}
|
|
1753
|
-
});
|
|
1754
|
-
const finishWithCode = (code) => {
|
|
1755
|
-
if (code !== 0) {
|
|
1756
|
-
if (crashOnError) {
|
|
1757
|
-
reject(new Error(output.join('\n').trim() ||
|
|
1758
|
-
`Command "${humanReadableCommand}" exited with code ${code}`));
|
|
1759
|
-
}
|
|
1760
|
-
else {
|
|
1761
|
-
if (isVerbose) {
|
|
1762
|
-
console.warn(`Command "${humanReadableCommand}" exited with code ${code}`);
|
|
1763
|
-
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
1764
|
-
}
|
|
1765
|
-
resolve(spaceTrim$1(output.join('\n')));
|
|
1766
|
-
}
|
|
1767
|
-
}
|
|
1768
|
-
else {
|
|
1769
|
-
resolve(spaceTrim$1(output.join('\n')));
|
|
1770
|
-
}
|
|
1771
|
-
};
|
|
1772
|
-
commandProcess.on('close', finishWithCode);
|
|
1773
|
-
commandProcess.on('exit', finishWithCode);
|
|
1774
|
-
commandProcess.on('disconnect', () => {
|
|
1775
|
-
// Note: Unexpected disconnection should always result in rejection
|
|
1776
|
-
reject(new Error(`Command "${humanReadableCommand}" disconnected`));
|
|
1777
|
-
});
|
|
1778
|
-
commandProcess.on('error', (error) => {
|
|
1779
|
-
if (crashOnError) {
|
|
1780
|
-
reject(new Error(`Command "${humanReadableCommand}" failed: \n${error.message}`));
|
|
1781
|
-
}
|
|
1782
|
-
else {
|
|
1783
|
-
if (isVerbose) {
|
|
1784
|
-
console.warn(error);
|
|
1785
|
-
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
1786
|
-
}
|
|
1787
|
-
resolve(spaceTrim$1(output.join('\n')));
|
|
1788
|
-
}
|
|
1789
|
-
});
|
|
1790
|
-
}
|
|
1791
|
-
catch (error) {
|
|
1792
|
-
// Note: Unexpected error in sync code should always result in rejection
|
|
1793
|
-
reject(error);
|
|
1794
|
-
}
|
|
1795
|
-
});
|
|
1796
|
-
}
|
|
1797
|
-
/**
|
|
1798
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
1799
|
-
*/
|
|
1800
|
-
|
|
1801
1867
|
/**
|
|
1802
1868
|
* Attempts to locate the specified application on a Linux system using the 'which' command.
|
|
1803
1869
|
* Returns the path to the executable if found, or null otherwise.
|
|
@@ -1837,6 +1903,7 @@ function $provideFilesystemForNode(options) {
|
|
|
1837
1903
|
writeFile,
|
|
1838
1904
|
readdir,
|
|
1839
1905
|
mkdir,
|
|
1906
|
+
watch,
|
|
1840
1907
|
};
|
|
1841
1908
|
}
|
|
1842
1909
|
/**
|
|
@@ -2121,7 +2188,7 @@ function checkSerializableAsJson(options) {
|
|
|
2121
2188
|
}
|
|
2122
2189
|
else if (typeof value === 'object') {
|
|
2123
2190
|
if (value instanceof Date) {
|
|
2124
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
2191
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2125
2192
|
\`${name}\` is Date
|
|
2126
2193
|
|
|
2127
2194
|
Use \`string_date_iso8601\` instead
|
|
@@ -2140,7 +2207,7 @@ function checkSerializableAsJson(options) {
|
|
|
2140
2207
|
throw new UnexpectedError(`${name} is RegExp`);
|
|
2141
2208
|
}
|
|
2142
2209
|
else if (value instanceof Error) {
|
|
2143
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
2210
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2144
2211
|
\`${name}\` is unserialized Error
|
|
2145
2212
|
|
|
2146
2213
|
Use function \`serializeError\`
|
|
@@ -2163,7 +2230,7 @@ function checkSerializableAsJson(options) {
|
|
|
2163
2230
|
}
|
|
2164
2231
|
catch (error) {
|
|
2165
2232
|
assertsError(error);
|
|
2166
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
2233
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2167
2234
|
\`${name}\` is not serializable
|
|
2168
2235
|
|
|
2169
2236
|
${block(error.stack || error.message)}
|
|
@@ -2195,7 +2262,7 @@ function checkSerializableAsJson(options) {
|
|
|
2195
2262
|
}
|
|
2196
2263
|
}
|
|
2197
2264
|
else {
|
|
2198
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
2265
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2199
2266
|
\`${name}\` is unknown type
|
|
2200
2267
|
|
|
2201
2268
|
Additional message for \`${name}\`:
|
|
@@ -2225,7 +2292,7 @@ function deepClone(objectValue) {
|
|
|
2225
2292
|
TODO: [🧠] Is there a better implementation?
|
|
2226
2293
|
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
2227
2294
|
> for (const propertyName of propertyNames) {
|
|
2228
|
-
> const value = (objectValue as
|
|
2295
|
+
> const value = (objectValue as chococake)[propertyName];
|
|
2229
2296
|
> if (value && typeof value === 'object') {
|
|
2230
2297
|
> deepClone(value);
|
|
2231
2298
|
> }
|
|
@@ -2447,6 +2514,8 @@ function isValidPipelineUrl(url) {
|
|
|
2447
2514
|
* - if it is valid json
|
|
2448
2515
|
* - if it is meaningful
|
|
2449
2516
|
*
|
|
2517
|
+
* Note: [🔂] This function is idempotent.
|
|
2518
|
+
*
|
|
2450
2519
|
* @param pipeline valid or invalid PipelineJson
|
|
2451
2520
|
* @returns the same pipeline if it is logically valid
|
|
2452
2521
|
* @throws {PipelineLogicError} on logical error in the pipeline
|
|
@@ -2803,7 +2872,7 @@ function jsonParse(value) {
|
|
|
2803
2872
|
}
|
|
2804
2873
|
else if (typeof value !== 'string') {
|
|
2805
2874
|
console.error('Can not parse JSON from non-string value.', { text: value });
|
|
2806
|
-
throw new Error(spaceTrim(`
|
|
2875
|
+
throw new Error(spaceTrim$2(`
|
|
2807
2876
|
Can not parse JSON from non-string value.
|
|
2808
2877
|
|
|
2809
2878
|
The value type: ${typeof value}
|
|
@@ -2817,7 +2886,7 @@ function jsonParse(value) {
|
|
|
2817
2886
|
if (!(error instanceof Error)) {
|
|
2818
2887
|
throw error;
|
|
2819
2888
|
}
|
|
2820
|
-
throw new Error(spaceTrim((block) => `
|
|
2889
|
+
throw new Error(spaceTrim$2((block) => `
|
|
2821
2890
|
${block(error.message)}
|
|
2822
2891
|
|
|
2823
2892
|
The expected JSON text:
|
|
@@ -2870,7 +2939,7 @@ function deserializeError(error) {
|
|
|
2870
2939
|
message = `${name}: ${message}`;
|
|
2871
2940
|
}
|
|
2872
2941
|
if (stack !== undefined && stack !== '') {
|
|
2873
|
-
message = spaceTrim((block) => `
|
|
2942
|
+
message = spaceTrim$2((block) => `
|
|
2874
2943
|
${block(message)}
|
|
2875
2944
|
|
|
2876
2945
|
Original stack trace:
|
|
@@ -2938,6 +3007,7 @@ function createTask(options) {
|
|
|
2938
3007
|
let updatedAt = createdAt;
|
|
2939
3008
|
const errors = [];
|
|
2940
3009
|
const warnings = [];
|
|
3010
|
+
const llmCalls = [];
|
|
2941
3011
|
let currentValue = {};
|
|
2942
3012
|
let customTldr = null;
|
|
2943
3013
|
const partialResultSubject = new Subject();
|
|
@@ -2953,6 +3023,9 @@ function createTask(options) {
|
|
|
2953
3023
|
}, (tldrInfo) => {
|
|
2954
3024
|
customTldr = tldrInfo;
|
|
2955
3025
|
updatedAt = new Date();
|
|
3026
|
+
}, (llmCall) => {
|
|
3027
|
+
llmCalls.push(llmCall);
|
|
3028
|
+
updatedAt = new Date();
|
|
2956
3029
|
});
|
|
2957
3030
|
finalResultPromise
|
|
2958
3031
|
.catch((error) => {
|
|
@@ -3075,7 +3148,7 @@ function createTask(options) {
|
|
|
3075
3148
|
}
|
|
3076
3149
|
return {
|
|
3077
3150
|
percent: percent,
|
|
3078
|
-
message,
|
|
3151
|
+
message: message + ' (!!!fallback)',
|
|
3079
3152
|
};
|
|
3080
3153
|
},
|
|
3081
3154
|
get createdAt() {
|
|
@@ -3098,6 +3171,10 @@ function createTask(options) {
|
|
|
3098
3171
|
return warnings;
|
|
3099
3172
|
// <- Note: [1] --||--
|
|
3100
3173
|
},
|
|
3174
|
+
get llmCalls() {
|
|
3175
|
+
return [...llmCalls, { foo: '!!! bar' }];
|
|
3176
|
+
// <- Note: [1] --||--
|
|
3177
|
+
},
|
|
3101
3178
|
get currentValue() {
|
|
3102
3179
|
return currentValue;
|
|
3103
3180
|
// <- Note: [1] --||--
|
|
@@ -3177,7 +3254,7 @@ const UNCERTAIN_USAGE = $deepFreeze({
|
|
|
3177
3254
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
3178
3255
|
*/
|
|
3179
3256
|
|
|
3180
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge from Markdown\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book`\n- INPUT PARAMETER `{knowledgeContent}` Markdown document content\n- OUTPUT PARAMETER `{knowledgePieces}` The knowledge JSON object\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}\n```\n\n`-> {knowledgePieces}`\n"}],sourceFile:"./books/prepare-knowledge-from-markdown.book"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Keywords\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-keywords.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{keywords}` Keywords separated by comma\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}\n```\n\n`-> {keywords}`\n"}],sourceFile:"./books/prepare-knowledge-keywords.book"},{title:"Prepare Knowledge-piece Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge-piece Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-title.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{title}` The title of the document\n\n## Knowledge\n\n- EXPECT MIN 1 WORD\n- EXPECT MAX 8 WORDS\n\n```markdown\nYou are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-knowledge-title.book"},{title:"Prepare Persona",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book",formfactorName:"GENERIC",parameters:[{name:"availableModels",description:"List of available model names together with their descriptions as JSON",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelsRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n```json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpful assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n```\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n```json\n{availableModels}\n```\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelsRequirements",format:"JSON",dependentParameterNames:["availableModels","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Persona\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-persona.book`\n- INPUT PARAMETER `{availableModels}` List of available model names together with their descriptions as JSON\n- INPUT PARAMETER `{personaDescription}` Description of the persona\n- OUTPUT PARAMETER `{modelsRequirements}` Specific requirements for the model\n\n## Make modelRequirements\n\n- FORMAT JSON\n\n```markdown\nYou are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n\\`\\`\\`json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpful assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n\\`\\`\\`\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n\\`\\`\\`json\n{availableModels}\n\\`\\`\\`\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}\n```\n\n`-> {modelsRequirements}`\n"}],sourceFile:"./books/prepare-persona.book"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-title.book",formfactorName:"GENERIC",parameters:[{name:"book",description:"The book to prepare the title for",isInput:true,isOutput:false},{name:"title",description:"Best title for the book",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-title",title:"Make title",content:"Make best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}",resultingParameterName:"title",expectations:{words:{min:1,max:8},lines:{min:1,max:1}},dependentParameterNames:["book"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-title.book`\n- INPUT PARAMETER `{book}` The book to prepare the title for\n- OUTPUT PARAMETER `{title}` Best title for the book\n\n## Make title\n\n- EXPECT MIN 1 Word\n- EXPECT MAX 8 Words\n- EXPECT EXACTLY 1 Line\n\n```markdown\nMake best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-title.book"},{title:"📊 Curriculum Audit",pipelineUrl:"https://promptbook.studio/promptbook//examples/lsvp-asistent.book",formfactorName:"GENERIC",parameters:[{name:"result",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"prompt",title:"Prompt",content:"Asistent pro LŠVP\n\nPERSONA Jsi asistent pro RVP Lyceum v rámci Národního pedagogického institutu České Republiky\nMETA IMAGE https://edulk.cz/getFile/id:475818/type:large/02%20zna%C4%8Dka%20npi.jpg\nRULE Pokud jsi nejsi jistý, napiš nevím\nKNOWLEDGE ./241129_Lyceum_final.pdf\nCONTEXT Obecně dokážeš řešit libovolné ŠVP, aktuálně řešíš {Školní vzdělávací program LYCEUM}\nRULE Z {Porovnání RVP a ŠVP - postup} je nejdůležitější fáze 3\nKNOWLEDGE {Školní vzdělávací program LYCEUM} ./ŠVP Lyceum - Finance v digitální době.pdf\nKNOWLEDGE @Slovník\n\n**Interní slovník - RVP/ŠVP**\n\n**RVP**\n\nRámcový vzdělávací program pro obor vzdělání Lyceum je dokument na národní úrovni, který formuluje požadavky na školní vzdělávací programy ve formě především očekávaných výsledků učení, kterých mají žáci absolvováním tohoto programu na dané škole dosáhnout.\n\n**ŠVP**\n\nŠkolní vzdělávací program pro obor vzdělání Lyceum je dokument každé jednotlivé školy, který popisuje v jakých vyučovacích předmětech/ vzdělávacích modulech a v jakých ročnících budou požadované očekávané výsledky učení naplněny. Zároveň formuluje další očekávané výsledky učení, které naplňují disponibilní část vyučovacího času určeného RVP pro tento obor vzdělání.\n\n**Očekávaný výsledek učení (OVU)**\n\nVyjadřuje jednotlivý požadavek na to, co mají žáci umět na konci vzdělávacího programu, tzn. jejich požadované kompetence. Je vyjádřen formulací, která je uvozena činnostním slovesem a dále obsahuje předmět této činnosti. Formulace je konkretizována resp. doplněna zpravidla formou odrážek vymezením dílčích znalostí, dovedností, postojů, jejichž splnění je předpokladem dosažení OVU jako celku.\n\n_Příklad:_\n\n<div class=\"joplin-table-wrapper\"><table><tbody><tr><th><p><strong>Žák/žákyně řídí realizaci jednoduchého projektu</strong></p></th></tr><tr><td><ul><li>naplánuje aktivity projektu</li></ul></td></tr><tr><td><ul><li>navrhne rozpočet projektu vzhledem k navrženým aktivitám</li></ul></td></tr><tr><td><ul><li>stanoví základní ukazatele a sleduje jejich naplňování</li></ul></td></tr><tr><td><ul><li>vede projektový tým</li></ul></td></tr><tr><td><ul><li>uvede, jak by řešil krizové situace v projektu</li></ul></td></tr><tr><td><ul><li>vyhodnotí úspěšnost projektu</li></ul></td></tr></tbody></table></div>\n\n**Vzdělávací oblasti**\n\nOčekávané výsledky učení jsou v **_RVP členěny do 4 vzdělávacích oblastí_**, které tvoří společný všeobecně vzdělávací základ:\n\n- Osobnostní rozvoj, vzdělávání ke zdraví, bezpečí a produktivnímu pracovnímu životu (kariéře)\n- Komunikační a jazykové vzdělávání\n- Aplikované vzdělávání STEM (Science, Technology, Engeneering, Math), tj. přírodní vědy, informatika, technika, matematika\n- Prakticky orientované vzdělávání společenskovědní a humanitní\n\nKaždá vzdělávací oblast se dále člení na okruhy, v jejichž rámci jsou OVU samostatně číslované.\n\n<div class=\"joplin-table-wrapper\"><table><tbody><tr><th rowspan=\"21\"><ul><li>Prakticky orientované vzdělávání společenskovědní a humanitní</li></ul></th><th rowspan=\"21\"><p><strong>Člověk, ekonomie a podnikání</strong></p></th><th rowspan=\"7\"><p><strong>1</strong></p></th><th><p><strong>zpracuje podklady související s podnikáním</strong></p></th></tr><tr><td><p>připraví podnikatelský záměr</p></td></tr><tr><td><p>sestaví zakladatelský rozpočet</p></td></tr><tr><td><p>zkalkuluje cenu zboží nebo služby</p></td></tr><tr><td><p>vysvětlí na příkladu základní povinnosti podnikatele vůči státu a zaměstnancům</p></td></tr><tr><td><p>vede daňovou evidenci</p></td></tr><tr><td><p>vysvětlí na příkladech etiku v podnikání</p></td></tr><tr><td rowspan=\"7\"><p><strong>2</strong></p></td><td><p><strong>řídí realizaci jednoduchého projektu</strong></p></td></tr><tr><td><p>naplánuje aktivity projektu</p></td></tr><tr><td><p>navrhne rozpočet projektu vzhledem k navrženým aktivitám</p></td></tr><tr><td><p>stanoví základní ukazatele a sleduje jejich naplňování</p></td></tr><tr><td><p>vede projektový tým</p></td></tr><tr><td><p>uvede, jak by řešil krizové situace v projektu</p></td></tr><tr><td><p>vyhodnotí úspěšnost projektu</p></td></tr><tr><td rowspan=\"7\"><p><strong>3</strong></p></td><td><p><strong>aplikuje ekonomické teorie v osobním a profesním životě</strong></p></td></tr><tr><td><p>vysvětlí základní ekonomické otázky</p></td></tr><tr><td><p>vysvětí stanovení rovnovážné ceny na dokonalém i nedokonalém trhu</p></td></tr><tr><td><p>charakterizuje výrobní faktory a vysvětlí hranici produkčních možností a náklady obětované příležitosti</p></td></tr><tr><td><p>uvede nejdůležitější makroekonomické pojmy a vliv jejich výše na kvalitu života a podnikání v daném státě</p></td></tr><tr><td><p>vysvětlí podstatu inflace a její důsledky na finanční situaci obyvatel a na příkladu ukáže jak se bránit jejím nepříznivým důsledkům</p></td></tr><tr><td><p>uvede hlavní výhody a nevýhody mezinárodního obchodu a vliv ochranářských opatření na ekonomickou situaci dané země</p></td></tr><tr><td></td><td></td><td><p><strong>4</strong></p></td><td><p>Atd.</p></td></tr></tbody></table></div>\n\n**Vyučovací předmět / vzdělávací modul**\n\nOčekávané výsledky učení jsou v **ŠVP** členěny do vyučovacích předmětů nebo vzdělávacích modulů, které jsou dále zařazeny do jednoho nebo více ročníků 4letého studia. Vyučovací předmět / vzdělávací modul tvoří vyučovací jednotku, kde jsou očekávané výsledky učení dále rozpracovány pro potřeby výuky podle následující šablony\n\n| **A. VSTUPNÍ ČÁST** |\n| --- |\n| **1\\. Název** |\n| **2\\. Kód** (kódy by měly být navázány na obory vzdělání a výsledky učení) |\n| **2a) Kategorie vzdělání** - v případě, že nebude součástí kódu |\n| **3\\. Typ vyučovací jednotky** (modul, předmět, stáž apod.) |\n| **4\\. Délka** (počet hodin - dělitelný čtyřmi (optimální modul 16, 32 hodin = týden výuky) |\n| **5\\. Platnost** (datum, od kterého platí) |\n| **6\\. Vstupní předpoklady** (vymezení požadované úrovně vstupních vědomostí a dovedností, které jsou předpokladem úspěšného studia) |\n| |\n| **B. JÁDRO VYUČOVACÍ JEDNOTKY** |\n| **1\\. Charakteristika** (stručná anotace popisující obecné cíle a pojetí) |\n| **2\\. Očekávané výsledky učení a jejich indikátory (převzaté z RVP nebo dále konkretizované)** |\n| **3\\. Podpora rozvoje klíčových kompetencí a základních gramotností** (které klíčové kompetence jsou v rozvíjeny) |\n| **4\\. Obsah vzdělávání** (rozpis učiva) |\n| **5\\. Vzdělávací strategie** (strategie výuky, resp. učební činnosti žáků, které jsou doporučené pro dosažení výsledků) |\n| |\n| **C. VÝSTUPNÍ ČÁST** |\n| **1\\. Způsob ověřování dosažených výsledků** (ve vazbě na jednotlivé výsledky učení) |\n| **2\\. Kritéria hodnocení** (co znamená splnění výsledků učení, kdy je splněna celá vyučovací jednotka, kritéria pro známky, příp. procentuální, slovní hodnocení) |\n| **3\\. Doporučená studijní literatura, odkazy na ilustrační zdroje** |\n| **4\\. Poznámky** |\n\n**Soulad OVU RVP a ŠVP**\n\nTento soulad je předmětem zjišťování. Soulad nastává, jestliže jsou očekávané výsledky učení z jednotlivých vzdělávacích oblastí RVP **obsaženy** ve vyučovacích předmětech/ vzdělávacích modulech ŠVP jednotlivých škol, tzn. že v ŠVP se objevuje jejich formulace buď v doslovném nebo podobném znění v jednom nebo více vyučovacích předmětech/ vzdělávacích modulech.\n\n_Příklad souladu:_\n\nRVP ŠVP - komunikace a marketing (SŠ obchodní Č.\n\n| **2** | **řídí realizaci jednoduchého projektu** |\n| --- | --- |\n| naplánuje aktivity projektu |\n| navrhne rozpočet projektu vzhledem k navrženým aktivitám |\n| stanoví základní ukazatele a sleduje jejich naplňování |\n| vede projektový tým |\n| uvede, jak by řešil krizové situace v projektu |\n| vyhodnotí úspěšnost projektu |\n\nKNOWLEDGE {Porovnání RVP a ŠVP - postup}\n\n\n# AUDITNÍ PROTOKOL ŠVP-RVP\n\n# (POPIS KONTROLNÍHO ALGORITMU)\n\nMetodika je určena pro **Kvantifikaci Shody** školního vzdělávacího programu (ŠVP) s Rámcovým vzdělávacím programem (RVP).\n\n## FÁZE 1: VALIDACE DOKUMENTACE\n\n**Cíl:** Ověřit platnost, aktuálnost a strukturu zdrojových dokumentů.\n\n- **RVP Verifikace:** Otevřít aktuální verzi RVP (např. RVP ZV/G/SOŠ).\n- **Typová shoda:** Ověřit, že RVP se vztahuje k danému typu školy.\n- **ŠVP Dimenze:** Identifikovat a izolovat relevantní části ŠVP: Profil absolventa, Klíčové kompetence (KK), Vzdělávací oblasti (VO), případně Učební plán (UP).\n- **Verzování:** Potvrdit, že obě verze (RVP a ŠVP) jsou nejnovější a platné (včetně dodatků RVP).\n\n## FÁZE 2: DATABÁZOVÉ MAPOVÁNÍ VÝSTUPŮ (MASTER MATICE)\n\n**Cíl:** Vytvořit systémovou databázi pro křížové porovnání všech povinných komponent RVP se ŠVP.\n\n- **Dekompozice RVP:** Rozložit RVP na základní povinné komponenty: Klíčové kompetence, Vzdělávací oblasti a obory, Očekávané výstupy (OVU), Průřezová témata (PT).\n- **Přiřazovací mapa:** Vytvořit hlavní kontrolní matici (Master Matice) pro záznam vazeb.\n\n| Oblast RVP | Výstup RVP (OVU) | Odpovídající Část ŠVP (Předmět/Ročník) | Konkrétní Tématický Celek v ŠVP | Stav Shody (Protokol) |\n| --- | --- | --- | --- | --- |\n| ... | ... | ... | ... | ... |\n| --- | --- | --- | --- | --- |\n\n## FÁZE 3: ALGORITMICKÁ KONTROLA POKRYTÍ A HLOUBKY\n\n**Cíl:** Posoudit, zda každý povinný výstup RVP je adekvátně reflektován v obsahu ŠVP, a přidělit bodovou hodnotu pro kvantifikaci.\n\n- **Audit OVU:** Projít každý jednotlivý Očekávaný výstup (OVU) z RVP.\n- **Kódování stavu a bodování:** U každého OVU v matici označit stav pokrytí dle následujícího schématu:\n\n| Kód (Protokol) | Popis (Kvalitativní zjištění) | Bodová hodnota (Kvantifikace) |\n| --- | --- | --- |\n| ✅ | Plná shoda (Výstup pokryt v plném rozsahu, odpovídající úrovni RVP) | 1,0 |\n| --- | --- | --- |\n| ⚠️ | Částečná shoda (Formální pokrytí, omezený rozsah, chybná návaznost) | 0,5 |\n| --- | --- | --- |\n| ❌ | Absence (Výstup zcela chybí v obsahu ŠVP) | 0,0 |\n| --- | --- | --- |\n\n- **Defektologie ŠVP:** Identifikovat a zaznamenat deficity ŠVP: Chybějící výstupy (❌), Sémantické překryvy, Přetížení obsahu.\n- **Kvalitativní posun:** Ověřit, zda je formulace výstupů v ŠVP **aktivní, měřitelná a v souladu** s úrovní RVP.\n\n## FÁZE 4: STRUKTURÁLNÍ VERIFIKACE NÁVAZNOSTI (VERTIKÁLA/HORIZONTÁLA)\n\n**Cíl:** Zkontrolovat logickou posloupnost a provázanost učiva v rámci ŠVP.\n\n- **Vertikální Kontrola:** Ověřit posloupnost OVU a učiva uvnitř jednoho předmětu/oblasti (postup od jednodušších ke složitějším konceptům napříč ročníky).\n- **Horizontální Kontrola:** Zkontrolovat logické provázání napříč vzdělávacími oblastmi a předměty (např. fyzika ↔ matematika).\n- **PT Integrace:** Audit reálné integrace Průřezových témat (PT) do konkrétních částí obsahu, metod a projektů.\n\n## FÁZE 5: ANALÝZA ŠKOLNÍ PROFILACE A ROZŠÍŘENÍ RVP\n\n**Cíl:** Validovat, že profilace školy je **v souladu** s RVP a nejedná se o **rozpor**.\n\n- **Nekonfliktnost:** Porovnat definovaný Profil absolventa školy s Klíčovými kompetencemi RVP. Profil ŠVP musí RVP rozvíjet, nikoli mu odporovat.\n- **Modularita:** Zkontrolovat, zda volitelné předměty a rozšiřující moduly logicky navazují na vzdělávací oblasti RVP.\n- **Implementace specializace:** Popisně uvést, jak je školní profilace (např. STEM zaměření, projektová výuka) integrována do OVU a kompetencí definovaných RVP.\n\n## FÁZE 6: GENERÁTOR ZÁVĚREČNÉ ZPRÁVY A KVANTIFIKACE\n\n**Cíl:** Syntetizovat výsledky, kvantifikovat soulad a generovat závazné návrhy na korekce.\n\n### 6.1 Kvantifikace Souladu\n\nVypočítat Index shody (IS) na základě bodového hodnocení (Fáze 3):\n\n### 6.2 Interpretace Indexu Shody (IS)\n\nKlasifikace souladu pro standardizované vyhodnocení:\n\n| Interval IS | Klasifikace souladu | Popis |\n| --- | --- | --- |\n| 95-100 % | Výborný soulad | ŠVP plně odpovídá RVP, pouze stylistické nebo formální rozdíly. |\n| --- | --- | --- |\n| 85-94 % | Dobrá shoda | ŠVP pokrývá všechny klíčové výstupy, menší korekce nutné. |\n| --- | --- | --- |\n| 70-84 % | Částečná shoda | Významné nedostatky v některých oblastech, nutná revize obsahu. |\n| --- | --- | --- |\n| < 70 % | Kritická neshoda | ŠVP neplní rámcové požadavky, ohrožuje legislativní soulad. |\n| --- | --- | --- |\n\n### 6.3 Doplňkové Indexy\n\nVypočítat následující doplňkové indexy pro detailní kvalitativní analýzu:\n\n- **Index kompetenčního souladu (IKS):** Poměr pokrytí klíčových kompetencí RVP v ŠVP.\n- **Index průřezové integrace (IPI):** Míra reálné integrace průřezových témat do výuky.\n- **Index hloubky pokrytí (IHP):** Procento výstupů, které jsou v ŠVP rozvedeny na konkrétní výukové cíle (měřitelné, aktivní formulace).\n- **Index profilové rozšiřitelnosti (IPR):** Kolik rozšiřujících nebo profilových výstupů přesahuje rámec RVP, aniž by narušily jeho strukturu.\n\n### 6.4 Vizuální výstupy\n\nZajistit generování následujících vizualizací pro Závěrečnou zprávu:\n\n- Graf pokrytí po vzdělávacích oblastech (Sloupcový graf IS pro VO).\n- Pavoukový diagram Klíčových kompetencí (RVP vs. ŠVP).\n- Mapa defektů (Vizualizace ❌ a ⚠️ výstupů).\n\n### 6.5 Struktura Závěrečné Zprávy\n\nZpráva musí být strukturována dle standardizovaného formátu:\n\n| Oddíl | Obsah |\n| --- | --- |\n| A. Identifikace | Název školy, IZO, typ školy, datum revize, zpracovatel, verze ŠVP a RVP. |\n| --- | --- |\n| B. Shrnutí výsledků | Celkový Index Shody (IS), hlavní závěry a doporučení. |\n| --- | --- |\n| C. Kvantitativní analýza | Přehled IS v % dle kategorií OVU / VO / kompetencí. |\n| --- | --- |\n| D. Kvalitativní analýza | Slovní zhodnocení kvality souladu (formulace, obtížnost, integrace PT). |\n| --- | --- |\n| E. Rizikové oblasti | Přehled nalezených defektů (chybějící OVU, přetížení, formální shoda). |\n| --- | --- |\n| F. Návrhy opatření (Korekční plán) | Přesné návrhy změn - **Co, Kde, Kdo** má upravit, včetně termínu. |\n| --- | --- |\n| G. Přílohy | Master Matice (Fáze 2-3), revizní tabulka, výstupní grafy a metriky. |\n| --- | --- |\n\n\n\n\n.",resultingParameterName:"result",dependentParameterNames:[]}],personas:[],preparations:[{id:1,promptbookVersion:"0.103.0-8",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"Asistent pro LŠVP\n\nPERSONA Jsi asistent pro RVP Lyceum v rámci Národního pedagogického institutu České Republiky\nMETA IMAGE https://edulk.cz/getFile/id:475818/type:large/02%20zna%C4%8Dka%20npi.jpg\nRULE Pokud jsi nejsi jistý, napiš nevím\nKNOWLEDGE ./241129_Lyceum_final.pdf\nCONTEXT Obecně dokážeš řešit libovolné ŠVP, aktuálně řešíš {Školní vzdělávací program LYCEUM}\nRULE Z {Porovnání RVP a ŠVP - postup} je nejdůležitější fáze 3\nKNOWLEDGE {Školní vzdělávací program LYCEUM} ./ŠVP Lyceum - Finance v digitální době.pdf\nKNOWLEDGE @Slovník\n\n**Interní slovník - RVP/ŠVP**\n\n**RVP**\n\nRámcový vzdělávací program pro obor vzdělání Lyceum je dokument na národní úrovni, který formuluje požadavky na školní vzdělávací programy ve formě především očekávaných výsledků učení, kterých mají žáci absolvováním tohoto programu na dané škole dosáhnout.\n\n**ŠVP**\n\nŠkolní vzdělávací program pro obor vzdělání Lyceum je dokument každé jednotlivé školy, který popisuje v jakých vyučovacích předmětech/ vzdělávacích modulech a v jakých ročnících budou požadované očekávané výsledky učení naplněny. Zároveň formuluje další očekávané výsledky učení, které naplňují disponibilní část vyučovacího času určeného RVP pro tento obor vzdělání.\n\n**Očekávaný výsledek učení (OVU)**\n\nVyjadřuje jednotlivý požadavek na to, co mají žáci umět na konci vzdělávacího programu, tzn. jejich požadované kompetence. Je vyjádřen formulací, která je uvozena činnostním slovesem a dále obsahuje předmět této činnosti. Formulace je konkretizována resp. doplněna zpravidla formou odrážek vymezením dílčích znalostí, dovedností, postojů, jejichž splnění je předpokladem dosažení OVU jako celku.\n\n_Příklad:_\n\n<div class=\"joplin-table-wrapper\"><table><tbody><tr><th><p><strong>Žák/žákyně řídí realizaci jednoduchého projektu</strong></p></th></tr><tr><td><ul><li>naplánuje aktivity projektu</li></ul></td></tr><tr><td><ul><li>navrhne rozpočet projektu vzhledem k navrženým aktivitám</li></ul></td></tr><tr><td><ul><li>stanoví základní ukazatele a sleduje jejich naplňování</li></ul></td></tr><tr><td><ul><li>vede projektový tým</li></ul></td></tr><tr><td><ul><li>uvede, jak by řešil krizové situace v projektu</li></ul></td></tr><tr><td><ul><li>vyhodnotí úspěšnost projektu</li></ul></td></tr></tbody></table></div>\n\n**Vzdělávací oblasti**\n\nOčekávané výsledky učení jsou v **_RVP členěny do 4 vzdělávacích oblastí_**, které tvoří společný všeobecně vzdělávací základ:\n\n- Osobnostní rozvoj, vzdělávání ke zdraví, bezpečí a produktivnímu pracovnímu životu (kariéře)\n- Komunikační a jazykové vzdělávání\n- Aplikované vzdělávání STEM (Science, Technology, Engeneering, Math), tj. přírodní vědy, informatika, technika, matematika\n- Prakticky orientované vzdělávání společenskovědní a humanitní\n\nKaždá vzdělávací oblast se dále člení na okruhy, v jejichž rámci jsou OVU samostatně číslované.\n\n<div class=\"joplin-table-wrapper\"><table><tbody><tr><th rowspan=\"21\"><ul><li>Prakticky orientované vzdělávání společenskovědní a humanitní</li></ul></th><th rowspan=\"21\"><p><strong>Člověk, ekonomie a podnikání</strong></p></th><th rowspan=\"7\"><p><strong>1</strong></p></th><th><p><strong>zpracuje podklady související s podnikáním</strong></p></th></tr><tr><td><p>připraví podnikatelský záměr</p></td></tr><tr><td><p>sestaví zakladatelský rozpočet</p></td></tr><tr><td><p>zkalkuluje cenu zboží nebo služby</p></td></tr><tr><td><p>vysvětlí na příkladu základní povinnosti podnikatele vůči státu a zaměstnancům</p></td></tr><tr><td><p>vede daňovou evidenci</p></td></tr><tr><td><p>vysvětlí na příkladech etiku v podnikání</p></td></tr><tr><td rowspan=\"7\"><p><strong>2</strong></p></td><td><p><strong>řídí realizaci jednoduchého projektu</strong></p></td></tr><tr><td><p>naplánuje aktivity projektu</p></td></tr><tr><td><p>navrhne rozpočet projektu vzhledem k navrženým aktivitám</p></td></tr><tr><td><p>stanoví základní ukazatele a sleduje jejich naplňování</p></td></tr><tr><td><p>vede projektový tým</p></td></tr><tr><td><p>uvede, jak by řešil krizové situace v projektu</p></td></tr><tr><td><p>vyhodnotí úspěšnost projektu</p></td></tr><tr><td rowspan=\"7\"><p><strong>3</strong></p></td><td><p><strong>aplikuje ekonomické teorie v osobním a profesním životě</strong></p></td></tr><tr><td><p>vysvětlí základní ekonomické otázky</p></td></tr><tr><td><p>vysvětí stanovení rovnovážné ceny na dokonalém i nedokonalém trhu</p></td></tr><tr><td><p>charakterizuje výrobní faktory a vysvětlí hranici produkčních možností a náklady obětované příležitosti</p></td></tr><tr><td><p>uvede nejdůležitější makroekonomické pojmy a vliv jejich výše na kvalitu života a podnikání v daném státě</p></td></tr><tr><td><p>vysvětlí podstatu inflace a její důsledky na finanční situaci obyvatel a na příkladu ukáže jak se bránit jejím nepříznivým důsledkům</p></td></tr><tr><td><p>uvede hlavní výhody a nevýhody mezinárodního obchodu a vliv ochranářských opatření na ekonomickou situaci dané země</p></td></tr><tr><td></td><td></td><td><p><strong>4</strong></p></td><td><p>Atd.</p></td></tr></tbody></table></div>\n\n**Vyučovací předmět / vzdělávací modul**\n\nOčekávané výsledky učení jsou v **ŠVP** členěny do vyučovacích předmětů nebo vzdělávacích modulů, které jsou dále zařazeny do jednoho nebo více ročníků 4letého studia. Vyučovací předmět / vzdělávací modul tvoří vyučovací jednotku, kde jsou očekávané výsledky učení dále rozpracovány pro potřeby výuky podle následující šablony\n\n| **A. VSTUPNÍ ČÁST** |\n| --- |\n| **1\\. Název** |\n| **2\\. Kód** (kódy by měly být navázány na obory vzdělání a výsledky učení) |\n| **2a) Kategorie vzdělání** - v případě, že nebude součástí kódu |\n| **3\\. Typ vyučovací jednotky** (modul, předmět, stáž apod.) |\n| **4\\. Délka** (počet hodin - dělitelný čtyřmi (optimální modul 16, 32 hodin = týden výuky) |\n| **5\\. Platnost** (datum, od kterého platí) |\n| **6\\. Vstupní předpoklady** (vymezení požadované úrovně vstupních vědomostí a dovedností, které jsou předpokladem úspěšného studia) |\n| |\n| **B. JÁDRO VYUČOVACÍ JEDNOTKY** |\n| **1\\. Charakteristika** (stručná anotace popisující obecné cíle a pojetí) |\n| **2\\. Očekávané výsledky učení a jejich indikátory (převzaté z RVP nebo dále konkretizované)** |\n| **3\\. Podpora rozvoje klíčových kompetencí a základních gramotností** (které klíčové kompetence jsou v rozvíjeny) |\n| **4\\. Obsah vzdělávání** (rozpis učiva) |\n| **5\\. Vzdělávací strategie** (strategie výuky, resp. učební činnosti žáků, které jsou doporučené pro dosažení výsledků) |\n| |\n| **C. VÝSTUPNÍ ČÁST** |\n| **1\\. Způsob ověřování dosažených výsledků** (ve vazbě na jednotlivé výsledky učení) |\n| **2\\. Kritéria hodnocení** (co znamená splnění výsledků učení, kdy je splněna celá vyučovací jednotka, kritéria pro známky, příp. procentuální, slovní hodnocení) |\n| **3\\. Doporučená studijní literatura, odkazy na ilustrační zdroje** |\n| **4\\. Poznámky** |\n\n**Soulad OVU RVP a ŠVP**\n\nTento soulad je předmětem zjišťování. Soulad nastává, jestliže jsou očekávané výsledky učení z jednotlivých vzdělávacích oblastí RVP **obsaženy** ve vyučovacích předmětech/ vzdělávacích modulech ŠVP jednotlivých škol, tzn. že v ŠVP se objevuje jejich formulace buď v doslovném nebo podobném znění v jednom nebo více vyučovacích předmětech/ vzdělávacích modulech.\n\n_Příklad souladu:_\n\nRVP ŠVP - komunikace a marketing (SŠ obchodní Č.\n\n| **2** | **řídí realizaci jednoduchého projektu** |\n| --- | --- |\n| naplánuje aktivity projektu |\n| navrhne rozpočet projektu vzhledem k navrženým aktivitám |\n| stanoví základní ukazatele a sleduje jejich naplňování |\n| vede projektový tým |\n| uvede, jak by řešil krizové situace v projektu |\n| vyhodnotí úspěšnost projektu |\n\nKNOWLEDGE {Porovnání RVP a ŠVP - postup}\n\n\n# AUDITNÍ PROTOKOL ŠVP-RVP\n\n# (POPIS KONTROLNÍHO ALGORITMU)\n\nMetodika je určena pro **Kvantifikaci Shody** školního vzdělávacího programu (ŠVP) s Rámcovým vzdělávacím programem (RVP).\n\n## FÁZE 1: VALIDACE DOKUMENTACE\n\n**Cíl:** Ověřit platnost, aktuálnost a strukturu zdrojových dokumentů.\n\n- **RVP Verifikace:** Otevřít aktuální verzi RVP (např. RVP ZV/G/SOŠ).\n- **Typová shoda:** Ověřit, že RVP se vztahuje k danému typu školy.\n- **ŠVP Dimenze:** Identifikovat a izolovat relevantní části ŠVP: Profil absolventa, Klíčové kompetence (KK), Vzdělávací oblasti (VO), případně Učební plán (UP).\n- **Verzování:** Potvrdit, že obě verze (RVP a ŠVP) jsou nejnovější a platné (včetně dodatků RVP).\n\n## FÁZE 2: DATABÁZOVÉ MAPOVÁNÍ VÝSTUPŮ (MASTER MATICE)\n\n**Cíl:** Vytvořit systémovou databázi pro křížové porovnání všech povinných komponent RVP se ŠVP.\n\n- **Dekompozice RVP:** Rozložit RVP na základní povinné komponenty: Klíčové kompetence, Vzdělávací oblasti a obory, Očekávané výstupy (OVU), Průřezová témata (PT).\n- **Přiřazovací mapa:** Vytvořit hlavní kontrolní matici (Master Matice) pro záznam vazeb.\n\n| Oblast RVP | Výstup RVP (OVU) | Odpovídající Část ŠVP (Předmět/Ročník) | Konkrétní Tématický Celek v ŠVP | Stav Shody (Protokol) |\n| --- | --- | --- | --- | --- |\n| ... | ... | ... | ... | ... |\n| --- | --- | --- | --- | --- |\n\n## FÁZE 3: ALGORITMICKÁ KONTROLA POKRYTÍ A HLOUBKY\n\n**Cíl:** Posoudit, zda každý povinný výstup RVP je adekvátně reflektován v obsahu ŠVP, a přidělit bodovou hodnotu pro kvantifikaci.\n\n- **Audit OVU:** Projít každý jednotlivý Očekávaný výstup (OVU) z RVP.\n- **Kódování stavu a bodování:** U každého OVU v matici označit stav pokrytí dle následujícího schématu:\n\n| Kód (Protokol) | Popis (Kvalitativní zjištění) | Bodová hodnota (Kvantifikace) |\n| --- | --- | --- |\n| ✅ | Plná shoda (Výstup pokryt v plném rozsahu, odpovídající úrovni RVP) | 1,0 |\n| --- | --- | --- |\n| ⚠️ | Částečná shoda (Formální pokrytí, omezený rozsah, chybná návaznost) | 0,5 |\n| --- | --- | --- |\n| ❌ | Absence (Výstup zcela chybí v obsahu ŠVP) | 0,0 |\n| --- | --- | --- |\n\n- **Defektologie ŠVP:** Identifikovat a zaznamenat deficity ŠVP: Chybějící výstupy (❌), Sémantické překryvy, Přetížení obsahu.\n- **Kvalitativní posun:** Ověřit, zda je formulace výstupů v ŠVP **aktivní, měřitelná a v souladu** s úrovní RVP.\n\n## FÁZE 4: STRUKTURÁLNÍ VERIFIKACE NÁVAZNOSTI (VERTIKÁLA/HORIZONTÁLA)\n\n**Cíl:** Zkontrolovat logickou posloupnost a provázanost učiva v rámci ŠVP.\n\n- **Vertikální Kontrola:** Ověřit posloupnost OVU a učiva uvnitř jednoho předmětu/oblasti (postup od jednodušších ke složitějším konceptům napříč ročníky).\n- **Horizontální Kontrola:** Zkontrolovat logické provázání napříč vzdělávacími oblastmi a předměty (např. fyzika ↔ matematika).\n- **PT Integrace:** Audit reálné integrace Průřezových témat (PT) do konkrétních částí obsahu, metod a projektů.\n\n## FÁZE 5: ANALÝZA ŠKOLNÍ PROFILACE A ROZŠÍŘENÍ RVP\n\n**Cíl:** Validovat, že profilace školy je **v souladu** s RVP a nejedná se o **rozpor**.\n\n- **Nekonfliktnost:** Porovnat definovaný Profil absolventa školy s Klíčovými kompetencemi RVP. Profil ŠVP musí RVP rozvíjet, nikoli mu odporovat.\n- **Modularita:** Zkontrolovat, zda volitelné předměty a rozšiřující moduly logicky navazují na vzdělávací oblasti RVP.\n- **Implementace specializace:** Popisně uvést, jak je školní profilace (např. STEM zaměření, projektová výuka) integrována do OVU a kompetencí definovaných RVP.\n\n## FÁZE 6: GENERÁTOR ZÁVĚREČNÉ ZPRÁVY A KVANTIFIKACE\n\n**Cíl:** Syntetizovat výsledky, kvantifikovat soulad a generovat závazné návrhy na korekce.\n\n### 6.1 Kvantifikace Souladu\n\nVypočítat Index shody (IS) na základě bodového hodnocení (Fáze 3):\n\n### 6.2 Interpretace Indexu Shody (IS)\n\nKlasifikace souladu pro standardizované vyhodnocení:\n\n| Interval IS | Klasifikace souladu | Popis |\n| --- | --- | --- |\n| 95-100 % | Výborný soulad | ŠVP plně odpovídá RVP, pouze stylistické nebo formální rozdíly. |\n| --- | --- | --- |\n| 85-94 % | Dobrá shoda | ŠVP pokrývá všechny klíčové výstupy, menší korekce nutné. |\n| --- | --- | --- |\n| 70-84 % | Částečná shoda | Významné nedostatky v některých oblastech, nutná revize obsahu. |\n| --- | --- | --- |\n| < 70 % | Kritická neshoda | ŠVP neplní rámcové požadavky, ohrožuje legislativní soulad. |\n| --- | --- | --- |\n\n### 6.3 Doplňkové Indexy\n\nVypočítat následující doplňkové indexy pro detailní kvalitativní analýzu:\n\n- **Index kompetenčního souladu (IKS):** Poměr pokrytí klíčových kompetencí RVP v ŠVP.\n- **Index průřezové integrace (IPI):** Míra reálné integrace průřezových témat do výuky.\n- **Index hloubky pokrytí (IHP):** Procento výstupů, které jsou v ŠVP rozvedeny na konkrétní výukové cíle (měřitelné, aktivní formulace).\n- **Index profilové rozšiřitelnosti (IPR):** Kolik rozšiřujících nebo profilových výstupů přesahuje rámec RVP, aniž by narušily jeho strukturu.\n\n### 6.4 Vizuální výstupy\n\nZajistit generování následujících vizualizací pro Závěrečnou zprávu:\n\n- Graf pokrytí po vzdělávacích oblastech (Sloupcový graf IS pro VO).\n- Pavoukový diagram Klíčových kompetencí (RVP vs. ŠVP).\n- Mapa defektů (Vizualizace ❌ a ⚠️ výstupů).\n\n### 6.5 Struktura Závěrečné Zprávy\n\nZpráva musí být strukturována dle standardizovaného formátu:\n\n| Oddíl | Obsah |\n| --- | --- |\n| A. Identifikace | Název školy, IZO, typ školy, datum revize, zpracovatel, verze ŠVP a RVP. |\n| --- | --- |\n| B. Shrnutí výsledků | Celkový Index Shody (IS), hlavní závěry a doporučení. |\n| --- | --- |\n| C. Kvantitativní analýza | Přehled IS v % dle kategorií OVU / VO / kompetencí. |\n| --- | --- |\n| D. Kvalitativní analýza | Slovní zhodnocení kvality souladu (formulace, obtížnost, integrace PT). |\n| --- | --- |\n| E. Rizikové oblasti | Přehled nalezených defektů (chybějící OVU, přetížení, formální shoda). |\n| --- | --- |\n| F. Návrhy opatření (Korekční plán) | Přesné návrhy změn - **Co, Kde, Kdo** má upravit, včetně termínu. |\n| --- | --- |\n| G. Přílohy | Master Matice (Fáze 2-3), revizní tabulka, výstupní grafy a metriky. |\n| --- | --- |\n\n\n\n\n.\n"}],sourceFile:"./books/examples/lsvp-asistent.book"}];
|
|
3257
|
+
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"}];
|
|
3181
3258
|
|
|
3182
3259
|
/**
|
|
3183
3260
|
* Checks if value is valid email
|
|
@@ -3254,6 +3331,8 @@ function isValidFilePath(filename) {
|
|
|
3254
3331
|
* Function `validatePipelineString` will validate the if the string is a valid pipeline string
|
|
3255
3332
|
* 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.
|
|
3256
3333
|
*
|
|
3334
|
+
* Note: [🔂] This function is idempotent.
|
|
3335
|
+
*
|
|
3257
3336
|
* @param {string} pipelineString the candidate for a pipeline string
|
|
3258
3337
|
* @returns {PipelineString} the same string as input, but validated as valid
|
|
3259
3338
|
* @throws {ParseError} if the string is not a valid pipeline string
|
|
@@ -3413,7 +3492,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
3413
3492
|
pipelineString += '\n\n';
|
|
3414
3493
|
pipelineString += '```' + contentLanguage;
|
|
3415
3494
|
pipelineString += '\n';
|
|
3416
|
-
pipelineString += spaceTrim(content);
|
|
3495
|
+
pipelineString += spaceTrim$2(content);
|
|
3417
3496
|
// <- TODO: [main] !!3 Escape
|
|
3418
3497
|
// <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
|
|
3419
3498
|
pipelineString += '\n';
|
|
@@ -3501,7 +3580,7 @@ function unpreparePipeline(pipeline) {
|
|
|
3501
3580
|
* Library of pipelines that groups together pipelines for an application.
|
|
3502
3581
|
* This implementation is a very thin wrapper around the Array / Map of pipelines.
|
|
3503
3582
|
*
|
|
3504
|
-
* @private internal function of `
|
|
3583
|
+
* @private internal function of `createPipelineCollectionFromJson`, use `createPipelineCollectionFromJson` instead
|
|
3505
3584
|
* @see https://github.com/webgptorg/pipeline#pipeline-collection
|
|
3506
3585
|
*/
|
|
3507
3586
|
class SimplePipelineCollection {
|
|
@@ -3511,7 +3590,7 @@ class SimplePipelineCollection {
|
|
|
3511
3590
|
* @param pipelines Array of pipeline JSON objects to include in the collection
|
|
3512
3591
|
*
|
|
3513
3592
|
* Note: During the construction logic of all pipelines are validated
|
|
3514
|
-
* Note: It is not recommended to use this constructor directly, use `
|
|
3593
|
+
* Note: It is not recommended to use this constructor directly, use `createPipelineCollectionFromJson` *(or other variant)* instead
|
|
3515
3594
|
*/
|
|
3516
3595
|
constructor(...pipelines) {
|
|
3517
3596
|
this.collection = new Map();
|
|
@@ -3599,16 +3678,16 @@ class SimplePipelineCollection {
|
|
|
3599
3678
|
}
|
|
3600
3679
|
|
|
3601
3680
|
/**
|
|
3602
|
-
* Creates PipelineCollection from array of PipelineJson or PipelineString
|
|
3681
|
+
* Creates `PipelineCollection` from array of PipelineJson or PipelineString
|
|
3603
3682
|
*
|
|
3604
|
-
* Note: Functions `
|
|
3683
|
+
* Note: Functions `pipelineCollectionToJson` and `createPipelineCollectionFromJson` are complementary
|
|
3605
3684
|
* Note: Syntax, parsing, and logic consistency checks are performed on all sources during build
|
|
3606
3685
|
*
|
|
3607
3686
|
* @param promptbookSources
|
|
3608
3687
|
* @returns PipelineCollection
|
|
3609
3688
|
* @public exported from `@promptbook/core`
|
|
3610
3689
|
*/
|
|
3611
|
-
function
|
|
3690
|
+
function createPipelineCollectionFromJson(...promptbooks) {
|
|
3612
3691
|
return new SimplePipelineCollection(...promptbooks);
|
|
3613
3692
|
}
|
|
3614
3693
|
|
|
@@ -3809,14 +3888,14 @@ class MultipleLlmExecutionTools {
|
|
|
3809
3888
|
if (description === undefined) {
|
|
3810
3889
|
return headLine;
|
|
3811
3890
|
}
|
|
3812
|
-
return spaceTrim((block) => `
|
|
3891
|
+
return spaceTrim$2((block) => `
|
|
3813
3892
|
${headLine}
|
|
3814
3893
|
|
|
3815
3894
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
3816
3895
|
`);
|
|
3817
3896
|
})
|
|
3818
3897
|
.join('\n\n');
|
|
3819
|
-
return spaceTrim((block) => `
|
|
3898
|
+
return spaceTrim$2((block) => `
|
|
3820
3899
|
Multiple LLM Providers:
|
|
3821
3900
|
|
|
3822
3901
|
${block(innerModelsTitlesAndDescriptions)}
|
|
@@ -3907,7 +3986,7 @@ class MultipleLlmExecutionTools {
|
|
|
3907
3986
|
// 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
3908
3987
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
3909
3988
|
// 3) ...
|
|
3910
|
-
spaceTrim((block) => `
|
|
3989
|
+
spaceTrim$2((block) => `
|
|
3911
3990
|
All execution tools of ${this.title} failed:
|
|
3912
3991
|
|
|
3913
3992
|
${block(errors
|
|
@@ -3920,7 +3999,7 @@ class MultipleLlmExecutionTools {
|
|
|
3920
3999
|
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
|
|
3921
4000
|
}
|
|
3922
4001
|
else {
|
|
3923
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
4002
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
3924
4003
|
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
|
|
3925
4004
|
|
|
3926
4005
|
Available \`LlmExecutionTools\`:
|
|
@@ -3953,7 +4032,7 @@ class MultipleLlmExecutionTools {
|
|
|
3953
4032
|
*/
|
|
3954
4033
|
function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
3955
4034
|
if (llmExecutionTools.length === 0) {
|
|
3956
|
-
const warningMessage = spaceTrim(`
|
|
4035
|
+
const warningMessage = spaceTrim$2(`
|
|
3957
4036
|
You have not provided any \`LlmExecutionTools\`
|
|
3958
4037
|
This means that you won't be able to execute any prompts that require large language models like GPT-4 or Anthropic's Claude.
|
|
3959
4038
|
|
|
@@ -3986,6 +4065,7 @@ function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
|
3986
4065
|
return new MultipleLlmExecutionTools(title || 'Multiple LLM Providers joined by `joinLlmExecutionTools`', ...llmExecutionTools);
|
|
3987
4066
|
}
|
|
3988
4067
|
/**
|
|
4068
|
+
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
3989
4069
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
3990
4070
|
*/
|
|
3991
4071
|
|
|
@@ -4002,6 +4082,7 @@ function getSingleLlmExecutionTools(oneOrMoreLlmExecutionTools) {
|
|
|
4002
4082
|
return llmTools;
|
|
4003
4083
|
}
|
|
4004
4084
|
/**
|
|
4085
|
+
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
4005
4086
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
4006
4087
|
*/
|
|
4007
4088
|
|
|
@@ -4017,7 +4098,7 @@ async function preparePersona(personaDescription, tools, options) {
|
|
|
4017
4098
|
throw new MissingToolsError('LLM tools are required for preparing persona');
|
|
4018
4099
|
}
|
|
4019
4100
|
// TODO: [🌼] In future use `ptbk make` and made getPipelineCollection
|
|
4020
|
-
const collection =
|
|
4101
|
+
const collection = createPipelineCollectionFromJson(...PipelineCollection);
|
|
4021
4102
|
const preparePersonaExecutor = createPipelineExecutor({
|
|
4022
4103
|
pipeline: await collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book'),
|
|
4023
4104
|
tools,
|
|
@@ -4268,14 +4349,14 @@ function $registeredScrapersMessage(availableScrapers) {
|
|
|
4268
4349
|
return { ...metadata, isMetadataAviailable, isInstalled, isAvailableInTools };
|
|
4269
4350
|
});
|
|
4270
4351
|
if (metadata.length === 0) {
|
|
4271
|
-
return spaceTrim(`
|
|
4352
|
+
return spaceTrim$2(`
|
|
4272
4353
|
**No scrapers are available**
|
|
4273
4354
|
|
|
4274
4355
|
This is a unexpected behavior, you are probably using some broken version of Promptbook
|
|
4275
4356
|
At least there should be available the metadata of the scrapers
|
|
4276
4357
|
`);
|
|
4277
4358
|
}
|
|
4278
|
-
return spaceTrim((block) => `
|
|
4359
|
+
return spaceTrim$2((block) => `
|
|
4279
4360
|
Available scrapers are:
|
|
4280
4361
|
${block(metadata
|
|
4281
4362
|
.map(({ packageName, className, isMetadataAviailable, isInstalled, mimeTypes, isAvailableInBrowser, isAvailableInTools, }, i) => {
|
|
@@ -4583,6 +4664,8 @@ function removeDiacritics(input) {
|
|
|
4583
4664
|
/**
|
|
4584
4665
|
* Converts a given text to kebab-case format.
|
|
4585
4666
|
*
|
|
4667
|
+
* Note: [🔂] This function is idempotent.
|
|
4668
|
+
*
|
|
4586
4669
|
* @param text The text to be converted.
|
|
4587
4670
|
* @returns The kebab-case formatted string.
|
|
4588
4671
|
* @example 'hello-world'
|
|
@@ -4738,6 +4821,8 @@ function removeEmojis(text) {
|
|
|
4738
4821
|
/**
|
|
4739
4822
|
* Converts a title string into a normalized name.
|
|
4740
4823
|
*
|
|
4824
|
+
* Note: [🔂] This function is idempotent.
|
|
4825
|
+
*
|
|
4741
4826
|
* @param value The title string to be converted to a name.
|
|
4742
4827
|
* @returns A normalized name derived from the input title.
|
|
4743
4828
|
* @example 'Hello World!' -> 'hello-world'
|
|
@@ -4777,7 +4862,7 @@ const promptbookFetch = async (urlOrRequest, init) => {
|
|
|
4777
4862
|
else if (urlOrRequest instanceof Request) {
|
|
4778
4863
|
url = urlOrRequest.url;
|
|
4779
4864
|
}
|
|
4780
|
-
throw new PromptbookFetchError(spaceTrim((block) => `
|
|
4865
|
+
throw new PromptbookFetchError(spaceTrim$2((block) => `
|
|
4781
4866
|
Can not fetch "${url}"
|
|
4782
4867
|
|
|
4783
4868
|
Fetch error:
|
|
@@ -4938,7 +5023,7 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
4938
5023
|
const fileExtension = getFileExtension(filename);
|
|
4939
5024
|
const mimeType = extensionToMimeType(fileExtension || '');
|
|
4940
5025
|
if (!(await isFileExisting(filename, tools.fs))) {
|
|
4941
|
-
throw new NotFoundError(spaceTrim((block) => `
|
|
5026
|
+
throw new NotFoundError(spaceTrim$2((block) => `
|
|
4942
5027
|
Can not make source handler for file which does not exist:
|
|
4943
5028
|
|
|
4944
5029
|
File:
|
|
@@ -5031,7 +5116,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
5031
5116
|
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
5032
5117
|
break;
|
|
5033
5118
|
}
|
|
5034
|
-
console.warn(spaceTrim((block) => `
|
|
5119
|
+
console.warn(spaceTrim$2((block) => `
|
|
5035
5120
|
Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
|
|
5036
5121
|
|
|
5037
5122
|
The source:
|
|
@@ -5047,7 +5132,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
5047
5132
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
5048
5133
|
}
|
|
5049
5134
|
if (partialPieces === null) {
|
|
5050
|
-
throw new KnowledgeScrapeError(spaceTrim((block) => `
|
|
5135
|
+
throw new KnowledgeScrapeError(spaceTrim$2((block) => `
|
|
5051
5136
|
Cannot scrape knowledge
|
|
5052
5137
|
|
|
5053
5138
|
The source:
|
|
@@ -5212,7 +5297,7 @@ async function preparePipeline(pipeline, tools, options) {
|
|
|
5212
5297
|
let title = pipeline.title;
|
|
5213
5298
|
if (title === undefined || title === '' || title === DEFAULT_BOOK_TITLE) {
|
|
5214
5299
|
// TODO: [🌼] In future use `ptbk make` and made getPipelineCollection
|
|
5215
|
-
const collection =
|
|
5300
|
+
const collection = createPipelineCollectionFromJson(...PipelineCollection);
|
|
5216
5301
|
const prepareTitleExecutor = createPipelineExecutor({
|
|
5217
5302
|
pipeline: await collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-title.book'),
|
|
5218
5303
|
tools,
|
|
@@ -5622,7 +5707,7 @@ const CsvFormatParser = {
|
|
|
5622
5707
|
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
5623
5708
|
const csv = csvParse(value, settings);
|
|
5624
5709
|
if (csv.errors.length !== 0) {
|
|
5625
|
-
throw new CsvFormatError(spaceTrim((block) => `
|
|
5710
|
+
throw new CsvFormatError(spaceTrim$2((block) => `
|
|
5626
5711
|
CSV parsing error
|
|
5627
5712
|
|
|
5628
5713
|
Error(s) from CSV parsing:
|
|
@@ -5667,7 +5752,7 @@ const CsvFormatParser = {
|
|
|
5667
5752
|
const { value, settings, mapCallback, onProgress } = options;
|
|
5668
5753
|
const csv = csvParse(value, settings);
|
|
5669
5754
|
if (csv.errors.length !== 0) {
|
|
5670
|
-
throw new CsvFormatError(spaceTrim((block) => `
|
|
5755
|
+
throw new CsvFormatError(spaceTrim$2((block) => `
|
|
5671
5756
|
CSV parsing error
|
|
5672
5757
|
|
|
5673
5758
|
Error(s) from CSV parsing:
|
|
@@ -5877,7 +5962,7 @@ function mapAvailableToExpectedParameters(options) {
|
|
|
5877
5962
|
}
|
|
5878
5963
|
// Phase 2️⃣: Non-matching mapping
|
|
5879
5964
|
if (expectedParameterNames.size !== availableParametersNames.size) {
|
|
5880
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
5965
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
5881
5966
|
Can not map available parameters to expected parameters
|
|
5882
5967
|
|
|
5883
5968
|
Mapped parameters:
|
|
@@ -6141,10 +6226,13 @@ const LINES_PER_STANDARD_PAGE = 44;
|
|
|
6141
6226
|
* @public exported from `@promptbook/utils`
|
|
6142
6227
|
*/
|
|
6143
6228
|
function countLines(text) {
|
|
6229
|
+
if (text === '') {
|
|
6230
|
+
return 0;
|
|
6231
|
+
}
|
|
6144
6232
|
text = text.replace('\r\n', '\n');
|
|
6145
6233
|
text = text.replace('\r', '\n');
|
|
6146
6234
|
const lines = text.split('\n');
|
|
6147
|
-
return lines.reduce((count, line) => count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 0);
|
|
6235
|
+
return lines.reduce((count, line) => count + Math.max(Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 1), 0);
|
|
6148
6236
|
}
|
|
6149
6237
|
/**
|
|
6150
6238
|
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
@@ -6269,6 +6357,8 @@ function checkExpectations(expectations, value) {
|
|
|
6269
6357
|
* This function provides a common abstraction for result validation that can be used
|
|
6270
6358
|
* by both execution logic and caching logic to ensure consistency.
|
|
6271
6359
|
*
|
|
6360
|
+
* Note: [🔂] This function is idempotent.
|
|
6361
|
+
*
|
|
6272
6362
|
* @param options - The validation options including result string, expectations, and format
|
|
6273
6363
|
* @returns Validation result with processed string and validity status
|
|
6274
6364
|
* @private internal function of `createPipelineExecutor` and `cacheLlmTools`
|
|
@@ -6337,7 +6427,7 @@ function validatePromptResult(options) {
|
|
|
6337
6427
|
*/
|
|
6338
6428
|
async function executeAttempts(options) {
|
|
6339
6429
|
const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
|
|
6340
|
-
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, } = options;
|
|
6430
|
+
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall, } = options;
|
|
6341
6431
|
const $ongoingTaskResult = {
|
|
6342
6432
|
$result: null,
|
|
6343
6433
|
$resultString: null,
|
|
@@ -6585,14 +6675,10 @@ async function executeAttempts(options) {
|
|
|
6585
6675
|
});
|
|
6586
6676
|
}
|
|
6587
6677
|
finally {
|
|
6588
|
-
if (!isJokerAttempt &&
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
// In that case we don’t want to make a report about it because it’s not a llm execution error
|
|
6593
|
-
) {
|
|
6594
|
-
// TODO: [🧠] Maybe put other taskTypes into report
|
|
6595
|
-
$executionReport.promptExecutions.push({
|
|
6678
|
+
if (!isJokerAttempt && task.taskType === 'PROMPT_TASK' && $ongoingTaskResult.$prompt) {
|
|
6679
|
+
// Note: [2] When some expected parameter is not defined, error will occur in templateParameters
|
|
6680
|
+
// In that case we don’t want to make a report about it because it’s not a llm execution error
|
|
6681
|
+
const executionPromptReport = {
|
|
6596
6682
|
prompt: {
|
|
6597
6683
|
...$ongoingTaskResult.$prompt,
|
|
6598
6684
|
// <- TODO: [🧠] How to pick everyhing except `pipelineUrl`
|
|
@@ -6601,7 +6687,14 @@ async function executeAttempts(options) {
|
|
|
6601
6687
|
error: $ongoingTaskResult.$expectError === null
|
|
6602
6688
|
? undefined
|
|
6603
6689
|
: serializeError($ongoingTaskResult.$expectError),
|
|
6604
|
-
}
|
|
6690
|
+
};
|
|
6691
|
+
$executionReport.promptExecutions.push(executionPromptReport);
|
|
6692
|
+
if (logLlmCall) {
|
|
6693
|
+
logLlmCall({
|
|
6694
|
+
modelName: 'model' /* <- TODO: How to get model name from the report */,
|
|
6695
|
+
report: executionPromptReport,
|
|
6696
|
+
});
|
|
6697
|
+
}
|
|
6605
6698
|
}
|
|
6606
6699
|
}
|
|
6607
6700
|
if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
|
|
@@ -6666,12 +6759,12 @@ async function executeAttempts(options) {
|
|
|
6666
6759
|
* @private internal utility of `createPipelineExecutor`
|
|
6667
6760
|
*/
|
|
6668
6761
|
async function executeFormatSubvalues(options) {
|
|
6669
|
-
const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, pipelineIdentification } = options;
|
|
6762
|
+
const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, logLlmCall, pipelineIdentification, } = options;
|
|
6670
6763
|
if (task.foreach === undefined) {
|
|
6671
|
-
return /* not await */ executeAttempts(options);
|
|
6764
|
+
return /* not await */ executeAttempts({ ...options, logLlmCall });
|
|
6672
6765
|
}
|
|
6673
6766
|
if (jokerParameterNames.length !== 0) {
|
|
6674
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
6767
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
6675
6768
|
JOKER parameters are not supported together with FOREACH command
|
|
6676
6769
|
|
|
6677
6770
|
[🧞♀️] This should be prevented in \`validatePipeline\`
|
|
@@ -6684,7 +6777,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6684
6777
|
if (formatDefinition === undefined) {
|
|
6685
6778
|
throw new UnexpectedError(
|
|
6686
6779
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
6687
|
-
spaceTrim((block) => `
|
|
6780
|
+
spaceTrim$2((block) => `
|
|
6688
6781
|
Unsupported format "${task.foreach.formatName}"
|
|
6689
6782
|
|
|
6690
6783
|
Available formats:
|
|
@@ -6701,7 +6794,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6701
6794
|
if (subvalueParser === undefined) {
|
|
6702
6795
|
throw new UnexpectedError(
|
|
6703
6796
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
6704
|
-
spaceTrim((block) => `
|
|
6797
|
+
spaceTrim$2((block) => `
|
|
6705
6798
|
Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
|
|
6706
6799
|
|
|
6707
6800
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -6741,7 +6834,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6741
6834
|
if (!(error instanceof PipelineExecutionError)) {
|
|
6742
6835
|
throw error;
|
|
6743
6836
|
}
|
|
6744
|
-
const highLevelError = new PipelineExecutionError(spaceTrim((block) => `
|
|
6837
|
+
const highLevelError = new PipelineExecutionError(spaceTrim$2((block) => `
|
|
6745
6838
|
${error.message}
|
|
6746
6839
|
|
|
6747
6840
|
This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -6765,7 +6858,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6765
6858
|
...options,
|
|
6766
6859
|
priority: priority + index,
|
|
6767
6860
|
parameters: allSubparameters,
|
|
6768
|
-
pipelineIdentification: spaceTrim((block) => `
|
|
6861
|
+
pipelineIdentification: spaceTrim$2((block) => `
|
|
6769
6862
|
${block(pipelineIdentification)}
|
|
6770
6863
|
Subparameter index: ${index}
|
|
6771
6864
|
`),
|
|
@@ -6774,7 +6867,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6774
6867
|
}
|
|
6775
6868
|
catch (error) {
|
|
6776
6869
|
if (length > BIG_DATASET_TRESHOLD) {
|
|
6777
|
-
console.error(spaceTrim((block) => `
|
|
6870
|
+
console.error(spaceTrim$2((block) => `
|
|
6778
6871
|
${error.message}
|
|
6779
6872
|
|
|
6780
6873
|
This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -6874,7 +6967,7 @@ async function getKnowledgeForTask(options) {
|
|
|
6874
6967
|
},
|
|
6875
6968
|
content: task.content,
|
|
6876
6969
|
parameters,
|
|
6877
|
-
};
|
|
6970
|
+
}; /* <- Note: [🤛] */
|
|
6878
6971
|
const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
|
|
6879
6972
|
const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
|
|
6880
6973
|
const { index } = knowledgePiece;
|
|
@@ -6969,7 +7062,7 @@ async function getReservedParametersForTask(options) {
|
|
|
6969
7062
|
* @private internal utility of `createPipelineExecutor`
|
|
6970
7063
|
*/
|
|
6971
7064
|
async function executeTask(options) {
|
|
6972
|
-
const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSuppressed, } = options;
|
|
7065
|
+
const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, logLlmCall, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSuppressed, } = options;
|
|
6973
7066
|
const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
|
|
6974
7067
|
// Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but it’s good to doublecheck
|
|
6975
7068
|
const usedParameterNames = extractParameterNamesFromTask(currentTask);
|
|
@@ -7048,6 +7141,7 @@ async function executeTask(options) {
|
|
|
7048
7141
|
tools,
|
|
7049
7142
|
$executionReport,
|
|
7050
7143
|
onProgress,
|
|
7144
|
+
logLlmCall,
|
|
7051
7145
|
pipelineIdentification,
|
|
7052
7146
|
maxExecutionAttempts,
|
|
7053
7147
|
maxParallelCount,
|
|
@@ -7091,6 +7185,29 @@ function filterJustOutputParameters(options) {
|
|
|
7091
7185
|
$warnings.push(new PipelineExecutionError(spaceTrim$1((block) => `
|
|
7092
7186
|
Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
|
|
7093
7187
|
|
|
7188
|
+
Note: This is a warning which happened after the pipeline was executed, and \`{${parameter.name}}\` was not for some reason defined in output parameters
|
|
7189
|
+
|
|
7190
|
+
All parameters:
|
|
7191
|
+
${block(preparedPipeline.parameters
|
|
7192
|
+
.map(({ name, isInput, isOutput, description }) => {
|
|
7193
|
+
let line = `\`{${name}}\``;
|
|
7194
|
+
if (isInput) {
|
|
7195
|
+
line += ' `[input parameter]`';
|
|
7196
|
+
}
|
|
7197
|
+
if (isOutput) {
|
|
7198
|
+
line += ' `[output parameter]`';
|
|
7199
|
+
}
|
|
7200
|
+
if (parametersToPass[name] === undefined) {
|
|
7201
|
+
line += ` <- Warning: Should be in the output but its not |`;
|
|
7202
|
+
}
|
|
7203
|
+
if (description) {
|
|
7204
|
+
line += ` ${description}`;
|
|
7205
|
+
}
|
|
7206
|
+
return line;
|
|
7207
|
+
})
|
|
7208
|
+
.map((line, index) => `${index + 1}) ${line}`)
|
|
7209
|
+
.join('\n'))}
|
|
7210
|
+
|
|
7094
7211
|
${block(pipelineIdentification)}
|
|
7095
7212
|
`)));
|
|
7096
7213
|
continue;
|
|
@@ -7111,7 +7228,7 @@ function filterJustOutputParameters(options) {
|
|
|
7111
7228
|
* @private internal utility of `createPipelineExecutor`
|
|
7112
7229
|
*/
|
|
7113
7230
|
async function executePipeline(options) {
|
|
7114
|
-
const { inputParameters, tools, onProgress, pipeline, setPreparedPipeline, pipelineIdentification, maxParallelCount, rootDirname, isVerbose, } = options;
|
|
7231
|
+
const { inputParameters, tools, onProgress, logLlmCall, pipeline, setPreparedPipeline, pipelineIdentification, maxParallelCount, rootDirname, isVerbose, } = options;
|
|
7115
7232
|
let { preparedPipeline } = options;
|
|
7116
7233
|
if (preparedPipeline === undefined) {
|
|
7117
7234
|
preparedPipeline = await preparePipeline(pipeline, tools, {
|
|
@@ -7289,6 +7406,7 @@ async function executePipeline(options) {
|
|
|
7289
7406
|
onProgress(newOngoingResult);
|
|
7290
7407
|
}
|
|
7291
7408
|
},
|
|
7409
|
+
logLlmCall,
|
|
7292
7410
|
$executionReport: executionReport,
|
|
7293
7411
|
pipelineIdentification: spaceTrim$1((block) => `
|
|
7294
7412
|
${block(pipelineIdentification)}
|
|
@@ -7412,7 +7530,7 @@ function createPipelineExecutor(options) {
|
|
|
7412
7530
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
7413
7531
|
}
|
|
7414
7532
|
let runCount = 0;
|
|
7415
|
-
const pipelineExecutorWithCallback = async (inputParameters, onProgress) => {
|
|
7533
|
+
const pipelineExecutorWithCallback = async (inputParameters, onProgress, logLlmCall) => {
|
|
7416
7534
|
runCount++;
|
|
7417
7535
|
return /* not await */ executePipeline({
|
|
7418
7536
|
pipeline,
|
|
@@ -7423,6 +7541,7 @@ function createPipelineExecutor(options) {
|
|
|
7423
7541
|
inputParameters,
|
|
7424
7542
|
tools,
|
|
7425
7543
|
onProgress,
|
|
7544
|
+
logLlmCall,
|
|
7426
7545
|
pipelineIdentification: spaceTrim$1((block) => `
|
|
7427
7546
|
${block(pipelineIdentification)}
|
|
7428
7547
|
${runCount === 1 ? '' : `Run #${runCount}`}
|
|
@@ -7626,10 +7745,10 @@ function $registeredLlmToolsMessage() {
|
|
|
7626
7745
|
var _a, _b;
|
|
7627
7746
|
const isMetadataAviailable = $llmToolsMetadataRegister
|
|
7628
7747
|
.list()
|
|
7629
|
-
.
|
|
7748
|
+
.some(({ packageName, className }) => metadata.packageName === packageName && metadata.className === className);
|
|
7630
7749
|
const isInstalled = $llmToolsRegister
|
|
7631
7750
|
.list()
|
|
7632
|
-
.
|
|
7751
|
+
.some(({ packageName, className }) => metadata.packageName === packageName && metadata.className === className);
|
|
7633
7752
|
const isFullyConfigured = ((_a = metadata.envVariables) === null || _a === void 0 ? void 0 : _a.every((envVariableName) => env[envVariableName] !== undefined)) || false;
|
|
7634
7753
|
const isPartiallyConfigured = ((_b = metadata.envVariables) === null || _b === void 0 ? void 0 : _b.some((envVariableName) => env[envVariableName] !== undefined)) || false;
|
|
7635
7754
|
// <- Note: [🗨]
|
|
@@ -7637,13 +7756,13 @@ function $registeredLlmToolsMessage() {
|
|
|
7637
7756
|
});
|
|
7638
7757
|
const usedEnvMessage = `Unknown \`.env\` file` ;
|
|
7639
7758
|
if (metadata.length === 0) {
|
|
7640
|
-
return spaceTrim((block) => `
|
|
7759
|
+
return spaceTrim$2((block) => `
|
|
7641
7760
|
No LLM providers are available.
|
|
7642
7761
|
|
|
7643
7762
|
${block(usedEnvMessage)}
|
|
7644
7763
|
`);
|
|
7645
7764
|
}
|
|
7646
|
-
return spaceTrim((block) => `
|
|
7765
|
+
return spaceTrim$2((block) => `
|
|
7647
7766
|
|
|
7648
7767
|
${block(usedEnvMessage)}
|
|
7649
7768
|
|
|
@@ -7689,7 +7808,7 @@ function $registeredLlmToolsMessage() {
|
|
|
7689
7808
|
morePieces.push(`Not configured`); // <- Note: Can not be configured via environment variables
|
|
7690
7809
|
}
|
|
7691
7810
|
}
|
|
7692
|
-
let providerMessage = spaceTrim(`
|
|
7811
|
+
let providerMessage = spaceTrim$2(`
|
|
7693
7812
|
${i + 1}) **${title}** \`${className}\` from \`${packageName}\`
|
|
7694
7813
|
${morePieces.join('; ')}
|
|
7695
7814
|
`);
|
|
@@ -7735,7 +7854,7 @@ function createLlmToolsFromConfiguration(configuration, options = {}) {
|
|
|
7735
7854
|
.find(({ packageName, className }) => llmConfiguration.packageName === packageName && llmConfiguration.className === className);
|
|
7736
7855
|
if (registeredItem === undefined) {
|
|
7737
7856
|
// console.log('$llmToolsRegister.list()', $llmToolsRegister.list());
|
|
7738
|
-
throw new Error(spaceTrim((block) => `
|
|
7857
|
+
throw new Error(spaceTrim$2((block) => `
|
|
7739
7858
|
There is no constructor for LLM provider \`${llmConfiguration.className}\` from \`${llmConfiguration.packageName}\`
|
|
7740
7859
|
Running in ${!$isRunningInBrowser() ? '' : 'browser environment'}${!$isRunningInNode() ? '' : 'node environment'}${!$isRunningInWebWorker() ? '' : 'worker environment'}
|
|
7741
7860
|
|
|
@@ -7806,6 +7925,8 @@ async function $provideScrapersForNode(tools, options) {
|
|
|
7806
7925
|
/**
|
|
7807
7926
|
* Normalizes a given text to camelCase format.
|
|
7808
7927
|
*
|
|
7928
|
+
* Note: [🔂] This function is idempotent.
|
|
7929
|
+
*
|
|
7809
7930
|
* @param text The text to be normalized.
|
|
7810
7931
|
* @param _isFirstLetterCapital Whether the first letter should be capitalized.
|
|
7811
7932
|
* @returns The camelCase formatted string.
|
|
@@ -7932,6 +8053,9 @@ function nameToUriParts(name) {
|
|
|
7932
8053
|
}
|
|
7933
8054
|
|
|
7934
8055
|
/**
|
|
8056
|
+
* Normalizes a given text to PascalCase format.
|
|
8057
|
+
*
|
|
8058
|
+
* Note: [🔂] This function is idempotent.
|
|
7935
8059
|
*
|
|
7936
8060
|
* @param text @public exported from `@promptbook/utils`
|
|
7937
8061
|
* @returns
|
|
@@ -8068,7 +8192,7 @@ function unwrapResult(text, options) {
|
|
|
8068
8192
|
function extractOneBlockFromMarkdown(markdown) {
|
|
8069
8193
|
const codeBlocks = extractAllBlocksFromMarkdown(markdown);
|
|
8070
8194
|
if (codeBlocks.length !== 1) {
|
|
8071
|
-
throw new ParseError(spaceTrim((block) => `
|
|
8195
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
8072
8196
|
There should be exactly 1 code block in task section, found ${codeBlocks.length} code blocks
|
|
8073
8197
|
|
|
8074
8198
|
${block(codeBlocks.map((block, i) => `Block ${i + 1}:\n${block.content}`).join('\n\n\n'))}
|
|
@@ -8177,8 +8301,8 @@ class JavascriptEvalExecutionTools {
|
|
|
8177
8301
|
}
|
|
8178
8302
|
// Note: [💎]
|
|
8179
8303
|
// Note: Using direct eval, following variables are in same scope as eval call so they are accessible from inside the evaluated script:
|
|
8180
|
-
const spaceTrim
|
|
8181
|
-
$preserve(spaceTrim
|
|
8304
|
+
const spaceTrim = (_) => spaceTrim$2(_);
|
|
8305
|
+
$preserve(spaceTrim);
|
|
8182
8306
|
const removeQuotes$1 = removeQuotes;
|
|
8183
8307
|
$preserve(removeQuotes$1);
|
|
8184
8308
|
const unwrapResult$1 = unwrapResult;
|
|
@@ -8231,7 +8355,7 @@ class JavascriptEvalExecutionTools {
|
|
|
8231
8355
|
// TODO: DRY [🍯]
|
|
8232
8356
|
const buildinFunctions = {
|
|
8233
8357
|
// TODO: [🍯] DRY all these functions across the file
|
|
8234
|
-
spaceTrim
|
|
8358
|
+
spaceTrim,
|
|
8235
8359
|
removeQuotes: removeQuotes$1,
|
|
8236
8360
|
unwrapResult: unwrapResult$1,
|
|
8237
8361
|
trimEndOfCodeBlock: trimEndOfCodeBlock$1,
|
|
@@ -8268,7 +8392,7 @@ class JavascriptEvalExecutionTools {
|
|
|
8268
8392
|
.join('\n');
|
|
8269
8393
|
// script = templateParameters(script, parameters);
|
|
8270
8394
|
// <- TODO: [🧠][🥳] Should be this is one of two variants how to use parameters in script
|
|
8271
|
-
const statementToEvaluate = spaceTrim((block) => `
|
|
8395
|
+
const statementToEvaluate = spaceTrim$2((block) => `
|
|
8272
8396
|
|
|
8273
8397
|
// Build-in functions:
|
|
8274
8398
|
${block(buildinFunctionsStatement)}
|
|
@@ -8283,7 +8407,7 @@ class JavascriptEvalExecutionTools {
|
|
|
8283
8407
|
(()=>{ ${script} })()
|
|
8284
8408
|
`);
|
|
8285
8409
|
if (this.options.isVerbose) {
|
|
8286
|
-
console.info(spaceTrim((block) => `
|
|
8410
|
+
console.info(spaceTrim$2((block) => `
|
|
8287
8411
|
🚀 Evaluating ${scriptLanguage} script:
|
|
8288
8412
|
|
|
8289
8413
|
${block(statementToEvaluate)}`));
|
|
@@ -8305,7 +8429,7 @@ class JavascriptEvalExecutionTools {
|
|
|
8305
8429
|
To: [PipelineExecutionError: Parameter `{thing}` is not defined],
|
|
8306
8430
|
*/
|
|
8307
8431
|
if (!statementToEvaluate.includes(undefinedName + '(')) {
|
|
8308
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
8432
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
8309
8433
|
|
|
8310
8434
|
Parameter \`{${undefinedName}}\` is not defined
|
|
8311
8435
|
|
|
@@ -8327,7 +8451,7 @@ class JavascriptEvalExecutionTools {
|
|
|
8327
8451
|
`));
|
|
8328
8452
|
}
|
|
8329
8453
|
else {
|
|
8330
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
8454
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
8331
8455
|
Function ${undefinedName}() is not defined
|
|
8332
8456
|
|
|
8333
8457
|
- Make sure that the function is one of built-in functions
|
|
@@ -8995,7 +9119,10 @@ function ServerBody({ info }) {
|
|
|
8995
9119
|
}), h(KeyVal, {
|
|
8996
9120
|
label: 'Application mode:',
|
|
8997
9121
|
value: info.isApplicationModeAllowed ? 'enabled' : 'disabled',
|
|
8998
|
-
}), h(KeyVal, { label: 'Running executions:', value: String(info.runningExecutions) })), h(Section, { title: 'Pipelines in collection' }, h(List, { items: info.pipelines })), h(Section, { title: 'Paths' }, h(List, { items: info.paths })), h(Section, { title: 'Instructions' }, h('ol', { className: 'list-decimal ml-6 space-y-1' }, h('li', null, 'The client ', h('a', {
|
|
9122
|
+
}), h(KeyVal, { label: 'Running executions:', value: String(info.runningExecutions) })), h(Section, { title: 'Pipelines in collection' }, h(List, { items: info.pipelines })), h(Section, { title: 'Paths' }, h(List, { items: info.paths })), h(Section, { title: 'Instructions' }, h('ol', { className: 'list-decimal ml-6 space-y-1' }, h('li', null, 'The client ', h('a', {
|
|
9123
|
+
href: 'https://www.npmjs.com/package/@promptbook/remote-client',
|
|
9124
|
+
className: 'text-blue-600 underline',
|
|
9125
|
+
}, 'https://www.npmjs.com/package/@promptbook/remote-client')), h('li', null, 'OpenAI compatible client ', h('span', { className: 'text-gray-500' }, '(Not working yet)')), h('li', null, 'REST API')), h('p', { className: 'mt-2' }, 'For more information look at: ', h('a', { href: 'https://github.com/webgptorg/promptbook', className: 'text-blue-600 underline' }, 'https://github.com/webgptorg/promptbook'))));
|
|
8999
9126
|
}
|
|
9000
9127
|
function HtmlDoc({ info }) {
|
|
9001
9128
|
return h('html', { lang: 'en' }, h('head', null, h('meta', { charSet: 'UTF-8' }), h('meta', { name: 'viewport', content: 'width=device-width, initial-scale=1.0' }), h('title', null, 'Promptbook Server'), h('link', {
|
|
@@ -9012,6 +9139,7 @@ function renderServerIndexHtml(info) {
|
|
|
9012
9139
|
return '<!DOCTYPE html>' + renderToStaticMarkup(h(HtmlDoc, { info }));
|
|
9013
9140
|
}
|
|
9014
9141
|
|
|
9142
|
+
// TODO: !!! Deprecate
|
|
9015
9143
|
/**
|
|
9016
9144
|
* Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
|
|
9017
9145
|
*
|
|
@@ -9318,10 +9446,10 @@ function startRemoteServer(options) {
|
|
|
9318
9446
|
.send({ error: serializeError(error) });
|
|
9319
9447
|
}
|
|
9320
9448
|
});
|
|
9321
|
-
function exportExecutionTask(executionTask,
|
|
9449
|
+
function exportExecutionTask(executionTask, isDetailed) {
|
|
9322
9450
|
// <- TODO: [🧠] This should be maybe method of `ExecutionTask` itself
|
|
9323
|
-
const { taskType, promptbookVersion, taskId, title, status, errors, tldr, warnings, createdAt, updatedAt, currentValue, } = executionTask;
|
|
9324
|
-
if (
|
|
9451
|
+
const { taskType, promptbookVersion, taskId, title, status, errors, tldr, warnings, createdAt, updatedAt, currentValue, llmCalls, } = executionTask;
|
|
9452
|
+
if (isDetailed) {
|
|
9325
9453
|
return {
|
|
9326
9454
|
taskId,
|
|
9327
9455
|
title,
|
|
@@ -9331,9 +9459,11 @@ function startRemoteServer(options) {
|
|
|
9331
9459
|
tldr,
|
|
9332
9460
|
errors: errors.map(serializeError),
|
|
9333
9461
|
warnings: warnings.map(serializeError),
|
|
9462
|
+
llmCalls,
|
|
9334
9463
|
createdAt,
|
|
9335
9464
|
updatedAt,
|
|
9336
9465
|
currentValue,
|
|
9466
|
+
ptbkNonce: 0,
|
|
9337
9467
|
};
|
|
9338
9468
|
}
|
|
9339
9469
|
else {
|
|
@@ -9346,6 +9476,8 @@ function startRemoteServer(options) {
|
|
|
9346
9476
|
tldr,
|
|
9347
9477
|
createdAt,
|
|
9348
9478
|
updatedAt,
|
|
9479
|
+
llmCalls,
|
|
9480
|
+
ptbkNonce: 0,
|
|
9349
9481
|
};
|
|
9350
9482
|
}
|
|
9351
9483
|
}
|
|
@@ -9573,18 +9705,21 @@ function startRemoteServer(options) {
|
|
|
9573
9705
|
};
|
|
9574
9706
|
}
|
|
9575
9707
|
/**
|
|
9708
|
+
|
|
9709
|
+
* TODO: [🕋] Use here `aboutPromptbookInformation`
|
|
9576
9710
|
* TODO: [🌡] Add CORS and security - probably via `helmet`
|
|
9577
9711
|
* TODO: Split this file into multiple functions - handler for each request
|
|
9578
9712
|
* TODO: Maybe use `$exportJson`
|
|
9579
9713
|
* TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
|
|
9580
|
-
* TODO: [⚖] Expose the collection to be able to connect to same collection via
|
|
9714
|
+
* TODO: [⚖] Expose the collection to be able to connect to same collection via createPipelineCollectionFromUrl
|
|
9581
9715
|
* TODO: Handle progress - support streaming
|
|
9582
9716
|
* TODO: [🗯] Do not hang up immediately but wait until client closes OR timeout
|
|
9583
9717
|
* TODO: [🗯] Timeout on chat to free up resources
|
|
9584
9718
|
* TODO: [🃏] Pass here some security token to prevent malitious usage and/or DDoS
|
|
9585
9719
|
* TODO: [0] Set unavailable models as undefined in `RemoteLlmExecutionTools` NOT throw error here
|
|
9586
9720
|
* TODO: Allow to constrain anonymous mode for specific models / providers
|
|
9721
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
9587
9722
|
*/
|
|
9588
9723
|
|
|
9589
|
-
export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION, startRemoteServer };
|
|
9724
|
+
export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION, startAgentServer, startRemoteServer };
|
|
9590
9725
|
//# sourceMappingURL=index.es.js.map
|