@promptbook/remote-server 0.103.0-10 → 0.103.0-100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -35
- package/esm/index.es.js +503 -386
- package/esm/index.es.js.map +1 -1
- package/esm/typings/books/index.d.ts +0 -81
- package/esm/typings/servers.d.ts +9 -7
- package/esm/typings/src/_packages/browser.index.d.ts +6 -0
- package/esm/typings/src/_packages/cli.index.d.ts +4 -0
- package/esm/typings/src/_packages/components.index.d.ts +20 -8
- package/esm/typings/src/_packages/core.index.d.ts +58 -18
- package/esm/typings/src/_packages/node.index.d.ts +2 -2
- package/esm/typings/src/_packages/remote-server.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +58 -8
- package/esm/typings/src/_packages/utils.index.d.ts +6 -0
- package/esm/typings/src/_packages/wizard.index.d.ts +4 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +19 -5
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +17 -1
- package/esm/typings/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +3 -2
- package/esm/typings/src/book-2.0/agent-source/computeAgentHash.d.ts +8 -0
- package/esm/typings/src/book-2.0/agent-source/createCommitmentRegex.d.ts +3 -3
- package/esm/typings/src/book-2.0/agent-source/createDefaultAgentName.d.ts +8 -0
- package/esm/typings/src/book-2.0/agent-source/normalizeAgentName.d.ts +9 -0
- package/esm/typings/src/book-2.0/agent-source/padBook.d.ts +18 -0
- package/esm/typings/src/book-2.0/agent-source/parseAgentSourceWithCommitments.d.ts +1 -1
- package/esm/typings/src/book-2.0/agent-source/string_book.d.ts +3 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +6 -1
- package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +77 -7
- package/esm/typings/src/book-components/BookEditor/BookEditorActionbar.d.ts +14 -0
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.d.ts +14 -0
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChatProps.d.ts +13 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +10 -0
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +15 -0
- package/esm/typings/src/book-components/Chat/MockedChat/MockedChat.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/save/_common/ChatSaveFormatDefinition.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/save/html/htmlSaveFormatDefinition.d.ts +1 -0
- package/esm/typings/src/book-components/Chat/save/pdf/pdfSaveFormatDefinition.d.ts +4 -0
- package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +1 -1
- package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgent.d.ts +29 -0
- package/esm/typings/src/book-components/Qr/BrandedQrCode.d.ts +18 -0
- package/esm/typings/src/book-components/Qr/GenericQrCode.d.ts +10 -0
- package/esm/typings/src/book-components/Qr/PromptbookQrCode.d.ts +18 -0
- package/esm/typings/src/book-components/Qr/useQrCode.d.ts +15 -0
- package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +15 -0
- package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +12 -0
- package/esm/typings/src/book-components/_common/Modal/Modal.d.ts +2 -2
- package/esm/typings/src/book-components/_common/Tooltip/Tooltip.d.ts +47 -0
- package/esm/typings/src/book-components/icons/AboutIcon.d.ts +9 -0
- package/esm/typings/src/book-components/icons/CloseIcon.d.ts +4 -8
- package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +9 -0
- package/esm/typings/src/book-components/icons/ExitFullscreenIcon.d.ts +7 -0
- package/esm/typings/src/book-components/icons/FullscreenIcon.d.ts +7 -0
- package/esm/typings/src/book-components/icons/MenuIcon.d.ts +12 -0
- package/esm/typings/src/book-components/icons/MicIcon.d.ts +8 -0
- package/esm/typings/src/cli/cli-commands/_boilerplate.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/about.d.ts +3 -1
- package/esm/typings/src/cli/cli-commands/hello.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/list-models.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/login.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/make.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/prettify.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/run.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/{start-server.d.ts → start-agents-server.d.ts} +3 -2
- package/esm/typings/src/cli/cli-commands/start-pipelines-server.d.ts +15 -0
- package/esm/typings/src/cli/cli-commands/test-command.d.ts +2 -1
- package/esm/typings/src/cli/common/$addGlobalOptionsToCommand.d.ts +2 -1
- package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +12 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +75 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabaseOptions.d.ts +10 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +154 -0
- package/esm/typings/src/collection/{PipelineCollection.d.ts → pipeline-collection/PipelineCollection.d.ts} +7 -3
- package/esm/typings/src/collection/{SimplePipelineCollection.d.ts → pipeline-collection/SimplePipelineCollection.d.ts} +5 -5
- package/esm/typings/src/collection/{constructors/createCollectionFromDirectory.d.ts → pipeline-collection/constructors/createPipelineCollectionFromDirectory.d.ts} +8 -11
- package/esm/typings/src/collection/pipeline-collection/constructors/createPipelineCollectionFromJson.d.ts +13 -0
- package/esm/typings/src/collection/{constructors/createCollectionFromPromise.d.ts → pipeline-collection/constructors/createPipelineCollectionFromPromise.d.ts} +6 -5
- package/esm/typings/src/collection/pipeline-collection/constructors/createPipelineCollectionFromPromise.test.d.ts +1 -0
- package/esm/typings/src/collection/{constructors/createCollectionFromUrl.d.ts → pipeline-collection/constructors/createPipelineCollectionFromUrl.d.ts} +3 -3
- package/esm/typings/src/collection/{constructors/createSubcollection.d.ts → pipeline-collection/constructors/createPipelineSubcollection.d.ts} +3 -3
- package/esm/typings/src/collection/pipeline-collection/pipelineCollectionToJson.d.ts +13 -0
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +4 -5
- package/esm/typings/src/{book-2.0/commitments → commitments}/ACTION/ACTION.d.ts +5 -1
- package/esm/typings/src/commitments/CLOSED/CLOSED.d.ts +35 -0
- package/esm/typings/src/commitments/COMPONENT/COMPONENT.d.ts +28 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/DELETE/DELETE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/FORMAT/FORMAT.d.ts +5 -1
- package/esm/typings/src/commitments/FROM/FROM.d.ts +34 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/GOAL/GOAL.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/KNOWLEDGE/KNOWLEDGE.d.ts +5 -5
- package/esm/typings/src/commitments/LANGUAGE/LANGUAGE.d.ts +35 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/MEMORY/MEMORY.d.ts +5 -1
- package/esm/typings/src/commitments/MESSAGE/AgentMessageCommitmentDefinition.d.ts +32 -0
- package/esm/typings/src/commitments/MESSAGE/InitialMessageCommitmentDefinition.d.ts +32 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/MESSAGE/MESSAGE.d.ts +5 -1
- package/esm/typings/src/commitments/MESSAGE/UserMessageCommitmentDefinition.d.ts +32 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/META/META.d.ts +5 -1
- package/esm/typings/src/commitments/META_COLOR/META_COLOR.d.ts +48 -0
- package/esm/typings/src/commitments/META_FONT/META_FONT.d.ts +42 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/META_IMAGE/META_IMAGE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/META_LINK/META_LINK.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/MODEL/MODEL.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/NOTE/NOTE.d.ts +5 -1
- package/esm/typings/src/commitments/OPEN/OPEN.d.ts +35 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/PERSONA/PERSONA.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/RULE/RULE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/SAMPLE/SAMPLE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/SCENARIO/SCENARIO.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/STYLE/STYLE.d.ts +5 -1
- package/esm/typings/src/commitments/USE/USE.d.ts +53 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +38 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.test.d.ts +1 -0
- package/esm/typings/src/commitments/USE_MCP/USE_MCP.d.ts +37 -0
- package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +38 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BaseCommitmentDefinition.d.ts +8 -2
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/CommitmentDefinition.d.ts +6 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/NotYetImplementedCommitmentDefinition.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/createEmptyAgentModelRequirements.d.ts +1 -1
- package/esm/typings/src/commitments/index.d.ts +93 -0
- package/esm/typings/src/config.d.ts +24 -3
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +2 -0
- package/esm/typings/src/errors/0-index.d.ts +6 -0
- package/esm/typings/src/errors/DatabaseError.d.ts +12 -0
- package/esm/typings/src/errors/NotAllowed.d.ts +9 -0
- package/esm/typings/src/errors/WrappedError.d.ts +2 -2
- package/esm/typings/src/execution/AvailableModel.d.ts +1 -0
- package/esm/typings/src/execution/Executables.d.ts +3 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +12 -3
- package/esm/typings/src/execution/ExecutionTools.d.ts +5 -0
- package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +21 -1
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +5 -0
- package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +5 -0
- package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +5 -0
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +5 -0
- package/esm/typings/src/execution/utils/usage-constants.d.ts +4 -124
- package/esm/typings/src/execution/utils/validatePromptResult.d.ts +2 -0
- package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +2 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +2 -2
- package/esm/typings/src/llm-providers/_common/register/$registeredLlmToolsMessage.d.ts +2 -1
- package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/assertUniqueModels.d.ts +12 -0
- package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +70 -0
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +26 -4
- package/esm/typings/src/llm-providers/agent/AgentOptions.d.ts +19 -0
- package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +17 -0
- package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +50 -0
- package/esm/typings/src/llm-providers/agent/RemoteAgentOptions.d.ts +11 -0
- package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.d.ts +1 -19
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +60 -2
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +7 -1
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/openai-models.test.d.ts +4 -0
- package/esm/typings/src/other/templates/getTemplatesPipelineCollection.d.ts +1 -1
- package/esm/typings/src/pipeline/validatePipelineString.d.ts +2 -0
- package/esm/typings/src/playground/permanent/_boilerplate.d.ts +5 -0
- package/esm/typings/src/playground/permanent/agent-with-browser-playground.d.ts +5 -0
- package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +1 -0
- package/esm/typings/src/remote-server/startAgentServer.d.ts +26 -0
- package/esm/typings/src/remote-server/startRemoteServer.d.ts +4 -1
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +3 -8
- package/esm/typings/src/scrapers/_boilerplate/createBoilerplateScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/_boilerplate/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/markitdown/createMarkitdownScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/markitdown/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -9
- package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +1 -0
- package/esm/typings/src/storage/env-storage/$EnvStorage.d.ts +2 -1
- package/esm/typings/src/transpilers/_common/BookTranspiler.d.ts +33 -0
- package/esm/typings/src/transpilers/_common/BookTranspilerOptions.d.ts +18 -0
- package/esm/typings/src/transpilers/_common/register/$bookTranspilersRegister.d.ts +15 -0
- package/esm/typings/src/transpilers/formatted-book-in-markdown/FormattedBookInMarkdownTranspiler.d.ts +16 -0
- package/esm/typings/src/transpilers/formatted-book-in-markdown/register.d.ts +15 -0
- package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.d.ts +16 -0
- package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.test.d.ts +1 -0
- package/esm/typings/src/transpilers/openai-sdk/playground/playground.d.ts +5 -0
- package/esm/typings/src/transpilers/openai-sdk/register.d.ts +15 -0
- package/esm/typings/src/types/LlmCall.d.ts +20 -0
- package/esm/typings/src/types/Updatable.d.ts +19 -0
- package/esm/typings/src/types/typeAliases.d.ts +32 -2
- package/esm/typings/src/utils/color/$randomColor.d.ts +1 -0
- package/esm/typings/src/utils/color/Color.d.ts +15 -0
- package/esm/typings/src/utils/color/Color.test.d.ts +1 -0
- package/esm/typings/src/utils/color/css-colors.d.ts +1 -0
- package/esm/typings/src/utils/color/internal-utils/checkChannelValue.d.ts +0 -3
- package/esm/typings/src/utils/color/operators/darken.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/grayscale.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/lighten.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/mixWithColor.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/saturate.d.ts +1 -1
- package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +16 -0
- package/esm/typings/src/utils/environment/$getGlobalScope.d.ts +2 -2
- package/esm/typings/src/utils/execCommand/$execCommand.d.ts +2 -1
- package/esm/typings/src/utils/execCommand/$execCommands.d.ts +2 -1
- package/esm/typings/src/utils/files/$induceBookDownload.d.ts +13 -0
- package/esm/typings/src/utils/files/$induceFileDownload.d.ts +13 -0
- package/esm/typings/src/utils/files/ObjectUrl.d.ts +46 -0
- package/esm/typings/src/utils/files/listAllFiles.d.ts +2 -3
- package/esm/typings/src/utils/misc/aboutPromptbookInformation.d.ts +27 -0
- package/esm/typings/src/utils/misc/computeHash.d.ts +11 -0
- package/esm/typings/src/utils/misc/computeHash.test.d.ts +1 -0
- package/esm/typings/src/utils/misc/xAboutPromptbookInformation.d.ts +13 -0
- package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +2 -0
- package/esm/typings/src/utils/normalization/normalizeMessageText.d.ts +9 -0
- package/esm/typings/src/utils/normalization/normalizeMessageText.test.d.ts +1 -0
- package/esm/typings/src/utils/normalization/normalizeTo_PascalCase.d.ts +3 -0
- package/esm/typings/src/utils/normalization/normalizeTo_camelCase.d.ts +2 -0
- package/esm/typings/src/utils/normalization/titleToName.d.ts +2 -0
- package/esm/typings/src/utils/organization/$sideEffect.d.ts +2 -2
- package/esm/typings/src/utils/organization/$side_effect.d.ts +7 -0
- package/esm/typings/src/utils/organization/TODO_USE.d.ts +2 -2
- package/esm/typings/src/utils/organization/keepUnused.d.ts +2 -2
- package/esm/typings/src/utils/organization/preserve.d.ts +3 -3
- package/esm/typings/src/utils/organization/really_any.d.ts +7 -0
- package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +25 -0
- package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +9 -0
- package/esm/typings/src/utils/random/$randomFullnameWithColor.d.ts +13 -0
- package/esm/typings/src/utils/random/$randomItem.d.ts +9 -0
- package/esm/typings/src/utils/random/$randomSeed.d.ts +3 -0
- package/esm/typings/src/utils/random/$randomToken.d.ts +2 -0
- package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +2 -1
- package/esm/typings/src/utils/serialization/asSerializable.d.ts +2 -2
- package/esm/typings/src/utils/serialization/serializeToPromptbookJavascript.d.ts +2 -2
- package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +2 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/esm/typings/src/wizard/$getCompiledBook.d.ts +1 -2
- package/package.json +7 -7
- package/umd/index.umd.js +524 -406
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/book-2.0/commitments/index.d.ts +0 -60
- package/esm/typings/src/book-components/BookEditor/config.d.ts +0 -11
- package/esm/typings/src/book-components/Chat/utils/renderMarkdown.d.ts +0 -21
- package/esm/typings/src/collection/collectionToJson.d.ts +0 -13
- package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +0 -13
- /package/esm/typings/src/{book-components/Chat/utils/renderMarkdown.test.d.ts → book-2.0/agent-source/computeAgentHash.test.d.ts} +0 -0
- /package/esm/typings/src/{collection/constructors/createCollectionFromDirectory.test.d.ts → book-2.0/agent-source/normalizeAgentName.test.d.ts} +0 -0
- /package/esm/typings/src/{collection/constructors/createCollectionFromJson.test.d.ts → book-components/Chat/AgentChat/AgentChat.test.d.ts} +0 -0
- /package/esm/typings/src/collection/{constructors/createCollectionFromPromise.test.d.ts → pipeline-collection/constructors/createPipelineCollectionFromDirectory.test.d.ts} +0 -0
- /package/esm/typings/src/{commands/_common/parseCommand.test.d.ts → collection/pipeline-collection/constructors/createPipelineCollectionFromJson.test.d.ts} +0 -0
- /package/esm/typings/src/collection/{collectionToJson.test.d.ts → pipeline-collection/pipelineCollectionToJson.test.d.ts} +0 -0
- /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BookCommitment.d.ts +0 -0
- /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/ParsedCommitment.d.ts +0 -0
package/esm/index.es.js
CHANGED
|
@@ -1,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.103.0-
|
|
36
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-100';
|
|
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
|
|
@@ -305,6 +314,28 @@ class Color {
|
|
|
305
314
|
throw new Error(`Can not create color from given object`);
|
|
306
315
|
}
|
|
307
316
|
}
|
|
317
|
+
/**
|
|
318
|
+
* Creates a new Color instance from miscellaneous formats
|
|
319
|
+
* It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
|
|
320
|
+
*
|
|
321
|
+
* @param color
|
|
322
|
+
* @returns Color object
|
|
323
|
+
*/
|
|
324
|
+
static fromSafe(color) {
|
|
325
|
+
try {
|
|
326
|
+
return Color.from(color);
|
|
327
|
+
}
|
|
328
|
+
catch (error) {
|
|
329
|
+
// <- Note: Can not use `assertsError(error)` here because it causes circular dependency
|
|
330
|
+
console.warn(spaceTrim((block) => `
|
|
331
|
+
Color.fromSafe error:
|
|
332
|
+
${block(error.message)}
|
|
333
|
+
|
|
334
|
+
Returning default PROMPTBOOK_COLOR.
|
|
335
|
+
`));
|
|
336
|
+
return Color.fromString('promptbook');
|
|
337
|
+
}
|
|
338
|
+
}
|
|
308
339
|
/**
|
|
309
340
|
* Creates a new Color instance from miscellaneous string formats
|
|
310
341
|
*
|
|
@@ -372,6 +403,9 @@ class Color {
|
|
|
372
403
|
if (hex.length === 3) {
|
|
373
404
|
return Color.fromHex3(hex);
|
|
374
405
|
}
|
|
406
|
+
if (hex.length === 4) {
|
|
407
|
+
return Color.fromHex4(hex);
|
|
408
|
+
}
|
|
375
409
|
if (hex.length === 6) {
|
|
376
410
|
return Color.fromHex6(hex);
|
|
377
411
|
}
|
|
@@ -392,6 +426,19 @@ class Color {
|
|
|
392
426
|
const b = parseInt(hex.substr(2, 1), 16) * 16;
|
|
393
427
|
return take(new Color(r, g, b));
|
|
394
428
|
}
|
|
429
|
+
/**
|
|
430
|
+
* Creates a new Color instance from color in hex format with 4 digits (with alpha channel)
|
|
431
|
+
*
|
|
432
|
+
* @param color in hex for example `09df`
|
|
433
|
+
* @returns Color object
|
|
434
|
+
*/
|
|
435
|
+
static fromHex4(hex) {
|
|
436
|
+
const r = parseInt(hex.substr(0, 1), 16) * 16;
|
|
437
|
+
const g = parseInt(hex.substr(1, 1), 16) * 16;
|
|
438
|
+
const b = parseInt(hex.substr(2, 1), 16) * 16;
|
|
439
|
+
const a = parseInt(hex.substr(3, 1), 16) * 16;
|
|
440
|
+
return take(new Color(r, g, b, a));
|
|
441
|
+
}
|
|
395
442
|
/**
|
|
396
443
|
* Creates a new Color instance from color in hex format with 6 color digits (without alpha channel)
|
|
397
444
|
*
|
|
@@ -582,7 +629,8 @@ class Color {
|
|
|
582
629
|
* @returns true if the value is a valid hex color string (e.g., `#009edd`, `#fff`, etc.)
|
|
583
630
|
*/
|
|
584
631
|
static isHexColorString(value) {
|
|
585
|
-
return typeof value === 'string' &&
|
|
632
|
+
return (typeof value === 'string' &&
|
|
633
|
+
/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(value));
|
|
586
634
|
}
|
|
587
635
|
/**
|
|
588
636
|
* Creates new Color object
|
|
@@ -697,6 +745,23 @@ class Color {
|
|
|
697
745
|
* TODO: Maybe connect with textures
|
|
698
746
|
*/
|
|
699
747
|
|
|
748
|
+
/**
|
|
749
|
+
* Makes color transformer which returns a grayscale version of the color
|
|
750
|
+
*
|
|
751
|
+
* @param amount from 0 to 1
|
|
752
|
+
*
|
|
753
|
+
* @public exported from `@promptbook/color`
|
|
754
|
+
*/
|
|
755
|
+
function grayscale(amount) {
|
|
756
|
+
return ({ red, green, blue, alpha }) => {
|
|
757
|
+
const average = (red + green + blue) / 3;
|
|
758
|
+
red = Math.round(average * amount + red * (1 - amount));
|
|
759
|
+
green = Math.round(average * amount + green * (1 - amount));
|
|
760
|
+
blue = Math.round(average * amount + blue * (1 - amount));
|
|
761
|
+
return Color.fromValues(red, green, blue, alpha);
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
|
|
700
765
|
/**
|
|
701
766
|
* Converts HSL values to RGB values
|
|
702
767
|
*
|
|
@@ -812,102 +877,6 @@ function lighten(amount) {
|
|
|
812
877
|
* TODO: Maybe implement by mix+hsl
|
|
813
878
|
*/
|
|
814
879
|
|
|
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
880
|
/**
|
|
912
881
|
* Makes color transformer which saturate the given color
|
|
913
882
|
*
|
|
@@ -984,16 +953,32 @@ const CLAIM = `Turn your company's scattered knowledge into AI ready books`;
|
|
|
984
953
|
*
|
|
985
954
|
* @public exported from `@promptbook/core`
|
|
986
955
|
*/
|
|
987
|
-
const PROMPTBOOK_COLOR = Color.
|
|
988
|
-
// <- TODO: [🧠] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
956
|
+
const PROMPTBOOK_COLOR = Color.fromString('promptbook');
|
|
957
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
958
|
+
/**
|
|
959
|
+
* Colors for syntax highlighting in the `<BookEditor/>`
|
|
960
|
+
*
|
|
961
|
+
* TODO: [🗽] Unite branding and make single place for it
|
|
962
|
+
*
|
|
963
|
+
* @public exported from `@promptbook/core`
|
|
964
|
+
*/
|
|
965
|
+
({
|
|
966
|
+
TITLE: Color.fromHex('#244EA8'),
|
|
967
|
+
LINE: Color.fromHex('#eeeeee'),
|
|
968
|
+
SEPARATOR: Color.fromHex('#cccccc'),
|
|
969
|
+
COMMITMENT: Color.fromHex('#DA0F78'),
|
|
970
|
+
PARAMETER: Color.fromHex('#8e44ad'),
|
|
971
|
+
});
|
|
972
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
989
973
|
/**
|
|
990
|
-
*
|
|
974
|
+
* Chat color of the Promptbook (in chat)
|
|
991
975
|
*
|
|
992
976
|
* TODO: [🗽] Unite branding and make single place for it
|
|
993
977
|
*
|
|
994
978
|
* @public exported from `@promptbook/core`
|
|
995
979
|
*/
|
|
996
980
|
PROMPTBOOK_COLOR.then(lighten(0.1)).then(saturate(0.9)).then(grayscale(0.9));
|
|
981
|
+
// <- TODO: [🧠][🈵] Using `Color` and `lighten`, `saturate`,... here increases the package size approx 3kb, maybe remove it
|
|
997
982
|
/**
|
|
998
983
|
* Color of the user (in chat)
|
|
999
984
|
*
|
|
@@ -1002,6 +987,7 @@ PROMPTBOOK_COLOR.then(lighten(0.1)).then(saturate(0.9)).then(grayscale(0.9));
|
|
|
1002
987
|
* @public exported from `@promptbook/core`
|
|
1003
988
|
*/
|
|
1004
989
|
Color.fromHex('#1D4ED8');
|
|
990
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
1005
991
|
/**
|
|
1006
992
|
* When the title is not provided, the default title is used
|
|
1007
993
|
*
|
|
@@ -1088,7 +1074,7 @@ const DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [🤹♂️]
|
|
|
1088
1074
|
* @public exported from `@promptbook/core`
|
|
1089
1075
|
*/
|
|
1090
1076
|
const DEFAULT_MAX_EXECUTION_ATTEMPTS = 7; // <- TODO: [🤹♂️]
|
|
1091
|
-
// <- TODO: [🕝] Make also `
|
|
1077
|
+
// <- TODO: [🕝] Make also `AGENTS_DIRNAME_ALTERNATIVES`
|
|
1092
1078
|
// TODO: Just `.promptbook` in config, hardcode subfolders like `download-cache` or `execution-cache`
|
|
1093
1079
|
/**
|
|
1094
1080
|
* Where to store the temporary downloads
|
|
@@ -1137,24 +1123,246 @@ const DEFAULT_IS_AUTO_INSTALLED = false;
|
|
|
1137
1123
|
*/
|
|
1138
1124
|
const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
|
|
1139
1125
|
/**
|
|
1140
|
-
* API request timeout in milliseconds
|
|
1141
|
-
* Can be overridden via API_REQUEST_TIMEOUT environment variable
|
|
1142
|
-
*
|
|
1143
|
-
* @public exported from `@promptbook/core`
|
|
1126
|
+
* API request timeout in milliseconds
|
|
1127
|
+
* Can be overridden via API_REQUEST_TIMEOUT environment variable
|
|
1128
|
+
*
|
|
1129
|
+
* @public exported from `@promptbook/core`
|
|
1130
|
+
*/
|
|
1131
|
+
parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
|
|
1132
|
+
/**
|
|
1133
|
+
* Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
|
|
1134
|
+
*
|
|
1135
|
+
* @private within the repository
|
|
1136
|
+
*/
|
|
1137
|
+
const IS_PIPELINE_LOGIC_VALIDATED = just(
|
|
1138
|
+
/**/
|
|
1139
|
+
// Note: In normal situations, we check the pipeline logic:
|
|
1140
|
+
true);
|
|
1141
|
+
/**
|
|
1142
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
1143
|
+
* TODO: [🧠][🧜♂️] Maybe join remoteServerUrl and path into single value
|
|
1144
|
+
*/
|
|
1145
|
+
|
|
1146
|
+
/**
|
|
1147
|
+
* This error type indicates that you try to use a feature that is not available in the current environment
|
|
1148
|
+
*
|
|
1149
|
+
* @public exported from `@promptbook/core`
|
|
1150
|
+
*/
|
|
1151
|
+
class EnvironmentMismatchError extends Error {
|
|
1152
|
+
constructor(message) {
|
|
1153
|
+
super(message);
|
|
1154
|
+
this.name = 'EnvironmentMismatchError';
|
|
1155
|
+
Object.setPrototypeOf(this, EnvironmentMismatchError.prototype);
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
/**
|
|
1160
|
+
* Detects if the code is running in a Node.js environment
|
|
1161
|
+
*
|
|
1162
|
+
* Note: `$` is used to indicate that this function is not a pure function - it looks at the global object to determine the environment
|
|
1163
|
+
*
|
|
1164
|
+
* @public exported from `@promptbook/utils`
|
|
1165
|
+
*/
|
|
1166
|
+
const $isRunningInNode = new Function(`
|
|
1167
|
+
try {
|
|
1168
|
+
return this === global;
|
|
1169
|
+
} catch (e) {
|
|
1170
|
+
return false;
|
|
1171
|
+
}
|
|
1172
|
+
`);
|
|
1173
|
+
/**
|
|
1174
|
+
* TODO: [🎺]
|
|
1175
|
+
*/
|
|
1176
|
+
|
|
1177
|
+
/**
|
|
1178
|
+
* Normalize options for `execCommand` and `execCommands`
|
|
1179
|
+
*
|
|
1180
|
+
* Note: `$` is used to indicate that this function behaves differently according to `process.platform`
|
|
1181
|
+
*
|
|
1182
|
+
* @private internal utility of `execCommand` and `execCommands`
|
|
1183
|
+
*/
|
|
1184
|
+
function $execCommandNormalizeOptions(options) {
|
|
1185
|
+
var _a, _b, _c, _d;
|
|
1186
|
+
let command;
|
|
1187
|
+
let cwd;
|
|
1188
|
+
let crashOnError;
|
|
1189
|
+
let args = [];
|
|
1190
|
+
let timeout;
|
|
1191
|
+
let isVerbose;
|
|
1192
|
+
if (typeof options === 'string') {
|
|
1193
|
+
// TODO: [1] DRY default values
|
|
1194
|
+
command = options;
|
|
1195
|
+
cwd = process.cwd();
|
|
1196
|
+
crashOnError = true;
|
|
1197
|
+
timeout = Infinity; // <- TODO: [⏳]
|
|
1198
|
+
isVerbose = DEFAULT_IS_VERBOSE;
|
|
1199
|
+
}
|
|
1200
|
+
else {
|
|
1201
|
+
/*
|
|
1202
|
+
TODO:
|
|
1203
|
+
if ((options as any).commands !== undefined) {
|
|
1204
|
+
commands = (options as any).commands;
|
|
1205
|
+
} else {
|
|
1206
|
+
commands = [(options as any).command];
|
|
1207
|
+
}
|
|
1208
|
+
*/
|
|
1209
|
+
// TODO: [1] DRY default values
|
|
1210
|
+
command = options.command;
|
|
1211
|
+
cwd = (_a = options.cwd) !== null && _a !== void 0 ? _a : process.cwd();
|
|
1212
|
+
crashOnError = (_b = options.crashOnError) !== null && _b !== void 0 ? _b : true;
|
|
1213
|
+
timeout = (_c = options.timeout) !== null && _c !== void 0 ? _c : Infinity;
|
|
1214
|
+
isVerbose = (_d = options.isVerbose) !== null && _d !== void 0 ? _d : DEFAULT_IS_VERBOSE;
|
|
1215
|
+
}
|
|
1216
|
+
// TODO: /(-[a-zA-Z0-9-]+\s+[^\s]*)|[^\s]*/g
|
|
1217
|
+
const _ = Array.from(command.matchAll(/(".*")|([^\s]*)/g))
|
|
1218
|
+
.map(([match]) => match)
|
|
1219
|
+
.filter((arg) => arg !== '');
|
|
1220
|
+
if (_.length > 1) {
|
|
1221
|
+
[command, ...args] = _;
|
|
1222
|
+
}
|
|
1223
|
+
if (options.args) {
|
|
1224
|
+
args = [...args, ...options.args];
|
|
1225
|
+
}
|
|
1226
|
+
let humanReadableCommand = !['npx', 'npm'].includes(command) ? command : args[0];
|
|
1227
|
+
if (['ts-node'].includes(humanReadableCommand)) {
|
|
1228
|
+
humanReadableCommand += ` ${args[1]}`;
|
|
1229
|
+
}
|
|
1230
|
+
if (/^win/.test(process.platform) && ['npm', 'npx'].includes(command)) {
|
|
1231
|
+
command = `${command}.cmd`;
|
|
1232
|
+
}
|
|
1233
|
+
return { command, humanReadableCommand, args, cwd, crashOnError, timeout, isVerbose };
|
|
1234
|
+
}
|
|
1235
|
+
// TODO: This should show type error> execCommandNormalizeOptions({ command: '', commands: [''] });
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* Run one command in a shell
|
|
1239
|
+
*
|
|
1240
|
+
*
|
|
1241
|
+
* Note: There are 2 similar functions in the codebase:
|
|
1242
|
+
* - `$execCommand` which runs a single command
|
|
1243
|
+
* - `$execCommands` which runs multiple commands
|
|
1244
|
+
* Note: `$` is used to indicate that this function is not a pure function - it runs a command in a shell
|
|
1245
|
+
*
|
|
1246
|
+
* @public exported from `@promptbook/node`
|
|
1247
|
+
*/
|
|
1248
|
+
function $execCommand(options) {
|
|
1249
|
+
if (!$isRunningInNode()) {
|
|
1250
|
+
throw new EnvironmentMismatchError('Function `$execCommand` can run only in Node environment.js');
|
|
1251
|
+
}
|
|
1252
|
+
return new Promise((resolve, reject) => {
|
|
1253
|
+
// eslint-disable-next-line prefer-const
|
|
1254
|
+
const { command, humanReadableCommand, args, cwd, crashOnError, timeout, isVerbose = DEFAULT_IS_VERBOSE, } = $execCommandNormalizeOptions(options);
|
|
1255
|
+
if (timeout !== Infinity) {
|
|
1256
|
+
// TODO: In waitasecond forTime(Infinity) should be equivalent to forEver()
|
|
1257
|
+
forTime(timeout).then(() => {
|
|
1258
|
+
if (crashOnError) {
|
|
1259
|
+
reject(new Error(`Command "${humanReadableCommand}" exceeded time limit of ${timeout}ms`));
|
|
1260
|
+
}
|
|
1261
|
+
else {
|
|
1262
|
+
console.warn(`Command "${humanReadableCommand}" exceeded time limit of ${timeout}ms but continues running`);
|
|
1263
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
1264
|
+
resolve('Command exceeded time limit');
|
|
1265
|
+
}
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
if (isVerbose) {
|
|
1269
|
+
console.info(colors.yellow(cwd) + ' ' + colors.green(command) + ' ' + colors.blue(args.join(' ')));
|
|
1270
|
+
}
|
|
1271
|
+
try {
|
|
1272
|
+
const commandProcess = spawn(command, args, { cwd, shell: true });
|
|
1273
|
+
if (isVerbose) {
|
|
1274
|
+
commandProcess.on('message', (message) => {
|
|
1275
|
+
console.info({ message });
|
|
1276
|
+
});
|
|
1277
|
+
}
|
|
1278
|
+
const output = [];
|
|
1279
|
+
commandProcess.stdout.on('data', (stdout) => {
|
|
1280
|
+
output.push(stdout.toString());
|
|
1281
|
+
if (isVerbose) {
|
|
1282
|
+
console.info(stdout.toString());
|
|
1283
|
+
}
|
|
1284
|
+
});
|
|
1285
|
+
commandProcess.stderr.on('data', (stderr) => {
|
|
1286
|
+
output.push(stderr.toString());
|
|
1287
|
+
if (isVerbose && stderr.toString().trim()) {
|
|
1288
|
+
console.warn(stderr.toString());
|
|
1289
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
1290
|
+
}
|
|
1291
|
+
});
|
|
1292
|
+
const finishWithCode = (code) => {
|
|
1293
|
+
if (code !== 0) {
|
|
1294
|
+
if (crashOnError) {
|
|
1295
|
+
reject(new Error(output.join('\n').trim() ||
|
|
1296
|
+
`Command "${humanReadableCommand}" exited with code ${code}`));
|
|
1297
|
+
}
|
|
1298
|
+
else {
|
|
1299
|
+
if (isVerbose) {
|
|
1300
|
+
console.warn(`Command "${humanReadableCommand}" exited with code ${code}`);
|
|
1301
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
1302
|
+
}
|
|
1303
|
+
resolve(spaceTrim$1(output.join('\n')));
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
else {
|
|
1307
|
+
resolve(spaceTrim$1(output.join('\n')));
|
|
1308
|
+
}
|
|
1309
|
+
};
|
|
1310
|
+
commandProcess.on('close', finishWithCode);
|
|
1311
|
+
commandProcess.on('exit', finishWithCode);
|
|
1312
|
+
commandProcess.on('disconnect', () => {
|
|
1313
|
+
// Note: Unexpected disconnection should always result in rejection
|
|
1314
|
+
reject(new Error(`Command "${humanReadableCommand}" disconnected`));
|
|
1315
|
+
});
|
|
1316
|
+
commandProcess.on('error', (error) => {
|
|
1317
|
+
if (crashOnError) {
|
|
1318
|
+
reject(new Error(`Command "${humanReadableCommand}" failed: \n${error.message}`));
|
|
1319
|
+
}
|
|
1320
|
+
else {
|
|
1321
|
+
if (isVerbose) {
|
|
1322
|
+
console.warn(error);
|
|
1323
|
+
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
1324
|
+
}
|
|
1325
|
+
resolve(spaceTrim$1(output.join('\n')));
|
|
1326
|
+
}
|
|
1327
|
+
});
|
|
1328
|
+
}
|
|
1329
|
+
catch (error) {
|
|
1330
|
+
// Note: Unexpected error in sync code should always result in rejection
|
|
1331
|
+
reject(error);
|
|
1332
|
+
}
|
|
1333
|
+
});
|
|
1334
|
+
}
|
|
1335
|
+
/**
|
|
1336
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
1144
1337
|
*/
|
|
1145
|
-
|
|
1338
|
+
|
|
1146
1339
|
/**
|
|
1147
|
-
*
|
|
1340
|
+
* [🐱🚀]
|
|
1341
|
+
* Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
|
|
1148
1342
|
*
|
|
1149
|
-
*
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1343
|
+
* You can simply use `RemoteExecutionTools` on client-side javascript and connect to your remote server.
|
|
1344
|
+
* This is useful to make all logic on browser side but not expose your API keys or no need to use customer's GPU.
|
|
1345
|
+
*
|
|
1346
|
+
* @see https://github.com/webgptorg/promptbook#remote-server
|
|
1347
|
+
* @public exported from `@promptbook/remote-server`
|
|
1348
|
+
* <- TODO: [🐱🚀] Change to `@promptbook/agent-server`
|
|
1349
|
+
*/
|
|
1350
|
+
async function startAgentServer(options) {
|
|
1351
|
+
const { port = 4440 } = options;
|
|
1352
|
+
// TODO: [🐱🚀] [🌕]
|
|
1353
|
+
const agentsServerRoot = join(__dirname, '../apps/agents-server');
|
|
1354
|
+
console.trace(`!!! Starting agents server on port ${port}...`);
|
|
1355
|
+
console.log(`!!! cwd`, process.cwd());
|
|
1356
|
+
console.log(`!!! __dirname`, __dirname);
|
|
1357
|
+
console.log(`!!! agentsServerRoot`, agentsServerRoot);
|
|
1358
|
+
await $execCommand({
|
|
1359
|
+
cwd: agentsServerRoot,
|
|
1360
|
+
command: `next dev --port ${port} `,
|
|
1361
|
+
isVerbose: true,
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1155
1364
|
/**
|
|
1156
|
-
* Note: [
|
|
1157
|
-
* TODO: [🧠][🧜♂️] Maybe join remoteServerUrl and path into single value
|
|
1365
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
1158
1366
|
*/
|
|
1159
1367
|
|
|
1160
1368
|
/**
|
|
@@ -1165,7 +1373,7 @@ true);
|
|
|
1165
1373
|
function getErrorReportUrl(error) {
|
|
1166
1374
|
const report = {
|
|
1167
1375
|
title: `🐜 Error report from ${NAME}`,
|
|
1168
|
-
body: spaceTrim((block) => `
|
|
1376
|
+
body: spaceTrim$2((block) => `
|
|
1169
1377
|
|
|
1170
1378
|
|
|
1171
1379
|
\`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
|
|
@@ -1289,6 +1497,7 @@ class AuthenticationError extends Error {
|
|
|
1289
1497
|
/**
|
|
1290
1498
|
* Generates random token
|
|
1291
1499
|
*
|
|
1500
|
+
* Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
|
|
1292
1501
|
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
1293
1502
|
*
|
|
1294
1503
|
* @private internal helper function
|
|
@@ -1298,6 +1507,7 @@ function $randomToken(randomness) {
|
|
|
1298
1507
|
return randomBytes(randomness).toString('hex');
|
|
1299
1508
|
}
|
|
1300
1509
|
/**
|
|
1510
|
+
* TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
|
|
1301
1511
|
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
1302
1512
|
*/
|
|
1303
1513
|
|
|
@@ -1364,17 +1574,20 @@ class CollectionError extends Error {
|
|
|
1364
1574
|
}
|
|
1365
1575
|
|
|
1366
1576
|
/**
|
|
1367
|
-
* This error
|
|
1577
|
+
* This error indicates error from the database
|
|
1368
1578
|
*
|
|
1369
1579
|
* @public exported from `@promptbook/core`
|
|
1370
1580
|
*/
|
|
1371
|
-
class
|
|
1581
|
+
class DatabaseError extends Error {
|
|
1372
1582
|
constructor(message) {
|
|
1373
1583
|
super(message);
|
|
1374
|
-
this.name = '
|
|
1375
|
-
Object.setPrototypeOf(this,
|
|
1584
|
+
this.name = 'DatabaseError';
|
|
1585
|
+
Object.setPrototypeOf(this, DatabaseError.prototype);
|
|
1376
1586
|
}
|
|
1377
1587
|
}
|
|
1588
|
+
/**
|
|
1589
|
+
* TODO: [🐱🚀] Explain that NotFoundError ([🐱🚀] and other specific errors) has priority over DatabaseError in some contexts
|
|
1590
|
+
*/
|
|
1378
1591
|
|
|
1379
1592
|
/**
|
|
1380
1593
|
* This error occurs when some expectation is not met in the execution of the pipeline
|
|
@@ -1436,6 +1649,19 @@ class MissingToolsError extends Error {
|
|
|
1436
1649
|
}
|
|
1437
1650
|
}
|
|
1438
1651
|
|
|
1652
|
+
/**
|
|
1653
|
+
* This error indicates that promptbook operation is not allowed
|
|
1654
|
+
*
|
|
1655
|
+
* @public exported from `@promptbook/core`
|
|
1656
|
+
*/
|
|
1657
|
+
class NotAllowed extends Error {
|
|
1658
|
+
constructor(message) {
|
|
1659
|
+
super(message);
|
|
1660
|
+
this.name = 'NotAllowed';
|
|
1661
|
+
Object.setPrototypeOf(this, NotAllowed.prototype);
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1439
1665
|
/**
|
|
1440
1666
|
* This error indicates that promptbook not found in the collection
|
|
1441
1667
|
*
|
|
@@ -1551,6 +1777,8 @@ const PROMPTBOOK_ERRORS = {
|
|
|
1551
1777
|
PromptbookFetchError,
|
|
1552
1778
|
UnexpectedError,
|
|
1553
1779
|
WrappedError,
|
|
1780
|
+
NotAllowed,
|
|
1781
|
+
DatabaseError,
|
|
1554
1782
|
// TODO: [🪑]> VersionMismatchError,
|
|
1555
1783
|
};
|
|
1556
1784
|
/**
|
|
@@ -1598,7 +1826,7 @@ function serializeError(error) {
|
|
|
1598
1826
|
const { name, message, stack } = error;
|
|
1599
1827
|
const { id } = error;
|
|
1600
1828
|
if (!Object.keys(ALL_ERRORS).includes(name)) {
|
|
1601
|
-
console.error(spaceTrim((block) => `
|
|
1829
|
+
console.error(spaceTrim$2((block) => `
|
|
1602
1830
|
|
|
1603
1831
|
Cannot serialize error with name "${name}"
|
|
1604
1832
|
|
|
@@ -1618,186 +1846,6 @@ function serializeError(error) {
|
|
|
1618
1846
|
};
|
|
1619
1847
|
}
|
|
1620
1848
|
|
|
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
1849
|
/**
|
|
1802
1850
|
* Attempts to locate the specified application on a Linux system using the 'which' command.
|
|
1803
1851
|
* Returns the path to the executable if found, or null otherwise.
|
|
@@ -1837,6 +1885,7 @@ function $provideFilesystemForNode(options) {
|
|
|
1837
1885
|
writeFile,
|
|
1838
1886
|
readdir,
|
|
1839
1887
|
mkdir,
|
|
1888
|
+
watch,
|
|
1840
1889
|
};
|
|
1841
1890
|
}
|
|
1842
1891
|
/**
|
|
@@ -2121,7 +2170,7 @@ function checkSerializableAsJson(options) {
|
|
|
2121
2170
|
}
|
|
2122
2171
|
else if (typeof value === 'object') {
|
|
2123
2172
|
if (value instanceof Date) {
|
|
2124
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
2173
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2125
2174
|
\`${name}\` is Date
|
|
2126
2175
|
|
|
2127
2176
|
Use \`string_date_iso8601\` instead
|
|
@@ -2140,7 +2189,7 @@ function checkSerializableAsJson(options) {
|
|
|
2140
2189
|
throw new UnexpectedError(`${name} is RegExp`);
|
|
2141
2190
|
}
|
|
2142
2191
|
else if (value instanceof Error) {
|
|
2143
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
2192
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2144
2193
|
\`${name}\` is unserialized Error
|
|
2145
2194
|
|
|
2146
2195
|
Use function \`serializeError\`
|
|
@@ -2163,7 +2212,7 @@ function checkSerializableAsJson(options) {
|
|
|
2163
2212
|
}
|
|
2164
2213
|
catch (error) {
|
|
2165
2214
|
assertsError(error);
|
|
2166
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
2215
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2167
2216
|
\`${name}\` is not serializable
|
|
2168
2217
|
|
|
2169
2218
|
${block(error.stack || error.message)}
|
|
@@ -2195,7 +2244,7 @@ function checkSerializableAsJson(options) {
|
|
|
2195
2244
|
}
|
|
2196
2245
|
}
|
|
2197
2246
|
else {
|
|
2198
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
2247
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2199
2248
|
\`${name}\` is unknown type
|
|
2200
2249
|
|
|
2201
2250
|
Additional message for \`${name}\`:
|
|
@@ -2225,7 +2274,7 @@ function deepClone(objectValue) {
|
|
|
2225
2274
|
TODO: [🧠] Is there a better implementation?
|
|
2226
2275
|
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
2227
2276
|
> for (const propertyName of propertyNames) {
|
|
2228
|
-
> const value = (objectValue as
|
|
2277
|
+
> const value = (objectValue as chococake)[propertyName];
|
|
2229
2278
|
> if (value && typeof value === 'object') {
|
|
2230
2279
|
> deepClone(value);
|
|
2231
2280
|
> }
|
|
@@ -2447,6 +2496,8 @@ function isValidPipelineUrl(url) {
|
|
|
2447
2496
|
* - if it is valid json
|
|
2448
2497
|
* - if it is meaningful
|
|
2449
2498
|
*
|
|
2499
|
+
* Note: [🔂] This function is idempotent.
|
|
2500
|
+
*
|
|
2450
2501
|
* @param pipeline valid or invalid PipelineJson
|
|
2451
2502
|
* @returns the same pipeline if it is logically valid
|
|
2452
2503
|
* @throws {PipelineLogicError} on logical error in the pipeline
|
|
@@ -2803,7 +2854,7 @@ function jsonParse(value) {
|
|
|
2803
2854
|
}
|
|
2804
2855
|
else if (typeof value !== 'string') {
|
|
2805
2856
|
console.error('Can not parse JSON from non-string value.', { text: value });
|
|
2806
|
-
throw new Error(spaceTrim(`
|
|
2857
|
+
throw new Error(spaceTrim$2(`
|
|
2807
2858
|
Can not parse JSON from non-string value.
|
|
2808
2859
|
|
|
2809
2860
|
The value type: ${typeof value}
|
|
@@ -2817,7 +2868,7 @@ function jsonParse(value) {
|
|
|
2817
2868
|
if (!(error instanceof Error)) {
|
|
2818
2869
|
throw error;
|
|
2819
2870
|
}
|
|
2820
|
-
throw new Error(spaceTrim((block) => `
|
|
2871
|
+
throw new Error(spaceTrim$2((block) => `
|
|
2821
2872
|
${block(error.message)}
|
|
2822
2873
|
|
|
2823
2874
|
The expected JSON text:
|
|
@@ -2870,7 +2921,7 @@ function deserializeError(error) {
|
|
|
2870
2921
|
message = `${name}: ${message}`;
|
|
2871
2922
|
}
|
|
2872
2923
|
if (stack !== undefined && stack !== '') {
|
|
2873
|
-
message = spaceTrim((block) => `
|
|
2924
|
+
message = spaceTrim$2((block) => `
|
|
2874
2925
|
${block(message)}
|
|
2875
2926
|
|
|
2876
2927
|
Original stack trace:
|
|
@@ -2938,6 +2989,7 @@ function createTask(options) {
|
|
|
2938
2989
|
let updatedAt = createdAt;
|
|
2939
2990
|
const errors = [];
|
|
2940
2991
|
const warnings = [];
|
|
2992
|
+
const llmCalls = [];
|
|
2941
2993
|
let currentValue = {};
|
|
2942
2994
|
let customTldr = null;
|
|
2943
2995
|
const partialResultSubject = new Subject();
|
|
@@ -2953,6 +3005,9 @@ function createTask(options) {
|
|
|
2953
3005
|
}, (tldrInfo) => {
|
|
2954
3006
|
customTldr = tldrInfo;
|
|
2955
3007
|
updatedAt = new Date();
|
|
3008
|
+
}, (llmCall) => {
|
|
3009
|
+
llmCalls.push(llmCall);
|
|
3010
|
+
updatedAt = new Date();
|
|
2956
3011
|
});
|
|
2957
3012
|
finalResultPromise
|
|
2958
3013
|
.catch((error) => {
|
|
@@ -3075,7 +3130,7 @@ function createTask(options) {
|
|
|
3075
3130
|
}
|
|
3076
3131
|
return {
|
|
3077
3132
|
percent: percent,
|
|
3078
|
-
message,
|
|
3133
|
+
message: message + ' (!!!fallback)',
|
|
3079
3134
|
};
|
|
3080
3135
|
},
|
|
3081
3136
|
get createdAt() {
|
|
@@ -3098,6 +3153,10 @@ function createTask(options) {
|
|
|
3098
3153
|
return warnings;
|
|
3099
3154
|
// <- Note: [1] --||--
|
|
3100
3155
|
},
|
|
3156
|
+
get llmCalls() {
|
|
3157
|
+
return [...llmCalls, { foo: '!!! bar' }];
|
|
3158
|
+
// <- Note: [1] --||--
|
|
3159
|
+
},
|
|
3101
3160
|
get currentValue() {
|
|
3102
3161
|
return currentValue;
|
|
3103
3162
|
// <- Note: [1] --||--
|
|
@@ -3177,7 +3236,7 @@ const UNCERTAIN_USAGE = $deepFreeze({
|
|
|
3177
3236
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
3178
3237
|
*/
|
|
3179
3238
|
|
|
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-9",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"Asistent pro LŠVP\n\nPERSONA Jsi asistent pro RVP Lyceum v rámci Národního pedagogického institutu České Republiky\nMETA IMAGE https://edulk.cz/getFile/id:475818/type:large/02%20zna%C4%8Dka%20npi.jpg\nRULE Pokud jsi nejsi jistý, napiš nevím\nKNOWLEDGE ./241129_Lyceum_final.pdf\nCONTEXT Obecně dokážeš řešit libovolné ŠVP, aktuálně řešíš {Školní vzdělávací program LYCEUM}\nRULE Z {Porovnání RVP a ŠVP - postup} je nejdůležitější fáze 3\nKNOWLEDGE {Školní vzdělávací program LYCEUM} ./ŠVP Lyceum - Finance v digitální době.pdf\nKNOWLEDGE @Slovník\n\n**Interní slovník - RVP/ŠVP**\n\n**RVP**\n\nRámcový vzdělávací program pro obor vzdělání Lyceum je dokument na národní úrovni, který formuluje požadavky na školní vzdělávací programy ve formě především očekávaných výsledků učení, kterých mají žáci absolvováním tohoto programu na dané škole dosáhnout.\n\n**ŠVP**\n\nŠkolní vzdělávací program pro obor vzdělání Lyceum je dokument každé jednotlivé školy, který popisuje v jakých vyučovacích předmětech/ vzdělávacích modulech a v jakých ročnících budou požadované očekávané výsledky učení naplněny. Zároveň formuluje další očekávané výsledky učení, které naplňují disponibilní část vyučovacího času určeného RVP pro tento obor vzdělání.\n\n**Očekávaný výsledek učení (OVU)**\n\nVyjadřuje jednotlivý požadavek na to, co mají žáci umět na konci vzdělávacího programu, tzn. jejich požadované kompetence. Je vyjádřen formulací, která je uvozena činnostním slovesem a dále obsahuje předmět této činnosti. Formulace je konkretizována resp. doplněna zpravidla formou odrážek vymezením dílčích znalostí, dovedností, postojů, jejichž splnění je předpokladem dosažení OVU jako celku.\n\n_Příklad:_\n\n<div class=\"joplin-table-wrapper\"><table><tbody><tr><th><p><strong>Žák/žákyně řídí realizaci jednoduchého projektu</strong></p></th></tr><tr><td><ul><li>naplánuje aktivity projektu</li></ul></td></tr><tr><td><ul><li>navrhne rozpočet projektu vzhledem k navrženým aktivitám</li></ul></td></tr><tr><td><ul><li>stanoví základní ukazatele a sleduje jejich naplňování</li></ul></td></tr><tr><td><ul><li>vede projektový tým</li></ul></td></tr><tr><td><ul><li>uvede, jak by řešil krizové situace v projektu</li></ul></td></tr><tr><td><ul><li>vyhodnotí úspěšnost projektu</li></ul></td></tr></tbody></table></div>\n\n**Vzdělávací oblasti**\n\nOčekávané výsledky učení jsou v **_RVP členěny do 4 vzdělávacích oblastí_**, které tvoří společný všeobecně vzdělávací základ:\n\n- Osobnostní rozvoj, vzdělávání ke zdraví, bezpečí a produktivnímu pracovnímu životu (kariéře)\n- Komunikační a jazykové vzdělávání\n- Aplikované vzdělávání STEM (Science, Technology, Engeneering, Math), tj. přírodní vědy, informatika, technika, matematika\n- Prakticky orientované vzdělávání společenskovědní a humanitní\n\nKaždá vzdělávací oblast se dále člení na okruhy, v jejichž rámci jsou OVU samostatně číslované.\n\n<div class=\"joplin-table-wrapper\"><table><tbody><tr><th rowspan=\"21\"><ul><li>Prakticky orientované vzdělávání společenskovědní a humanitní</li></ul></th><th rowspan=\"21\"><p><strong>Člověk, ekonomie a podnikání</strong></p></th><th rowspan=\"7\"><p><strong>1</strong></p></th><th><p><strong>zpracuje podklady související s podnikáním</strong></p></th></tr><tr><td><p>připraví podnikatelský záměr</p></td></tr><tr><td><p>sestaví zakladatelský rozpočet</p></td></tr><tr><td><p>zkalkuluje cenu zboží nebo služby</p></td></tr><tr><td><p>vysvětlí na příkladu základní povinnosti podnikatele vůči státu a zaměstnancům</p></td></tr><tr><td><p>vede daňovou evidenci</p></td></tr><tr><td><p>vysvětlí na příkladech etiku v podnikání</p></td></tr><tr><td rowspan=\"7\"><p><strong>2</strong></p></td><td><p><strong>řídí realizaci jednoduchého projektu</strong></p></td></tr><tr><td><p>naplánuje aktivity projektu</p></td></tr><tr><td><p>navrhne rozpočet projektu vzhledem k navrženým aktivitám</p></td></tr><tr><td><p>stanoví základní ukazatele a sleduje jejich naplňování</p></td></tr><tr><td><p>vede projektový tým</p></td></tr><tr><td><p>uvede, jak by řešil krizové situace v projektu</p></td></tr><tr><td><p>vyhodnotí úspěšnost projektu</p></td></tr><tr><td rowspan=\"7\"><p><strong>3</strong></p></td><td><p><strong>aplikuje ekonomické teorie v osobním a profesním životě</strong></p></td></tr><tr><td><p>vysvětlí základní ekonomické otázky</p></td></tr><tr><td><p>vysvětí stanovení rovnovážné ceny na dokonalém i nedokonalém trhu</p></td></tr><tr><td><p>charakterizuje výrobní faktory a vysvětlí hranici produkčních možností a náklady obětované příležitosti</p></td></tr><tr><td><p>uvede nejdůležitější makroekonomické pojmy a vliv jejich výše na kvalitu života a podnikání v daném státě</p></td></tr><tr><td><p>vysvětlí podstatu inflace a její důsledky na finanční situaci obyvatel a na příkladu ukáže jak se bránit jejím nepříznivým důsledkům</p></td></tr><tr><td><p>uvede hlavní výhody a nevýhody mezinárodního obchodu a vliv ochranářských opatření na ekonomickou situaci dané země</p></td></tr><tr><td></td><td></td><td><p><strong>4</strong></p></td><td><p>Atd.</p></td></tr></tbody></table></div>\n\n**Vyučovací předmět / vzdělávací modul**\n\nOčekávané výsledky učení jsou v **ŠVP** členěny do vyučovacích předmětů nebo vzdělávacích modulů, které jsou dále zařazeny do jednoho nebo více ročníků 4letého studia. Vyučovací předmět / vzdělávací modul tvoří vyučovací jednotku, kde jsou očekávané výsledky učení dále rozpracovány pro potřeby výuky podle následující šablony\n\n| **A. VSTUPNÍ ČÁST** |\n| --- |\n| **1\\. Název** |\n| **2\\. Kód** (kódy by měly být navázány na obory vzdělání a výsledky učení) |\n| **2a) Kategorie vzdělání** - v případě, že nebude součástí kódu |\n| **3\\. Typ vyučovací jednotky** (modul, předmět, stáž apod.) |\n| **4\\. Délka** (počet hodin - dělitelný čtyřmi (optimální modul 16, 32 hodin = týden výuky) |\n| **5\\. Platnost** (datum, od kterého platí) |\n| **6\\. Vstupní předpoklady** (vymezení požadované úrovně vstupních vědomostí a dovedností, které jsou předpokladem úspěšného studia) |\n| |\n| **B. JÁDRO VYUČOVACÍ JEDNOTKY** |\n| **1\\. Charakteristika** (stručná anotace popisující obecné cíle a pojetí) |\n| **2\\. Očekávané výsledky učení a jejich indikátory (převzaté z RVP nebo dále konkretizované)** |\n| **3\\. Podpora rozvoje klíčových kompetencí a základních gramotností** (které klíčové kompetence jsou v rozvíjeny) |\n| **4\\. Obsah vzdělávání** (rozpis učiva) |\n| **5\\. Vzdělávací strategie** (strategie výuky, resp. učební činnosti žáků, které jsou doporučené pro dosažení výsledků) |\n| |\n| **C. VÝSTUPNÍ ČÁST** |\n| **1\\. Způsob ověřování dosažených výsledků** (ve vazbě na jednotlivé výsledky učení) |\n| **2\\. Kritéria hodnocení** (co znamená splnění výsledků učení, kdy je splněna celá vyučovací jednotka, kritéria pro známky, příp. procentuální, slovní hodnocení) |\n| **3\\. Doporučená studijní literatura, odkazy na ilustrační zdroje** |\n| **4\\. Poznámky** |\n\n**Soulad OVU RVP a ŠVP**\n\nTento soulad je předmětem zjišťování. Soulad nastává, jestliže jsou očekávané výsledky učení z jednotlivých vzdělávacích oblastí RVP **obsaženy** ve vyučovacích předmětech/ vzdělávacích modulech ŠVP jednotlivých škol, tzn. že v ŠVP se objevuje jejich formulace buď v doslovném nebo podobném znění v jednom nebo více vyučovacích předmětech/ vzdělávacích modulech.\n\n_Příklad souladu:_\n\nRVP ŠVP - komunikace a marketing (SŠ obchodní Č.\n\n| **2** | **řídí realizaci jednoduchého projektu** |\n| --- | --- |\n| naplánuje aktivity projektu |\n| navrhne rozpočet projektu vzhledem k navrženým aktivitám |\n| stanoví základní ukazatele a sleduje jejich naplňování |\n| vede projektový tým |\n| uvede, jak by řešil krizové situace v projektu |\n| vyhodnotí úspěšnost projektu |\n\nKNOWLEDGE {Porovnání RVP a ŠVP - postup}\n\n\n# AUDITNÍ PROTOKOL ŠVP-RVP\n\n# (POPIS KONTROLNÍHO ALGORITMU)\n\nMetodika je určena pro **Kvantifikaci Shody** školního vzdělávacího programu (ŠVP) s Rámcovým vzdělávacím programem (RVP).\n\n## FÁZE 1: VALIDACE DOKUMENTACE\n\n**Cíl:** Ověřit platnost, aktuálnost a strukturu zdrojových dokumentů.\n\n- **RVP Verifikace:** Otevřít aktuální verzi RVP (např. RVP ZV/G/SOŠ).\n- **Typová shoda:** Ověřit, že RVP se vztahuje k danému typu školy.\n- **ŠVP Dimenze:** Identifikovat a izolovat relevantní části ŠVP: Profil absolventa, Klíčové kompetence (KK), Vzdělávací oblasti (VO), případně Učební plán (UP).\n- **Verzování:** Potvrdit, že obě verze (RVP a ŠVP) jsou nejnovější a platné (včetně dodatků RVP).\n\n## FÁZE 2: DATABÁZOVÉ MAPOVÁNÍ VÝSTUPŮ (MASTER MATICE)\n\n**Cíl:** Vytvořit systémovou databázi pro křížové porovnání všech povinných komponent RVP se ŠVP.\n\n- **Dekompozice RVP:** Rozložit RVP na základní povinné komponenty: Klíčové kompetence, Vzdělávací oblasti a obory, Očekávané výstupy (OVU), Průřezová témata (PT).\n- **Přiřazovací mapa:** Vytvořit hlavní kontrolní matici (Master Matice) pro záznam vazeb.\n\n| Oblast RVP | Výstup RVP (OVU) | Odpovídající Část ŠVP (Předmět/Ročník) | Konkrétní Tématický Celek v ŠVP | Stav Shody (Protokol) |\n| --- | --- | --- | --- | --- |\n| ... | ... | ... | ... | ... |\n| --- | --- | --- | --- | --- |\n\n## FÁZE 3: ALGORITMICKÁ KONTROLA POKRYTÍ A HLOUBKY\n\n**Cíl:** Posoudit, zda každý povinný výstup RVP je adekvátně reflektován v obsahu ŠVP, a přidělit bodovou hodnotu pro kvantifikaci.\n\n- **Audit OVU:** Projít každý jednotlivý Očekávaný výstup (OVU) z RVP.\n- **Kódování stavu a bodování:** U každého OVU v matici označit stav pokrytí dle následujícího schématu:\n\n| Kód (Protokol) | Popis (Kvalitativní zjištění) | Bodová hodnota (Kvantifikace) |\n| --- | --- | --- |\n| ✅ | Plná shoda (Výstup pokryt v plném rozsahu, odpovídající úrovni RVP) | 1,0 |\n| --- | --- | --- |\n| ⚠️ | Částečná shoda (Formální pokrytí, omezený rozsah, chybná návaznost) | 0,5 |\n| --- | --- | --- |\n| ❌ | Absence (Výstup zcela chybí v obsahu ŠVP) | 0,0 |\n| --- | --- | --- |\n\n- **Defektologie ŠVP:** Identifikovat a zaznamenat deficity ŠVP: Chybějící výstupy (❌), Sémantické překryvy, Přetížení obsahu.\n- **Kvalitativní posun:** Ověřit, zda je formulace výstupů v ŠVP **aktivní, měřitelná a v souladu** s úrovní RVP.\n\n## FÁZE 4: STRUKTURÁLNÍ VERIFIKACE NÁVAZNOSTI (VERTIKÁLA/HORIZONTÁLA)\n\n**Cíl:** Zkontrolovat logickou posloupnost a provázanost učiva v rámci ŠVP.\n\n- **Vertikální Kontrola:** Ověřit posloupnost OVU a učiva uvnitř jednoho předmětu/oblasti (postup od jednodušších ke složitějším konceptům napříč ročníky).\n- **Horizontální Kontrola:** Zkontrolovat logické provázání napříč vzdělávacími oblastmi a předměty (např. fyzika ↔ matematika).\n- **PT Integrace:** Audit reálné integrace Průřezových témat (PT) do konkrétních částí obsahu, metod a projektů.\n\n## FÁZE 5: ANALÝZA ŠKOLNÍ PROFILACE A ROZŠÍŘENÍ RVP\n\n**Cíl:** Validovat, že profilace školy je **v souladu** s RVP a nejedná se o **rozpor**.\n\n- **Nekonfliktnost:** Porovnat definovaný Profil absolventa školy s Klíčovými kompetencemi RVP. Profil ŠVP musí RVP rozvíjet, nikoli mu odporovat.\n- **Modularita:** Zkontrolovat, zda volitelné předměty a rozšiřující moduly logicky navazují na vzdělávací oblasti RVP.\n- **Implementace specializace:** Popisně uvést, jak je školní profilace (např. STEM zaměření, projektová výuka) integrována do OVU a kompetencí definovaných RVP.\n\n## FÁZE 6: GENERÁTOR ZÁVĚREČNÉ ZPRÁVY A KVANTIFIKACE\n\n**Cíl:** Syntetizovat výsledky, kvantifikovat soulad a generovat závazné návrhy na korekce.\n\n### 6.1 Kvantifikace Souladu\n\nVypočítat Index shody (IS) na základě bodového hodnocení (Fáze 3):\n\n### 6.2 Interpretace Indexu Shody (IS)\n\nKlasifikace souladu pro standardizované vyhodnocení:\n\n| Interval IS | Klasifikace souladu | Popis |\n| --- | --- | --- |\n| 95-100 % | Výborný soulad | ŠVP plně odpovídá RVP, pouze stylistické nebo formální rozdíly. |\n| --- | --- | --- |\n| 85-94 % | Dobrá shoda | ŠVP pokrývá všechny klíčové výstupy, menší korekce nutné. |\n| --- | --- | --- |\n| 70-84 % | Částečná shoda | Významné nedostatky v některých oblastech, nutná revize obsahu. |\n| --- | --- | --- |\n| < 70 % | Kritická neshoda | ŠVP neplní rámcové požadavky, ohrožuje legislativní soulad. |\n| --- | --- | --- |\n\n### 6.3 Doplňkové Indexy\n\nVypočítat následující doplňkové indexy pro detailní kvalitativní analýzu:\n\n- **Index kompetenčního souladu (IKS):** Poměr pokrytí klíčových kompetencí RVP v ŠVP.\n- **Index průřezové integrace (IPI):** Míra reálné integrace průřezových témat do výuky.\n- **Index hloubky pokrytí (IHP):** Procento výstupů, které jsou v ŠVP rozvedeny na konkrétní výukové cíle (měřitelné, aktivní formulace).\n- **Index profilové rozšiřitelnosti (IPR):** Kolik rozšiřujících nebo profilových výstupů přesahuje rámec RVP, aniž by narušily jeho strukturu.\n\n### 6.4 Vizuální výstupy\n\nZajistit generování následujících vizualizací pro Závěrečnou zprávu:\n\n- Graf pokrytí po vzdělávacích oblastech (Sloupcový graf IS pro VO).\n- Pavoukový diagram Klíčových kompetencí (RVP vs. ŠVP).\n- Mapa defektů (Vizualizace ❌ a ⚠️ výstupů).\n\n### 6.5 Struktura Závěrečné Zprávy\n\nZpráva musí být strukturována dle standardizovaného formátu:\n\n| Oddíl | Obsah |\n| --- | --- |\n| A. Identifikace | Název školy, IZO, typ školy, datum revize, zpracovatel, verze ŠVP a RVP. |\n| --- | --- |\n| B. Shrnutí výsledků | Celkový Index Shody (IS), hlavní závěry a doporučení. |\n| --- | --- |\n| C. Kvantitativní analýza | Přehled IS v % dle kategorií OVU / VO / kompetencí. |\n| --- | --- |\n| D. Kvalitativní analýza | Slovní zhodnocení kvality souladu (formulace, obtížnost, integrace PT). |\n| --- | --- |\n| E. Rizikové oblasti | Přehled nalezených defektů (chybějící OVU, přetížení, formální shoda). |\n| --- | --- |\n| F. Návrhy opatření (Korekční plán) | Přesné návrhy změn - **Co, Kde, Kdo** má upravit, včetně termínu. |\n| --- | --- |\n| G. Přílohy | Master Matice (Fáze 2-3), revizní tabulka, výstupní grafy a metriky. |\n| --- | --- |\n\n\n\n\n.\n"}],sourceFile:"./books/examples/lsvp-asistent.book"}];
|
|
3239
|
+
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
3240
|
|
|
3182
3241
|
/**
|
|
3183
3242
|
* Checks if value is valid email
|
|
@@ -3254,6 +3313,8 @@ function isValidFilePath(filename) {
|
|
|
3254
3313
|
* Function `validatePipelineString` will validate the if the string is a valid pipeline string
|
|
3255
3314
|
* 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
3315
|
*
|
|
3316
|
+
* Note: [🔂] This function is idempotent.
|
|
3317
|
+
*
|
|
3257
3318
|
* @param {string} pipelineString the candidate for a pipeline string
|
|
3258
3319
|
* @returns {PipelineString} the same string as input, but validated as valid
|
|
3259
3320
|
* @throws {ParseError} if the string is not a valid pipeline string
|
|
@@ -3413,7 +3474,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
3413
3474
|
pipelineString += '\n\n';
|
|
3414
3475
|
pipelineString += '```' + contentLanguage;
|
|
3415
3476
|
pipelineString += '\n';
|
|
3416
|
-
pipelineString += spaceTrim(content);
|
|
3477
|
+
pipelineString += spaceTrim$2(content);
|
|
3417
3478
|
// <- TODO: [main] !!3 Escape
|
|
3418
3479
|
// <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
|
|
3419
3480
|
pipelineString += '\n';
|
|
@@ -3501,7 +3562,7 @@ function unpreparePipeline(pipeline) {
|
|
|
3501
3562
|
* Library of pipelines that groups together pipelines for an application.
|
|
3502
3563
|
* This implementation is a very thin wrapper around the Array / Map of pipelines.
|
|
3503
3564
|
*
|
|
3504
|
-
* @private internal function of `
|
|
3565
|
+
* @private internal function of `createPipelineCollectionFromJson`, use `createPipelineCollectionFromJson` instead
|
|
3505
3566
|
* @see https://github.com/webgptorg/pipeline#pipeline-collection
|
|
3506
3567
|
*/
|
|
3507
3568
|
class SimplePipelineCollection {
|
|
@@ -3511,7 +3572,7 @@ class SimplePipelineCollection {
|
|
|
3511
3572
|
* @param pipelines Array of pipeline JSON objects to include in the collection
|
|
3512
3573
|
*
|
|
3513
3574
|
* Note: During the construction logic of all pipelines are validated
|
|
3514
|
-
* Note: It is not recommended to use this constructor directly, use `
|
|
3575
|
+
* Note: It is not recommended to use this constructor directly, use `createPipelineCollectionFromJson` *(or other variant)* instead
|
|
3515
3576
|
*/
|
|
3516
3577
|
constructor(...pipelines) {
|
|
3517
3578
|
this.collection = new Map();
|
|
@@ -3599,16 +3660,16 @@ class SimplePipelineCollection {
|
|
|
3599
3660
|
}
|
|
3600
3661
|
|
|
3601
3662
|
/**
|
|
3602
|
-
* Creates PipelineCollection from array of PipelineJson or PipelineString
|
|
3663
|
+
* Creates `PipelineCollection` from array of PipelineJson or PipelineString
|
|
3603
3664
|
*
|
|
3604
|
-
* Note: Functions `
|
|
3665
|
+
* Note: Functions `pipelineCollectionToJson` and `createPipelineCollectionFromJson` are complementary
|
|
3605
3666
|
* Note: Syntax, parsing, and logic consistency checks are performed on all sources during build
|
|
3606
3667
|
*
|
|
3607
3668
|
* @param promptbookSources
|
|
3608
3669
|
* @returns PipelineCollection
|
|
3609
3670
|
* @public exported from `@promptbook/core`
|
|
3610
3671
|
*/
|
|
3611
|
-
function
|
|
3672
|
+
function createPipelineCollectionFromJson(...promptbooks) {
|
|
3612
3673
|
return new SimplePipelineCollection(...promptbooks);
|
|
3613
3674
|
}
|
|
3614
3675
|
|
|
@@ -3809,14 +3870,14 @@ class MultipleLlmExecutionTools {
|
|
|
3809
3870
|
if (description === undefined) {
|
|
3810
3871
|
return headLine;
|
|
3811
3872
|
}
|
|
3812
|
-
return spaceTrim((block) => `
|
|
3873
|
+
return spaceTrim$2((block) => `
|
|
3813
3874
|
${headLine}
|
|
3814
3875
|
|
|
3815
3876
|
${ /* <- Note: Indenting the description: */block(description)}
|
|
3816
3877
|
`);
|
|
3817
3878
|
})
|
|
3818
3879
|
.join('\n\n');
|
|
3819
|
-
return spaceTrim((block) => `
|
|
3880
|
+
return spaceTrim$2((block) => `
|
|
3820
3881
|
Multiple LLM Providers:
|
|
3821
3882
|
|
|
3822
3883
|
${block(innerModelsTitlesAndDescriptions)}
|
|
@@ -3907,7 +3968,7 @@ class MultipleLlmExecutionTools {
|
|
|
3907
3968
|
// 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
3908
3969
|
// 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
|
|
3909
3970
|
// 3) ...
|
|
3910
|
-
spaceTrim((block) => `
|
|
3971
|
+
spaceTrim$2((block) => `
|
|
3911
3972
|
All execution tools of ${this.title} failed:
|
|
3912
3973
|
|
|
3913
3974
|
${block(errors
|
|
@@ -3920,7 +3981,7 @@ class MultipleLlmExecutionTools {
|
|
|
3920
3981
|
throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
|
|
3921
3982
|
}
|
|
3922
3983
|
else {
|
|
3923
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
3984
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
3924
3985
|
You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
|
|
3925
3986
|
|
|
3926
3987
|
Available \`LlmExecutionTools\`:
|
|
@@ -3953,7 +4014,7 @@ class MultipleLlmExecutionTools {
|
|
|
3953
4014
|
*/
|
|
3954
4015
|
function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
3955
4016
|
if (llmExecutionTools.length === 0) {
|
|
3956
|
-
const warningMessage = spaceTrim(`
|
|
4017
|
+
const warningMessage = spaceTrim$2(`
|
|
3957
4018
|
You have not provided any \`LlmExecutionTools\`
|
|
3958
4019
|
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
4020
|
|
|
@@ -3986,6 +4047,7 @@ function joinLlmExecutionTools(title, ...llmExecutionTools) {
|
|
|
3986
4047
|
return new MultipleLlmExecutionTools(title || 'Multiple LLM Providers joined by `joinLlmExecutionTools`', ...llmExecutionTools);
|
|
3987
4048
|
}
|
|
3988
4049
|
/**
|
|
4050
|
+
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
3989
4051
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
3990
4052
|
*/
|
|
3991
4053
|
|
|
@@ -4002,6 +4064,7 @@ function getSingleLlmExecutionTools(oneOrMoreLlmExecutionTools) {
|
|
|
4002
4064
|
return llmTools;
|
|
4003
4065
|
}
|
|
4004
4066
|
/**
|
|
4067
|
+
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
4005
4068
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
4006
4069
|
*/
|
|
4007
4070
|
|
|
@@ -4017,7 +4080,7 @@ async function preparePersona(personaDescription, tools, options) {
|
|
|
4017
4080
|
throw new MissingToolsError('LLM tools are required for preparing persona');
|
|
4018
4081
|
}
|
|
4019
4082
|
// TODO: [🌼] In future use `ptbk make` and made getPipelineCollection
|
|
4020
|
-
const collection =
|
|
4083
|
+
const collection = createPipelineCollectionFromJson(...PipelineCollection);
|
|
4021
4084
|
const preparePersonaExecutor = createPipelineExecutor({
|
|
4022
4085
|
pipeline: await collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book'),
|
|
4023
4086
|
tools,
|
|
@@ -4268,14 +4331,14 @@ function $registeredScrapersMessage(availableScrapers) {
|
|
|
4268
4331
|
return { ...metadata, isMetadataAviailable, isInstalled, isAvailableInTools };
|
|
4269
4332
|
});
|
|
4270
4333
|
if (metadata.length === 0) {
|
|
4271
|
-
return spaceTrim(`
|
|
4334
|
+
return spaceTrim$2(`
|
|
4272
4335
|
**No scrapers are available**
|
|
4273
4336
|
|
|
4274
4337
|
This is a unexpected behavior, you are probably using some broken version of Promptbook
|
|
4275
4338
|
At least there should be available the metadata of the scrapers
|
|
4276
4339
|
`);
|
|
4277
4340
|
}
|
|
4278
|
-
return spaceTrim((block) => `
|
|
4341
|
+
return spaceTrim$2((block) => `
|
|
4279
4342
|
Available scrapers are:
|
|
4280
4343
|
${block(metadata
|
|
4281
4344
|
.map(({ packageName, className, isMetadataAviailable, isInstalled, mimeTypes, isAvailableInBrowser, isAvailableInTools, }, i) => {
|
|
@@ -4583,6 +4646,8 @@ function removeDiacritics(input) {
|
|
|
4583
4646
|
/**
|
|
4584
4647
|
* Converts a given text to kebab-case format.
|
|
4585
4648
|
*
|
|
4649
|
+
* Note: [🔂] This function is idempotent.
|
|
4650
|
+
*
|
|
4586
4651
|
* @param text The text to be converted.
|
|
4587
4652
|
* @returns The kebab-case formatted string.
|
|
4588
4653
|
* @example 'hello-world'
|
|
@@ -4738,6 +4803,8 @@ function removeEmojis(text) {
|
|
|
4738
4803
|
/**
|
|
4739
4804
|
* Converts a title string into a normalized name.
|
|
4740
4805
|
*
|
|
4806
|
+
* Note: [🔂] This function is idempotent.
|
|
4807
|
+
*
|
|
4741
4808
|
* @param value The title string to be converted to a name.
|
|
4742
4809
|
* @returns A normalized name derived from the input title.
|
|
4743
4810
|
* @example 'Hello World!' -> 'hello-world'
|
|
@@ -4777,7 +4844,7 @@ const promptbookFetch = async (urlOrRequest, init) => {
|
|
|
4777
4844
|
else if (urlOrRequest instanceof Request) {
|
|
4778
4845
|
url = urlOrRequest.url;
|
|
4779
4846
|
}
|
|
4780
|
-
throw new PromptbookFetchError(spaceTrim((block) => `
|
|
4847
|
+
throw new PromptbookFetchError(spaceTrim$2((block) => `
|
|
4781
4848
|
Can not fetch "${url}"
|
|
4782
4849
|
|
|
4783
4850
|
Fetch error:
|
|
@@ -4938,7 +5005,7 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
|
4938
5005
|
const fileExtension = getFileExtension(filename);
|
|
4939
5006
|
const mimeType = extensionToMimeType(fileExtension || '');
|
|
4940
5007
|
if (!(await isFileExisting(filename, tools.fs))) {
|
|
4941
|
-
throw new NotFoundError(spaceTrim((block) => `
|
|
5008
|
+
throw new NotFoundError(spaceTrim$2((block) => `
|
|
4942
5009
|
Can not make source handler for file which does not exist:
|
|
4943
5010
|
|
|
4944
5011
|
File:
|
|
@@ -5031,7 +5098,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
5031
5098
|
// <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
|
|
5032
5099
|
break;
|
|
5033
5100
|
}
|
|
5034
|
-
console.warn(spaceTrim((block) => `
|
|
5101
|
+
console.warn(spaceTrim$2((block) => `
|
|
5035
5102
|
Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
|
|
5036
5103
|
|
|
5037
5104
|
The source:
|
|
@@ -5047,7 +5114,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
|
|
|
5047
5114
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
5048
5115
|
}
|
|
5049
5116
|
if (partialPieces === null) {
|
|
5050
|
-
throw new KnowledgeScrapeError(spaceTrim((block) => `
|
|
5117
|
+
throw new KnowledgeScrapeError(spaceTrim$2((block) => `
|
|
5051
5118
|
Cannot scrape knowledge
|
|
5052
5119
|
|
|
5053
5120
|
The source:
|
|
@@ -5212,7 +5279,7 @@ async function preparePipeline(pipeline, tools, options) {
|
|
|
5212
5279
|
let title = pipeline.title;
|
|
5213
5280
|
if (title === undefined || title === '' || title === DEFAULT_BOOK_TITLE) {
|
|
5214
5281
|
// TODO: [🌼] In future use `ptbk make` and made getPipelineCollection
|
|
5215
|
-
const collection =
|
|
5282
|
+
const collection = createPipelineCollectionFromJson(...PipelineCollection);
|
|
5216
5283
|
const prepareTitleExecutor = createPipelineExecutor({
|
|
5217
5284
|
pipeline: await collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-title.book'),
|
|
5218
5285
|
tools,
|
|
@@ -5622,7 +5689,7 @@ const CsvFormatParser = {
|
|
|
5622
5689
|
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
5623
5690
|
const csv = csvParse(value, settings);
|
|
5624
5691
|
if (csv.errors.length !== 0) {
|
|
5625
|
-
throw new CsvFormatError(spaceTrim((block) => `
|
|
5692
|
+
throw new CsvFormatError(spaceTrim$2((block) => `
|
|
5626
5693
|
CSV parsing error
|
|
5627
5694
|
|
|
5628
5695
|
Error(s) from CSV parsing:
|
|
@@ -5667,7 +5734,7 @@ const CsvFormatParser = {
|
|
|
5667
5734
|
const { value, settings, mapCallback, onProgress } = options;
|
|
5668
5735
|
const csv = csvParse(value, settings);
|
|
5669
5736
|
if (csv.errors.length !== 0) {
|
|
5670
|
-
throw new CsvFormatError(spaceTrim((block) => `
|
|
5737
|
+
throw new CsvFormatError(spaceTrim$2((block) => `
|
|
5671
5738
|
CSV parsing error
|
|
5672
5739
|
|
|
5673
5740
|
Error(s) from CSV parsing:
|
|
@@ -5877,7 +5944,7 @@ function mapAvailableToExpectedParameters(options) {
|
|
|
5877
5944
|
}
|
|
5878
5945
|
// Phase 2️⃣: Non-matching mapping
|
|
5879
5946
|
if (expectedParameterNames.size !== availableParametersNames.size) {
|
|
5880
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
5947
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
5881
5948
|
Can not map available parameters to expected parameters
|
|
5882
5949
|
|
|
5883
5950
|
Mapped parameters:
|
|
@@ -6141,10 +6208,13 @@ const LINES_PER_STANDARD_PAGE = 44;
|
|
|
6141
6208
|
* @public exported from `@promptbook/utils`
|
|
6142
6209
|
*/
|
|
6143
6210
|
function countLines(text) {
|
|
6211
|
+
if (text === '') {
|
|
6212
|
+
return 0;
|
|
6213
|
+
}
|
|
6144
6214
|
text = text.replace('\r\n', '\n');
|
|
6145
6215
|
text = text.replace('\r', '\n');
|
|
6146
6216
|
const lines = text.split('\n');
|
|
6147
|
-
return lines.reduce((count, line) => count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 0);
|
|
6217
|
+
return lines.reduce((count, line) => count + Math.max(Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 1), 0);
|
|
6148
6218
|
}
|
|
6149
6219
|
/**
|
|
6150
6220
|
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
@@ -6269,6 +6339,8 @@ function checkExpectations(expectations, value) {
|
|
|
6269
6339
|
* This function provides a common abstraction for result validation that can be used
|
|
6270
6340
|
* by both execution logic and caching logic to ensure consistency.
|
|
6271
6341
|
*
|
|
6342
|
+
* Note: [🔂] This function is idempotent.
|
|
6343
|
+
*
|
|
6272
6344
|
* @param options - The validation options including result string, expectations, and format
|
|
6273
6345
|
* @returns Validation result with processed string and validity status
|
|
6274
6346
|
* @private internal function of `createPipelineExecutor` and `cacheLlmTools`
|
|
@@ -6337,7 +6409,7 @@ function validatePromptResult(options) {
|
|
|
6337
6409
|
*/
|
|
6338
6410
|
async function executeAttempts(options) {
|
|
6339
6411
|
const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
|
|
6340
|
-
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, } = options;
|
|
6412
|
+
preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall, } = options;
|
|
6341
6413
|
const $ongoingTaskResult = {
|
|
6342
6414
|
$result: null,
|
|
6343
6415
|
$resultString: null,
|
|
@@ -6585,14 +6657,10 @@ async function executeAttempts(options) {
|
|
|
6585
6657
|
});
|
|
6586
6658
|
}
|
|
6587
6659
|
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({
|
|
6660
|
+
if (!isJokerAttempt && task.taskType === 'PROMPT_TASK' && $ongoingTaskResult.$prompt) {
|
|
6661
|
+
// Note: [2] When some expected parameter is not defined, error will occur in templateParameters
|
|
6662
|
+
// In that case we don’t want to make a report about it because it’s not a llm execution error
|
|
6663
|
+
const executionPromptReport = {
|
|
6596
6664
|
prompt: {
|
|
6597
6665
|
...$ongoingTaskResult.$prompt,
|
|
6598
6666
|
// <- TODO: [🧠] How to pick everyhing except `pipelineUrl`
|
|
@@ -6601,7 +6669,14 @@ async function executeAttempts(options) {
|
|
|
6601
6669
|
error: $ongoingTaskResult.$expectError === null
|
|
6602
6670
|
? undefined
|
|
6603
6671
|
: serializeError($ongoingTaskResult.$expectError),
|
|
6604
|
-
}
|
|
6672
|
+
};
|
|
6673
|
+
$executionReport.promptExecutions.push(executionPromptReport);
|
|
6674
|
+
if (logLlmCall) {
|
|
6675
|
+
logLlmCall({
|
|
6676
|
+
modelName: 'model' /* <- TODO: How to get model name from the report */,
|
|
6677
|
+
report: executionPromptReport,
|
|
6678
|
+
});
|
|
6679
|
+
}
|
|
6605
6680
|
}
|
|
6606
6681
|
}
|
|
6607
6682
|
if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
|
|
@@ -6666,12 +6741,12 @@ async function executeAttempts(options) {
|
|
|
6666
6741
|
* @private internal utility of `createPipelineExecutor`
|
|
6667
6742
|
*/
|
|
6668
6743
|
async function executeFormatSubvalues(options) {
|
|
6669
|
-
const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, pipelineIdentification } = options;
|
|
6744
|
+
const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, logLlmCall, pipelineIdentification, } = options;
|
|
6670
6745
|
if (task.foreach === undefined) {
|
|
6671
|
-
return /* not await */ executeAttempts(options);
|
|
6746
|
+
return /* not await */ executeAttempts({ ...options, logLlmCall });
|
|
6672
6747
|
}
|
|
6673
6748
|
if (jokerParameterNames.length !== 0) {
|
|
6674
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
6749
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
6675
6750
|
JOKER parameters are not supported together with FOREACH command
|
|
6676
6751
|
|
|
6677
6752
|
[🧞♀️] This should be prevented in \`validatePipeline\`
|
|
@@ -6684,7 +6759,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6684
6759
|
if (formatDefinition === undefined) {
|
|
6685
6760
|
throw new UnexpectedError(
|
|
6686
6761
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
6687
|
-
spaceTrim((block) => `
|
|
6762
|
+
spaceTrim$2((block) => `
|
|
6688
6763
|
Unsupported format "${task.foreach.formatName}"
|
|
6689
6764
|
|
|
6690
6765
|
Available formats:
|
|
@@ -6701,7 +6776,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6701
6776
|
if (subvalueParser === undefined) {
|
|
6702
6777
|
throw new UnexpectedError(
|
|
6703
6778
|
// <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
|
|
6704
|
-
spaceTrim((block) => `
|
|
6779
|
+
spaceTrim$2((block) => `
|
|
6705
6780
|
Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
|
|
6706
6781
|
|
|
6707
6782
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -6741,7 +6816,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6741
6816
|
if (!(error instanceof PipelineExecutionError)) {
|
|
6742
6817
|
throw error;
|
|
6743
6818
|
}
|
|
6744
|
-
const highLevelError = new PipelineExecutionError(spaceTrim((block) => `
|
|
6819
|
+
const highLevelError = new PipelineExecutionError(spaceTrim$2((block) => `
|
|
6745
6820
|
${error.message}
|
|
6746
6821
|
|
|
6747
6822
|
This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -6765,7 +6840,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6765
6840
|
...options,
|
|
6766
6841
|
priority: priority + index,
|
|
6767
6842
|
parameters: allSubparameters,
|
|
6768
|
-
pipelineIdentification: spaceTrim((block) => `
|
|
6843
|
+
pipelineIdentification: spaceTrim$2((block) => `
|
|
6769
6844
|
${block(pipelineIdentification)}
|
|
6770
6845
|
Subparameter index: ${index}
|
|
6771
6846
|
`),
|
|
@@ -6774,7 +6849,7 @@ async function executeFormatSubvalues(options) {
|
|
|
6774
6849
|
}
|
|
6775
6850
|
catch (error) {
|
|
6776
6851
|
if (length > BIG_DATASET_TRESHOLD) {
|
|
6777
|
-
console.error(spaceTrim((block) => `
|
|
6852
|
+
console.error(spaceTrim$2((block) => `
|
|
6778
6853
|
${error.message}
|
|
6779
6854
|
|
|
6780
6855
|
This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
|
|
@@ -6874,7 +6949,7 @@ async function getKnowledgeForTask(options) {
|
|
|
6874
6949
|
},
|
|
6875
6950
|
content: task.content,
|
|
6876
6951
|
parameters,
|
|
6877
|
-
};
|
|
6952
|
+
}; /* <- Note: [🤛] */
|
|
6878
6953
|
const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
|
|
6879
6954
|
const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
|
|
6880
6955
|
const { index } = knowledgePiece;
|
|
@@ -6969,7 +7044,7 @@ async function getReservedParametersForTask(options) {
|
|
|
6969
7044
|
* @private internal utility of `createPipelineExecutor`
|
|
6970
7045
|
*/
|
|
6971
7046
|
async function executeTask(options) {
|
|
6972
|
-
const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSuppressed, } = options;
|
|
7047
|
+
const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, logLlmCall, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSuppressed, } = options;
|
|
6973
7048
|
const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
|
|
6974
7049
|
// Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but it’s good to doublecheck
|
|
6975
7050
|
const usedParameterNames = extractParameterNamesFromTask(currentTask);
|
|
@@ -7048,6 +7123,7 @@ async function executeTask(options) {
|
|
|
7048
7123
|
tools,
|
|
7049
7124
|
$executionReport,
|
|
7050
7125
|
onProgress,
|
|
7126
|
+
logLlmCall,
|
|
7051
7127
|
pipelineIdentification,
|
|
7052
7128
|
maxExecutionAttempts,
|
|
7053
7129
|
maxParallelCount,
|
|
@@ -7091,6 +7167,29 @@ function filterJustOutputParameters(options) {
|
|
|
7091
7167
|
$warnings.push(new PipelineExecutionError(spaceTrim$1((block) => `
|
|
7092
7168
|
Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
|
|
7093
7169
|
|
|
7170
|
+
Note: This is a warning which happened after the pipeline was executed, and \`{${parameter.name}}\` was not for some reason defined in output parameters
|
|
7171
|
+
|
|
7172
|
+
All parameters:
|
|
7173
|
+
${block(preparedPipeline.parameters
|
|
7174
|
+
.map(({ name, isInput, isOutput, description }) => {
|
|
7175
|
+
let line = `\`{${name}}\``;
|
|
7176
|
+
if (isInput) {
|
|
7177
|
+
line += ' `[input parameter]`';
|
|
7178
|
+
}
|
|
7179
|
+
if (isOutput) {
|
|
7180
|
+
line += ' `[output parameter]`';
|
|
7181
|
+
}
|
|
7182
|
+
if (parametersToPass[name] === undefined) {
|
|
7183
|
+
line += ` <- Warning: Should be in the output but its not |`;
|
|
7184
|
+
}
|
|
7185
|
+
if (description) {
|
|
7186
|
+
line += ` ${description}`;
|
|
7187
|
+
}
|
|
7188
|
+
return line;
|
|
7189
|
+
})
|
|
7190
|
+
.map((line, index) => `${index + 1}) ${line}`)
|
|
7191
|
+
.join('\n'))}
|
|
7192
|
+
|
|
7094
7193
|
${block(pipelineIdentification)}
|
|
7095
7194
|
`)));
|
|
7096
7195
|
continue;
|
|
@@ -7111,7 +7210,7 @@ function filterJustOutputParameters(options) {
|
|
|
7111
7210
|
* @private internal utility of `createPipelineExecutor`
|
|
7112
7211
|
*/
|
|
7113
7212
|
async function executePipeline(options) {
|
|
7114
|
-
const { inputParameters, tools, onProgress, pipeline, setPreparedPipeline, pipelineIdentification, maxParallelCount, rootDirname, isVerbose, } = options;
|
|
7213
|
+
const { inputParameters, tools, onProgress, logLlmCall, pipeline, setPreparedPipeline, pipelineIdentification, maxParallelCount, rootDirname, isVerbose, } = options;
|
|
7115
7214
|
let { preparedPipeline } = options;
|
|
7116
7215
|
if (preparedPipeline === undefined) {
|
|
7117
7216
|
preparedPipeline = await preparePipeline(pipeline, tools, {
|
|
@@ -7289,6 +7388,7 @@ async function executePipeline(options) {
|
|
|
7289
7388
|
onProgress(newOngoingResult);
|
|
7290
7389
|
}
|
|
7291
7390
|
},
|
|
7391
|
+
logLlmCall,
|
|
7292
7392
|
$executionReport: executionReport,
|
|
7293
7393
|
pipelineIdentification: spaceTrim$1((block) => `
|
|
7294
7394
|
${block(pipelineIdentification)}
|
|
@@ -7412,7 +7512,7 @@ function createPipelineExecutor(options) {
|
|
|
7412
7512
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
7413
7513
|
}
|
|
7414
7514
|
let runCount = 0;
|
|
7415
|
-
const pipelineExecutorWithCallback = async (inputParameters, onProgress) => {
|
|
7515
|
+
const pipelineExecutorWithCallback = async (inputParameters, onProgress, logLlmCall) => {
|
|
7416
7516
|
runCount++;
|
|
7417
7517
|
return /* not await */ executePipeline({
|
|
7418
7518
|
pipeline,
|
|
@@ -7423,6 +7523,7 @@ function createPipelineExecutor(options) {
|
|
|
7423
7523
|
inputParameters,
|
|
7424
7524
|
tools,
|
|
7425
7525
|
onProgress,
|
|
7526
|
+
logLlmCall,
|
|
7426
7527
|
pipelineIdentification: spaceTrim$1((block) => `
|
|
7427
7528
|
${block(pipelineIdentification)}
|
|
7428
7529
|
${runCount === 1 ? '' : `Run #${runCount}`}
|
|
@@ -7626,10 +7727,10 @@ function $registeredLlmToolsMessage() {
|
|
|
7626
7727
|
var _a, _b;
|
|
7627
7728
|
const isMetadataAviailable = $llmToolsMetadataRegister
|
|
7628
7729
|
.list()
|
|
7629
|
-
.
|
|
7730
|
+
.some(({ packageName, className }) => metadata.packageName === packageName && metadata.className === className);
|
|
7630
7731
|
const isInstalled = $llmToolsRegister
|
|
7631
7732
|
.list()
|
|
7632
|
-
.
|
|
7733
|
+
.some(({ packageName, className }) => metadata.packageName === packageName && metadata.className === className);
|
|
7633
7734
|
const isFullyConfigured = ((_a = metadata.envVariables) === null || _a === void 0 ? void 0 : _a.every((envVariableName) => env[envVariableName] !== undefined)) || false;
|
|
7634
7735
|
const isPartiallyConfigured = ((_b = metadata.envVariables) === null || _b === void 0 ? void 0 : _b.some((envVariableName) => env[envVariableName] !== undefined)) || false;
|
|
7635
7736
|
// <- Note: [🗨]
|
|
@@ -7637,13 +7738,13 @@ function $registeredLlmToolsMessage() {
|
|
|
7637
7738
|
});
|
|
7638
7739
|
const usedEnvMessage = `Unknown \`.env\` file` ;
|
|
7639
7740
|
if (metadata.length === 0) {
|
|
7640
|
-
return spaceTrim((block) => `
|
|
7741
|
+
return spaceTrim$2((block) => `
|
|
7641
7742
|
No LLM providers are available.
|
|
7642
7743
|
|
|
7643
7744
|
${block(usedEnvMessage)}
|
|
7644
7745
|
`);
|
|
7645
7746
|
}
|
|
7646
|
-
return spaceTrim((block) => `
|
|
7747
|
+
return spaceTrim$2((block) => `
|
|
7647
7748
|
|
|
7648
7749
|
${block(usedEnvMessage)}
|
|
7649
7750
|
|
|
@@ -7689,7 +7790,7 @@ function $registeredLlmToolsMessage() {
|
|
|
7689
7790
|
morePieces.push(`Not configured`); // <- Note: Can not be configured via environment variables
|
|
7690
7791
|
}
|
|
7691
7792
|
}
|
|
7692
|
-
let providerMessage = spaceTrim(`
|
|
7793
|
+
let providerMessage = spaceTrim$2(`
|
|
7693
7794
|
${i + 1}) **${title}** \`${className}\` from \`${packageName}\`
|
|
7694
7795
|
${morePieces.join('; ')}
|
|
7695
7796
|
`);
|
|
@@ -7735,7 +7836,7 @@ function createLlmToolsFromConfiguration(configuration, options = {}) {
|
|
|
7735
7836
|
.find(({ packageName, className }) => llmConfiguration.packageName === packageName && llmConfiguration.className === className);
|
|
7736
7837
|
if (registeredItem === undefined) {
|
|
7737
7838
|
// console.log('$llmToolsRegister.list()', $llmToolsRegister.list());
|
|
7738
|
-
throw new Error(spaceTrim((block) => `
|
|
7839
|
+
throw new Error(spaceTrim$2((block) => `
|
|
7739
7840
|
There is no constructor for LLM provider \`${llmConfiguration.className}\` from \`${llmConfiguration.packageName}\`
|
|
7740
7841
|
Running in ${!$isRunningInBrowser() ? '' : 'browser environment'}${!$isRunningInNode() ? '' : 'node environment'}${!$isRunningInWebWorker() ? '' : 'worker environment'}
|
|
7741
7842
|
|
|
@@ -7806,6 +7907,8 @@ async function $provideScrapersForNode(tools, options) {
|
|
|
7806
7907
|
/**
|
|
7807
7908
|
* Normalizes a given text to camelCase format.
|
|
7808
7909
|
*
|
|
7910
|
+
* Note: [🔂] This function is idempotent.
|
|
7911
|
+
*
|
|
7809
7912
|
* @param text The text to be normalized.
|
|
7810
7913
|
* @param _isFirstLetterCapital Whether the first letter should be capitalized.
|
|
7811
7914
|
* @returns The camelCase formatted string.
|
|
@@ -7932,6 +8035,9 @@ function nameToUriParts(name) {
|
|
|
7932
8035
|
}
|
|
7933
8036
|
|
|
7934
8037
|
/**
|
|
8038
|
+
* Normalizes a given text to PascalCase format.
|
|
8039
|
+
*
|
|
8040
|
+
* Note: [🔂] This function is idempotent.
|
|
7935
8041
|
*
|
|
7936
8042
|
* @param text @public exported from `@promptbook/utils`
|
|
7937
8043
|
* @returns
|
|
@@ -8068,7 +8174,7 @@ function unwrapResult(text, options) {
|
|
|
8068
8174
|
function extractOneBlockFromMarkdown(markdown) {
|
|
8069
8175
|
const codeBlocks = extractAllBlocksFromMarkdown(markdown);
|
|
8070
8176
|
if (codeBlocks.length !== 1) {
|
|
8071
|
-
throw new ParseError(spaceTrim((block) => `
|
|
8177
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
8072
8178
|
There should be exactly 1 code block in task section, found ${codeBlocks.length} code blocks
|
|
8073
8179
|
|
|
8074
8180
|
${block(codeBlocks.map((block, i) => `Block ${i + 1}:\n${block.content}`).join('\n\n\n'))}
|
|
@@ -8177,8 +8283,8 @@ class JavascriptEvalExecutionTools {
|
|
|
8177
8283
|
}
|
|
8178
8284
|
// Note: [💎]
|
|
8179
8285
|
// 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
|
|
8286
|
+
const spaceTrim = (_) => spaceTrim$2(_);
|
|
8287
|
+
$preserve(spaceTrim);
|
|
8182
8288
|
const removeQuotes$1 = removeQuotes;
|
|
8183
8289
|
$preserve(removeQuotes$1);
|
|
8184
8290
|
const unwrapResult$1 = unwrapResult;
|
|
@@ -8231,7 +8337,7 @@ class JavascriptEvalExecutionTools {
|
|
|
8231
8337
|
// TODO: DRY [🍯]
|
|
8232
8338
|
const buildinFunctions = {
|
|
8233
8339
|
// TODO: [🍯] DRY all these functions across the file
|
|
8234
|
-
spaceTrim
|
|
8340
|
+
spaceTrim,
|
|
8235
8341
|
removeQuotes: removeQuotes$1,
|
|
8236
8342
|
unwrapResult: unwrapResult$1,
|
|
8237
8343
|
trimEndOfCodeBlock: trimEndOfCodeBlock$1,
|
|
@@ -8268,7 +8374,7 @@ class JavascriptEvalExecutionTools {
|
|
|
8268
8374
|
.join('\n');
|
|
8269
8375
|
// script = templateParameters(script, parameters);
|
|
8270
8376
|
// <- TODO: [🧠][🥳] Should be this is one of two variants how to use parameters in script
|
|
8271
|
-
const statementToEvaluate = spaceTrim((block) => `
|
|
8377
|
+
const statementToEvaluate = spaceTrim$2((block) => `
|
|
8272
8378
|
|
|
8273
8379
|
// Build-in functions:
|
|
8274
8380
|
${block(buildinFunctionsStatement)}
|
|
@@ -8283,7 +8389,7 @@ class JavascriptEvalExecutionTools {
|
|
|
8283
8389
|
(()=>{ ${script} })()
|
|
8284
8390
|
`);
|
|
8285
8391
|
if (this.options.isVerbose) {
|
|
8286
|
-
console.info(spaceTrim((block) => `
|
|
8392
|
+
console.info(spaceTrim$2((block) => `
|
|
8287
8393
|
🚀 Evaluating ${scriptLanguage} script:
|
|
8288
8394
|
|
|
8289
8395
|
${block(statementToEvaluate)}`));
|
|
@@ -8305,7 +8411,7 @@ class JavascriptEvalExecutionTools {
|
|
|
8305
8411
|
To: [PipelineExecutionError: Parameter `{thing}` is not defined],
|
|
8306
8412
|
*/
|
|
8307
8413
|
if (!statementToEvaluate.includes(undefinedName + '(')) {
|
|
8308
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
8414
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
8309
8415
|
|
|
8310
8416
|
Parameter \`{${undefinedName}}\` is not defined
|
|
8311
8417
|
|
|
@@ -8327,7 +8433,7 @@ class JavascriptEvalExecutionTools {
|
|
|
8327
8433
|
`));
|
|
8328
8434
|
}
|
|
8329
8435
|
else {
|
|
8330
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
8436
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
8331
8437
|
Function ${undefinedName}() is not defined
|
|
8332
8438
|
|
|
8333
8439
|
- Make sure that the function is one of built-in functions
|
|
@@ -8995,7 +9101,10 @@ function ServerBody({ info }) {
|
|
|
8995
9101
|
}), h(KeyVal, {
|
|
8996
9102
|
label: 'Application mode:',
|
|
8997
9103
|
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', {
|
|
9104
|
+
}), 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', {
|
|
9105
|
+
href: 'https://www.npmjs.com/package/@promptbook/remote-client',
|
|
9106
|
+
className: 'text-blue-600 underline',
|
|
9107
|
+
}, '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
9108
|
}
|
|
9000
9109
|
function HtmlDoc({ info }) {
|
|
9001
9110
|
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 +9121,7 @@ function renderServerIndexHtml(info) {
|
|
|
9012
9121
|
return '<!DOCTYPE html>' + renderToStaticMarkup(h(HtmlDoc, { info }));
|
|
9013
9122
|
}
|
|
9014
9123
|
|
|
9124
|
+
// TODO: !!! Deprecate
|
|
9015
9125
|
/**
|
|
9016
9126
|
* Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
|
|
9017
9127
|
*
|
|
@@ -9318,10 +9428,10 @@ function startRemoteServer(options) {
|
|
|
9318
9428
|
.send({ error: serializeError(error) });
|
|
9319
9429
|
}
|
|
9320
9430
|
});
|
|
9321
|
-
function exportExecutionTask(executionTask,
|
|
9431
|
+
function exportExecutionTask(executionTask, isDetailed) {
|
|
9322
9432
|
// <- 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 (
|
|
9433
|
+
const { taskType, promptbookVersion, taskId, title, status, errors, tldr, warnings, createdAt, updatedAt, currentValue, llmCalls, } = executionTask;
|
|
9434
|
+
if (isDetailed) {
|
|
9325
9435
|
return {
|
|
9326
9436
|
taskId,
|
|
9327
9437
|
title,
|
|
@@ -9331,9 +9441,11 @@ function startRemoteServer(options) {
|
|
|
9331
9441
|
tldr,
|
|
9332
9442
|
errors: errors.map(serializeError),
|
|
9333
9443
|
warnings: warnings.map(serializeError),
|
|
9444
|
+
llmCalls,
|
|
9334
9445
|
createdAt,
|
|
9335
9446
|
updatedAt,
|
|
9336
9447
|
currentValue,
|
|
9448
|
+
ptbkNonce: 0,
|
|
9337
9449
|
};
|
|
9338
9450
|
}
|
|
9339
9451
|
else {
|
|
@@ -9346,6 +9458,8 @@ function startRemoteServer(options) {
|
|
|
9346
9458
|
tldr,
|
|
9347
9459
|
createdAt,
|
|
9348
9460
|
updatedAt,
|
|
9461
|
+
llmCalls,
|
|
9462
|
+
ptbkNonce: 0,
|
|
9349
9463
|
};
|
|
9350
9464
|
}
|
|
9351
9465
|
}
|
|
@@ -9573,18 +9687,21 @@ function startRemoteServer(options) {
|
|
|
9573
9687
|
};
|
|
9574
9688
|
}
|
|
9575
9689
|
/**
|
|
9690
|
+
|
|
9691
|
+
* TODO: [🕋] Use here `aboutPromptbookInformation`
|
|
9576
9692
|
* TODO: [🌡] Add CORS and security - probably via `helmet`
|
|
9577
9693
|
* TODO: Split this file into multiple functions - handler for each request
|
|
9578
9694
|
* TODO: Maybe use `$exportJson`
|
|
9579
9695
|
* TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
|
|
9580
|
-
* TODO: [⚖] Expose the collection to be able to connect to same collection via
|
|
9696
|
+
* TODO: [⚖] Expose the collection to be able to connect to same collection via createPipelineCollectionFromUrl
|
|
9581
9697
|
* TODO: Handle progress - support streaming
|
|
9582
9698
|
* TODO: [🗯] Do not hang up immediately but wait until client closes OR timeout
|
|
9583
9699
|
* TODO: [🗯] Timeout on chat to free up resources
|
|
9584
9700
|
* TODO: [🃏] Pass here some security token to prevent malitious usage and/or DDoS
|
|
9585
9701
|
* TODO: [0] Set unavailable models as undefined in `RemoteLlmExecutionTools` NOT throw error here
|
|
9586
9702
|
* TODO: Allow to constrain anonymous mode for specific models / providers
|
|
9703
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
9587
9704
|
*/
|
|
9588
9705
|
|
|
9589
|
-
export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION, startRemoteServer };
|
|
9706
|
+
export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION, startAgentServer, startRemoteServer };
|
|
9590
9707
|
//# sourceMappingURL=index.es.js.map
|