@promptbook/markdown-utils 0.103.0-1 → 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.
Files changed (258) hide show
  1. package/README.md +153 -89
  2. package/esm/index.es.js +307 -236
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/books/index.d.ts +0 -81
  5. package/esm/typings/servers.d.ts +9 -7
  6. package/esm/typings/src/_packages/browser.index.d.ts +6 -0
  7. package/esm/typings/src/_packages/cli.index.d.ts +4 -0
  8. package/esm/typings/src/_packages/components.index.d.ts +20 -8
  9. package/esm/typings/src/_packages/core.index.d.ts +58 -18
  10. package/esm/typings/src/_packages/node.index.d.ts +2 -2
  11. package/esm/typings/src/_packages/remote-server.index.d.ts +2 -0
  12. package/esm/typings/src/_packages/types.index.d.ts +58 -8
  13. package/esm/typings/src/_packages/utils.index.d.ts +6 -0
  14. package/esm/typings/src/_packages/wizard.index.d.ts +4 -0
  15. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +19 -5
  16. package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +17 -1
  17. package/esm/typings/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +3 -2
  18. package/esm/typings/src/book-2.0/agent-source/computeAgentHash.d.ts +8 -0
  19. package/esm/typings/src/book-2.0/agent-source/createCommitmentRegex.d.ts +3 -3
  20. package/esm/typings/src/book-2.0/agent-source/createDefaultAgentName.d.ts +8 -0
  21. package/esm/typings/src/book-2.0/agent-source/normalizeAgentName.d.ts +9 -0
  22. package/esm/typings/src/book-2.0/agent-source/padBook.d.ts +18 -0
  23. package/esm/typings/src/book-2.0/agent-source/parseAgentSourceWithCommitments.d.ts +1 -1
  24. package/esm/typings/src/book-2.0/agent-source/string_book.d.ts +3 -0
  25. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +10 -0
  26. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfileTooltip.d.ts +15 -0
  27. package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +83 -8
  28. package/esm/typings/src/book-components/BookEditor/BookEditorActionbar.d.ts +14 -0
  29. package/esm/typings/src/book-components/BookEditor/BookEditorMonaco.d.ts +5 -0
  30. package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.d.ts +14 -0
  31. package/esm/typings/src/book-components/Chat/AgentChat/AgentChatProps.d.ts +13 -0
  32. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +10 -0
  33. package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +5 -0
  34. package/esm/typings/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +15 -0
  35. package/esm/typings/src/book-components/Chat/MockedChat/MockedChat.d.ts +5 -0
  36. package/esm/typings/src/book-components/Chat/save/_common/ChatSaveFormatDefinition.d.ts +1 -1
  37. package/esm/typings/src/book-components/Chat/save/html/htmlSaveFormatDefinition.d.ts +1 -0
  38. package/esm/typings/src/book-components/Chat/save/pdf/pdfSaveFormatDefinition.d.ts +4 -0
  39. package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +5 -0
  40. package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgent.d.ts +29 -0
  41. package/esm/typings/src/book-components/Qr/BrandedQrCode.d.ts +18 -0
  42. package/esm/typings/src/book-components/Qr/GenericQrCode.d.ts +10 -0
  43. package/esm/typings/src/book-components/Qr/PromptbookQrCode.d.ts +18 -0
  44. package/esm/typings/src/book-components/Qr/useQrCode.d.ts +15 -0
  45. package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +15 -0
  46. package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +12 -0
  47. package/esm/typings/src/book-components/_common/Modal/Modal.d.ts +13 -0
  48. package/esm/typings/src/book-components/_common/Tooltip/Tooltip.d.ts +47 -0
  49. package/esm/typings/src/book-components/_common/react-utils/classNames.d.ts +1 -1
  50. package/esm/typings/src/book-components/icons/AboutIcon.d.ts +9 -0
  51. package/esm/typings/src/book-components/icons/CloseIcon.d.ts +4 -8
  52. package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +9 -0
  53. package/esm/typings/src/book-components/icons/ExitFullscreenIcon.d.ts +7 -0
  54. package/esm/typings/src/book-components/icons/FullscreenIcon.d.ts +7 -0
  55. package/esm/typings/src/book-components/icons/MenuIcon.d.ts +12 -0
  56. package/esm/typings/src/book-components/icons/MicIcon.d.ts +8 -0
  57. package/esm/typings/src/cli/cli-commands/_boilerplate.d.ts +2 -1
  58. package/esm/typings/src/cli/cli-commands/about.d.ts +3 -1
  59. package/esm/typings/src/cli/cli-commands/hello.d.ts +2 -1
  60. package/esm/typings/src/cli/cli-commands/list-models.d.ts +2 -1
  61. package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +2 -1
  62. package/esm/typings/src/cli/cli-commands/login.d.ts +2 -1
  63. package/esm/typings/src/cli/cli-commands/make.d.ts +2 -1
  64. package/esm/typings/src/cli/cli-commands/prettify.d.ts +2 -1
  65. package/esm/typings/src/cli/cli-commands/run.d.ts +2 -1
  66. package/esm/typings/src/cli/cli-commands/{start-server.d.ts → start-agents-server.d.ts} +3 -2
  67. package/esm/typings/src/cli/cli-commands/start-pipelines-server.d.ts +15 -0
  68. package/esm/typings/src/cli/cli-commands/test-command.d.ts +2 -1
  69. package/esm/typings/src/cli/common/$addGlobalOptionsToCommand.d.ts +2 -1
  70. package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +12 -0
  71. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +75 -0
  72. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabaseOptions.d.ts +10 -0
  73. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +154 -0
  74. package/esm/typings/src/collection/{PipelineCollection.d.ts → pipeline-collection/PipelineCollection.d.ts} +7 -3
  75. package/esm/typings/src/collection/{SimplePipelineCollection.d.ts → pipeline-collection/SimplePipelineCollection.d.ts} +5 -5
  76. package/esm/typings/src/collection/{constructors/createCollectionFromDirectory.d.ts → pipeline-collection/constructors/createPipelineCollectionFromDirectory.d.ts} +8 -11
  77. package/esm/typings/src/collection/pipeline-collection/constructors/createPipelineCollectionFromJson.d.ts +13 -0
  78. package/esm/typings/src/collection/{constructors/createCollectionFromPromise.d.ts → pipeline-collection/constructors/createPipelineCollectionFromPromise.d.ts} +6 -5
  79. package/esm/typings/src/collection/pipeline-collection/constructors/createPipelineCollectionFromPromise.test.d.ts +1 -0
  80. package/esm/typings/src/collection/{constructors/createCollectionFromUrl.d.ts → pipeline-collection/constructors/createPipelineCollectionFromUrl.d.ts} +3 -3
  81. package/esm/typings/src/collection/{constructors/createSubcollection.d.ts → pipeline-collection/constructors/createPipelineSubcollection.d.ts} +3 -3
  82. package/esm/typings/src/collection/pipeline-collection/pipelineCollectionToJson.d.ts +13 -0
  83. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +4 -5
  84. package/esm/typings/src/{book-2.0/commitments → commitments}/ACTION/ACTION.d.ts +5 -1
  85. package/esm/typings/src/commitments/CLOSED/CLOSED.d.ts +35 -0
  86. package/esm/typings/src/commitments/COMPONENT/COMPONENT.d.ts +28 -0
  87. package/esm/typings/src/{book-2.0/commitments → commitments}/DELETE/DELETE.d.ts +5 -1
  88. package/esm/typings/src/{book-2.0/commitments → commitments}/FORMAT/FORMAT.d.ts +5 -1
  89. package/esm/typings/src/commitments/FROM/FROM.d.ts +34 -0
  90. package/esm/typings/src/{book-2.0/commitments → commitments}/GOAL/GOAL.d.ts +5 -1
  91. package/esm/typings/src/{book-2.0/commitments → commitments}/KNOWLEDGE/KNOWLEDGE.d.ts +5 -5
  92. package/esm/typings/src/commitments/LANGUAGE/LANGUAGE.d.ts +35 -0
  93. package/esm/typings/src/{book-2.0/commitments → commitments}/MEMORY/MEMORY.d.ts +5 -1
  94. package/esm/typings/src/commitments/MESSAGE/AgentMessageCommitmentDefinition.d.ts +32 -0
  95. package/esm/typings/src/commitments/MESSAGE/InitialMessageCommitmentDefinition.d.ts +32 -0
  96. package/esm/typings/src/{book-2.0/commitments → commitments}/MESSAGE/MESSAGE.d.ts +5 -1
  97. package/esm/typings/src/commitments/MESSAGE/UserMessageCommitmentDefinition.d.ts +32 -0
  98. package/esm/typings/src/{book-2.0/commitments → commitments}/META/META.d.ts +5 -1
  99. package/esm/typings/src/commitments/META_COLOR/META_COLOR.d.ts +48 -0
  100. package/esm/typings/src/commitments/META_FONT/META_FONT.d.ts +42 -0
  101. package/esm/typings/src/{book-2.0/commitments → commitments}/META_IMAGE/META_IMAGE.d.ts +5 -1
  102. package/esm/typings/src/{book-2.0/commitments → commitments}/META_LINK/META_LINK.d.ts +5 -1
  103. package/esm/typings/src/{book-2.0/commitments → commitments}/MODEL/MODEL.d.ts +5 -1
  104. package/esm/typings/src/{book-2.0/commitments → commitments}/NOTE/NOTE.d.ts +5 -1
  105. package/esm/typings/src/commitments/OPEN/OPEN.d.ts +35 -0
  106. package/esm/typings/src/{book-2.0/commitments → commitments}/PERSONA/PERSONA.d.ts +5 -1
  107. package/esm/typings/src/{book-2.0/commitments → commitments}/RULE/RULE.d.ts +5 -1
  108. package/esm/typings/src/{book-2.0/commitments → commitments}/SAMPLE/SAMPLE.d.ts +5 -1
  109. package/esm/typings/src/{book-2.0/commitments → commitments}/SCENARIO/SCENARIO.d.ts +5 -1
  110. package/esm/typings/src/{book-2.0/commitments → commitments}/STYLE/STYLE.d.ts +5 -1
  111. package/esm/typings/src/commitments/USE/USE.d.ts +53 -0
  112. package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +38 -0
  113. package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.test.d.ts +1 -0
  114. package/esm/typings/src/commitments/USE_MCP/USE_MCP.d.ts +37 -0
  115. package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +38 -0
  116. package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BaseCommitmentDefinition.d.ts +8 -2
  117. package/esm/typings/src/{book-2.0/commitments → commitments}/_base/CommitmentDefinition.d.ts +6 -1
  118. package/esm/typings/src/{book-2.0/commitments → commitments}/_base/NotYetImplementedCommitmentDefinition.d.ts +5 -1
  119. package/esm/typings/src/{book-2.0/commitments → commitments}/_base/createEmptyAgentModelRequirements.d.ts +1 -1
  120. package/esm/typings/src/commitments/index.d.ts +93 -0
  121. package/esm/typings/src/config.d.ts +24 -3
  122. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +2 -0
  123. package/esm/typings/src/errors/0-index.d.ts +6 -0
  124. package/esm/typings/src/errors/DatabaseError.d.ts +12 -0
  125. package/esm/typings/src/errors/NotAllowed.d.ts +9 -0
  126. package/esm/typings/src/errors/WrappedError.d.ts +2 -2
  127. package/esm/typings/src/execution/AvailableModel.d.ts +1 -0
  128. package/esm/typings/src/execution/Executables.d.ts +3 -0
  129. package/esm/typings/src/execution/ExecutionTask.d.ts +12 -3
  130. package/esm/typings/src/execution/ExecutionTools.d.ts +5 -0
  131. package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
  132. package/esm/typings/src/execution/LlmExecutionTools.d.ts +21 -1
  133. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +5 -0
  134. package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +5 -0
  135. package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +5 -0
  136. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +5 -0
  137. package/esm/typings/src/execution/utils/usage-constants.d.ts +4 -124
  138. package/esm/typings/src/execution/utils/validatePromptResult.d.ts +2 -0
  139. package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +2 -1
  140. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +2 -2
  141. package/esm/typings/src/llm-providers/_common/register/$registeredLlmToolsMessage.d.ts +2 -1
  142. package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +1 -1
  143. package/esm/typings/src/llm-providers/_common/utils/assertUniqueModels.d.ts +12 -0
  144. package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -0
  145. package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +1 -0
  146. package/esm/typings/src/llm-providers/agent/Agent.d.ts +70 -0
  147. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +26 -4
  148. package/esm/typings/src/llm-providers/agent/AgentOptions.d.ts +19 -0
  149. package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +17 -0
  150. package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +50 -0
  151. package/esm/typings/src/llm-providers/agent/RemoteAgentOptions.d.ts +11 -0
  152. package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.d.ts +1 -19
  153. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  154. package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
  155. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +60 -2
  156. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +7 -1
  157. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
  158. package/esm/typings/src/llm-providers/openai/openai-models.test.d.ts +4 -0
  159. package/esm/typings/src/other/templates/getTemplatesPipelineCollection.d.ts +1 -1
  160. package/esm/typings/src/pipeline/validatePipelineString.d.ts +2 -0
  161. package/esm/typings/src/playground/permanent/_boilerplate.d.ts +5 -0
  162. package/esm/typings/src/playground/permanent/agent-with-browser-playground.d.ts +5 -0
  163. package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +1 -0
  164. package/esm/typings/src/remote-server/startAgentServer.d.ts +26 -0
  165. package/esm/typings/src/remote-server/startRemoteServer.d.ts +4 -1
  166. package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +3 -8
  167. package/esm/typings/src/scrapers/_boilerplate/createBoilerplateScraper.d.ts +1 -12
  168. package/esm/typings/src/scrapers/_boilerplate/register-metadata.d.ts +1 -9
  169. package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +1 -12
  170. package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -9
  171. package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +1 -12
  172. package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -9
  173. package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +1 -12
  174. package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -9
  175. package/esm/typings/src/scrapers/markitdown/createMarkitdownScraper.d.ts +1 -12
  176. package/esm/typings/src/scrapers/markitdown/register-metadata.d.ts +1 -9
  177. package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +1 -12
  178. package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +1 -9
  179. package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +1 -12
  180. package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -9
  181. package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +1 -0
  182. package/esm/typings/src/storage/env-storage/$EnvStorage.d.ts +2 -1
  183. package/esm/typings/src/transpilers/_common/BookTranspiler.d.ts +33 -0
  184. package/esm/typings/src/transpilers/_common/BookTranspilerOptions.d.ts +18 -0
  185. package/esm/typings/src/transpilers/_common/register/$bookTranspilersRegister.d.ts +15 -0
  186. package/esm/typings/src/transpilers/formatted-book-in-markdown/FormattedBookInMarkdownTranspiler.d.ts +16 -0
  187. package/esm/typings/src/transpilers/formatted-book-in-markdown/register.d.ts +15 -0
  188. package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.d.ts +16 -0
  189. package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.test.d.ts +1 -0
  190. package/esm/typings/src/transpilers/openai-sdk/playground/playground.d.ts +5 -0
  191. package/esm/typings/src/transpilers/openai-sdk/register.d.ts +15 -0
  192. package/esm/typings/src/types/LlmCall.d.ts +20 -0
  193. package/esm/typings/src/types/Updatable.d.ts +19 -0
  194. package/esm/typings/src/types/typeAliases.d.ts +32 -2
  195. package/esm/typings/src/utils/color/$randomColor.d.ts +1 -0
  196. package/esm/typings/src/utils/color/Color.d.ts +15 -0
  197. package/esm/typings/src/utils/color/Color.test.d.ts +1 -0
  198. package/esm/typings/src/utils/color/css-colors.d.ts +1 -0
  199. package/esm/typings/src/utils/color/internal-utils/checkChannelValue.d.ts +0 -3
  200. package/esm/typings/src/utils/color/operators/darken.d.ts +1 -1
  201. package/esm/typings/src/utils/color/operators/grayscale.d.ts +1 -1
  202. package/esm/typings/src/utils/color/operators/lighten.d.ts +1 -1
  203. package/esm/typings/src/utils/color/operators/mixWithColor.d.ts +1 -1
  204. package/esm/typings/src/utils/color/operators/saturate.d.ts +1 -1
  205. package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +16 -0
  206. package/esm/typings/src/utils/environment/$getGlobalScope.d.ts +2 -2
  207. package/esm/typings/src/utils/execCommand/$execCommand.d.ts +2 -1
  208. package/esm/typings/src/utils/execCommand/$execCommands.d.ts +2 -1
  209. package/esm/typings/src/utils/files/$induceBookDownload.d.ts +13 -0
  210. package/esm/typings/src/utils/files/$induceFileDownload.d.ts +13 -0
  211. package/esm/typings/src/utils/files/ObjectUrl.d.ts +46 -0
  212. package/esm/typings/src/utils/files/listAllFiles.d.ts +2 -3
  213. package/esm/typings/src/utils/misc/aboutPromptbookInformation.d.ts +27 -0
  214. package/esm/typings/src/utils/misc/computeHash.d.ts +11 -0
  215. package/esm/typings/src/utils/misc/computeHash.test.d.ts +1 -0
  216. package/esm/typings/src/utils/misc/injectCssModuleIntoShadowRoot.d.ts +1 -0
  217. package/esm/typings/src/utils/misc/xAboutPromptbookInformation.d.ts +13 -0
  218. package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +2 -0
  219. package/esm/typings/src/utils/normalization/normalizeMessageText.d.ts +9 -0
  220. package/esm/typings/src/utils/normalization/normalizeMessageText.test.d.ts +1 -0
  221. package/esm/typings/src/utils/normalization/normalizeTo_PascalCase.d.ts +3 -0
  222. package/esm/typings/src/utils/normalization/normalizeTo_camelCase.d.ts +2 -0
  223. package/esm/typings/src/utils/normalization/titleToName.d.ts +2 -0
  224. package/esm/typings/src/utils/organization/$sideEffect.d.ts +2 -2
  225. package/esm/typings/src/utils/organization/$side_effect.d.ts +7 -0
  226. package/esm/typings/src/utils/organization/TODO_USE.d.ts +2 -2
  227. package/esm/typings/src/utils/organization/keepUnused.d.ts +2 -2
  228. package/esm/typings/src/utils/organization/preserve.d.ts +3 -3
  229. package/esm/typings/src/utils/organization/really_any.d.ts +7 -0
  230. package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +25 -0
  231. package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +9 -0
  232. package/esm/typings/src/utils/random/$randomFullnameWithColor.d.ts +13 -0
  233. package/esm/typings/src/utils/random/$randomItem.d.ts +9 -0
  234. package/esm/typings/src/utils/random/$randomSeed.d.ts +3 -0
  235. package/esm/typings/src/utils/random/$randomToken.d.ts +2 -0
  236. package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +2 -1
  237. package/esm/typings/src/utils/serialization/asSerializable.d.ts +2 -2
  238. package/esm/typings/src/utils/serialization/serializeToPromptbookJavascript.d.ts +2 -2
  239. package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +2 -0
  240. package/esm/typings/src/version.d.ts +1 -1
  241. package/esm/typings/src/wizard/$getCompiledBook.d.ts +1 -2
  242. package/package.json +5 -5
  243. package/umd/index.umd.js +272 -201
  244. package/umd/index.umd.js.map +1 -1
  245. package/esm/typings/src/book-2.0/commitments/index.d.ts +0 -60
  246. package/esm/typings/src/book-components/BookEditor/BookEditorInner.d.ts +0 -5
  247. package/esm/typings/src/book-components/BookEditor/config.d.ts +0 -10
  248. package/esm/typings/src/book-components/Chat/utils/renderMarkdown.d.ts +0 -21
  249. package/esm/typings/src/collection/collectionToJson.d.ts +0 -13
  250. package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +0 -13
  251. /package/esm/typings/src/{book-components/Chat/utils/renderMarkdown.test.d.ts → book-2.0/agent-source/computeAgentHash.test.d.ts} +0 -0
  252. /package/esm/typings/src/{collection/constructors/createCollectionFromDirectory.test.d.ts → book-2.0/agent-source/normalizeAgentName.test.d.ts} +0 -0
  253. /package/esm/typings/src/{collection/constructors/createCollectionFromJson.test.d.ts → book-components/Chat/AgentChat/AgentChat.test.d.ts} +0 -0
  254. /package/esm/typings/src/collection/{constructors/createCollectionFromPromise.test.d.ts → pipeline-collection/constructors/createPipelineCollectionFromDirectory.test.d.ts} +0 -0
  255. /package/esm/typings/src/{commands/_common/parseCommand.test.d.ts → collection/pipeline-collection/constructors/createPipelineCollectionFromJson.test.d.ts} +0 -0
  256. /package/esm/typings/src/collection/{collectionToJson.test.d.ts → pipeline-collection/pipelineCollectionToJson.test.d.ts} +0 -0
  257. /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BookCommitment.d.ts +0 -0
  258. /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/ParsedCommitment.d.ts +0 -0
package/esm/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
1
+ import spaceTrim$1, { spaceTrim as spaceTrim$2 } from 'spacetrim';
2
2
  import { randomBytes } from 'crypto';
3
3
  import { Subject } from 'rxjs';
4
4
  import { forTime } from 'waitasecond';
@@ -16,14 +16,14 @@ import { parse, unparse } from 'papaparse';
16
16
  * @generated
17
17
  * @see https://github.com/webgptorg/book
18
18
  */
19
- const BOOK_LANGUAGE_VERSION = '1.0.0';
19
+ const BOOK_LANGUAGE_VERSION = '2.0.0';
20
20
  /**
21
21
  * The version of the Promptbook engine
22
22
  *
23
23
  * @generated
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-1';
26
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-100';
27
27
  /**
28
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
29
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -141,7 +141,7 @@ function extractAllBlocksFromMarkdown(markdown) {
141
141
  function extractOneBlockFromMarkdown(markdown) {
142
142
  const codeBlocks = extractAllBlocksFromMarkdown(markdown);
143
143
  if (codeBlocks.length !== 1) {
144
- throw new ParseError(spaceTrim((block) => `
144
+ throw new ParseError(spaceTrim$1((block) => `
145
145
  There should be exactly 1 code block in task section, found ${codeBlocks.length} code blocks
146
146
 
147
147
  ${block(codeBlocks.map((block, i) => `Block ${i + 1}:\n${block.content}`).join('\n\n\n'))}
@@ -172,6 +172,17 @@ function extractBlock(markdown) {
172
172
  return content;
173
173
  }
174
174
 
175
+ /**
176
+ * Trims string from all 4 sides
177
+ *
178
+ * Note: This is a re-exported function from the `spacetrim` package which is
179
+ * Developed by same author @hejny as this package
180
+ *
181
+ * @public exported from `@promptbook/utils`
182
+ * @see https://github.com/hejny/spacetrim#usage
183
+ */
184
+ const spaceTrim = spaceTrim$2;
185
+
175
186
  /**
176
187
  * @private util of `@promptbook/color`
177
188
  * @de
@@ -220,6 +231,7 @@ function take(initialValue) {
220
231
  * @public exported from `@promptbook/color`
221
232
  */
222
233
  const CSS_COLORS = {
234
+ promptbook: '#79EAFD',
223
235
  transparent: 'rgba(0,0,0,0)',
224
236
  aliceblue: '#f0f8ff',
225
237
  antiquewhite: '#faebd7',
@@ -401,9 +413,6 @@ function checkChannelValue(channelName, value) {
401
413
  throw new Error(`${channelName} channel is greater than 255, it is ${value}`);
402
414
  }
403
415
  }
404
- /**
405
- * TODO: [🧠][🚓] Is/which combination it better to use asserts/check, validate or is utility function?
406
- */
407
416
 
408
417
  /**
409
418
  * Color object represents an RGB color with alpha channel
@@ -438,6 +447,28 @@ class Color {
438
447
  throw new Error(`Can not create color from given object`);
439
448
  }
440
449
  }
450
+ /**
451
+ * Creates a new Color instance from miscellaneous formats
452
+ * It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
453
+ *
454
+ * @param color
455
+ * @returns Color object
456
+ */
457
+ static fromSafe(color) {
458
+ try {
459
+ return Color.from(color);
460
+ }
461
+ catch (error) {
462
+ // <- Note: Can not use `assertsError(error)` here because it causes circular dependency
463
+ console.warn(spaceTrim((block) => `
464
+ Color.fromSafe error:
465
+ ${block(error.message)}
466
+
467
+ Returning default PROMPTBOOK_COLOR.
468
+ `));
469
+ return Color.fromString('promptbook');
470
+ }
471
+ }
441
472
  /**
442
473
  * Creates a new Color instance from miscellaneous string formats
443
474
  *
@@ -505,6 +536,9 @@ class Color {
505
536
  if (hex.length === 3) {
506
537
  return Color.fromHex3(hex);
507
538
  }
539
+ if (hex.length === 4) {
540
+ return Color.fromHex4(hex);
541
+ }
508
542
  if (hex.length === 6) {
509
543
  return Color.fromHex6(hex);
510
544
  }
@@ -525,6 +559,19 @@ class Color {
525
559
  const b = parseInt(hex.substr(2, 1), 16) * 16;
526
560
  return take(new Color(r, g, b));
527
561
  }
562
+ /**
563
+ * Creates a new Color instance from color in hex format with 4 digits (with alpha channel)
564
+ *
565
+ * @param color in hex for example `09df`
566
+ * @returns Color object
567
+ */
568
+ static fromHex4(hex) {
569
+ const r = parseInt(hex.substr(0, 1), 16) * 16;
570
+ const g = parseInt(hex.substr(1, 1), 16) * 16;
571
+ const b = parseInt(hex.substr(2, 1), 16) * 16;
572
+ const a = parseInt(hex.substr(3, 1), 16) * 16;
573
+ return take(new Color(r, g, b, a));
574
+ }
528
575
  /**
529
576
  * Creates a new Color instance from color in hex format with 6 color digits (without alpha channel)
530
577
  *
@@ -715,7 +762,8 @@ class Color {
715
762
  * @returns true if the value is a valid hex color string (e.g., `#009edd`, `#fff`, etc.)
716
763
  */
717
764
  static isHexColorString(value) {
718
- return typeof value === 'string' && /^#(?:[0-9a-fA-F]{3}){1,2}$/.test(value);
765
+ return (typeof value === 'string' &&
766
+ /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(value));
719
767
  }
720
768
  /**
721
769
  * Creates new Color object
@@ -830,6 +878,23 @@ class Color {
830
878
  * TODO: Maybe connect with textures
831
879
  */
832
880
 
881
+ /**
882
+ * Makes color transformer which returns a grayscale version of the color
883
+ *
884
+ * @param amount from 0 to 1
885
+ *
886
+ * @public exported from `@promptbook/color`
887
+ */
888
+ function grayscale(amount) {
889
+ return ({ red, green, blue, alpha }) => {
890
+ const average = (red + green + blue) / 3;
891
+ red = Math.round(average * amount + red * (1 - amount));
892
+ green = Math.round(average * amount + green * (1 - amount));
893
+ blue = Math.round(average * amount + blue * (1 - amount));
894
+ return Color.fromValues(red, green, blue, alpha);
895
+ };
896
+ }
897
+
833
898
  /**
834
899
  * Converts HSL values to RGB values
835
900
  *
@@ -945,102 +1010,6 @@ function lighten(amount) {
945
1010
  * TODO: Maybe implement by mix+hsl
946
1011
  */
947
1012
 
948
- /**
949
- * Calculates distance between two colors
950
- *
951
- * @param color1 first color
952
- * @param color2 second color
953
- *
954
- * Note: This function is inefficient. Use colorDistanceSquared instead if possible.
955
- *
956
- * @public exported from `@promptbook/color`
957
- */
958
- /**
959
- * Calculates distance between two colors without square root
960
- *
961
- * @param color1 first color
962
- * @param color2 second color
963
- *
964
- * @public exported from `@promptbook/color`
965
- */
966
- function colorDistanceSquared(color1, color2) {
967
- const rmean = (color1.red + color2.red) / 2;
968
- const r = color1.red - color2.red;
969
- const g = color1.green - color2.green;
970
- const b = color1.blue - color2.blue;
971
- const weightR = 2 + rmean / 256;
972
- const weightG = 4.0;
973
- const weightB = 2 + (255 - rmean) / 256;
974
- const distance = weightR * r * r + weightG * g * g + weightB * b * b;
975
- return distance;
976
- }
977
-
978
- /**
979
- * Makes color transformer which finds the nearest color from the given list
980
- *
981
- * @param colors array of colors to choose from
982
- *
983
- * @public exported from `@promptbook/color`
984
- */
985
- function nearest(...colors) {
986
- return (color) => {
987
- const distances = colors.map((c) => colorDistanceSquared(c, color));
988
- const minDistance = Math.min(...distances);
989
- const minIndex = distances.indexOf(minDistance);
990
- const nearestColor = colors[minIndex];
991
- return nearestColor;
992
- };
993
- }
994
-
995
- /**
996
- * Color transformer which returns the negative color
997
- *
998
- * @public exported from `@promptbook/color`
999
- */
1000
- function negative(color) {
1001
- const r = 255 - color.red;
1002
- const g = 255 - color.green;
1003
- const b = 255 - color.blue;
1004
- return Color.fromValues(r, g, b, color.alpha);
1005
- }
1006
-
1007
- /**
1008
- * Makes color transformer which finds the furthest color from the given list
1009
- *
1010
- * @param colors array of colors to choose from
1011
- *
1012
- * @public exported from `@promptbook/color`
1013
- */
1014
- function furthest(...colors) {
1015
- return (color) => {
1016
- const furthestColor = negative(nearest(...colors.map(negative))(color));
1017
- return furthestColor;
1018
- };
1019
- }
1020
- /**
1021
- * Makes color transformer which finds the best text color (black or white) for the given background color
1022
- *
1023
- * @public exported from `@promptbook/color`
1024
- */
1025
- furthest(Color.get('white'), Color.from('black'));
1026
-
1027
- /**
1028
- * Makes color transformer which returns a grayscale version of the color
1029
- *
1030
- * @param amount from 0 to 1
1031
- *
1032
- * @public exported from `@promptbook/color`
1033
- */
1034
- function grayscale(amount) {
1035
- return ({ red, green, blue, alpha }) => {
1036
- const average = (red + green + blue) / 3;
1037
- red = Math.round(average * amount + red * (1 - amount));
1038
- green = Math.round(average * amount + green * (1 - amount));
1039
- blue = Math.round(average * amount + blue * (1 - amount));
1040
- return Color.fromValues(red, green, blue, alpha);
1041
- };
1042
- }
1043
-
1044
1013
  /**
1045
1014
  * Makes color transformer which saturate the given color
1046
1015
  *
@@ -1115,16 +1084,32 @@ const ADMIN_GITHUB_NAME = 'hejny';
1115
1084
  *
1116
1085
  * @public exported from `@promptbook/core`
1117
1086
  */
1118
- const PROMPTBOOK_COLOR = Color.fromHex('#79EAFD');
1119
- // <- TODO: [🧠] Using `Color` here increases the package size approx 3kb, maybe remove it
1087
+ const PROMPTBOOK_COLOR = Color.fromString('promptbook');
1088
+ // <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
1120
1089
  /**
1121
- * Dark color of the Promptbook
1090
+ * Colors for syntax highlighting in the `<BookEditor/>`
1091
+ *
1092
+ * TODO: [🗽] Unite branding and make single place for it
1093
+ *
1094
+ * @public exported from `@promptbook/core`
1095
+ */
1096
+ ({
1097
+ TITLE: Color.fromHex('#244EA8'),
1098
+ LINE: Color.fromHex('#eeeeee'),
1099
+ SEPARATOR: Color.fromHex('#cccccc'),
1100
+ COMMITMENT: Color.fromHex('#DA0F78'),
1101
+ PARAMETER: Color.fromHex('#8e44ad'),
1102
+ });
1103
+ // <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
1104
+ /**
1105
+ * Chat color of the Promptbook (in chat)
1122
1106
  *
1123
1107
  * TODO: [🗽] Unite branding and make single place for it
1124
1108
  *
1125
1109
  * @public exported from `@promptbook/core`
1126
1110
  */
1127
1111
  PROMPTBOOK_COLOR.then(lighten(0.1)).then(saturate(0.9)).then(grayscale(0.9));
1112
+ // <- TODO: [🧠][🈵] Using `Color` and `lighten`, `saturate`,... here increases the package size approx 3kb, maybe remove it
1128
1113
  /**
1129
1114
  * Color of the user (in chat)
1130
1115
  *
@@ -1133,6 +1118,7 @@ PROMPTBOOK_COLOR.then(lighten(0.1)).then(saturate(0.9)).then(grayscale(0.9));
1133
1118
  * @public exported from `@promptbook/core`
1134
1119
  */
1135
1120
  Color.fromHex('#1D4ED8');
1121
+ // <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
1136
1122
  /**
1137
1123
  * When the title is not provided, the default title is used
1138
1124
  *
@@ -1219,7 +1205,7 @@ const DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [🤹‍♂️]
1219
1205
  * @public exported from `@promptbook/core`
1220
1206
  */
1221
1207
  const DEFAULT_MAX_EXECUTION_ATTEMPTS = 7; // <- TODO: [🤹‍♂️]
1222
- // <- TODO: [🕝] Make also `BOOKS_DIRNAME_ALTERNATIVES`
1208
+ // <- TODO: [🕝] Make also `AGENTS_DIRNAME_ALTERNATIVES`
1223
1209
  // TODO: Just `.promptbook` in config, hardcode subfolders like `download-cache` or `execution-cache`
1224
1210
  /**
1225
1211
  * Where to store the temporary downloads
@@ -1296,7 +1282,7 @@ true);
1296
1282
  function getErrorReportUrl(error) {
1297
1283
  const report = {
1298
1284
  title: `🐜 Error report from ${NAME}`,
1299
- body: spaceTrim((block) => `
1285
+ body: spaceTrim$1((block) => `
1300
1286
 
1301
1287
 
1302
1288
  \`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
@@ -1339,7 +1325,7 @@ function getErrorReportUrl(error) {
1339
1325
  */
1340
1326
  class UnexpectedError extends Error {
1341
1327
  constructor(message) {
1342
- super(spaceTrim$1((block) => `
1328
+ super(spaceTrim$2((block) => `
1343
1329
  ${block(message)}
1344
1330
 
1345
1331
  Note: This error should not happen.
@@ -1365,7 +1351,7 @@ class WrappedError extends Error {
1365
1351
  constructor(whatWasThrown) {
1366
1352
  const tag = `[🤮]`;
1367
1353
  console.error(tag, whatWasThrown);
1368
- super(spaceTrim$1(`
1354
+ super(spaceTrim$2(`
1369
1355
  Non-Error object was thrown
1370
1356
 
1371
1357
  Note: Look for ${tag} in the console for more details
@@ -1479,7 +1465,7 @@ function extractJsonBlock(markdown) {
1479
1465
  function keepUnused(...valuesToKeep) {
1480
1466
  }
1481
1467
 
1482
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge from Markdown\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book`\n- INPUT PARAMETER `{knowledgeContent}` Markdown document content\n- OUTPUT PARAMETER `{knowledgePieces}` The knowledge JSON object\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}\n```\n\n`-> {knowledgePieces}`\n"}],sourceFile:"./books/prepare-knowledge-from-markdown.book"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Keywords\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-keywords.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{keywords}` Keywords separated by comma\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}\n```\n\n`-> {keywords}`\n"}],sourceFile:"./books/prepare-knowledge-keywords.book"},{title:"Prepare Knowledge-piece Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge-piece Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-title.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{title}` The title of the document\n\n## Knowledge\n\n- EXPECT MIN 1 WORD\n- EXPECT MAX 8 WORDS\n\n```markdown\nYou are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-knowledge-title.book"},{title:"Prepare Persona",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book",formfactorName:"GENERIC",parameters:[{name:"availableModels",description:"List of available model names together with their descriptions as JSON",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelsRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n```json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpful assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n```\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n```json\n{availableModels}\n```\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelsRequirements",format:"JSON",dependentParameterNames:["availableModels","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Persona\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-persona.book`\n- INPUT PARAMETER `{availableModels}` List of available model names together with their descriptions as JSON\n- INPUT PARAMETER `{personaDescription}` Description of the persona\n- OUTPUT PARAMETER `{modelsRequirements}` Specific requirements for the model\n\n## Make modelRequirements\n\n- FORMAT JSON\n\n```markdown\nYou are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n\\`\\`\\`json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpful assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n\\`\\`\\`\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n\\`\\`\\`json\n{availableModels}\n\\`\\`\\`\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}\n```\n\n`-> {modelsRequirements}`\n"}],sourceFile:"./books/prepare-persona.book"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-title.book",formfactorName:"GENERIC",parameters:[{name:"book",description:"The book to prepare the title for",isInput:true,isOutput:false},{name:"title",description:"Best title for the book",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-title",title:"Make title",content:"Make best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}",resultingParameterName:"title",expectations:{words:{min:1,max:8},lines:{min:1,max:1}},dependentParameterNames:["book"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-title.book`\n- INPUT PARAMETER `{book}` The book to prepare the title for\n- OUTPUT PARAMETER `{title}` Best title for the book\n\n## Make title\n\n- EXPECT MIN 1 Word\n- EXPECT MAX 8 Words\n- EXPECT EXACTLY 1 Line\n\n```markdown\nMake best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-title.book"},{title:"📊 Curriculum Audit",pipelineUrl:"https://promptbook.studio/promptbook//examples/lsvp-asistent.book",formfactorName:"GENERIC",parameters:[{name:"result",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"prompt",title:"Prompt",content:"Asistent pro LŠVP\n\nPERSONA Jsi asistent pro RVP Lyceum v rámci Národního pedagogického institutu České Republiky\nMETA IMAGE https://edulk.cz/getFile/id:475818/type:large/02%20zna%C4%8Dka%20npi.jpg\nRULE Pokud jsi nejsi jistý, napiš nevím\nKNOWLEDGE ./241129_Lyceum_final.pdf\nCONTEXT Obecně dokážeš řešit libovolné ŠVP, aktuálně řešíš {Školní vzdělávací program LYCEUM}\nRULE Z {Porovnání RVP a ŠVP - postup} je nejdůležitější fáze 3\nKNOWLEDGE {Školní vzdělávací program LYCEUM} ./ŠVP Lyceum - Finance v digitální době.pdf\nKNOWLEDGE @Slovník\n\n**Interní slovník - RVP/ŠVP**\n\n**RVP**\n\nRámcový vzdělávací program pro obor vzdělání Lyceum je dokument na národní úrovni, který formuluje požadavky na školní vzdělávací programy ve formě především očekávaných výsledků učení, kterých mají žáci absolvováním tohoto programu na dané škole dosáhnout.\n\n**ŠVP**\n\nŠkolní vzdělávací program pro obor vzdělání Lyceum je dokument každé jednotlivé školy, který popisuje v jakých vyučovacích předmětech/ vzdělávacích modulech a v jakých ročnících budou požadované očekávané výsledky učení naplněny. Zároveň formuluje další očekávané výsledky učení, které naplňují disponibilní část vyučovacího času určeného RVP pro tento obor vzdělání.\n\n**Očekávaný výsledek učení (OVU)**\n\nVyjadřuje jednotlivý požadavek na to, co mají žáci umět na konci vzdělávacího programu, tzn. jejich požadované kompetence. Je vyjádřen formulací, která je uvozena činnostním slovesem a dále obsahuje předmět této činnosti. Formulace je konkretizována resp. doplněna zpravidla formou odrážek vymezením dílčích znalostí, dovedností, postojů, jejichž splnění je předpokladem dosažení OVU jako celku.\n\n_Příklad:_\n\n<div class=\"joplin-table-wrapper\"><table><tbody><tr><th><p><strong>Žák/žákyně řídí realizaci jednoduchého projektu</strong></p></th></tr><tr><td><ul><li>naplánuje aktivity projektu</li></ul></td></tr><tr><td><ul><li>navrhne rozpočet projektu vzhledem k navrženým aktivitám</li></ul></td></tr><tr><td><ul><li>stanoví základní ukazatele a sleduje jejich naplňování</li></ul></td></tr><tr><td><ul><li>vede projektový tým</li></ul></td></tr><tr><td><ul><li>uvede, jak by řešil krizové situace v projektu</li></ul></td></tr><tr><td><ul><li>vyhodnotí úspěšnost projektu</li></ul></td></tr></tbody></table></div>\n\n**Vzdělávací oblasti**\n\nOčekávané výsledky učení jsou v **_RVP členěny do 4 vzdělávacích oblastí_**, které tvoří společný všeobecně vzdělávací základ:\n\n- Osobnostní rozvoj, vzdělávání ke zdraví, bezpečí a produktivnímu pracovnímu životu (kariéře)\n- Komunikační a jazykové vzdělávání\n- Aplikované vzdělávání STEM (Science, Technology, Engeneering, Math), tj. přírodní vědy, informatika, technika, matematika\n- Prakticky orientované vzdělávání společenskovědní a humanitní\n\nKaždá vzdělávací oblast se dále člení na okruhy, v jejichž rámci jsou OVU samostatně číslované.\n\n<div class=\"joplin-table-wrapper\"><table><tbody><tr><th rowspan=\"21\"><ul><li>Prakticky orientované vzdělávání společenskovědní a humanitní</li></ul></th><th rowspan=\"21\"><p><strong>Člověk, ekonomie a podnikání</strong></p></th><th rowspan=\"7\"><p><strong>1</strong></p></th><th><p><strong>zpracuje podklady související s podnikáním</strong></p></th></tr><tr><td><p>připraví podnikatelský záměr</p></td></tr><tr><td><p>sestaví zakladatelský rozpočet</p></td></tr><tr><td><p>zkalkuluje cenu zboží nebo služby</p></td></tr><tr><td><p>vysvětlí na příkladu základní povinnosti podnikatele vůči státu a zaměstnancům</p></td></tr><tr><td><p>vede daňovou evidenci</p></td></tr><tr><td><p>vysvětlí na příkladech etiku v podnikání</p></td></tr><tr><td rowspan=\"7\"><p><strong>2</strong></p></td><td><p><strong>řídí realizaci jednoduchého projektu</strong></p></td></tr><tr><td><p>naplánuje aktivity projektu</p></td></tr><tr><td><p>navrhne rozpočet projektu vzhledem k navrženým aktivitám</p></td></tr><tr><td><p>stanoví základní ukazatele a sleduje jejich naplňování</p></td></tr><tr><td><p>vede projektový tým</p></td></tr><tr><td><p>uvede, jak by řešil krizové situace v projektu</p></td></tr><tr><td><p>vyhodnotí úspěšnost projektu</p></td></tr><tr><td rowspan=\"7\"><p><strong>3</strong></p></td><td><p><strong>aplikuje ekonomické teorie v osobním a profesním životě</strong></p></td></tr><tr><td><p>vysvětlí základní ekonomické otázky</p></td></tr><tr><td><p>vysvětí stanovení rovnovážné ceny na dokonalém i nedokonalém trhu</p></td></tr><tr><td><p>charakterizuje výrobní faktory a vysvětlí hranici produkčních možností a náklady obětované příležitosti</p></td></tr><tr><td><p>uvede nejdůležitější makroekonomické pojmy a vliv jejich výše na kvalitu života a podnikání v daném státě</p></td></tr><tr><td><p>vysvětlí podstatu inflace a její důsledky na finanční situaci obyvatel a na příkladu ukáže jak se bránit jejím nepříznivým důsledkům</p></td></tr><tr><td><p>uvede hlavní výhody a nevýhody mezinárodního obchodu a vliv ochranářských opatření na ekonomickou situaci dané země</p></td></tr><tr><td></td><td></td><td><p><strong>4</strong></p></td><td><p>Atd.</p></td></tr></tbody></table></div>\n\n**Vyučovací předmět / vzdělávací modul**\n\nOčekávané výsledky učení jsou v **ŠVP** členěny do vyučovacích předmětů nebo vzdělávacích modulů, které jsou dále zařazeny do jednoho nebo více ročníků 4letého studia. Vyučovací předmět / vzdělávací modul tvoří vyučovací jednotku, kde jsou očekávané výsledky učení dále rozpracovány pro potřeby výuky podle následující šablony\n\n| **A. VSTUPNÍ ČÁST** |\n| --- |\n| **1\\. Název** |\n| **2\\. Kód** (kódy by měly být navázány na obory vzdělání a výsledky učení) |\n| **2a) Kategorie vzdělání** - v případě, že nebude součástí kódu |\n| **3\\. Typ vyučovací jednotky** (modul, předmět, stáž apod.) |\n| **4\\. Délka** (počet hodin - dělitelný čtyřmi (optimální modul 16, 32 hodin = týden výuky) |\n| **5\\. Platnost** (datum, od kterého platí) |\n| **6\\. Vstupní předpoklady** (vymezení požadované úrovně vstupních vědomostí a dovedností, které jsou předpokladem úspěšného studia) |\n| |\n| **B. JÁDRO VYUČOVACÍ JEDNOTKY** |\n| **1\\. Charakteristika** (stručná anotace popisující obecné cíle a pojetí) |\n| **2\\. Očekávané výsledky učení a jejich indikátory (převzaté z RVP nebo dále konkretizované)** |\n| **3\\. Podpora rozvoje klíčových kompetencí a základních gramotností** (které klíčové kompetence jsou v rozvíjeny) |\n| **4\\. Obsah vzdělávání** (rozpis učiva) |\n| **5\\. Vzdělávací strategie** (strategie výuky, resp. učební činnosti žáků, které jsou doporučené pro dosažení výsledků) |\n| |\n| **C. VÝSTUPNÍ ČÁST** |\n| **1\\. Způsob ověřování dosažených výsledků** (ve vazbě na jednotlivé výsledky učení) |\n| **2\\. Kritéria hodnocení** (co znamená splnění výsledků učení, kdy je splněna celá vyučovací jednotka, kritéria pro známky, příp. procentuální, slovní hodnocení) |\n| **3\\. Doporučená studijní literatura, odkazy na ilustrační zdroje** |\n| **4\\. Poznámky** |\n\n**Soulad OVU RVP a ŠVP**\n\nTento soulad je předmětem zjišťování. Soulad nastává, jestliže jsou očekávané výsledky učení z jednotlivých vzdělávacích oblastí RVP **obsaženy** ve vyučovacích předmětech/ vzdělávacích modulech ŠVP jednotlivých škol, tzn. že v ŠVP se objevuje jejich formulace buď v doslovném nebo podobném znění v jednom nebo více vyučovacích předmětech/ vzdělávacích modulech.\n\n_Příklad souladu:_\n\nRVP ŠVP - komunikace a marketing (SŠ obchodní Č.\n\n| **2** | **řídí realizaci jednoduchého projektu** |\n| --- | --- |\n| naplánuje aktivity projektu |\n| navrhne rozpočet projektu vzhledem k navrženým aktivitám |\n| stanoví základní ukazatele a sleduje jejich naplňování |\n| vede projektový tým |\n| uvede, jak by řešil krizové situace v projektu |\n| vyhodnotí úspěšnost projektu |\n\nKNOWLEDGE {Porovnání RVP a ŠVP - postup}\n\n\n# AUDITNÍ PROTOKOL ŠVP-RVP\n\n# (POPIS KONTROLNÍHO ALGORITMU)\n\nMetodika je určena pro **Kvantifikaci Shody** školního vzdělávacího programu (ŠVP) s Rámcovým vzdělávacím programem (RVP).\n\n## FÁZE 1: VALIDACE DOKUMENTACE\n\n**Cíl:** Ověřit platnost, aktuálnost a strukturu zdrojových dokumentů.\n\n- **RVP Verifikace:** Otevřít aktuální verzi RVP (např. RVP ZV/G/SOŠ).\n- **Typová shoda:** Ověřit, že RVP se vztahuje k danému typu školy.\n- **ŠVP Dimenze:** Identifikovat a izolovat relevantní části ŠVP: Profil absolventa, Klíčové kompetence (KK), Vzdělávací oblasti (VO), případně Učební plán (UP).\n- **Verzování:** Potvrdit, že obě verze (RVP a ŠVP) jsou nejnovější a platné (včetně dodatků RVP).\n\n## FÁZE 2: DATABÁZOVÉ MAPOVÁNÍ VÝSTUPŮ (MASTER MATICE)\n\n**Cíl:** Vytvořit systémovou databázi pro křížové porovnání všech povinných komponent RVP se ŠVP.\n\n- **Dekompozice RVP:** Rozložit RVP na základní povinné komponenty: Klíčové kompetence, Vzdělávací oblasti a obory, Očekávané výstupy (OVU), Průřezová témata (PT).\n- **Přiřazovací mapa:** Vytvořit hlavní kontrolní matici (Master Matice) pro záznam vazeb.\n\n| Oblast RVP | Výstup RVP (OVU) | Odpovídající Část ŠVP (Předmět/Ročník) | Konkrétní Tématický Celek v ŠVP | Stav Shody (Protokol) |\n| --- | --- | --- | --- | --- |\n| ... | ... | ... | ... | ... |\n| --- | --- | --- | --- | --- |\n\n## FÁZE 3: ALGORITMICKÁ KONTROLA POKRYTÍ A HLOUBKY\n\n**Cíl:** Posoudit, zda každý povinný výstup RVP je adekvátně reflektován v obsahu ŠVP, a přidělit bodovou hodnotu pro kvantifikaci.\n\n- **Audit OVU:** Projít každý jednotlivý Očekávaný výstup (OVU) z RVP.\n- **Kódování stavu a bodování:** U každého OVU v matici označit stav pokrytí dle následujícího schématu:\n\n| Kód (Protokol) | Popis (Kvalitativní zjištění) | Bodová hodnota (Kvantifikace) |\n| --- | --- | --- |\n| ✅ | Plná shoda (Výstup pokryt v plném rozsahu, odpovídající úrovni RVP) | 1,0 |\n| --- | --- | --- |\n| ⚠️ | Částečná shoda (Formální pokrytí, omezený rozsah, chybná návaznost) | 0,5 |\n| --- | --- | --- |\n| ❌ | Absence (Výstup zcela chybí v obsahu ŠVP) | 0,0 |\n| --- | --- | --- |\n\n- **Defektologie ŠVP:** Identifikovat a zaznamenat deficity ŠVP: Chybějící výstupy (❌), Sémantické překryvy, Přetížení obsahu.\n- **Kvalitativní posun:** Ověřit, zda je formulace výstupů v ŠVP **aktivní, měřitelná a v souladu** s úrovní RVP.\n\n## FÁZE 4: STRUKTURÁLNÍ VERIFIKACE NÁVAZNOSTI (VERTIKÁLA/HORIZONTÁLA)\n\n**Cíl:** Zkontrolovat logickou posloupnost a provázanost učiva v rámci ŠVP.\n\n- **Vertikální Kontrola:** Ověřit posloupnost OVU a učiva uvnitř jednoho předmětu/oblasti (postup od jednodušších ke složitějším konceptům napříč ročníky).\n- **Horizontální Kontrola:** Zkontrolovat logické provázání napříč vzdělávacími oblastmi a předměty (např. fyzika ↔ matematika).\n- **PT Integrace:** Audit reálné integrace Průřezových témat (PT) do konkrétních částí obsahu, metod a projektů.\n\n## FÁZE 5: ANALÝZA ŠKOLNÍ PROFILACE A ROZŠÍŘENÍ RVP\n\n**Cíl:** Validovat, že profilace školy je **v souladu** s RVP a nejedná se o **rozpor**.\n\n- **Nekonfliktnost:** Porovnat definovaný Profil absolventa školy s Klíčovými kompetencemi RVP. Profil ŠVP musí RVP rozvíjet, nikoli mu odporovat.\n- **Modularita:** Zkontrolovat, zda volitelné předměty a rozšiřující moduly logicky navazují na vzdělávací oblasti RVP.\n- **Implementace specializace:** Popisně uvést, jak je školní profilace (např. STEM zaměření, projektová výuka) integrována do OVU a kompetencí definovaných RVP.\n\n## FÁZE 6: GENERÁTOR ZÁVĚREČNÉ ZPRÁVY A KVANTIFIKACE\n\n**Cíl:** Syntetizovat výsledky, kvantifikovat soulad a generovat závazné návrhy na korekce.\n\n### 6.1 Kvantifikace Souladu\n\nVypočítat Index shody (IS) na základě bodového hodnocení (Fáze 3):\n\n### 6.2 Interpretace Indexu Shody (IS)\n\nKlasifikace souladu pro standardizované vyhodnocení:\n\n| Interval IS | Klasifikace souladu | Popis |\n| --- | --- | --- |\n| 95-100 % | Výborný soulad | ŠVP plně odpovídá RVP, pouze stylistické nebo formální rozdíly. |\n| --- | --- | --- |\n| 85-94 % | Dobrá shoda | ŠVP pokrývá všechny klíčové výstupy, menší korekce nutné. |\n| --- | --- | --- |\n| 70-84 % | Částečná shoda | Významné nedostatky v některých oblastech, nutná revize obsahu. |\n| --- | --- | --- |\n| < 70 % | Kritická neshoda | ŠVP neplní rámcové požadavky, ohrožuje legislativní soulad. |\n| --- | --- | --- |\n\n### 6.3 Doplňkové Indexy\n\nVypočítat následující doplňkové indexy pro detailní kvalitativní analýzu:\n\n- **Index kompetenčního souladu (IKS):** Poměr pokrytí klíčových kompetencí RVP v ŠVP.\n- **Index průřezové integrace (IPI):** Míra reálné integrace průřezových témat do výuky.\n- **Index hloubky pokrytí (IHP):** Procento výstupů, které jsou v ŠVP rozvedeny na konkrétní výukové cíle (měřitelné, aktivní formulace).\n- **Index profilové rozšiřitelnosti (IPR):** Kolik rozšiřujících nebo profilových výstupů přesahuje rámec RVP, aniž by narušily jeho strukturu.\n\n### 6.4 Vizuální výstupy\n\nZajistit generování následujících vizualizací pro Závěrečnou zprávu:\n\n- Graf pokrytí po vzdělávacích oblastech (Sloupcový graf IS pro VO).\n- Pavoukový diagram Klíčových kompetencí (RVP vs. ŠVP).\n- Mapa defektů (Vizualizace ❌ a ⚠️ výstupů).\n\n### 6.5 Struktura Závěrečné Zprávy\n\nZpráva musí být strukturována dle standardizovaného formátu:\n\n| Oddíl | Obsah |\n| --- | --- |\n| A. Identifikace | Název školy, IZO, typ školy, datum revize, zpracovatel, verze ŠVP a RVP. |\n| --- | --- |\n| B. Shrnutí výsledků | Celkový Index Shody (IS), hlavní závěry a doporučení. |\n| --- | --- |\n| C. Kvantitativní analýza | Přehled IS v % dle kategorií OVU / VO / kompetencí. |\n| --- | --- |\n| D. Kvalitativní analýza | Slovní zhodnocení kvality souladu (formulace, obtížnost, integrace PT). |\n| --- | --- |\n| E. Rizikové oblasti | Přehled nalezených defektů (chybějící OVU, přetížení, formální shoda). |\n| --- | --- |\n| F. Návrhy opatření (Korekční plán) | Přesné návrhy změn - **Co, Kde, Kdo** má upravit, včetně termínu. |\n| --- | --- |\n| G. Přílohy | Master Matice (Fáze 2-3), revizní tabulka, výstupní grafy a metriky. |\n| --- | --- |\n\n\n\n\n.",resultingParameterName:"result",dependentParameterNames:[]}],personas:[],preparations:[{id:1,promptbookVersion:"0.103.0-0",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"}];
1468
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge from Markdown\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book`\n- INPUT PARAMETER `{knowledgeContent}` Markdown document content\n- OUTPUT PARAMETER `{knowledgePieces}` The knowledge JSON object\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}\n```\n\n`-> {knowledgePieces}`\n"}],sourceFile:"./books/prepare-knowledge-from-markdown.book"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Keywords\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-keywords.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{keywords}` Keywords separated by comma\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}\n```\n\n`-> {keywords}`\n"}],sourceFile:"./books/prepare-knowledge-keywords.book"},{title:"Prepare Knowledge-piece Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge-piece Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-title.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{title}` The title of the document\n\n## Knowledge\n\n- EXPECT MIN 1 WORD\n- EXPECT MAX 8 WORDS\n\n```markdown\nYou are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-knowledge-title.book"},{title:"Prepare Persona",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book",formfactorName:"GENERIC",parameters:[{name:"availableModels",description:"List of available model names together with their descriptions as JSON",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelsRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n```json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpful assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n```\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n```json\n{availableModels}\n```\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelsRequirements",format:"JSON",dependentParameterNames:["availableModels","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Persona\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-persona.book`\n- INPUT PARAMETER `{availableModels}` List of available model names together with their descriptions as JSON\n- INPUT PARAMETER `{personaDescription}` Description of the persona\n- OUTPUT PARAMETER `{modelsRequirements}` Specific requirements for the model\n\n## Make modelRequirements\n\n- FORMAT JSON\n\n```markdown\nYou are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n\\`\\`\\`json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpful assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n\\`\\`\\`\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n\\`\\`\\`json\n{availableModels}\n\\`\\`\\`\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}\n```\n\n`-> {modelsRequirements}`\n"}],sourceFile:"./books/prepare-persona.book"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-title.book",formfactorName:"GENERIC",parameters:[{name:"book",description:"The book to prepare the title for",isInput:true,isOutput:false},{name:"title",description:"Best title for the book",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-title",title:"Make title",content:"Make best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}",resultingParameterName:"title",expectations:{words:{min:1,max:8},lines:{min:1,max:1}},dependentParameterNames:["book"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-title.book`\n- INPUT PARAMETER `{book}` The book to prepare the title for\n- OUTPUT PARAMETER `{title}` Best title for the book\n\n## Make title\n\n- EXPECT MIN 1 Word\n- EXPECT MAX 8 Words\n- EXPECT EXACTLY 1 Line\n\n```markdown\nMake best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-title.book"}];
1483
1469
 
1484
1470
  /**
1485
1471
  * Checks if value is valid email
@@ -1586,6 +1572,8 @@ function isValidUrl(url) {
1586
1572
  * Function `validatePipelineString` will validate the if the string is a valid pipeline string
1587
1573
  * It does not check if the string is fully logically correct, but if it is a string that can be a pipeline string or the string looks completely different.
1588
1574
  *
1575
+ * Note: [🔂] This function is idempotent.
1576
+ *
1589
1577
  * @param {string} pipelineString the candidate for a pipeline string
1590
1578
  * @returns {PipelineString} the same string as input, but validated as valid
1591
1579
  * @throws {ParseError} if the string is not a valid pipeline string
@@ -1734,7 +1722,7 @@ function pipelineJsonToString(pipelineJson) {
1734
1722
  pipelineString += '\n\n';
1735
1723
  pipelineString += '```' + contentLanguage;
1736
1724
  pipelineString += '\n';
1737
- pipelineString += spaceTrim(content);
1725
+ pipelineString += spaceTrim$1(content);
1738
1726
  // <- TODO: [main] !!3 Escape
1739
1727
  // <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
1740
1728
  pipelineString += '\n';
@@ -1855,7 +1843,7 @@ function checkSerializableAsJson(options) {
1855
1843
  }
1856
1844
  else if (typeof value === 'object') {
1857
1845
  if (value instanceof Date) {
1858
- throw new UnexpectedError(spaceTrim((block) => `
1846
+ throw new UnexpectedError(spaceTrim$1((block) => `
1859
1847
  \`${name}\` is Date
1860
1848
 
1861
1849
  Use \`string_date_iso8601\` instead
@@ -1874,7 +1862,7 @@ function checkSerializableAsJson(options) {
1874
1862
  throw new UnexpectedError(`${name} is RegExp`);
1875
1863
  }
1876
1864
  else if (value instanceof Error) {
1877
- throw new UnexpectedError(spaceTrim((block) => `
1865
+ throw new UnexpectedError(spaceTrim$1((block) => `
1878
1866
  \`${name}\` is unserialized Error
1879
1867
 
1880
1868
  Use function \`serializeError\`
@@ -1897,7 +1885,7 @@ function checkSerializableAsJson(options) {
1897
1885
  }
1898
1886
  catch (error) {
1899
1887
  assertsError(error);
1900
- throw new UnexpectedError(spaceTrim((block) => `
1888
+ throw new UnexpectedError(spaceTrim$1((block) => `
1901
1889
  \`${name}\` is not serializable
1902
1890
 
1903
1891
  ${block(error.stack || error.message)}
@@ -1929,7 +1917,7 @@ function checkSerializableAsJson(options) {
1929
1917
  }
1930
1918
  }
1931
1919
  else {
1932
- throw new UnexpectedError(spaceTrim((block) => `
1920
+ throw new UnexpectedError(spaceTrim$1((block) => `
1933
1921
  \`${name}\` is unknown type
1934
1922
 
1935
1923
  Additional message for \`${name}\`:
@@ -1959,7 +1947,7 @@ function deepClone(objectValue) {
1959
1947
  TODO: [🧠] Is there a better implementation?
1960
1948
  > const propertyNames = Object.getOwnPropertyNames(objectValue);
1961
1949
  > for (const propertyName of propertyNames) {
1962
- > const value = (objectValue as really_any)[propertyName];
1950
+ > const value = (objectValue as chococake)[propertyName];
1963
1951
  > if (value && typeof value === 'object') {
1964
1952
  > deepClone(value);
1965
1953
  > }
@@ -2164,6 +2152,8 @@ function isValidPipelineUrl(url) {
2164
2152
  * - if it is valid json
2165
2153
  * - if it is meaningful
2166
2154
  *
2155
+ * Note: [🔂] This function is idempotent.
2156
+ *
2167
2157
  * @param pipeline valid or invalid PipelineJson
2168
2158
  * @returns the same pipeline if it is logically valid
2169
2159
  * @throws {PipelineLogicError} on logical error in the pipeline
@@ -2181,7 +2171,7 @@ function validatePipeline(pipeline) {
2181
2171
  if (!(error instanceof PipelineLogicError)) {
2182
2172
  throw error;
2183
2173
  }
2184
- console.error(spaceTrim$1((block) => `
2174
+ console.error(spaceTrim$2((block) => `
2185
2175
  Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
2186
2176
 
2187
2177
  ${block(error.message)}
@@ -2208,7 +2198,7 @@ function validatePipeline_InnerFunction(pipeline) {
2208
2198
  })();
2209
2199
  if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
2210
2200
  // <- Note: [🚲]
2211
- throw new PipelineLogicError(spaceTrim$1((block) => `
2201
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2212
2202
  Invalid promptbook URL "${pipeline.pipelineUrl}"
2213
2203
 
2214
2204
  ${block(pipelineIdentification)}
@@ -2216,7 +2206,7 @@ function validatePipeline_InnerFunction(pipeline) {
2216
2206
  }
2217
2207
  if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
2218
2208
  // <- Note: [🚲]
2219
- throw new PipelineLogicError(spaceTrim$1((block) => `
2209
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2220
2210
  Invalid Promptbook Version "${pipeline.bookVersion}"
2221
2211
 
2222
2212
  ${block(pipelineIdentification)}
@@ -2225,7 +2215,7 @@ function validatePipeline_InnerFunction(pipeline) {
2225
2215
  // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2226
2216
  if (!Array.isArray(pipeline.parameters)) {
2227
2217
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2228
- throw new ParseError(spaceTrim$1((block) => `
2218
+ throw new ParseError(spaceTrim$2((block) => `
2229
2219
  Pipeline is valid JSON but with wrong structure
2230
2220
 
2231
2221
  \`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
@@ -2236,7 +2226,7 @@ function validatePipeline_InnerFunction(pipeline) {
2236
2226
  // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2237
2227
  if (!Array.isArray(pipeline.tasks)) {
2238
2228
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2239
- throw new ParseError(spaceTrim$1((block) => `
2229
+ throw new ParseError(spaceTrim$2((block) => `
2240
2230
  Pipeline is valid JSON but with wrong structure
2241
2231
 
2242
2232
  \`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
@@ -2262,7 +2252,7 @@ function validatePipeline_InnerFunction(pipeline) {
2262
2252
  // Note: Check each parameter individually
2263
2253
  for (const parameter of pipeline.parameters) {
2264
2254
  if (parameter.isInput && parameter.isOutput) {
2265
- throw new PipelineLogicError(spaceTrim$1((block) => `
2255
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2266
2256
 
2267
2257
  Parameter \`{${parameter.name}}\` can not be both input and output
2268
2258
 
@@ -2273,7 +2263,7 @@ function validatePipeline_InnerFunction(pipeline) {
2273
2263
  if (!parameter.isInput &&
2274
2264
  !parameter.isOutput &&
2275
2265
  !pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
2276
- throw new PipelineLogicError(spaceTrim$1((block) => `
2266
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2277
2267
  Parameter \`{${parameter.name}}\` is created but not used
2278
2268
 
2279
2269
  You can declare {${parameter.name}} as output parameter by adding in the header:
@@ -2285,7 +2275,7 @@ function validatePipeline_InnerFunction(pipeline) {
2285
2275
  }
2286
2276
  // Note: Testing that parameter is either input or result of some task
2287
2277
  if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
2288
- throw new PipelineLogicError(spaceTrim$1((block) => `
2278
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2289
2279
  Parameter \`{${parameter.name}}\` is declared but not defined
2290
2280
 
2291
2281
  You can do one of these:
@@ -2301,14 +2291,14 @@ function validatePipeline_InnerFunction(pipeline) {
2301
2291
  // Note: Checking each task individually
2302
2292
  for (const task of pipeline.tasks) {
2303
2293
  if (definedParameters.has(task.resultingParameterName)) {
2304
- throw new PipelineLogicError(spaceTrim$1((block) => `
2294
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2305
2295
  Parameter \`{${task.resultingParameterName}}\` is defined multiple times
2306
2296
 
2307
2297
  ${block(pipelineIdentification)}
2308
2298
  `));
2309
2299
  }
2310
2300
  if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
2311
- throw new PipelineLogicError(spaceTrim$1((block) => `
2301
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2312
2302
  Parameter name {${task.resultingParameterName}} is reserved, please use different name
2313
2303
 
2314
2304
  ${block(pipelineIdentification)}
@@ -2318,7 +2308,7 @@ function validatePipeline_InnerFunction(pipeline) {
2318
2308
  if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
2319
2309
  if (!task.format &&
2320
2310
  !task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
2321
- throw new PipelineLogicError(spaceTrim$1((block) => `
2311
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2322
2312
  Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
2323
2313
 
2324
2314
  ${block(pipelineIdentification)}
@@ -2326,7 +2316,7 @@ function validatePipeline_InnerFunction(pipeline) {
2326
2316
  }
2327
2317
  for (const joker of task.jokerParameterNames) {
2328
2318
  if (!task.dependentParameterNames.includes(joker)) {
2329
- throw new PipelineLogicError(spaceTrim$1((block) => `
2319
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2330
2320
  Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
2331
2321
 
2332
2322
  ${block(pipelineIdentification)}
@@ -2337,21 +2327,21 @@ function validatePipeline_InnerFunction(pipeline) {
2337
2327
  if (task.expectations) {
2338
2328
  for (const [unit, { min, max }] of Object.entries(task.expectations)) {
2339
2329
  if (min !== undefined && max !== undefined && min > max) {
2340
- throw new PipelineLogicError(spaceTrim$1((block) => `
2330
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2341
2331
  Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
2342
2332
 
2343
2333
  ${block(pipelineIdentification)}
2344
2334
  `));
2345
2335
  }
2346
2336
  if (min !== undefined && min < 0) {
2347
- throw new PipelineLogicError(spaceTrim$1((block) => `
2337
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2348
2338
  Min expectation of ${unit} must be zero or positive
2349
2339
 
2350
2340
  ${block(pipelineIdentification)}
2351
2341
  `));
2352
2342
  }
2353
2343
  if (max !== undefined && max <= 0) {
2354
- throw new PipelineLogicError(spaceTrim$1((block) => `
2344
+ throw new PipelineLogicError(spaceTrim$2((block) => `
2355
2345
  Max expectation of ${unit} must be positive
2356
2346
 
2357
2347
  ${block(pipelineIdentification)}
@@ -2373,7 +2363,7 @@ function validatePipeline_InnerFunction(pipeline) {
2373
2363
  while (unresovedTasks.length > 0) {
2374
2364
  if (loopLimit-- < 0) {
2375
2365
  // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
2376
- throw new UnexpectedError(spaceTrim$1((block) => `
2366
+ throw new UnexpectedError(spaceTrim$2((block) => `
2377
2367
  Loop limit reached during detection of circular dependencies in \`validatePipeline\`
2378
2368
 
2379
2369
  ${block(pipelineIdentification)}
@@ -2383,7 +2373,7 @@ function validatePipeline_InnerFunction(pipeline) {
2383
2373
  if (currentlyResovedTasks.length === 0) {
2384
2374
  throw new PipelineLogicError(
2385
2375
  // TODO: [🐎] DRY
2386
- spaceTrim$1((block) => `
2376
+ spaceTrim$2((block) => `
2387
2377
 
2388
2378
  Can not resolve some parameters:
2389
2379
  Either you are using a parameter that is not defined, or there are some circular dependencies.
@@ -2530,7 +2520,7 @@ function unpreparePipeline(pipeline) {
2530
2520
  * Library of pipelines that groups together pipelines for an application.
2531
2521
  * This implementation is a very thin wrapper around the Array / Map of pipelines.
2532
2522
  *
2533
- * @private internal function of `createCollectionFromJson`, use `createCollectionFromJson` instead
2523
+ * @private internal function of `createPipelineCollectionFromJson`, use `createPipelineCollectionFromJson` instead
2534
2524
  * @see https://github.com/webgptorg/pipeline#pipeline-collection
2535
2525
  */
2536
2526
  class SimplePipelineCollection {
@@ -2540,14 +2530,14 @@ class SimplePipelineCollection {
2540
2530
  * @param pipelines Array of pipeline JSON objects to include in the collection
2541
2531
  *
2542
2532
  * Note: During the construction logic of all pipelines are validated
2543
- * Note: It is not recommended to use this constructor directly, use `createCollectionFromJson` *(or other variant)* instead
2533
+ * Note: It is not recommended to use this constructor directly, use `createPipelineCollectionFromJson` *(or other variant)* instead
2544
2534
  */
2545
2535
  constructor(...pipelines) {
2546
2536
  this.collection = new Map();
2547
2537
  for (const pipeline of pipelines) {
2548
2538
  // TODO: [👠] DRY
2549
2539
  if (pipeline.pipelineUrl === undefined) {
2550
- throw new PipelineUrlError(spaceTrim$1(`
2540
+ throw new PipelineUrlError(spaceTrim$2(`
2551
2541
  Pipeline with name "${pipeline.title}" does not have defined URL
2552
2542
 
2553
2543
  File:
@@ -2569,7 +2559,7 @@ class SimplePipelineCollection {
2569
2559
  pipelineJsonToString(unpreparePipeline(pipeline)) !==
2570
2560
  pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
2571
2561
  const existing = this.collection.get(pipeline.pipelineUrl);
2572
- throw new PipelineUrlError(spaceTrim$1(`
2562
+ throw new PipelineUrlError(spaceTrim$2(`
2573
2563
  Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍎
2574
2564
 
2575
2565
  Conflicting files:
@@ -2601,13 +2591,13 @@ class SimplePipelineCollection {
2601
2591
  const pipeline = this.collection.get(url);
2602
2592
  if (!pipeline) {
2603
2593
  if (this.listPipelines().length === 0) {
2604
- throw new NotFoundError(spaceTrim$1(`
2594
+ throw new NotFoundError(spaceTrim$2(`
2605
2595
  Pipeline with url "${url}" not found
2606
2596
 
2607
2597
  No pipelines available
2608
2598
  `));
2609
2599
  }
2610
- throw new NotFoundError(spaceTrim$1((block) => `
2600
+ throw new NotFoundError(spaceTrim$2((block) => `
2611
2601
  Pipeline with url "${url}" not found
2612
2602
 
2613
2603
  Available pipelines:
@@ -2628,16 +2618,16 @@ class SimplePipelineCollection {
2628
2618
  }
2629
2619
 
2630
2620
  /**
2631
- * Creates PipelineCollection from array of PipelineJson or PipelineString
2621
+ * Creates `PipelineCollection` from array of PipelineJson or PipelineString
2632
2622
  *
2633
- * Note: Functions `collectionToJson` and `createCollectionFromJson` are complementary
2623
+ * Note: Functions `pipelineCollectionToJson` and `createPipelineCollectionFromJson` are complementary
2634
2624
  * Note: Syntax, parsing, and logic consistency checks are performed on all sources during build
2635
2625
  *
2636
2626
  * @param promptbookSources
2637
2627
  * @returns PipelineCollection
2638
2628
  * @public exported from `@promptbook/core`
2639
2629
  */
2640
- function createCollectionFromJson(...promptbooks) {
2630
+ function createPipelineCollectionFromJson(...promptbooks) {
2641
2631
  return new SimplePipelineCollection(...promptbooks);
2642
2632
  }
2643
2633
 
@@ -2648,7 +2638,7 @@ function createCollectionFromJson(...promptbooks) {
2648
2638
  */
2649
2639
  class MissingToolsError extends Error {
2650
2640
  constructor(message) {
2651
- super(spaceTrim$1((block) => `
2641
+ super(spaceTrim$2((block) => `
2652
2642
  ${block(message)}
2653
2643
 
2654
2644
  Note: You have probably forgot to provide some tools for pipeline execution or preparation
@@ -2662,6 +2652,7 @@ class MissingToolsError extends Error {
2662
2652
  /**
2663
2653
  * Generates random token
2664
2654
  *
2655
+ * Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
2665
2656
  * Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
2666
2657
  *
2667
2658
  * @private internal helper function
@@ -2671,6 +2662,7 @@ function $randomToken(randomness) {
2671
2662
  return randomBytes(randomness).toString('hex');
2672
2663
  }
2673
2664
  /**
2665
+ * TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
2674
2666
  * TODO: Maybe use nanoid instead https://github.com/ai/nanoid
2675
2667
  */
2676
2668
 
@@ -2789,6 +2781,22 @@ class CollectionError extends Error {
2789
2781
  }
2790
2782
  }
2791
2783
 
2784
+ /**
2785
+ * This error indicates error from the database
2786
+ *
2787
+ * @public exported from `@promptbook/core`
2788
+ */
2789
+ class DatabaseError extends Error {
2790
+ constructor(message) {
2791
+ super(message);
2792
+ this.name = 'DatabaseError';
2793
+ Object.setPrototypeOf(this, DatabaseError.prototype);
2794
+ }
2795
+ }
2796
+ /**
2797
+ * TODO: [🐱‍🚀] Explain that NotFoundError ([🐱‍🚀] and other specific errors) has priority over DatabaseError in some contexts
2798
+ */
2799
+
2792
2800
  /**
2793
2801
  * This error type indicates that you try to use a feature that is not available in the current environment
2794
2802
  *
@@ -2844,6 +2852,19 @@ class LimitReachedError extends Error {
2844
2852
  }
2845
2853
  }
2846
2854
 
2855
+ /**
2856
+ * This error indicates that promptbook operation is not allowed
2857
+ *
2858
+ * @public exported from `@promptbook/core`
2859
+ */
2860
+ class NotAllowed extends Error {
2861
+ constructor(message) {
2862
+ super(message);
2863
+ this.name = 'NotAllowed';
2864
+ Object.setPrototypeOf(this, NotAllowed.prototype);
2865
+ }
2866
+ }
2867
+
2847
2868
  /**
2848
2869
  * This error type indicates that some part of the code is not implemented yet
2849
2870
  *
@@ -2851,7 +2872,7 @@ class LimitReachedError extends Error {
2851
2872
  */
2852
2873
  class NotYetImplementedError extends Error {
2853
2874
  constructor(message) {
2854
- super(spaceTrim$1((block) => `
2875
+ super(spaceTrim$2((block) => `
2855
2876
  ${block(message)}
2856
2877
 
2857
2878
  Note: This feature is not implemented yet but it will be soon.
@@ -2904,6 +2925,8 @@ const PROMPTBOOK_ERRORS = {
2904
2925
  PromptbookFetchError,
2905
2926
  UnexpectedError,
2906
2927
  WrappedError,
2928
+ NotAllowed,
2929
+ DatabaseError,
2907
2930
  // TODO: [🪑]> VersionMismatchError,
2908
2931
  };
2909
2932
  /**
@@ -2951,7 +2974,7 @@ function serializeError(error) {
2951
2974
  const { name, message, stack } = error;
2952
2975
  const { id } = error;
2953
2976
  if (!Object.keys(ALL_ERRORS).includes(name)) {
2954
- console.error(spaceTrim((block) => `
2977
+ console.error(spaceTrim$1((block) => `
2955
2978
 
2956
2979
  Cannot serialize error with name "${name}"
2957
2980
 
@@ -2984,7 +3007,7 @@ function jsonParse(value) {
2984
3007
  }
2985
3008
  else if (typeof value !== 'string') {
2986
3009
  console.error('Can not parse JSON from non-string value.', { text: value });
2987
- throw new Error(spaceTrim(`
3010
+ throw new Error(spaceTrim$1(`
2988
3011
  Can not parse JSON from non-string value.
2989
3012
 
2990
3013
  The value type: ${typeof value}
@@ -2998,7 +3021,7 @@ function jsonParse(value) {
2998
3021
  if (!(error instanceof Error)) {
2999
3022
  throw error;
3000
3023
  }
3001
- throw new Error(spaceTrim((block) => `
3024
+ throw new Error(spaceTrim$1((block) => `
3002
3025
  ${block(error.message)}
3003
3026
 
3004
3027
  The expected JSON text:
@@ -3051,7 +3074,7 @@ function deserializeError(error) {
3051
3074
  message = `${name}: ${message}`;
3052
3075
  }
3053
3076
  if (stack !== undefined && stack !== '') {
3054
- message = spaceTrim((block) => `
3077
+ message = spaceTrim$1((block) => `
3055
3078
  ${block(message)}
3056
3079
 
3057
3080
  Original stack trace:
@@ -3088,11 +3111,11 @@ function assertsTaskSuccessful(executionResult) {
3088
3111
  throw deserializeError(errors[0]);
3089
3112
  }
3090
3113
  else {
3091
- throw new PipelineExecutionError(spaceTrim$1((block) => `
3114
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
3092
3115
  Multiple errors occurred during Promptbook execution
3093
3116
 
3094
3117
  ${block(errors
3095
- .map(({ name, stack, message }, index) => spaceTrim$1((block) => `
3118
+ .map(({ name, stack, message }, index) => spaceTrim$2((block) => `
3096
3119
  ${name} ${index + 1}:
3097
3120
  ${block(stack || message)}
3098
3121
  `))
@@ -3119,6 +3142,7 @@ function createTask(options) {
3119
3142
  let updatedAt = createdAt;
3120
3143
  const errors = [];
3121
3144
  const warnings = [];
3145
+ const llmCalls = [];
3122
3146
  let currentValue = {};
3123
3147
  let customTldr = null;
3124
3148
  const partialResultSubject = new Subject();
@@ -3134,6 +3158,9 @@ function createTask(options) {
3134
3158
  }, (tldrInfo) => {
3135
3159
  customTldr = tldrInfo;
3136
3160
  updatedAt = new Date();
3161
+ }, (llmCall) => {
3162
+ llmCalls.push(llmCall);
3163
+ updatedAt = new Date();
3137
3164
  });
3138
3165
  finalResultPromise
3139
3166
  .catch((error) => {
@@ -3256,7 +3283,7 @@ function createTask(options) {
3256
3283
  }
3257
3284
  return {
3258
3285
  percent: percent,
3259
- message,
3286
+ message: message + ' (!!!fallback)',
3260
3287
  };
3261
3288
  },
3262
3289
  get createdAt() {
@@ -3279,6 +3306,10 @@ function createTask(options) {
3279
3306
  return warnings;
3280
3307
  // <- Note: [1] --||--
3281
3308
  },
3309
+ get llmCalls() {
3310
+ return [...llmCalls, { foo: '!!! bar' }];
3311
+ // <- Note: [1] --||--
3312
+ },
3282
3313
  get currentValue() {
3283
3314
  return currentValue;
3284
3315
  // <- Note: [1] --||--
@@ -3555,14 +3586,14 @@ class MultipleLlmExecutionTools {
3555
3586
  if (description === undefined) {
3556
3587
  return headLine;
3557
3588
  }
3558
- return spaceTrim((block) => `
3589
+ return spaceTrim$1((block) => `
3559
3590
  ${headLine}
3560
3591
 
3561
3592
  ${ /* <- Note: Indenting the description: */block(description)}
3562
3593
  `);
3563
3594
  })
3564
3595
  .join('\n\n');
3565
- return spaceTrim((block) => `
3596
+ return spaceTrim$1((block) => `
3566
3597
  Multiple LLM Providers:
3567
3598
 
3568
3599
  ${block(innerModelsTitlesAndDescriptions)}
@@ -3653,7 +3684,7 @@ class MultipleLlmExecutionTools {
3653
3684
  // 1) OpenAI throw PipelineExecutionError: Parameter `{knowledge}` is not defined
3654
3685
  // 2) AnthropicClaude throw PipelineExecutionError: Parameter `{knowledge}` is not defined
3655
3686
  // 3) ...
3656
- spaceTrim((block) => `
3687
+ spaceTrim$1((block) => `
3657
3688
  All execution tools of ${this.title} failed:
3658
3689
 
3659
3690
  ${block(errors
@@ -3666,7 +3697,7 @@ class MultipleLlmExecutionTools {
3666
3697
  throw new PipelineExecutionError(`You have not provided any \`LlmExecutionTools\` into ${this.title}`);
3667
3698
  }
3668
3699
  else {
3669
- throw new PipelineExecutionError(spaceTrim((block) => `
3700
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
3670
3701
  You have not provided any \`LlmExecutionTools\` that support model variant "${prompt.modelRequirements.modelVariant}" into ${this.title}
3671
3702
 
3672
3703
  Available \`LlmExecutionTools\`:
@@ -3699,7 +3730,7 @@ class MultipleLlmExecutionTools {
3699
3730
  */
3700
3731
  function joinLlmExecutionTools(title, ...llmExecutionTools) {
3701
3732
  if (llmExecutionTools.length === 0) {
3702
- const warningMessage = spaceTrim(`
3733
+ const warningMessage = spaceTrim$1(`
3703
3734
  You have not provided any \`LlmExecutionTools\`
3704
3735
  This means that you won't be able to execute any prompts that require large language models like GPT-4 or Anthropic's Claude.
3705
3736
 
@@ -3732,6 +3763,7 @@ function joinLlmExecutionTools(title, ...llmExecutionTools) {
3732
3763
  return new MultipleLlmExecutionTools(title || 'Multiple LLM Providers joined by `joinLlmExecutionTools`', ...llmExecutionTools);
3733
3764
  }
3734
3765
  /**
3766
+ * TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
3735
3767
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
3736
3768
  */
3737
3769
 
@@ -3748,6 +3780,7 @@ function getSingleLlmExecutionTools(oneOrMoreLlmExecutionTools) {
3748
3780
  return llmTools;
3749
3781
  }
3750
3782
  /**
3783
+ * TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
3751
3784
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
3752
3785
  */
3753
3786
 
@@ -3763,7 +3796,7 @@ async function preparePersona(personaDescription, tools, options) {
3763
3796
  throw new MissingToolsError('LLM tools are required for preparing persona');
3764
3797
  }
3765
3798
  // TODO: [🌼] In future use `ptbk make` and made getPipelineCollection
3766
- const collection = createCollectionFromJson(...PipelineCollection);
3799
+ const collection = createPipelineCollectionFromJson(...PipelineCollection);
3767
3800
  const preparePersonaExecutor = createPipelineExecutor({
3768
3801
  pipeline: await collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book'),
3769
3802
  tools,
@@ -4014,14 +4047,14 @@ function $registeredScrapersMessage(availableScrapers) {
4014
4047
  return { ...metadata, isMetadataAviailable, isInstalled, isAvailableInTools };
4015
4048
  });
4016
4049
  if (metadata.length === 0) {
4017
- return spaceTrim(`
4050
+ return spaceTrim$1(`
4018
4051
  **No scrapers are available**
4019
4052
 
4020
4053
  This is a unexpected behavior, you are probably using some broken version of Promptbook
4021
4054
  At least there should be available the metadata of the scrapers
4022
4055
  `);
4023
4056
  }
4024
- return spaceTrim((block) => `
4057
+ return spaceTrim$1((block) => `
4025
4058
  Available scrapers are:
4026
4059
  ${block(metadata
4027
4060
  .map(({ packageName, className, isMetadataAviailable, isInstalled, mimeTypes, isAvailableInBrowser, isAvailableInTools, }, i) => {
@@ -4329,6 +4362,8 @@ function removeDiacritics(input) {
4329
4362
  /**
4330
4363
  * Converts a given text to kebab-case format.
4331
4364
  *
4365
+ * Note: [🔂] This function is idempotent.
4366
+ *
4332
4367
  * @param text The text to be converted.
4333
4368
  * @returns The kebab-case formatted string.
4334
4369
  * @example 'hello-world'
@@ -4484,6 +4519,8 @@ function removeEmojis(text) {
4484
4519
  /**
4485
4520
  * Converts a title string into a normalized name.
4486
4521
  *
4522
+ * Note: [🔂] This function is idempotent.
4523
+ *
4487
4524
  * @param value The title string to be converted to a name.
4488
4525
  * @returns A normalized name derived from the input title.
4489
4526
  * @example 'Hello World!' -> 'hello-world'
@@ -4523,7 +4560,7 @@ const promptbookFetch = async (urlOrRequest, init) => {
4523
4560
  else if (urlOrRequest instanceof Request) {
4524
4561
  url = urlOrRequest.url;
4525
4562
  }
4526
- throw new PromptbookFetchError(spaceTrim((block) => `
4563
+ throw new PromptbookFetchError(spaceTrim$1((block) => `
4527
4564
  Can not fetch "${url}"
4528
4565
 
4529
4566
  Fetch error:
@@ -4684,7 +4721,7 @@ async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
4684
4721
  const fileExtension = getFileExtension(filename);
4685
4722
  const mimeType = extensionToMimeType(fileExtension || '');
4686
4723
  if (!(await isFileExisting(filename, tools.fs))) {
4687
- throw new NotFoundError(spaceTrim((block) => `
4724
+ throw new NotFoundError(spaceTrim$1((block) => `
4688
4725
  Can not make source handler for file which does not exist:
4689
4726
 
4690
4727
  File:
@@ -4777,7 +4814,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
4777
4814
  // <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
4778
4815
  break;
4779
4816
  }
4780
- console.warn(spaceTrim((block) => `
4817
+ console.warn(spaceTrim$1((block) => `
4781
4818
  Cannot scrape knowledge from source despite the scraper \`${scraper.metadata.className}\` supports the mime type "${sourceHandler.mimeType}".
4782
4819
 
4783
4820
  The source:
@@ -4793,7 +4830,7 @@ async function prepareKnowledgePieces(knowledgeSources, tools, options) {
4793
4830
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
4794
4831
  }
4795
4832
  if (partialPieces === null) {
4796
- throw new KnowledgeScrapeError(spaceTrim((block) => `
4833
+ throw new KnowledgeScrapeError(spaceTrim$1((block) => `
4797
4834
  Cannot scrape knowledge
4798
4835
 
4799
4836
  The source:
@@ -4872,7 +4909,7 @@ async function prepareTasks(pipeline, tools, options) {
4872
4909
  if (task.taskType === 'PROMPT_TASK' &&
4873
4910
  knowledgePiecesCount > 0 &&
4874
4911
  !dependentParameterNames.includes('knowledge')) {
4875
- preparedContent = spaceTrim$1(`
4912
+ preparedContent = spaceTrim$2(`
4876
4913
  {content}
4877
4914
 
4878
4915
  ## Knowledge
@@ -4958,7 +4995,7 @@ async function preparePipeline(pipeline, tools, options) {
4958
4995
  let title = pipeline.title;
4959
4996
  if (title === undefined || title === '' || title === DEFAULT_BOOK_TITLE) {
4960
4997
  // TODO: [🌼] In future use `ptbk make` and made getPipelineCollection
4961
- const collection = createCollectionFromJson(...PipelineCollection);
4998
+ const collection = createPipelineCollectionFromJson(...PipelineCollection);
4962
4999
  const prepareTitleExecutor = createPipelineExecutor({
4963
5000
  pipeline: await collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-title.book'),
4964
5001
  tools,
@@ -5185,7 +5222,7 @@ function extractVariablesFromJavascript(script) {
5185
5222
  }
5186
5223
  catch (error) {
5187
5224
  assertsError(error);
5188
- throw new ParseError(spaceTrim$1((block) => `
5225
+ throw new ParseError(spaceTrim$2((block) => `
5189
5226
  Can not extract variables from the script
5190
5227
  ${block(error.stack || error.message)}
5191
5228
 
@@ -5368,7 +5405,7 @@ const CsvFormatParser = {
5368
5405
  const { value, outputParameterName, settings, mapCallback, onProgress } = options;
5369
5406
  const csv = csvParse(value, settings);
5370
5407
  if (csv.errors.length !== 0) {
5371
- throw new CsvFormatError(spaceTrim((block) => `
5408
+ throw new CsvFormatError(spaceTrim$1((block) => `
5372
5409
  CSV parsing error
5373
5410
 
5374
5411
  Error(s) from CSV parsing:
@@ -5413,7 +5450,7 @@ const CsvFormatParser = {
5413
5450
  const { value, settings, mapCallback, onProgress } = options;
5414
5451
  const csv = csvParse(value, settings);
5415
5452
  if (csv.errors.length !== 0) {
5416
- throw new CsvFormatError(spaceTrim((block) => `
5453
+ throw new CsvFormatError(spaceTrim$1((block) => `
5417
5454
  CSV parsing error
5418
5455
 
5419
5456
  Error(s) from CSV parsing:
@@ -5623,7 +5660,7 @@ function mapAvailableToExpectedParameters(options) {
5623
5660
  }
5624
5661
  // Phase 2️⃣: Non-matching mapping
5625
5662
  if (expectedParameterNames.size !== availableParametersNames.size) {
5626
- throw new PipelineExecutionError(spaceTrim((block) => `
5663
+ throw new PipelineExecutionError(spaceTrim$1((block) => `
5627
5664
  Can not map available parameters to expected parameters
5628
5665
 
5629
5666
  Mapped parameters:
@@ -5768,10 +5805,13 @@ const LINES_PER_STANDARD_PAGE = 44;
5768
5805
  * @public exported from `@promptbook/utils`
5769
5806
  */
5770
5807
  function countLines(text) {
5808
+ if (text === '') {
5809
+ return 0;
5810
+ }
5771
5811
  text = text.replace('\r\n', '\n');
5772
5812
  text = text.replace('\r', '\n');
5773
5813
  const lines = text.split('\n');
5774
- return lines.reduce((count, line) => count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 0);
5814
+ return lines.reduce((count, line) => count + Math.max(Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 1), 0);
5775
5815
  }
5776
5816
  /**
5777
5817
  * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
@@ -5896,6 +5936,8 @@ function checkExpectations(expectations, value) {
5896
5936
  * This function provides a common abstraction for result validation that can be used
5897
5937
  * by both execution logic and caching logic to ensure consistency.
5898
5938
  *
5939
+ * Note: [🔂] This function is idempotent.
5940
+ *
5899
5941
  * @param options - The validation options including result string, expectations, and format
5900
5942
  * @returns Validation result with processed string and validity status
5901
5943
  * @private internal function of `createPipelineExecutor` and `cacheLlmTools`
@@ -5915,7 +5957,7 @@ function validatePromptResult(options) {
5915
5957
  }
5916
5958
  catch (error) {
5917
5959
  keepUnused(error);
5918
- throw new ExpectError(spaceTrim$1((block) => `
5960
+ throw new ExpectError(spaceTrim$2((block) => `
5919
5961
  Expected valid JSON string
5920
5962
 
5921
5963
  The expected JSON text:
@@ -5964,7 +6006,7 @@ function validatePromptResult(options) {
5964
6006
  */
5965
6007
  async function executeAttempts(options) {
5966
6008
  const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
5967
- preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, } = options;
6009
+ preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall, } = options;
5968
6010
  const $ongoingTaskResult = {
5969
6011
  $result: null,
5970
6012
  $resultString: null,
@@ -5978,7 +6020,7 @@ async function executeAttempts(options) {
5978
6020
  const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
5979
6021
  // TODO: [🧠][🍭] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
5980
6022
  if (isJokerAttempt && !jokerParameterName) {
5981
- throw new UnexpectedError(spaceTrim$1((block) => `
6023
+ throw new UnexpectedError(spaceTrim$2((block) => `
5982
6024
  Joker not found in attempt ${attemptIndex}
5983
6025
 
5984
6026
  ${block(pipelineIdentification)}
@@ -5989,7 +6031,7 @@ async function executeAttempts(options) {
5989
6031
  $ongoingTaskResult.$expectError = null;
5990
6032
  if (isJokerAttempt) {
5991
6033
  if (parameters[jokerParameterName] === undefined) {
5992
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6034
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
5993
6035
  Joker parameter {${jokerParameterName}} not defined
5994
6036
 
5995
6037
  ${block(pipelineIdentification)}
@@ -6047,7 +6089,7 @@ async function executeAttempts(options) {
6047
6089
  $ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
6048
6090
  break variant;
6049
6091
  case 'EMBEDDING':
6050
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6092
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
6051
6093
  Embedding model can not be used in pipeline
6052
6094
 
6053
6095
  This should be catched during parsing
@@ -6058,7 +6100,7 @@ async function executeAttempts(options) {
6058
6100
  break variant;
6059
6101
  // <- case [🤖]:
6060
6102
  default:
6061
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6103
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
6062
6104
  Unknown model variant "${task.modelRequirements.modelVariant}"
6063
6105
 
6064
6106
  ${block(pipelineIdentification)}
@@ -6069,14 +6111,14 @@ async function executeAttempts(options) {
6069
6111
  break;
6070
6112
  case 'SCRIPT_TASK':
6071
6113
  if (arrayableToArray(tools.script).length === 0) {
6072
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6114
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
6073
6115
  No script execution tools are available
6074
6116
 
6075
6117
  ${block(pipelineIdentification)}
6076
6118
  `));
6077
6119
  }
6078
6120
  if (!task.contentLanguage) {
6079
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6121
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
6080
6122
  Script language is not defined for SCRIPT TASK "${task.name}"
6081
6123
 
6082
6124
  ${block(pipelineIdentification)}
@@ -6107,7 +6149,7 @@ async function executeAttempts(options) {
6107
6149
  throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
6108
6150
  }
6109
6151
  else {
6110
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6152
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
6111
6153
  Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
6112
6154
 
6113
6155
  ${block(pipelineIdentification)}
@@ -6121,7 +6163,7 @@ async function executeAttempts(options) {
6121
6163
  break taskType;
6122
6164
  case 'DIALOG_TASK':
6123
6165
  if (tools.userInterface === undefined) {
6124
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6166
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
6125
6167
  User interface tools are not available
6126
6168
 
6127
6169
  ${block(pipelineIdentification)}
@@ -6139,7 +6181,7 @@ async function executeAttempts(options) {
6139
6181
  break taskType;
6140
6182
  // <- case: [🅱]
6141
6183
  default:
6142
- throw new PipelineExecutionError(spaceTrim$1((block) => `
6184
+ throw new PipelineExecutionError(spaceTrim$2((block) => `
6143
6185
  Unknown execution type "${task.taskType}"
6144
6186
 
6145
6187
  ${block(pipelineIdentification)}
@@ -6212,14 +6254,10 @@ async function executeAttempts(options) {
6212
6254
  });
6213
6255
  }
6214
6256
  finally {
6215
- if (!isJokerAttempt &&
6216
- task.taskType === 'PROMPT_TASK' &&
6217
- $ongoingTaskResult.$prompt
6218
- // <- Note: [2] When some expected parameter is not defined, error will occur in templateParameters
6219
- // In that case we don’t want to make a report about it because it’s not a llm execution error
6220
- ) {
6221
- // TODO: [🧠] Maybe put other taskTypes into report
6222
- $executionReport.promptExecutions.push({
6257
+ if (!isJokerAttempt && task.taskType === 'PROMPT_TASK' && $ongoingTaskResult.$prompt) {
6258
+ // Note: [2] When some expected parameter is not defined, error will occur in templateParameters
6259
+ // In that case we don’t want to make a report about it because it’s not a llm execution error
6260
+ const executionPromptReport = {
6223
6261
  prompt: {
6224
6262
  ...$ongoingTaskResult.$prompt,
6225
6263
  // <- TODO: [🧠] How to pick everyhing except `pipelineUrl`
@@ -6228,13 +6266,20 @@ async function executeAttempts(options) {
6228
6266
  error: $ongoingTaskResult.$expectError === null
6229
6267
  ? undefined
6230
6268
  : serializeError($ongoingTaskResult.$expectError),
6231
- });
6269
+ };
6270
+ $executionReport.promptExecutions.push(executionPromptReport);
6271
+ if (logLlmCall) {
6272
+ logLlmCall({
6273
+ modelName: 'model' /* <- TODO: How to get model name from the report */,
6274
+ report: executionPromptReport,
6275
+ });
6276
+ }
6232
6277
  }
6233
6278
  }
6234
6279
  if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
6235
6280
  // Note: Create a summary of all failures
6236
6281
  const failuresSummary = $ongoingTaskResult.$failedResults
6237
- .map((failure) => spaceTrim$1((block) => {
6282
+ .map((failure) => spaceTrim$2((block) => {
6238
6283
  var _a, _b;
6239
6284
  return `
6240
6285
  Attempt ${failure.attemptIndex + 1}:
@@ -6244,14 +6289,14 @@ async function executeAttempts(options) {
6244
6289
  Result:
6245
6290
  ${block(failure.result === null
6246
6291
  ? 'null'
6247
- : spaceTrim$1(failure.result)
6292
+ : spaceTrim$2(failure.result)
6248
6293
  .split('\n')
6249
6294
  .map((line) => `> ${line}`)
6250
6295
  .join('\n'))}
6251
6296
  `;
6252
6297
  }))
6253
6298
  .join('\n\n---\n\n');
6254
- throw new PipelineExecutionError(spaceTrim$1((block) => {
6299
+ throw new PipelineExecutionError(spaceTrim$2((block) => {
6255
6300
  var _a;
6256
6301
  return `
6257
6302
  LLM execution failed ${maxExecutionAttempts}x
@@ -6271,7 +6316,7 @@ async function executeAttempts(options) {
6271
6316
  }
6272
6317
  }
6273
6318
  if ($ongoingTaskResult.$resultString === null) {
6274
- throw new UnexpectedError(spaceTrim$1((block) => `
6319
+ throw new UnexpectedError(spaceTrim$2((block) => `
6275
6320
  Something went wrong and prompt result is null
6276
6321
 
6277
6322
  ${block(pipelineIdentification)}
@@ -6293,12 +6338,12 @@ async function executeAttempts(options) {
6293
6338
  * @private internal utility of `createPipelineExecutor`
6294
6339
  */
6295
6340
  async function executeFormatSubvalues(options) {
6296
- const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, pipelineIdentification } = options;
6341
+ const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, logLlmCall, pipelineIdentification, } = options;
6297
6342
  if (task.foreach === undefined) {
6298
- return /* not await */ executeAttempts(options);
6343
+ return /* not await */ executeAttempts({ ...options, logLlmCall });
6299
6344
  }
6300
6345
  if (jokerParameterNames.length !== 0) {
6301
- throw new UnexpectedError(spaceTrim((block) => `
6346
+ throw new UnexpectedError(spaceTrim$1((block) => `
6302
6347
  JOKER parameters are not supported together with FOREACH command
6303
6348
 
6304
6349
  [🧞‍♀️] This should be prevented in \`validatePipeline\`
@@ -6311,7 +6356,7 @@ async function executeFormatSubvalues(options) {
6311
6356
  if (formatDefinition === undefined) {
6312
6357
  throw new UnexpectedError(
6313
6358
  // <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
6314
- spaceTrim((block) => `
6359
+ spaceTrim$1((block) => `
6315
6360
  Unsupported format "${task.foreach.formatName}"
6316
6361
 
6317
6362
  Available formats:
@@ -6328,7 +6373,7 @@ async function executeFormatSubvalues(options) {
6328
6373
  if (subvalueParser === undefined) {
6329
6374
  throw new UnexpectedError(
6330
6375
  // <- TODO: [🧠][🧐] Should be formats fixed per promptbook version or behave as plugins (=> change UnexpectedError)
6331
- spaceTrim((block) => `
6376
+ spaceTrim$1((block) => `
6332
6377
  Unsupported subformat name "${task.foreach.subformatName}" for format "${task.foreach.formatName}"
6333
6378
 
6334
6379
  Available subformat names for format "${formatDefinition.formatName}":
@@ -6368,7 +6413,7 @@ async function executeFormatSubvalues(options) {
6368
6413
  if (!(error instanceof PipelineExecutionError)) {
6369
6414
  throw error;
6370
6415
  }
6371
- const highLevelError = new PipelineExecutionError(spaceTrim((block) => `
6416
+ const highLevelError = new PipelineExecutionError(spaceTrim$1((block) => `
6372
6417
  ${error.message}
6373
6418
 
6374
6419
  This is error in FOREACH command when mapping ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
@@ -6392,7 +6437,7 @@ async function executeFormatSubvalues(options) {
6392
6437
  ...options,
6393
6438
  priority: priority + index,
6394
6439
  parameters: allSubparameters,
6395
- pipelineIdentification: spaceTrim((block) => `
6440
+ pipelineIdentification: spaceTrim$1((block) => `
6396
6441
  ${block(pipelineIdentification)}
6397
6442
  Subparameter index: ${index}
6398
6443
  `),
@@ -6401,7 +6446,7 @@ async function executeFormatSubvalues(options) {
6401
6446
  }
6402
6447
  catch (error) {
6403
6448
  if (length > BIG_DATASET_TRESHOLD) {
6404
- console.error(spaceTrim((block) => `
6449
+ console.error(spaceTrim$1((block) => `
6405
6450
  ${error.message}
6406
6451
 
6407
6452
  This is error in FOREACH command when processing ${formatDefinition.formatName} ${subvalueParser.subvalueName} data (${index + 1}/${length})
@@ -6501,7 +6546,7 @@ async function getKnowledgeForTask(options) {
6501
6546
  },
6502
6547
  content: task.content,
6503
6548
  parameters,
6504
- };
6549
+ }; /* <- Note: [🤛] */
6505
6550
  const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
6506
6551
  const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
6507
6552
  const { index } = knowledgePiece;
@@ -6577,7 +6622,7 @@ async function getReservedParametersForTask(options) {
6577
6622
  // Note: Doublecheck that ALL reserved parameters are defined:
6578
6623
  for (const parameterName of RESERVED_PARAMETER_NAMES) {
6579
6624
  if (reservedParameters[parameterName] === undefined) {
6580
- throw new UnexpectedError(spaceTrim$1((block) => `
6625
+ throw new UnexpectedError(spaceTrim$2((block) => `
6581
6626
  Reserved parameter {${parameterName}} is not defined
6582
6627
 
6583
6628
  ${block(pipelineIdentification)}
@@ -6596,14 +6641,14 @@ async function getReservedParametersForTask(options) {
6596
6641
  * @private internal utility of `createPipelineExecutor`
6597
6642
  */
6598
6643
  async function executeTask(options) {
6599
- const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSuppressed, } = options;
6644
+ const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, logLlmCall, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSuppressed, } = options;
6600
6645
  const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
6601
6646
  // Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but it’s good to doublecheck
6602
6647
  const usedParameterNames = extractParameterNamesFromTask(currentTask);
6603
6648
  const dependentParameterNames = new Set(currentTask.dependentParameterNames);
6604
6649
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
6605
6650
  if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
6606
- throw new UnexpectedError(spaceTrim$1((block) => `
6651
+ throw new UnexpectedError(spaceTrim$2((block) => `
6607
6652
  Dependent parameters are not consistent with used parameters:
6608
6653
 
6609
6654
  Dependent parameters:
@@ -6647,7 +6692,7 @@ async function executeTask(options) {
6647
6692
  else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
6648
6693
  // Houston, we have a problem
6649
6694
  // Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
6650
- throw new UnexpectedError(spaceTrim$1((block) => `
6695
+ throw new UnexpectedError(spaceTrim$2((block) => `
6651
6696
  Parameter \`{${parameterName}}\` is NOT defined
6652
6697
  BUT used in task "${currentTask.title || currentTask.name}"
6653
6698
 
@@ -6675,6 +6720,7 @@ async function executeTask(options) {
6675
6720
  tools,
6676
6721
  $executionReport,
6677
6722
  onProgress,
6723
+ logLlmCall,
6678
6724
  pipelineIdentification,
6679
6725
  maxExecutionAttempts,
6680
6726
  maxParallelCount,
@@ -6715,9 +6761,32 @@ function filterJustOutputParameters(options) {
6715
6761
  for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
6716
6762
  if (parametersToPass[parameter.name] === undefined) {
6717
6763
  // [4]
6718
- $warnings.push(new PipelineExecutionError(spaceTrim$1((block) => `
6764
+ $warnings.push(new PipelineExecutionError(spaceTrim$2((block) => `
6719
6765
  Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
6720
6766
 
6767
+ Note: This is a warning which happened after the pipeline was executed, and \`{${parameter.name}}\` was not for some reason defined in output parameters
6768
+
6769
+ All parameters:
6770
+ ${block(preparedPipeline.parameters
6771
+ .map(({ name, isInput, isOutput, description }) => {
6772
+ let line = `\`{${name}}\``;
6773
+ if (isInput) {
6774
+ line += ' `[input parameter]`';
6775
+ }
6776
+ if (isOutput) {
6777
+ line += ' `[output parameter]`';
6778
+ }
6779
+ if (parametersToPass[name] === undefined) {
6780
+ line += ` <- Warning: Should be in the output but its not |`;
6781
+ }
6782
+ if (description) {
6783
+ line += ` ${description}`;
6784
+ }
6785
+ return line;
6786
+ })
6787
+ .map((line, index) => `${index + 1}) ${line}`)
6788
+ .join('\n'))}
6789
+
6721
6790
  ${block(pipelineIdentification)}
6722
6791
  `)));
6723
6792
  continue;
@@ -6738,7 +6807,7 @@ function filterJustOutputParameters(options) {
6738
6807
  * @private internal utility of `createPipelineExecutor`
6739
6808
  */
6740
6809
  async function executePipeline(options) {
6741
- const { inputParameters, tools, onProgress, pipeline, setPreparedPipeline, pipelineIdentification, maxParallelCount, rootDirname, isVerbose, } = options;
6810
+ const { inputParameters, tools, onProgress, logLlmCall, pipeline, setPreparedPipeline, pipelineIdentification, maxParallelCount, rootDirname, isVerbose, } = options;
6742
6811
  let { preparedPipeline } = options;
6743
6812
  if (preparedPipeline === undefined) {
6744
6813
  preparedPipeline = await preparePipeline(pipeline, tools, {
@@ -6800,7 +6869,7 @@ async function executePipeline(options) {
6800
6869
  for (const parameterName of Object.keys(inputParameters)) {
6801
6870
  const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
6802
6871
  if (parameter === undefined) {
6803
- warnings.push(new PipelineExecutionError(spaceTrim$1((block) => `
6872
+ warnings.push(new PipelineExecutionError(spaceTrim$2((block) => `
6804
6873
  Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
6805
6874
 
6806
6875
  ${block(pipelineIdentification)}
@@ -6815,7 +6884,7 @@ async function executePipeline(options) {
6815
6884
  // TODO: [🧠] This should be also non-critical error
6816
6885
  return exportJson({
6817
6886
  name: 'pipelineExecutorResult',
6818
- message: spaceTrim$1((block) => `
6887
+ message: spaceTrim$2((block) => `
6819
6888
  Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
6820
6889
 
6821
6890
  ${block(pipelineIdentification)}
@@ -6824,7 +6893,7 @@ async function executePipeline(options) {
6824
6893
  value: {
6825
6894
  isSuccessful: false,
6826
6895
  errors: [
6827
- new PipelineExecutionError(spaceTrim$1((block) => `
6896
+ new PipelineExecutionError(spaceTrim$2((block) => `
6828
6897
  Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
6829
6898
 
6830
6899
  ${block(pipelineIdentification)}
@@ -6851,7 +6920,7 @@ async function executePipeline(options) {
6851
6920
  while (unresovedTasks.length > 0) {
6852
6921
  if (loopLimit-- < 0) {
6853
6922
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
6854
- throw new UnexpectedError(spaceTrim$1((block) => `
6923
+ throw new UnexpectedError(spaceTrim$2((block) => `
6855
6924
  Loop limit reached during resolving parameters pipeline execution
6856
6925
 
6857
6926
  ${block(pipelineIdentification)}
@@ -6861,7 +6930,7 @@ async function executePipeline(options) {
6861
6930
  if (!currentTask && resolving.length === 0) {
6862
6931
  throw new UnexpectedError(
6863
6932
  // TODO: [🐎] DRY
6864
- spaceTrim$1((block) => `
6933
+ spaceTrim$2((block) => `
6865
6934
  Can not resolve some parameters:
6866
6935
 
6867
6936
  ${block(pipelineIdentification)}
@@ -6901,7 +6970,7 @@ async function executePipeline(options) {
6901
6970
  tools,
6902
6971
  onProgress(newOngoingResult) {
6903
6972
  if (isReturned) {
6904
- throw new UnexpectedError(spaceTrim$1((block) => `
6973
+ throw new UnexpectedError(spaceTrim$2((block) => `
6905
6974
  Can not call \`onProgress\` after pipeline execution is finished
6906
6975
 
6907
6976
  ${block(pipelineIdentification)}
@@ -6916,8 +6985,9 @@ async function executePipeline(options) {
6916
6985
  onProgress(newOngoingResult);
6917
6986
  }
6918
6987
  },
6988
+ logLlmCall,
6919
6989
  $executionReport: executionReport,
6920
- pipelineIdentification: spaceTrim$1((block) => `
6990
+ pipelineIdentification: spaceTrim$2((block) => `
6921
6991
  ${block(pipelineIdentification)}
6922
6992
  Task name: ${currentTask.name}
6923
6993
  Task title: ${currentTask.title}
@@ -7026,7 +7096,7 @@ function createPipelineExecutor(options) {
7026
7096
  preparedPipeline = pipeline;
7027
7097
  }
7028
7098
  else if (isNotPreparedWarningSuppressed !== true) {
7029
- console.warn(spaceTrim$1((block) => `
7099
+ console.warn(spaceTrim$2((block) => `
7030
7100
  Pipeline is not prepared
7031
7101
 
7032
7102
  ${block(pipelineIdentification)}
@@ -7039,7 +7109,7 @@ function createPipelineExecutor(options) {
7039
7109
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
7040
7110
  }
7041
7111
  let runCount = 0;
7042
- const pipelineExecutorWithCallback = async (inputParameters, onProgress) => {
7112
+ const pipelineExecutorWithCallback = async (inputParameters, onProgress, logLlmCall) => {
7043
7113
  runCount++;
7044
7114
  return /* not await */ executePipeline({
7045
7115
  pipeline,
@@ -7050,7 +7120,8 @@ function createPipelineExecutor(options) {
7050
7120
  inputParameters,
7051
7121
  tools,
7052
7122
  onProgress,
7053
- pipelineIdentification: spaceTrim$1((block) => `
7123
+ logLlmCall,
7124
+ pipelineIdentification: spaceTrim$2((block) => `
7054
7125
  ${block(pipelineIdentification)}
7055
7126
  ${runCount === 1 ? '' : `Run #${runCount}`}
7056
7127
  `),
@@ -7211,7 +7282,7 @@ class MarkdownScraper {
7211
7282
  }
7212
7283
  const llmTools = getSingleLlmExecutionTools(llm);
7213
7284
  // TODO: [🌼] In future use `ptbk make` and made getPipelineCollection
7214
- const collection = createCollectionFromJson(...PipelineCollection);
7285
+ const collection = createPipelineCollectionFromJson(...PipelineCollection);
7215
7286
  const prepareKnowledgeFromMarkdownExecutor = createPipelineExecutor({
7216
7287
  pipeline: await collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book'),
7217
7288
  tools: {
@@ -7247,8 +7318,8 @@ class MarkdownScraper {
7247
7318
  knowledgeTextPieces.map(async (knowledgeTextPiece, i) => {
7248
7319
  // Note: These are just default values, they will be overwritten by the actual values:
7249
7320
  let name = `piece-${i}`;
7250
- let title = spaceTrim(knowledgeTextPiece.substring(0, 100));
7251
- const knowledgePieceContent = spaceTrim(knowledgeTextPiece);
7321
+ let title = spaceTrim$1(knowledgeTextPiece.substring(0, 100));
7322
+ const knowledgePieceContent = spaceTrim$1(knowledgeTextPiece);
7252
7323
  let keywords = [];
7253
7324
  const index = [];
7254
7325
  /*
@@ -7261,7 +7332,7 @@ class MarkdownScraper {
7261
7332
  isCrashedOnError: true,
7262
7333
  });
7263
7334
  const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
7264
- title = spaceTrim(titleRaw) /* <- TODO: Maybe do in pipeline */;
7335
+ title = spaceTrim$1(titleRaw) /* <- TODO: Maybe do in pipeline */;
7265
7336
  name = titleToName(title);
7266
7337
  // --- Keywords
7267
7338
  const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
@@ -7358,7 +7429,7 @@ const _MarkdownScraperRegistration = $scrapersRegister.register(createMarkdownSc
7358
7429
  * @public exported from `@promptbook/markdown-utils`
7359
7430
  */
7360
7431
  function removeMarkdownComments(content) {
7361
- return spaceTrim$1(content.replace(/<!--(.*?)-->/gs, ''));
7432
+ return spaceTrim$2(content.replace(/<!--(.*?)-->/gs, ''));
7362
7433
  }
7363
7434
 
7364
7435
  /**
@@ -7371,7 +7442,7 @@ function addAutoGeneratedSection(content, options) {
7371
7442
  const warningLine = `<!-- ${GENERATOR_WARNING} -->`;
7372
7443
  const sectionRegex = new RegExp(`<!--${sectionName}-->([\\s\\S]*?)<!--/${sectionName}-->`, 'g');
7373
7444
  const sectionMatch = content.match(sectionRegex);
7374
- const contentToInsert = spaceTrim$1((block) => `
7445
+ const contentToInsert = spaceTrim$2((block) => `
7375
7446
  <!--${sectionName}-->
7376
7447
  ${block(warningLine)}
7377
7448
  ${block(sectionContent)}
@@ -7384,7 +7455,7 @@ function addAutoGeneratedSection(content, options) {
7384
7455
  const placeForSection = removeMarkdownComments(content).match(/^##.*$/im);
7385
7456
  if (placeForSection !== null) {
7386
7457
  const [heading] = placeForSection;
7387
- return content.replace(heading, spaceTrim$1((block) => `
7458
+ return content.replace(heading, spaceTrim$2((block) => `
7388
7459
  ${block(contentToInsert)}
7389
7460
 
7390
7461
  ${block(heading)}
@@ -7393,7 +7464,7 @@ function addAutoGeneratedSection(content, options) {
7393
7464
  console.warn(`No place where to put the section <!--${sectionName}-->, using the end of the file`);
7394
7465
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
7395
7466
  // <- TODO: [🏮] Some better way how to get warnings from pipeline parsing / logic
7396
- return spaceTrim$1((block) => `
7467
+ return spaceTrim$2((block) => `
7397
7468
  ${block(content)}
7398
7469
 
7399
7470
  ${block(contentToInsert)}
@@ -7514,7 +7585,7 @@ function parseMarkdownSection(value) {
7514
7585
  }
7515
7586
  const title = lines[0].replace(/^#+\s*/, '');
7516
7587
  const level = (_b = (_a = lines[0].match(/^#+/)) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
7517
- const content = spaceTrim(lines.slice(1).join('\n'));
7588
+ const content = spaceTrim$1(lines.slice(1).join('\n'));
7518
7589
  if (level < 1 || level > 6) {
7519
7590
  throw new ParseError('Markdown section must have heading level between 1 and 6');
7520
7591
  }
@@ -7542,7 +7613,7 @@ function splitMarkdownIntoSections(markdown) {
7542
7613
  if (buffer.length === 0) {
7543
7614
  return;
7544
7615
  }
7545
- let section = spaceTrim(buffer.join('\n'));
7616
+ let section = spaceTrim$1(buffer.join('\n'));
7546
7617
  if (section === '') {
7547
7618
  return;
7548
7619
  }
@@ -7617,7 +7688,7 @@ function flattenMarkdown(markdown) {
7617
7688
  flattenedMarkdown += `## ${title}` + `\n\n`;
7618
7689
  flattenedMarkdown += content + `\n\n`; // <- [🧠] Maybe 3 new lines?
7619
7690
  }
7620
- return spaceTrim(flattenedMarkdown);
7691
+ return spaceTrim$1(flattenedMarkdown);
7621
7692
  }
7622
7693
  /**
7623
7694
  * TODO: [🏛] This can be part of markdown builder
@@ -7808,13 +7879,13 @@ function removeMarkdownLinks(str) {
7808
7879
  * @public exported from `@promptbook/markdown-utils`
7809
7880
  */
7810
7881
  function trimCodeBlock(value) {
7811
- value = spaceTrim$1(value);
7882
+ value = spaceTrim$2(value);
7812
7883
  if (!/^```[a-z]*(.*)```$/is.test(value)) {
7813
7884
  return value;
7814
7885
  }
7815
7886
  value = value.replace(/^```[a-z]*/i, '');
7816
7887
  value = value.replace(/```$/i, '');
7817
- value = spaceTrim$1(value);
7888
+ value = spaceTrim$2(value);
7818
7889
  return value;
7819
7890
  }
7820
7891
 
@@ -7827,9 +7898,9 @@ function trimCodeBlock(value) {
7827
7898
  * @public exported from `@promptbook/markdown-utils`
7828
7899
  */
7829
7900
  function trimEndOfCodeBlock(value) {
7830
- value = spaceTrim$1(value);
7901
+ value = spaceTrim$2(value);
7831
7902
  value = value.replace(/```$/g, '');
7832
- value = spaceTrim$1(value);
7903
+ value = spaceTrim$2(value);
7833
7904
  return value;
7834
7905
  }
7835
7906