@promptbook/ollama 0.103.0-8 → 0.103.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -39
- package/esm/index.es.js +324 -142
- package/esm/index.es.js.map +1 -1
- package/esm/typings/books/index.d.ts +0 -81
- package/esm/typings/servers.d.ts +9 -7
- package/esm/typings/src/_packages/browser.index.d.ts +6 -0
- package/esm/typings/src/_packages/cli.index.d.ts +4 -0
- package/esm/typings/src/_packages/components.index.d.ts +22 -8
- package/esm/typings/src/_packages/core.index.d.ts +58 -18
- package/esm/typings/src/_packages/node.index.d.ts +2 -2
- package/esm/typings/src/_packages/remote-server.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +70 -8
- package/esm/typings/src/_packages/utils.index.d.ts +6 -0
- package/esm/typings/src/_packages/wizard.index.d.ts +4 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +20 -5
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +17 -1
- package/esm/typings/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +3 -2
- package/esm/typings/src/book-2.0/agent-source/computeAgentHash.d.ts +8 -0
- package/esm/typings/src/book-2.0/agent-source/createCommitmentRegex.d.ts +3 -3
- package/esm/typings/src/book-2.0/agent-source/createDefaultAgentName.d.ts +8 -0
- package/esm/typings/src/book-2.0/agent-source/normalizeAgentName.d.ts +9 -0
- package/esm/typings/src/book-2.0/agent-source/padBook.d.ts +18 -0
- package/esm/typings/src/book-2.0/agent-source/parseAgentSourceWithCommitments.d.ts +1 -1
- package/esm/typings/src/book-2.0/agent-source/string_book.d.ts +3 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +6 -1
- package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +85 -14
- package/esm/typings/src/book-components/BookEditor/BookEditorActionbar.d.ts +18 -0
- package/esm/typings/src/book-components/BookEditor/BookEditorMonaco.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.d.ts +17 -0
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChatProps.d.ts +13 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +16 -0
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +15 -0
- package/esm/typings/src/book-components/Chat/MockedChat/MockedChat.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/save/_common/ChatSaveFormatDefinition.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/save/html/htmlSaveFormatDefinition.d.ts +1 -0
- package/esm/typings/src/book-components/Chat/save/pdf/pdfSaveFormatDefinition.d.ts +4 -0
- package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +1 -1
- package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgentIntegration.d.ts +52 -0
- package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgentSeamlessIntegration.d.ts +14 -0
- package/esm/typings/src/book-components/Qr/BrandedQrCode.d.ts +18 -0
- package/esm/typings/src/book-components/Qr/GenericQrCode.d.ts +10 -0
- package/esm/typings/src/book-components/Qr/PromptbookQrCode.d.ts +18 -0
- package/esm/typings/src/book-components/Qr/useQrCode.d.ts +15 -0
- package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +15 -0
- package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +12 -0
- package/esm/typings/src/book-components/_common/Modal/Modal.d.ts +2 -2
- package/esm/typings/src/book-components/_common/Tooltip/Tooltip.d.ts +47 -0
- package/esm/typings/src/book-components/icons/AboutIcon.d.ts +9 -0
- package/esm/typings/src/book-components/icons/CameraIcon.d.ts +11 -0
- package/esm/typings/src/book-components/icons/CloseIcon.d.ts +4 -8
- package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +9 -0
- package/esm/typings/src/book-components/icons/ExitFullscreenIcon.d.ts +7 -0
- package/esm/typings/src/book-components/icons/FullscreenIcon.d.ts +7 -0
- package/esm/typings/src/book-components/icons/MenuIcon.d.ts +12 -0
- package/esm/typings/src/book-components/icons/MicIcon.d.ts +8 -0
- package/esm/typings/src/book-components/icons/SendIcon.d.ts +3 -0
- package/esm/typings/src/cli/cli-commands/_boilerplate.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/about.d.ts +3 -1
- package/esm/typings/src/cli/cli-commands/hello.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/list-models.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/login.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/make.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/prettify.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/run.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/{start-server.d.ts → start-agents-server.d.ts} +3 -2
- package/esm/typings/src/cli/cli-commands/start-pipelines-server.d.ts +15 -0
- package/esm/typings/src/cli/cli-commands/test-command.d.ts +2 -1
- package/esm/typings/src/cli/common/$addGlobalOptionsToCommand.d.ts +2 -1
- package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +12 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +75 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabaseOptions.d.ts +10 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +154 -0
- package/esm/typings/src/collection/{PipelineCollection.d.ts → pipeline-collection/PipelineCollection.d.ts} +7 -3
- package/esm/typings/src/collection/{SimplePipelineCollection.d.ts → pipeline-collection/SimplePipelineCollection.d.ts} +5 -5
- package/esm/typings/src/collection/{constructors/createCollectionFromDirectory.d.ts → pipeline-collection/constructors/createPipelineCollectionFromDirectory.d.ts} +8 -11
- package/esm/typings/src/collection/pipeline-collection/constructors/createPipelineCollectionFromJson.d.ts +13 -0
- package/esm/typings/src/collection/{constructors/createCollectionFromPromise.d.ts → pipeline-collection/constructors/createPipelineCollectionFromPromise.d.ts} +6 -5
- package/esm/typings/src/collection/pipeline-collection/constructors/createPipelineCollectionFromPromise.test.d.ts +1 -0
- package/esm/typings/src/collection/{constructors/createCollectionFromUrl.d.ts → pipeline-collection/constructors/createPipelineCollectionFromUrl.d.ts} +3 -3
- package/esm/typings/src/collection/{constructors/createSubcollection.d.ts → pipeline-collection/constructors/createPipelineSubcollection.d.ts} +3 -3
- package/esm/typings/src/collection/pipeline-collection/pipelineCollectionToJson.d.ts +13 -0
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +4 -5
- package/esm/typings/src/{book-2.0/commitments → commitments}/ACTION/ACTION.d.ts +5 -1
- package/esm/typings/src/commitments/CLOSED/CLOSED.d.ts +39 -0
- package/esm/typings/src/commitments/CLOSED/CLOSED.test.d.ts +4 -0
- package/esm/typings/src/commitments/COMPONENT/COMPONENT.d.ts +28 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/DELETE/DELETE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/FORMAT/FORMAT.d.ts +5 -1
- package/esm/typings/src/commitments/FROM/FROM.d.ts +34 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/GOAL/GOAL.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/KNOWLEDGE/KNOWLEDGE.d.ts +5 -5
- package/esm/typings/src/commitments/LANGUAGE/LANGUAGE.d.ts +35 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/MEMORY/MEMORY.d.ts +5 -1
- package/esm/typings/src/commitments/MESSAGE/AgentMessageCommitmentDefinition.d.ts +32 -0
- package/esm/typings/src/commitments/MESSAGE/InitialMessageCommitmentDefinition.d.ts +32 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/MESSAGE/MESSAGE.d.ts +5 -1
- package/esm/typings/src/commitments/MESSAGE/UserMessageCommitmentDefinition.d.ts +32 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/META/META.d.ts +5 -1
- package/esm/typings/src/commitments/META_COLOR/META_COLOR.d.ts +48 -0
- package/esm/typings/src/commitments/META_FONT/META_FONT.d.ts +42 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/META_IMAGE/META_IMAGE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/META_LINK/META_LINK.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/MODEL/MODEL.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/NOTE/NOTE.d.ts +5 -1
- package/esm/typings/src/commitments/OPEN/OPEN.d.ts +35 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/PERSONA/PERSONA.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/RULE/RULE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/SAMPLE/SAMPLE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/SCENARIO/SCENARIO.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/STYLE/STYLE.d.ts +5 -1
- package/esm/typings/src/commitments/USE/USE.d.ts +53 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +42 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.test.d.ts +1 -0
- package/esm/typings/src/commitments/USE_MCP/USE_MCP.d.ts +37 -0
- package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +38 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BaseCommitmentDefinition.d.ts +14 -2
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/CommitmentDefinition.d.ts +6 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/NotYetImplementedCommitmentDefinition.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/createEmptyAgentModelRequirements.d.ts +1 -1
- package/esm/typings/src/commitments/index.d.ts +93 -0
- package/esm/typings/src/config.d.ts +24 -3
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +2 -0
- package/esm/typings/src/errors/0-index.d.ts +6 -0
- package/esm/typings/src/errors/DatabaseError.d.ts +12 -0
- package/esm/typings/src/errors/NotAllowed.d.ts +9 -0
- package/esm/typings/src/errors/WrappedError.d.ts +2 -2
- package/esm/typings/src/execution/AvailableModel.d.ts +1 -0
- package/esm/typings/src/execution/Executables.d.ts +3 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +12 -3
- package/esm/typings/src/execution/ExecutionTools.d.ts +5 -0
- package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +26 -2
- package/esm/typings/src/execution/PromptResult.d.ts +7 -1
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +5 -0
- package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +5 -0
- package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +5 -0
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +5 -0
- package/esm/typings/src/execution/utils/usage-constants.d.ts +4 -124
- package/esm/typings/src/execution/utils/validatePromptResult.d.ts +2 -0
- package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +2 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +2 -2
- package/esm/typings/src/llm-providers/_common/register/$registeredLlmToolsMessage.d.ts +2 -1
- package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/assertUniqueModels.d.ts +12 -0
- package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +72 -0
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +26 -4
- package/esm/typings/src/llm-providers/agent/AgentOptions.d.ts +19 -0
- package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +17 -0
- package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +50 -0
- package/esm/typings/src/llm-providers/agent/RemoteAgentOptions.d.ts +11 -0
- package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.d.ts +1 -19
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/ollama/OllamaExecutionTools.d.ts +4 -0
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +60 -2
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +7 -1
- package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +13 -1
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +4 -0
- package/esm/typings/src/llm-providers/openai/createOpenAiCompatibleExecutionTools.d.ts +6 -6
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/openai-models.test.d.ts +4 -0
- package/esm/typings/src/other/templates/getTemplatesPipelineCollection.d.ts +1 -1
- package/esm/typings/src/pipeline/validatePipelineString.d.ts +2 -0
- package/esm/typings/src/playground/permanent/_boilerplate.d.ts +5 -0
- package/esm/typings/src/playground/permanent/agent-with-browser-playground.d.ts +5 -0
- package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +1 -0
- package/esm/typings/src/remote-server/startAgentServer.d.ts +26 -0
- package/esm/typings/src/remote-server/startRemoteServer.d.ts +4 -1
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +3 -8
- package/esm/typings/src/scrapers/_boilerplate/createBoilerplateScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/_boilerplate/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/markitdown/createMarkitdownScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/markitdown/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -9
- package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +1 -0
- package/esm/typings/src/storage/env-storage/$EnvStorage.d.ts +2 -1
- package/esm/typings/src/transpilers/_common/BookTranspiler.d.ts +33 -0
- package/esm/typings/src/transpilers/_common/BookTranspilerOptions.d.ts +18 -0
- package/esm/typings/src/transpilers/_common/register/$bookTranspilersRegister.d.ts +15 -0
- package/esm/typings/src/transpilers/formatted-book-in-markdown/FormattedBookInMarkdownTranspiler.d.ts +16 -0
- package/esm/typings/src/transpilers/formatted-book-in-markdown/register.d.ts +15 -0
- package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.d.ts +16 -0
- package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.test.d.ts +1 -0
- package/esm/typings/src/transpilers/openai-sdk/playground/playground.d.ts +5 -0
- package/esm/typings/src/transpilers/openai-sdk/register.d.ts +15 -0
- package/esm/typings/src/types/LlmCall.d.ts +20 -0
- package/esm/typings/src/types/ModelRequirements.d.ts +13 -1
- package/esm/typings/src/types/ModelVariant.d.ts +1 -1
- package/esm/typings/src/types/Prompt.d.ts +13 -1
- package/esm/typings/src/types/Updatable.d.ts +19 -0
- package/esm/typings/src/types/typeAliases.d.ts +38 -2
- package/esm/typings/src/utils/color/$randomColor.d.ts +1 -0
- package/esm/typings/src/utils/color/Color.d.ts +16 -1
- package/esm/typings/src/utils/color/Color.test.d.ts +1 -0
- package/esm/typings/src/utils/color/css-colors.d.ts +1 -0
- package/esm/typings/src/utils/color/internal-utils/checkChannelValue.d.ts +0 -3
- package/esm/typings/src/utils/color/operators/darken.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/grayscale.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/lighten.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/mixWithColor.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/saturate.d.ts +1 -1
- package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +16 -0
- package/esm/typings/src/utils/environment/$getGlobalScope.d.ts +2 -2
- package/esm/typings/src/utils/execCommand/$execCommand.d.ts +2 -1
- package/esm/typings/src/utils/execCommand/$execCommands.d.ts +2 -1
- package/esm/typings/src/utils/files/$induceBookDownload.d.ts +13 -0
- package/esm/typings/src/utils/files/$induceFileDownload.d.ts +13 -0
- package/esm/typings/src/utils/files/ObjectUrl.d.ts +46 -0
- package/esm/typings/src/utils/files/listAllFiles.d.ts +2 -3
- package/esm/typings/src/utils/misc/aboutPromptbookInformation.d.ts +27 -0
- package/esm/typings/src/utils/misc/computeHash.d.ts +11 -0
- package/esm/typings/src/utils/misc/computeHash.test.d.ts +1 -0
- package/esm/typings/src/utils/misc/injectCssModuleIntoShadowRoot.d.ts +1 -0
- package/esm/typings/src/utils/misc/xAboutPromptbookInformation.d.ts +13 -0
- package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +2 -0
- package/esm/typings/src/utils/normalization/normalizeMessageText.d.ts +9 -0
- package/esm/typings/src/utils/normalization/normalizeMessageText.test.d.ts +1 -0
- package/esm/typings/src/utils/normalization/normalizeTo_PascalCase.d.ts +3 -0
- package/esm/typings/src/utils/normalization/normalizeTo_camelCase.d.ts +2 -0
- package/esm/typings/src/utils/normalization/titleToName.d.ts +2 -0
- package/esm/typings/src/utils/organization/$sideEffect.d.ts +2 -2
- package/esm/typings/src/utils/organization/$side_effect.d.ts +7 -0
- package/esm/typings/src/utils/organization/TODO_USE.d.ts +2 -2
- package/esm/typings/src/utils/organization/keepUnused.d.ts +2 -2
- package/esm/typings/src/utils/organization/preserve.d.ts +3 -3
- package/esm/typings/src/utils/organization/really_any.d.ts +7 -0
- package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +31 -0
- package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +9 -0
- package/esm/typings/src/utils/random/$randomFullnameWithColor.d.ts +13 -0
- package/esm/typings/src/utils/random/$randomItem.d.ts +9 -0
- package/esm/typings/src/utils/random/$randomSeed.d.ts +3 -0
- package/esm/typings/src/utils/random/$randomToken.d.ts +2 -0
- package/esm/typings/src/utils/random/CzechNamePool.d.ts +7 -0
- package/esm/typings/src/utils/random/EnglishNamePool.d.ts +7 -0
- package/esm/typings/src/utils/random/NamePool.d.ts +17 -0
- package/esm/typings/src/utils/random/getNamePool.d.ts +10 -0
- package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +2 -1
- package/esm/typings/src/utils/serialization/asSerializable.d.ts +2 -2
- package/esm/typings/src/utils/serialization/serializeToPromptbookJavascript.d.ts +2 -2
- package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +2 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/esm/typings/src/wizard/$getCompiledBook.d.ts +1 -2
- package/package.json +6 -6
- package/umd/index.umd.js +323 -141
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/book-2.0/commitments/index.d.ts +0 -60
- package/esm/typings/src/book-components/BookEditor/BookEditorInner.d.ts +0 -5
- package/esm/typings/src/book-components/BookEditor/BookEditorWrapper.d.ts +0 -9
- package/esm/typings/src/book-components/BookEditor/config.d.ts +0 -10
- package/esm/typings/src/book-components/Chat/utils/renderMarkdown.d.ts +0 -21
- package/esm/typings/src/collection/collectionToJson.d.ts +0 -13
- package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +0 -13
- /package/esm/typings/src/{book-components/Chat/utils/renderMarkdown.test.d.ts → book-2.0/agent-source/computeAgentHash.test.d.ts} +0 -0
- /package/esm/typings/src/{collection/constructors/createCollectionFromDirectory.test.d.ts → book-2.0/agent-source/normalizeAgentName.test.d.ts} +0 -0
- /package/esm/typings/src/{collection/constructors/createCollectionFromJson.test.d.ts → book-components/Chat/AgentChat/AgentChat.test.d.ts} +0 -0
- /package/esm/typings/src/collection/{constructors/createCollectionFromPromise.test.d.ts → pipeline-collection/constructors/createPipelineCollectionFromDirectory.test.d.ts} +0 -0
- /package/esm/typings/src/{commands/_common/parseCommand.test.d.ts → collection/pipeline-collection/constructors/createPipelineCollectionFromJson.test.d.ts} +0 -0
- /package/esm/typings/src/collection/{collectionToJson.test.d.ts → pipeline-collection/pipelineCollectionToJson.test.d.ts} +0 -0
- /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BookCommitment.d.ts +0 -0
- /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/ParsedCommitment.d.ts +0 -0
package/esm/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
1
|
+
import spaceTrim$2, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
2
2
|
import { randomBytes } from 'crypto';
|
|
3
3
|
import Bottleneck from 'bottleneck';
|
|
4
4
|
import colors from 'colors';
|
|
@@ -11,14 +11,14 @@ import OpenAI from 'openai';
|
|
|
11
11
|
* @generated
|
|
12
12
|
* @see https://github.com/webgptorg/book
|
|
13
13
|
*/
|
|
14
|
-
const BOOK_LANGUAGE_VERSION = '
|
|
14
|
+
const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
15
15
|
/**
|
|
16
16
|
* The version of the Promptbook engine
|
|
17
17
|
*
|
|
18
18
|
* @generated
|
|
19
19
|
* @see https://github.com/webgptorg/promptbook
|
|
20
20
|
*/
|
|
21
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0
|
|
21
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0';
|
|
22
22
|
/**
|
|
23
23
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
24
24
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -174,6 +174,17 @@ function orderJson(options) {
|
|
|
174
174
|
return orderedValue;
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
+
/**
|
|
178
|
+
* Trims string from all 4 sides
|
|
179
|
+
*
|
|
180
|
+
* Note: This is a re-exported function from the `spacetrim` package which is
|
|
181
|
+
* Developed by same author @hejny as this package
|
|
182
|
+
*
|
|
183
|
+
* @public exported from `@promptbook/utils`
|
|
184
|
+
* @see https://github.com/hejny/spacetrim#usage
|
|
185
|
+
*/
|
|
186
|
+
const spaceTrim = spaceTrim$1;
|
|
187
|
+
|
|
177
188
|
/**
|
|
178
189
|
* @private util of `@promptbook/color`
|
|
179
190
|
* @de
|
|
@@ -222,6 +233,7 @@ function take(initialValue) {
|
|
|
222
233
|
* @public exported from `@promptbook/color`
|
|
223
234
|
*/
|
|
224
235
|
const CSS_COLORS = {
|
|
236
|
+
promptbook: '#79EAFD',
|
|
225
237
|
transparent: 'rgba(0,0,0,0)',
|
|
226
238
|
aliceblue: '#f0f8ff',
|
|
227
239
|
antiquewhite: '#faebd7',
|
|
@@ -403,9 +415,6 @@ function checkChannelValue(channelName, value) {
|
|
|
403
415
|
throw new Error(`${channelName} channel is greater than 255, it is ${value}`);
|
|
404
416
|
}
|
|
405
417
|
}
|
|
406
|
-
/**
|
|
407
|
-
* TODO: [🧠][🚓] Is/which combination it better to use asserts/check, validate or is utility function?
|
|
408
|
-
*/
|
|
409
418
|
|
|
410
419
|
/**
|
|
411
420
|
* Color object represents an RGB color with alpha channel
|
|
@@ -425,21 +434,61 @@ class Color {
|
|
|
425
434
|
* @param color
|
|
426
435
|
* @returns Color object
|
|
427
436
|
*/
|
|
428
|
-
static from(color) {
|
|
429
|
-
if (color
|
|
437
|
+
static from(color, _isSingleValue = false) {
|
|
438
|
+
if (color === '') {
|
|
439
|
+
throw new Error(`Can not create color from empty string`);
|
|
440
|
+
}
|
|
441
|
+
else if (color instanceof Color) {
|
|
430
442
|
return take(color);
|
|
431
443
|
}
|
|
432
444
|
else if (Color.isColor(color)) {
|
|
433
445
|
return take(color);
|
|
434
446
|
}
|
|
435
447
|
else if (typeof color === 'string') {
|
|
436
|
-
|
|
448
|
+
try {
|
|
449
|
+
return Color.fromString(color);
|
|
450
|
+
}
|
|
451
|
+
catch (error) {
|
|
452
|
+
// <- Note: Can not use `assertsError(error)` here because it causes circular dependency
|
|
453
|
+
if (_isSingleValue) {
|
|
454
|
+
throw error;
|
|
455
|
+
}
|
|
456
|
+
const parts = color.split(/[\s+,;|]/);
|
|
457
|
+
if (parts.length > 0) {
|
|
458
|
+
return Color.from(parts[0].trim(), true);
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
throw new Error(`Can not create color from given string "${color}"`);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
437
464
|
}
|
|
438
465
|
else {
|
|
439
466
|
console.error({ color });
|
|
440
467
|
throw new Error(`Can not create color from given object`);
|
|
441
468
|
}
|
|
442
469
|
}
|
|
470
|
+
/**
|
|
471
|
+
* Creates a new Color instance from miscellaneous formats
|
|
472
|
+
* It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
|
|
473
|
+
*
|
|
474
|
+
* @param color
|
|
475
|
+
* @returns Color object
|
|
476
|
+
*/
|
|
477
|
+
static fromSafe(color) {
|
|
478
|
+
try {
|
|
479
|
+
return Color.from(color);
|
|
480
|
+
}
|
|
481
|
+
catch (error) {
|
|
482
|
+
// <- Note: Can not use `assertsError(error)` here because it causes circular dependency
|
|
483
|
+
console.warn(spaceTrim((block) => `
|
|
484
|
+
Color.fromSafe error:
|
|
485
|
+
${block(error.message)}
|
|
486
|
+
|
|
487
|
+
Returning default PROMPTBOOK_COLOR.
|
|
488
|
+
`));
|
|
489
|
+
return Color.fromString('promptbook');
|
|
490
|
+
}
|
|
491
|
+
}
|
|
443
492
|
/**
|
|
444
493
|
* Creates a new Color instance from miscellaneous string formats
|
|
445
494
|
*
|
|
@@ -507,6 +556,9 @@ class Color {
|
|
|
507
556
|
if (hex.length === 3) {
|
|
508
557
|
return Color.fromHex3(hex);
|
|
509
558
|
}
|
|
559
|
+
if (hex.length === 4) {
|
|
560
|
+
return Color.fromHex4(hex);
|
|
561
|
+
}
|
|
510
562
|
if (hex.length === 6) {
|
|
511
563
|
return Color.fromHex6(hex);
|
|
512
564
|
}
|
|
@@ -527,6 +579,19 @@ class Color {
|
|
|
527
579
|
const b = parseInt(hex.substr(2, 1), 16) * 16;
|
|
528
580
|
return take(new Color(r, g, b));
|
|
529
581
|
}
|
|
582
|
+
/**
|
|
583
|
+
* Creates a new Color instance from color in hex format with 4 digits (with alpha channel)
|
|
584
|
+
*
|
|
585
|
+
* @param color in hex for example `09df`
|
|
586
|
+
* @returns Color object
|
|
587
|
+
*/
|
|
588
|
+
static fromHex4(hex) {
|
|
589
|
+
const r = parseInt(hex.substr(0, 1), 16) * 16;
|
|
590
|
+
const g = parseInt(hex.substr(1, 1), 16) * 16;
|
|
591
|
+
const b = parseInt(hex.substr(2, 1), 16) * 16;
|
|
592
|
+
const a = parseInt(hex.substr(3, 1), 16) * 16;
|
|
593
|
+
return take(new Color(r, g, b, a));
|
|
594
|
+
}
|
|
530
595
|
/**
|
|
531
596
|
* Creates a new Color instance from color in hex format with 6 color digits (without alpha channel)
|
|
532
597
|
*
|
|
@@ -717,7 +782,8 @@ class Color {
|
|
|
717
782
|
* @returns true if the value is a valid hex color string (e.g., `#009edd`, `#fff`, etc.)
|
|
718
783
|
*/
|
|
719
784
|
static isHexColorString(value) {
|
|
720
|
-
return typeof value === 'string' &&
|
|
785
|
+
return (typeof value === 'string' &&
|
|
786
|
+
/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(value));
|
|
721
787
|
}
|
|
722
788
|
/**
|
|
723
789
|
* Creates new Color object
|
|
@@ -832,6 +898,23 @@ class Color {
|
|
|
832
898
|
* TODO: Maybe connect with textures
|
|
833
899
|
*/
|
|
834
900
|
|
|
901
|
+
/**
|
|
902
|
+
* Makes color transformer which returns a grayscale version of the color
|
|
903
|
+
*
|
|
904
|
+
* @param amount from 0 to 1
|
|
905
|
+
*
|
|
906
|
+
* @public exported from `@promptbook/color`
|
|
907
|
+
*/
|
|
908
|
+
function grayscale(amount) {
|
|
909
|
+
return ({ red, green, blue, alpha }) => {
|
|
910
|
+
const average = (red + green + blue) / 3;
|
|
911
|
+
red = Math.round(average * amount + red * (1 - amount));
|
|
912
|
+
green = Math.round(average * amount + green * (1 - amount));
|
|
913
|
+
blue = Math.round(average * amount + blue * (1 - amount));
|
|
914
|
+
return Color.fromValues(red, green, blue, alpha);
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
|
|
835
918
|
/**
|
|
836
919
|
* Converts HSL values to RGB values
|
|
837
920
|
*
|
|
@@ -947,102 +1030,6 @@ function lighten(amount) {
|
|
|
947
1030
|
* TODO: Maybe implement by mix+hsl
|
|
948
1031
|
*/
|
|
949
1032
|
|
|
950
|
-
/**
|
|
951
|
-
* Calculates distance between two colors
|
|
952
|
-
*
|
|
953
|
-
* @param color1 first color
|
|
954
|
-
* @param color2 second color
|
|
955
|
-
*
|
|
956
|
-
* Note: This function is inefficient. Use colorDistanceSquared instead if possible.
|
|
957
|
-
*
|
|
958
|
-
* @public exported from `@promptbook/color`
|
|
959
|
-
*/
|
|
960
|
-
/**
|
|
961
|
-
* Calculates distance between two colors without square root
|
|
962
|
-
*
|
|
963
|
-
* @param color1 first color
|
|
964
|
-
* @param color2 second color
|
|
965
|
-
*
|
|
966
|
-
* @public exported from `@promptbook/color`
|
|
967
|
-
*/
|
|
968
|
-
function colorDistanceSquared(color1, color2) {
|
|
969
|
-
const rmean = (color1.red + color2.red) / 2;
|
|
970
|
-
const r = color1.red - color2.red;
|
|
971
|
-
const g = color1.green - color2.green;
|
|
972
|
-
const b = color1.blue - color2.blue;
|
|
973
|
-
const weightR = 2 + rmean / 256;
|
|
974
|
-
const weightG = 4.0;
|
|
975
|
-
const weightB = 2 + (255 - rmean) / 256;
|
|
976
|
-
const distance = weightR * r * r + weightG * g * g + weightB * b * b;
|
|
977
|
-
return distance;
|
|
978
|
-
}
|
|
979
|
-
|
|
980
|
-
/**
|
|
981
|
-
* Makes color transformer which finds the nearest color from the given list
|
|
982
|
-
*
|
|
983
|
-
* @param colors array of colors to choose from
|
|
984
|
-
*
|
|
985
|
-
* @public exported from `@promptbook/color`
|
|
986
|
-
*/
|
|
987
|
-
function nearest(...colors) {
|
|
988
|
-
return (color) => {
|
|
989
|
-
const distances = colors.map((c) => colorDistanceSquared(c, color));
|
|
990
|
-
const minDistance = Math.min(...distances);
|
|
991
|
-
const minIndex = distances.indexOf(minDistance);
|
|
992
|
-
const nearestColor = colors[minIndex];
|
|
993
|
-
return nearestColor;
|
|
994
|
-
};
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
/**
|
|
998
|
-
* Color transformer which returns the negative color
|
|
999
|
-
*
|
|
1000
|
-
* @public exported from `@promptbook/color`
|
|
1001
|
-
*/
|
|
1002
|
-
function negative(color) {
|
|
1003
|
-
const r = 255 - color.red;
|
|
1004
|
-
const g = 255 - color.green;
|
|
1005
|
-
const b = 255 - color.blue;
|
|
1006
|
-
return Color.fromValues(r, g, b, color.alpha);
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
/**
|
|
1010
|
-
* Makes color transformer which finds the furthest color from the given list
|
|
1011
|
-
*
|
|
1012
|
-
* @param colors array of colors to choose from
|
|
1013
|
-
*
|
|
1014
|
-
* @public exported from `@promptbook/color`
|
|
1015
|
-
*/
|
|
1016
|
-
function furthest(...colors) {
|
|
1017
|
-
return (color) => {
|
|
1018
|
-
const furthestColor = negative(nearest(...colors.map(negative))(color));
|
|
1019
|
-
return furthestColor;
|
|
1020
|
-
};
|
|
1021
|
-
}
|
|
1022
|
-
/**
|
|
1023
|
-
* Makes color transformer which finds the best text color (black or white) for the given background color
|
|
1024
|
-
*
|
|
1025
|
-
* @public exported from `@promptbook/color`
|
|
1026
|
-
*/
|
|
1027
|
-
furthest(Color.get('white'), Color.from('black'));
|
|
1028
|
-
|
|
1029
|
-
/**
|
|
1030
|
-
* Makes color transformer which returns a grayscale version of the color
|
|
1031
|
-
*
|
|
1032
|
-
* @param amount from 0 to 1
|
|
1033
|
-
*
|
|
1034
|
-
* @public exported from `@promptbook/color`
|
|
1035
|
-
*/
|
|
1036
|
-
function grayscale(amount) {
|
|
1037
|
-
return ({ red, green, blue, alpha }) => {
|
|
1038
|
-
const average = (red + green + blue) / 3;
|
|
1039
|
-
red = Math.round(average * amount + red * (1 - amount));
|
|
1040
|
-
green = Math.round(average * amount + green * (1 - amount));
|
|
1041
|
-
blue = Math.round(average * amount + blue * (1 - amount));
|
|
1042
|
-
return Color.fromValues(red, green, blue, alpha);
|
|
1043
|
-
};
|
|
1044
|
-
}
|
|
1045
|
-
|
|
1046
1033
|
/**
|
|
1047
1034
|
* Makes color transformer which saturate the given color
|
|
1048
1035
|
*
|
|
@@ -1091,16 +1078,32 @@ const ADMIN_GITHUB_NAME = 'hejny';
|
|
|
1091
1078
|
*
|
|
1092
1079
|
* @public exported from `@promptbook/core`
|
|
1093
1080
|
*/
|
|
1094
|
-
const PROMPTBOOK_COLOR = Color.
|
|
1095
|
-
// <- TODO: [🧠] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
1081
|
+
const PROMPTBOOK_COLOR = Color.fromString('promptbook');
|
|
1082
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
1083
|
+
/**
|
|
1084
|
+
* Colors for syntax highlighting in the `<BookEditor/>`
|
|
1085
|
+
*
|
|
1086
|
+
* TODO: [🗽] Unite branding and make single place for it
|
|
1087
|
+
*
|
|
1088
|
+
* @public exported from `@promptbook/core`
|
|
1089
|
+
*/
|
|
1090
|
+
({
|
|
1091
|
+
TITLE: Color.fromHex('#244EA8'),
|
|
1092
|
+
LINE: Color.fromHex('#eeeeee'),
|
|
1093
|
+
SEPARATOR: Color.fromHex('#cccccc'),
|
|
1094
|
+
COMMITMENT: Color.fromHex('#DA0F78'),
|
|
1095
|
+
PARAMETER: Color.fromHex('#8e44ad'),
|
|
1096
|
+
});
|
|
1097
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
1096
1098
|
/**
|
|
1097
|
-
*
|
|
1099
|
+
* Chat color of the Promptbook (in chat)
|
|
1098
1100
|
*
|
|
1099
1101
|
* TODO: [🗽] Unite branding and make single place for it
|
|
1100
1102
|
*
|
|
1101
1103
|
* @public exported from `@promptbook/core`
|
|
1102
1104
|
*/
|
|
1103
1105
|
PROMPTBOOK_COLOR.then(lighten(0.1)).then(saturate(0.9)).then(grayscale(0.9));
|
|
1106
|
+
// <- TODO: [🧠][🈵] Using `Color` and `lighten`, `saturate`,... here increases the package size approx 3kb, maybe remove it
|
|
1104
1107
|
/**
|
|
1105
1108
|
* Color of the user (in chat)
|
|
1106
1109
|
*
|
|
@@ -1184,7 +1187,7 @@ const API_REQUEST_TIMEOUT = parseInt(process.env.API_REQUEST_TIMEOUT || '90000')
|
|
|
1184
1187
|
function getErrorReportUrl(error) {
|
|
1185
1188
|
const report = {
|
|
1186
1189
|
title: `🐜 Error report from ${NAME}`,
|
|
1187
|
-
body: spaceTrim((block) => `
|
|
1190
|
+
body: spaceTrim$2((block) => `
|
|
1188
1191
|
|
|
1189
1192
|
|
|
1190
1193
|
\`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
|
|
@@ -1342,7 +1345,7 @@ function checkSerializableAsJson(options) {
|
|
|
1342
1345
|
}
|
|
1343
1346
|
else if (typeof value === 'object') {
|
|
1344
1347
|
if (value instanceof Date) {
|
|
1345
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
1348
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
1346
1349
|
\`${name}\` is Date
|
|
1347
1350
|
|
|
1348
1351
|
Use \`string_date_iso8601\` instead
|
|
@@ -1361,7 +1364,7 @@ function checkSerializableAsJson(options) {
|
|
|
1361
1364
|
throw new UnexpectedError(`${name} is RegExp`);
|
|
1362
1365
|
}
|
|
1363
1366
|
else if (value instanceof Error) {
|
|
1364
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
1367
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
1365
1368
|
\`${name}\` is unserialized Error
|
|
1366
1369
|
|
|
1367
1370
|
Use function \`serializeError\`
|
|
@@ -1384,7 +1387,7 @@ function checkSerializableAsJson(options) {
|
|
|
1384
1387
|
}
|
|
1385
1388
|
catch (error) {
|
|
1386
1389
|
assertsError(error);
|
|
1387
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
1390
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
1388
1391
|
\`${name}\` is not serializable
|
|
1389
1392
|
|
|
1390
1393
|
${block(error.stack || error.message)}
|
|
@@ -1416,7 +1419,7 @@ function checkSerializableAsJson(options) {
|
|
|
1416
1419
|
}
|
|
1417
1420
|
}
|
|
1418
1421
|
else {
|
|
1419
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
1422
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
1420
1423
|
\`${name}\` is unknown type
|
|
1421
1424
|
|
|
1422
1425
|
Additional message for \`${name}\`:
|
|
@@ -1446,7 +1449,7 @@ function deepClone(objectValue) {
|
|
|
1446
1449
|
TODO: [🧠] Is there a better implementation?
|
|
1447
1450
|
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
1448
1451
|
> for (const propertyName of propertyNames) {
|
|
1449
|
-
> const value = (objectValue as
|
|
1452
|
+
> const value = (objectValue as chococake)[propertyName];
|
|
1450
1453
|
> if (value && typeof value === 'object') {
|
|
1451
1454
|
> deepClone(value);
|
|
1452
1455
|
> }
|
|
@@ -1543,6 +1546,7 @@ exportJson({
|
|
|
1543
1546
|
/**
|
|
1544
1547
|
* Generates random token
|
|
1545
1548
|
*
|
|
1549
|
+
* Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
|
|
1546
1550
|
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
1547
1551
|
*
|
|
1548
1552
|
* @private internal helper function
|
|
@@ -1552,6 +1556,7 @@ function $randomToken(randomness) {
|
|
|
1552
1556
|
return randomBytes(randomness).toString('hex');
|
|
1553
1557
|
}
|
|
1554
1558
|
/**
|
|
1559
|
+
* TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
|
|
1555
1560
|
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
1556
1561
|
*/
|
|
1557
1562
|
|
|
@@ -1618,10 +1623,13 @@ const LINES_PER_STANDARD_PAGE = 44;
|
|
|
1618
1623
|
* @public exported from `@promptbook/utils`
|
|
1619
1624
|
*/
|
|
1620
1625
|
function countLines(text) {
|
|
1626
|
+
if (text === '') {
|
|
1627
|
+
return 0;
|
|
1628
|
+
}
|
|
1621
1629
|
text = text.replace('\r\n', '\n');
|
|
1622
1630
|
text = text.replace('\r', '\n');
|
|
1623
1631
|
const lines = text.split('\n');
|
|
1624
|
-
return lines.reduce((count, line) => count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 0);
|
|
1632
|
+
return lines.reduce((count, line) => count + Math.max(Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 1), 0);
|
|
1625
1633
|
}
|
|
1626
1634
|
/**
|
|
1627
1635
|
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
@@ -2008,7 +2016,7 @@ function pricing(value) {
|
|
|
2008
2016
|
/**
|
|
2009
2017
|
* List of available OpenAI models with pricing
|
|
2010
2018
|
*
|
|
2011
|
-
* Note: Synced with official API docs at 2025-
|
|
2019
|
+
* Note: Synced with official API docs at 2025-11-19
|
|
2012
2020
|
*
|
|
2013
2021
|
* @see https://platform.openai.com/docs/models/
|
|
2014
2022
|
* @see https://openai.com/api/pricing/
|
|
@@ -2018,11 +2026,21 @@ const OPENAI_MODELS = exportJson({
|
|
|
2018
2026
|
name: 'OPENAI_MODELS',
|
|
2019
2027
|
value: [
|
|
2020
2028
|
/**/
|
|
2029
|
+
{
|
|
2030
|
+
modelVariant: 'CHAT',
|
|
2031
|
+
modelTitle: 'gpt-5.1',
|
|
2032
|
+
modelName: 'gpt-5.1',
|
|
2033
|
+
modelDescription: 'The best model for coding and agentic tasks with configurable reasoning effort.',
|
|
2034
|
+
pricing: {
|
|
2035
|
+
prompt: pricing(`$1.25 / 1M tokens`),
|
|
2036
|
+
output: pricing(`$10.00 / 1M tokens`),
|
|
2037
|
+
},
|
|
2038
|
+
},
|
|
2021
2039
|
{
|
|
2022
2040
|
modelVariant: 'CHAT',
|
|
2023
2041
|
modelTitle: 'gpt-5',
|
|
2024
2042
|
modelName: 'gpt-5',
|
|
2025
|
-
modelDescription: "OpenAI's most advanced language model with unprecedented reasoning capabilities and 200K context window. Features revolutionary improvements in complex problem-solving, scientific reasoning, and creative tasks. Demonstrates human-level performance across diverse domains with enhanced safety measures and alignment. Represents the next generation of AI with superior understanding, nuanced responses, and advanced multimodal capabilities.",
|
|
2043
|
+
modelDescription: "OpenAI's most advanced language model with unprecedented reasoning capabilities and 200K context window. Features revolutionary improvements in complex problem-solving, scientific reasoning, and creative tasks. Demonstrates human-level performance across diverse domains with enhanced safety measures and alignment. Represents the next generation of AI with superior understanding, nuanced responses, and advanced multimodal capabilities. DEPRECATED: Use gpt-5.1 instead.",
|
|
2026
2044
|
pricing: {
|
|
2027
2045
|
prompt: pricing(`$1.25 / 1M tokens`),
|
|
2028
2046
|
output: pricing(`$10.00 / 1M tokens`),
|
|
@@ -2149,12 +2167,18 @@ const OPENAI_MODELS = exportJson({
|
|
|
2149
2167
|
},
|
|
2150
2168
|
},
|
|
2151
2169
|
/**/
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2170
|
+
/**/
|
|
2171
|
+
{
|
|
2172
|
+
modelVariant: 'IMAGE_GENERATION',
|
|
2173
|
+
modelTitle: 'dall-e-3',
|
|
2174
|
+
modelName: 'dall-e-3',
|
|
2175
|
+
modelDescription: 'DALL·E 3 is the latest version of the DALL·E art generation model. It understands significantly more nuance and detail than our previous systems, allowing you to easily translate your ideas into exceptionally accurate images.',
|
|
2176
|
+
pricing: {
|
|
2177
|
+
prompt: 0,
|
|
2178
|
+
output: 0.04,
|
|
2179
|
+
},
|
|
2180
|
+
},
|
|
2181
|
+
/**/
|
|
2158
2182
|
/*/
|
|
2159
2183
|
{
|
|
2160
2184
|
modelTitle: 'whisper-1',
|
|
@@ -2173,12 +2197,18 @@ const OPENAI_MODELS = exportJson({
|
|
|
2173
2197
|
},
|
|
2174
2198
|
},
|
|
2175
2199
|
/**/
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2200
|
+
/**/
|
|
2201
|
+
{
|
|
2202
|
+
modelVariant: 'IMAGE_GENERATION',
|
|
2203
|
+
modelTitle: 'dall-e-2',
|
|
2204
|
+
modelName: 'dall-e-2',
|
|
2205
|
+
modelDescription: 'DALL·E 2 is an AI system that can create realistic images and art from a description in natural language.',
|
|
2206
|
+
pricing: {
|
|
2207
|
+
prompt: 0,
|
|
2208
|
+
output: 0.02,
|
|
2209
|
+
},
|
|
2210
|
+
},
|
|
2211
|
+
/**/
|
|
2182
2212
|
/**/
|
|
2183
2213
|
{
|
|
2184
2214
|
modelVariant: 'CHAT',
|
|
@@ -2192,17 +2222,17 @@ const OPENAI_MODELS = exportJson({
|
|
|
2192
2222
|
},
|
|
2193
2223
|
/**/
|
|
2194
2224
|
/*/
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2225
|
+
{
|
|
2226
|
+
modelTitle: 'tts-1-hd-1106',
|
|
2227
|
+
modelName: 'tts-1-hd-1106',
|
|
2228
|
+
},
|
|
2229
|
+
/**/
|
|
2200
2230
|
/*/
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2231
|
+
{
|
|
2232
|
+
modelTitle: 'tts-1-hd',
|
|
2233
|
+
modelName: 'tts-1-hd',
|
|
2234
|
+
},
|
|
2235
|
+
/**/
|
|
2206
2236
|
/**/
|
|
2207
2237
|
{
|
|
2208
2238
|
modelVariant: 'CHAT',
|
|
@@ -3389,6 +3419,151 @@ class OpenAiCompatibleExecutionTools {
|
|
|
3389
3419
|
return this.callEmbeddingModelWithRetry(prompt, modifiedModelRequirements, attemptStack, retriedUnsupportedParameters);
|
|
3390
3420
|
}
|
|
3391
3421
|
}
|
|
3422
|
+
/**
|
|
3423
|
+
* Calls OpenAI compatible API to use a image generation model
|
|
3424
|
+
*/
|
|
3425
|
+
async callImageGenerationModel(prompt) {
|
|
3426
|
+
// Deep clone prompt and modelRequirements to avoid mutation across calls
|
|
3427
|
+
const clonedPrompt = JSON.parse(JSON.stringify(prompt));
|
|
3428
|
+
const retriedUnsupportedParameters = new Set();
|
|
3429
|
+
return this.callImageGenerationModelWithRetry(clonedPrompt, clonedPrompt.modelRequirements, [], retriedUnsupportedParameters);
|
|
3430
|
+
}
|
|
3431
|
+
/**
|
|
3432
|
+
* Internal method that handles parameter retry for image generation model calls
|
|
3433
|
+
*/
|
|
3434
|
+
async callImageGenerationModelWithRetry(prompt, currentModelRequirements, attemptStack = [], retriedUnsupportedParameters = new Set()) {
|
|
3435
|
+
var _a, _b;
|
|
3436
|
+
if (this.options.isVerbose) {
|
|
3437
|
+
console.info(`🎨 ${this.title} callImageGenerationModel call`, { prompt, currentModelRequirements });
|
|
3438
|
+
}
|
|
3439
|
+
const { content, parameters } = prompt;
|
|
3440
|
+
const client = await this.getClient();
|
|
3441
|
+
// TODO: [☂] Use here more modelRequirements
|
|
3442
|
+
if (currentModelRequirements.modelVariant !== 'IMAGE_GENERATION') {
|
|
3443
|
+
throw new PipelineExecutionError('Use callImageGenerationModel only for IMAGE_GENERATION variant');
|
|
3444
|
+
}
|
|
3445
|
+
const modelName = currentModelRequirements.modelName || this.getDefaultImageGenerationModel().modelName;
|
|
3446
|
+
const modelSettings = {
|
|
3447
|
+
model: modelName,
|
|
3448
|
+
// size: currentModelRequirements.size,
|
|
3449
|
+
// quality: currentModelRequirements.quality,
|
|
3450
|
+
// style: currentModelRequirements.style,
|
|
3451
|
+
};
|
|
3452
|
+
const rawPromptContent = templateParameters(content, { ...parameters, modelName });
|
|
3453
|
+
const rawRequest = {
|
|
3454
|
+
...modelSettings,
|
|
3455
|
+
prompt: rawPromptContent,
|
|
3456
|
+
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
3457
|
+
response_format: 'url', // TODO: [🧠] Maybe allow b64_json
|
|
3458
|
+
};
|
|
3459
|
+
const start = $getCurrentDate();
|
|
3460
|
+
if (this.options.isVerbose) {
|
|
3461
|
+
console.info(colors.bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
|
3462
|
+
}
|
|
3463
|
+
try {
|
|
3464
|
+
const rawResponse = await this.limiter
|
|
3465
|
+
.schedule(() => this.makeRequestWithNetworkRetry(() => client.images.generate(rawRequest)))
|
|
3466
|
+
.catch((error) => {
|
|
3467
|
+
assertsError(error);
|
|
3468
|
+
if (this.options.isVerbose) {
|
|
3469
|
+
console.info(colors.bgRed('error'), error);
|
|
3470
|
+
}
|
|
3471
|
+
throw error;
|
|
3472
|
+
});
|
|
3473
|
+
if (this.options.isVerbose) {
|
|
3474
|
+
console.info(colors.bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
|
|
3475
|
+
}
|
|
3476
|
+
const complete = $getCurrentDate();
|
|
3477
|
+
if (!rawResponse.data[0]) {
|
|
3478
|
+
throw new PipelineExecutionError(`No choises from ${this.title}`);
|
|
3479
|
+
}
|
|
3480
|
+
if (rawResponse.data.length > 1) {
|
|
3481
|
+
throw new PipelineExecutionError(`More than one choise from ${this.title}`);
|
|
3482
|
+
}
|
|
3483
|
+
const resultContent = rawResponse.data[0].url;
|
|
3484
|
+
const modelInfo = this.HARDCODED_MODELS.find((model) => model.modelName === modelName);
|
|
3485
|
+
const price = ((_b = modelInfo === null || modelInfo === void 0 ? void 0 : modelInfo.pricing) === null || _b === void 0 ? void 0 : _b.output) ? uncertainNumber(modelInfo.pricing.output) : uncertainNumber();
|
|
3486
|
+
return exportJson({
|
|
3487
|
+
name: 'promptResult',
|
|
3488
|
+
message: `Result of \`OpenAiCompatibleExecutionTools.callImageGenerationModel\``,
|
|
3489
|
+
order: [],
|
|
3490
|
+
value: {
|
|
3491
|
+
content: resultContent,
|
|
3492
|
+
modelName: modelName,
|
|
3493
|
+
timing: {
|
|
3494
|
+
start,
|
|
3495
|
+
complete,
|
|
3496
|
+
},
|
|
3497
|
+
usage: {
|
|
3498
|
+
price,
|
|
3499
|
+
input: {
|
|
3500
|
+
tokensCount: uncertainNumber(0),
|
|
3501
|
+
...computeUsageCounts(rawPromptContent),
|
|
3502
|
+
},
|
|
3503
|
+
output: {
|
|
3504
|
+
tokensCount: uncertainNumber(0),
|
|
3505
|
+
...computeUsageCounts(''),
|
|
3506
|
+
},
|
|
3507
|
+
},
|
|
3508
|
+
rawPromptContent,
|
|
3509
|
+
rawRequest,
|
|
3510
|
+
rawResponse,
|
|
3511
|
+
},
|
|
3512
|
+
});
|
|
3513
|
+
}
|
|
3514
|
+
catch (error) {
|
|
3515
|
+
assertsError(error);
|
|
3516
|
+
if (!isUnsupportedParameterError(error)) {
|
|
3517
|
+
if (attemptStack.length > 0) {
|
|
3518
|
+
throw new PipelineExecutionError(`All attempts failed. Attempt history:\n` +
|
|
3519
|
+
attemptStack
|
|
3520
|
+
.map((a, i) => ` ${i + 1}. Model: ${a.modelName}` +
|
|
3521
|
+
(a.unsupportedParameter ? `, Stripped: ${a.unsupportedParameter}` : '') +
|
|
3522
|
+
`, Error: ${a.errorMessage}` +
|
|
3523
|
+
(a.stripped ? ' (stripped and retried)' : ''))
|
|
3524
|
+
.join('\n') +
|
|
3525
|
+
`\nFinal error: ${error.message}`);
|
|
3526
|
+
}
|
|
3527
|
+
throw error;
|
|
3528
|
+
}
|
|
3529
|
+
const unsupportedParameter = parseUnsupportedParameterError(error.message);
|
|
3530
|
+
if (!unsupportedParameter) {
|
|
3531
|
+
if (this.options.isVerbose) {
|
|
3532
|
+
console.warn(colors.bgYellow('Warning'), 'Could not parse unsupported parameter from error:', error.message);
|
|
3533
|
+
}
|
|
3534
|
+
throw error;
|
|
3535
|
+
}
|
|
3536
|
+
const retryKey = `${modelName}-${unsupportedParameter}`;
|
|
3537
|
+
if (retriedUnsupportedParameters.has(retryKey)) {
|
|
3538
|
+
attemptStack.push({
|
|
3539
|
+
modelName,
|
|
3540
|
+
unsupportedParameter,
|
|
3541
|
+
errorMessage: error.message,
|
|
3542
|
+
stripped: true,
|
|
3543
|
+
});
|
|
3544
|
+
throw new PipelineExecutionError(`All attempts failed. Attempt history:\n` +
|
|
3545
|
+
attemptStack
|
|
3546
|
+
.map((a, i) => ` ${i + 1}. Model: ${a.modelName}` +
|
|
3547
|
+
(a.unsupportedParameter ? `, Stripped: ${a.unsupportedParameter}` : '') +
|
|
3548
|
+
`, Error: ${a.errorMessage}` +
|
|
3549
|
+
(a.stripped ? ' (stripped and retried)' : ''))
|
|
3550
|
+
.join('\n') +
|
|
3551
|
+
`\nFinal error: ${error.message}`);
|
|
3552
|
+
}
|
|
3553
|
+
retriedUnsupportedParameters.add(retryKey);
|
|
3554
|
+
if (this.options.isVerbose) {
|
|
3555
|
+
console.warn(colors.bgYellow('Warning'), `Removing unsupported parameter '${unsupportedParameter}' for model '${modelName}' and retrying request`);
|
|
3556
|
+
}
|
|
3557
|
+
attemptStack.push({
|
|
3558
|
+
modelName,
|
|
3559
|
+
unsupportedParameter,
|
|
3560
|
+
errorMessage: error.message,
|
|
3561
|
+
stripped: true,
|
|
3562
|
+
});
|
|
3563
|
+
const modifiedModelRequirements = removeUnsupportedModelRequirement(currentModelRequirements, unsupportedParameter);
|
|
3564
|
+
return this.callImageGenerationModelWithRetry(prompt, modifiedModelRequirements, attemptStack, retriedUnsupportedParameters);
|
|
3565
|
+
}
|
|
3566
|
+
}
|
|
3392
3567
|
// <- Note: [🤖] callXxxModel
|
|
3393
3568
|
/**
|
|
3394
3569
|
* Get the model that should be used as default
|
|
@@ -3397,7 +3572,7 @@ class OpenAiCompatibleExecutionTools {
|
|
|
3397
3572
|
// Note: Match exact or prefix for model families
|
|
3398
3573
|
const model = this.HARDCODED_MODELS.find(({ modelName }) => modelName === defaultModelName || modelName.startsWith(defaultModelName));
|
|
3399
3574
|
if (model === undefined) {
|
|
3400
|
-
throw new PipelineExecutionError(spaceTrim((block) => `
|
|
3575
|
+
throw new PipelineExecutionError(spaceTrim$2((block) => `
|
|
3401
3576
|
Cannot find model in ${this.title} models with name "${defaultModelName}" which should be used as default.
|
|
3402
3577
|
|
|
3403
3578
|
Available models:
|
|
@@ -3769,7 +3944,7 @@ class OllamaExecutionTools extends OpenAiCompatibleExecutionTools {
|
|
|
3769
3944
|
...ollamaOptions,
|
|
3770
3945
|
apiKey: 'ollama',
|
|
3771
3946
|
isProxied: false, // <- Note: Ollama is always local
|
|
3772
|
-
};
|
|
3947
|
+
}; /* <- Note: [🤛] */
|
|
3773
3948
|
super(openAiCompatibleOptions);
|
|
3774
3949
|
}
|
|
3775
3950
|
get title() {
|
|
@@ -3819,6 +3994,13 @@ class OllamaExecutionTools extends OpenAiCompatibleExecutionTools {
|
|
|
3819
3994
|
return this.getDefaultModel('text-embedding-3-large'); // <- TODO: [🧠] Pick the best default model
|
|
3820
3995
|
// <- TODO: [🛄]
|
|
3821
3996
|
}
|
|
3997
|
+
/**
|
|
3998
|
+
* Default model for image generation variant.
|
|
3999
|
+
*/
|
|
4000
|
+
getDefaultImageGenerationModel() {
|
|
4001
|
+
return this.getDefaultModel('!!!'); // <- TODO: [🧠] Pick the best default model
|
|
4002
|
+
// <- TODO: [🛄]
|
|
4003
|
+
}
|
|
3822
4004
|
}
|
|
3823
4005
|
/**
|
|
3824
4006
|
* TODO: [🛄] Some way how to re-wrap the errors from `OpenAiCompatibleExecutionTools`
|