@promptbook/openai 0.61.0-9 โ 0.62.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -5
- package/esm/index.es.js +238 -31
- package/esm/index.es.js.map +1 -1
- package/esm/typings/promptbook-collection/index.d.ts +200 -30
- package/esm/typings/src/_packages/core.index.d.ts +9 -3
- package/esm/typings/src/_packages/execute-javascript.index.d.ts +1 -1
- package/esm/typings/src/_packages/node.index.d.ts +2 -1
- package/esm/typings/src/_packages/types.index.d.ts +12 -8
- package/esm/typings/src/_packages/utils.index.d.ts +11 -8
- package/esm/typings/src/cli/cli-commands/hello.d.ts +3 -0
- package/esm/typings/src/cli/cli-commands/make.d.ts +3 -0
- package/esm/typings/src/cli/cli-commands/prettify.d.ts +3 -0
- package/esm/typings/src/cli/promptbookCli.d.ts +1 -0
- package/esm/typings/src/collection/PipelineCollection.d.ts +1 -1
- package/esm/typings/src/collection/SimplePipelineCollection.d.ts +10 -10
- package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +7 -7
- package/esm/typings/src/collection/constructors/createCollectionFromUrl.d.ts +2 -2
- package/esm/typings/src/commands/KNOWLEDGE/KnowledgeCommand.d.ts +2 -3
- package/esm/typings/src/commands/MODEL/ModelCommand.d.ts +2 -2
- package/esm/typings/src/commands/PERSONA/PersonaCommand.d.ts +4 -2
- package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -0
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +42 -14
- package/esm/typings/src/config.d.ts +46 -1
- package/esm/typings/src/config.test.d.ts +4 -0
- package/esm/typings/src/conversion/pipelineJsonToString.d.ts +3 -2
- package/esm/typings/src/conversion/pipelineStringToJson.d.ts +9 -5
- package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +6 -3
- package/esm/typings/src/conversion/prettify/PrettifyOptions.d.ts +2 -2
- package/{umd/typings/src/conversion/utils/extractParametersFromPromptTemplate.d.ts โ esm/typings/src/conversion/utils/extractParameterNamesFromPromptTemplate.d.ts} +2 -2
- package/esm/typings/src/conversion/utils/renameParameter.d.ts +3 -3
- package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +14 -0
- package/esm/typings/src/conversion/validation/_importPipeline.d.ts +12 -3
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +10 -1
- package/esm/typings/src/errors/EnvironmentMismatchError.d.ts +7 -0
- package/esm/typings/src/errors/LimitReachedError.d.ts +7 -0
- package/esm/typings/src/errors/VersionMismatchError.d.ts +8 -0
- package/esm/typings/src/execution/CommonExecutionToolsOptions.d.ts +1 -0
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +10 -8
- package/esm/typings/src/execution/PipelineExecutor.d.ts +48 -26
- package/esm/typings/src/execution/PromptResult.d.ts +39 -54
- package/esm/typings/src/execution/PromptResultUsage.d.ts +29 -0
- package/esm/typings/src/execution/ScriptExecutionTools.d.ts +5 -4
- package/esm/typings/src/execution/UncertainNumber.d.ts +18 -0
- package/esm/typings/src/execution/UserInterfaceTools.d.ts +5 -5
- package/esm/typings/src/execution/createPipelineExecutor.d.ts +31 -3
- package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +2 -2
- package/esm/typings/src/execution/utils/addUsage.d.ts +58 -2
- package/esm/typings/src/execution/utils/computeUsageCounts.d.ts +1 -1
- package/esm/typings/src/execution/utils/forEachAsync.d.ts +1 -1
- package/esm/typings/src/execution/utils/uncertainNumber.d.ts +1 -1
- package/esm/typings/src/execution/utils/usageToHuman.d.ts +15 -0
- package/esm/typings/src/execution/utils/usageToWorktime.d.ts +2 -2
- package/esm/typings/src/formats/_common/FormatDefinition.d.ts +1 -1
- package/esm/typings/src/formats/csv/ListFormatDefinition.d.ts +2 -1
- package/esm/typings/src/formats/json/JsonFormatDefinition.d.ts +2 -1
- package/esm/typings/src/formats/list/ListFormatDefinition.d.ts +2 -1
- package/esm/typings/src/formats/xml/XmlFormatDefinition.d.ts +1 -0
- package/esm/typings/src/knowledge/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +1 -1
- package/esm/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +3 -0
- package/esm/typings/src/knowledge/prepare-knowledge/_common/Scraper.d.ts +27 -0
- package/esm/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.d.ts +18 -0
- package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +9 -23
- package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +3 -0
- package/esm/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +8 -14
- package/esm/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +31 -0
- package/esm/typings/src/llm-providers/_common/getLlmToolsForCli.d.ts +11 -0
- package/esm/typings/src/llm-providers/_common/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +12 -0
- package/esm/typings/src/llm-providers/_common/utils/cache/CacheItem.d.ts +29 -0
- package/esm/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +10 -0
- package/esm/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +19 -0
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts +14 -0
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/countTotalUsage.d.ts +17 -0
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +35 -0
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +4 -3
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +3 -3
- package/esm/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +3 -0
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +5 -4
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +5 -5
- package/esm/typings/src/llm-providers/azure-openai/playground/playground.d.ts +3 -0
- package/esm/typings/src/llm-providers/langtail/LangtailExecutionTools.d.ts +3 -0
- package/esm/typings/src/llm-providers/langtail/LangtailExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +5 -5
- package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +7 -7
- package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +12 -8
- package/esm/typings/src/llm-providers/multiple/joinLlmExecutionTools.d.ts +3 -0
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +7 -6
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/computeOpenaiUsage.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/computeUsage.d.ts +2 -2
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +3 -2
- package/esm/typings/src/llm-providers/openai/playground/playground.d.ts +3 -0
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +10 -8
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +2 -2
- package/esm/typings/src/personas/preparePersona.d.ts +15 -0
- package/esm/typings/src/prepare/PrepareOptions.d.ts +22 -0
- package/esm/typings/src/prepare/isPipelinePrepared.d.ts +14 -0
- package/esm/typings/src/prepare/preparePipeline.d.ts +16 -0
- package/esm/typings/src/prepare/prepareTemplates.d.ts +31 -0
- package/esm/typings/src/prepare/unpreparePipeline.d.ts +11 -0
- package/esm/typings/src/scripting/javascript/JavascriptExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
- package/esm/typings/src/scripting/javascript/utils/unknownToString.d.ts +2 -1
- package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +25 -0
- package/esm/typings/src/storage/_common/PromptbookStorage.test-type.d.ts +5 -0
- package/esm/typings/src/storage/files-storage/FilesStorage.d.ts +30 -0
- package/esm/typings/src/storage/files-storage/FilesStorageOptions.d.ts +13 -0
- package/esm/typings/src/storage/files-storage/utils/nameToSubfolderPath.d.ts +7 -0
- package/esm/typings/src/storage/local-storage/getLocalStorage.d.ts +9 -0
- package/esm/typings/src/storage/local-storage/getSessionStorage.d.ts +9 -0
- package/esm/typings/src/storage/memory/MemoryStorage.d.ts +34 -0
- package/esm/typings/src/storage/utils/PrefixStorage.d.ts +26 -0
- package/esm/typings/src/storage/utils/makePromptbookStorageFromWebStorage.d.ts +11 -0
- package/esm/typings/src/types/ModelRequirements.d.ts +71 -11
- package/esm/typings/src/types/ModelVariant.d.ts +14 -0
- package/esm/typings/src/types/PipelineJson/Expectations.d.ts +6 -2
- package/esm/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +70 -0
- package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +27 -0
- package/esm/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +10 -1
- package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +41 -0
- package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +31 -5
- package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +22 -0
- package/esm/typings/src/types/PipelineJson/PromptDialogJson.d.ts +8 -2
- package/esm/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +5 -1
- package/esm/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +23 -4
- package/esm/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +12 -2
- package/esm/typings/src/types/PipelineJson/ScriptJson.d.ts +7 -2
- package/esm/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +7 -2
- package/esm/typings/src/types/PipelineString.d.ts +1 -1
- package/esm/typings/src/types/Prompt.d.ts +54 -10
- package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +4 -4
- package/esm/typings/src/types/execution-report/ExecutionReportStringOptions.d.ts +3 -3
- package/esm/typings/src/types/execution-report/countWorkingDuration.d.ts +1 -1
- package/esm/typings/src/types/typeAliases.d.ts +114 -15
- package/esm/typings/src/utils/FromtoItems.d.ts +3 -3
- package/esm/typings/src/utils/currentDate.d.ts +7 -0
- package/esm/typings/src/utils/deepClone.d.ts +9 -0
- package/esm/typings/src/utils/deepFreeze.d.ts +22 -0
- package/esm/typings/src/utils/emojis.d.ts +2 -2
- package/esm/typings/src/utils/{extractParameters.d.ts โ extractParameterNames.d.ts} +2 -2
- package/esm/typings/src/utils/formatNumber.d.ts +1 -1
- package/esm/typings/src/utils/isRunningInWhatever.d.ts +3 -0
- package/esm/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +3 -3
- package/esm/typings/src/utils/markdown/createMarkdownChart.d.ts +7 -10
- package/esm/typings/src/utils/markdown/createMarkdownTable.d.ts +1 -1
- package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown-real.test.d.ts +1 -0
- package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +9 -2
- package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +1 -1
- package/esm/typings/src/utils/markdown/parseMarkdownSection.d.ts +3 -3
- package/esm/typings/src/utils/normalization/parseKeywords.d.ts +2 -1
- package/esm/typings/src/utils/organization/TODO_USE.d.ts +12 -0
- package/esm/typings/src/utils/organization/TODO_any.d.ts +6 -0
- package/esm/typings/src/utils/organization/TODO_object.d.ts +6 -0
- package/esm/typings/src/utils/organization/TODO_unknown.d.ts +6 -0
- package/esm/typings/src/utils/organization/___.d.ts +6 -0
- package/{umd/typings/src/utils โ esm/typings/src/utils/organization}/just.d.ts +5 -1
- package/esm/typings/src/utils/organization/keepUnused.d.ts +16 -0
- package/esm/typings/src/utils/organization/really_any.d.ts +6 -0
- package/esm/typings/src/utils/organization/really_unknown.d.ts +6 -0
- package/esm/typings/src/utils/random/randomSeed.d.ts +7 -0
- package/esm/typings/src/{execution/utils โ utils}/replaceParameters.d.ts +2 -4
- package/esm/typings/src/utils/replaceParameters.test.d.ts +1 -0
- package/esm/typings/src/utils/sets/difference.d.ts +3 -0
- package/esm/typings/src/utils/validators/email/isValidEmail.d.ts +2 -1
- package/esm/typings/src/utils/validators/filePath/isValidFilePath.d.ts +2 -1
- package/esm/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +2 -1
- package/esm/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.d.ts +2 -1
- package/esm/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.d.ts +2 -1
- package/esm/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -1
- package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +2 -1
- package/esm/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -1
- package/package.json +3 -3
- package/umd/index.umd.js +238 -31
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/promptbook-collection/index.d.ts +200 -30
- package/umd/typings/src/_packages/core.index.d.ts +9 -3
- package/umd/typings/src/_packages/execute-javascript.index.d.ts +1 -1
- package/umd/typings/src/_packages/node.index.d.ts +2 -1
- package/umd/typings/src/_packages/types.index.d.ts +12 -8
- package/umd/typings/src/_packages/utils.index.d.ts +11 -8
- package/umd/typings/src/cli/cli-commands/hello.d.ts +3 -0
- package/umd/typings/src/cli/cli-commands/make.d.ts +3 -0
- package/umd/typings/src/cli/cli-commands/prettify.d.ts +3 -0
- package/umd/typings/src/cli/promptbookCli.d.ts +1 -0
- package/umd/typings/src/collection/PipelineCollection.d.ts +1 -1
- package/umd/typings/src/collection/SimplePipelineCollection.d.ts +10 -10
- package/umd/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +7 -7
- package/umd/typings/src/collection/constructors/createCollectionFromUrl.d.ts +2 -2
- package/umd/typings/src/commands/KNOWLEDGE/KnowledgeCommand.d.ts +2 -3
- package/umd/typings/src/commands/MODEL/ModelCommand.d.ts +2 -2
- package/umd/typings/src/commands/PERSONA/PersonaCommand.d.ts +4 -2
- package/umd/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -0
- package/umd/typings/src/commands/_common/types/CommandParser.d.ts +42 -14
- package/umd/typings/src/config.d.ts +46 -1
- package/umd/typings/src/config.test.d.ts +4 -0
- package/umd/typings/src/conversion/pipelineJsonToString.d.ts +3 -2
- package/umd/typings/src/conversion/pipelineStringToJson.d.ts +9 -5
- package/umd/typings/src/conversion/pipelineStringToJsonSync.d.ts +6 -3
- package/umd/typings/src/conversion/prettify/PrettifyOptions.d.ts +2 -2
- package/{esm/typings/src/conversion/utils/extractParametersFromPromptTemplate.d.ts โ umd/typings/src/conversion/utils/extractParameterNamesFromPromptTemplate.d.ts} +2 -2
- package/umd/typings/src/conversion/utils/extractParameterNamesFromPromptTemplate.test.d.ts +1 -0
- package/umd/typings/src/conversion/utils/renameParameter.d.ts +3 -3
- package/umd/typings/src/conversion/utils/stringifyPipelineJson.d.ts +14 -0
- package/umd/typings/src/conversion/utils/stringifyPipelineJson.test.d.ts +1 -0
- package/umd/typings/src/conversion/validation/_importPipeline.d.ts +12 -3
- package/umd/typings/src/conversion/validation/validatePipeline.d.ts +10 -1
- package/umd/typings/src/errors/EnvironmentMismatchError.d.ts +7 -0
- package/umd/typings/src/errors/LimitReachedError.d.ts +7 -0
- package/umd/typings/src/errors/VersionMismatchError.d.ts +8 -0
- package/umd/typings/src/execution/CommonExecutionToolsOptions.d.ts +1 -0
- package/umd/typings/src/execution/LlmExecutionTools.d.ts +10 -8
- package/umd/typings/src/execution/PipelineExecutor.d.ts +48 -26
- package/umd/typings/src/execution/PromptResult.d.ts +39 -54
- package/umd/typings/src/execution/PromptResultUsage.d.ts +29 -0
- package/umd/typings/src/execution/ScriptExecutionTools.d.ts +5 -4
- package/umd/typings/src/execution/UncertainNumber.d.ts +18 -0
- package/umd/typings/src/execution/UserInterfaceTools.d.ts +5 -5
- package/umd/typings/src/execution/createPipelineExecutor.d.ts +31 -3
- package/umd/typings/src/execution/translation/automatic-translate/automatic-translators/TranslatorOptions.d.ts +2 -2
- package/umd/typings/src/execution/utils/addUsage.d.ts +58 -2
- package/umd/typings/src/execution/utils/computeUsageCounts.d.ts +1 -1
- package/umd/typings/src/execution/utils/forEachAsync.d.ts +1 -1
- package/umd/typings/src/execution/utils/uncertainNumber.d.ts +1 -1
- package/umd/typings/src/execution/utils/usageToHuman.d.ts +15 -0
- package/umd/typings/src/execution/utils/usageToHuman.test.d.ts +1 -0
- package/umd/typings/src/execution/utils/usageToWorktime.d.ts +2 -2
- package/umd/typings/src/formats/_common/FormatDefinition.d.ts +1 -1
- package/umd/typings/src/formats/csv/ListFormatDefinition.d.ts +2 -1
- package/umd/typings/src/formats/json/JsonFormatDefinition.d.ts +2 -1
- package/umd/typings/src/formats/list/ListFormatDefinition.d.ts +2 -1
- package/umd/typings/src/formats/xml/XmlFormatDefinition.d.ts +1 -0
- package/umd/typings/src/knowledge/dialogs/callback/CallbackInterfaceToolsOptions.d.ts +1 -1
- package/umd/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +3 -0
- package/umd/typings/src/knowledge/prepare-knowledge/_common/Scraper.d.ts +27 -0
- package/umd/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.d.ts +18 -0
- package/umd/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.test.d.ts +1 -0
- package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +9 -23
- package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +3 -0
- package/umd/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +8 -14
- package/umd/typings/src/llm-providers/_common/createLlmToolsFromEnv.d.ts +31 -0
- package/umd/typings/src/llm-providers/_common/getLlmToolsForCli.d.ts +11 -0
- package/umd/typings/src/llm-providers/_common/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +12 -0
- package/umd/typings/src/llm-providers/_common/utils/cache/CacheItem.d.ts +29 -0
- package/umd/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +10 -0
- package/umd/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +19 -0
- package/umd/typings/src/llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts +14 -0
- package/umd/typings/src/llm-providers/_common/utils/count-total-usage/countTotalUsage.d.ts +17 -0
- package/umd/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +35 -0
- package/umd/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +4 -3
- package/umd/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
- package/umd/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +3 -3
- package/umd/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +3 -0
- package/umd/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +5 -4
- package/umd/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +5 -5
- package/umd/typings/src/llm-providers/azure-openai/playground/playground.d.ts +3 -0
- package/umd/typings/src/llm-providers/langtail/LangtailExecutionTools.d.ts +3 -0
- package/umd/typings/src/llm-providers/langtail/LangtailExecutionToolsOptions.d.ts +1 -1
- package/umd/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +5 -5
- package/umd/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +7 -7
- package/umd/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +12 -8
- package/umd/typings/src/llm-providers/multiple/joinLlmExecutionTools.d.ts +3 -0
- package/umd/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +7 -6
- package/umd/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +1 -1
- package/umd/typings/src/llm-providers/openai/computeOpenaiUsage.d.ts +1 -1
- package/umd/typings/src/llm-providers/openai/computeUsage.d.ts +2 -2
- package/umd/typings/src/llm-providers/openai/openai-models.d.ts +3 -2
- package/umd/typings/src/llm-providers/openai/playground/playground.d.ts +3 -0
- package/umd/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +10 -8
- package/umd/typings/src/llm-providers/remote/RemoteLlmExecutionToolsOptions.d.ts +1 -1
- package/umd/typings/src/llm-providers/remote/startRemoteServer.d.ts +2 -2
- package/umd/typings/src/personas/preparePersona.d.ts +15 -0
- package/umd/typings/src/personas/preparePersona.test.d.ts +1 -0
- package/umd/typings/src/prepare/PrepareOptions.d.ts +22 -0
- package/umd/typings/src/prepare/isPipelinePrepared.d.ts +14 -0
- package/umd/typings/src/prepare/isPipelinePrepared.test.d.ts +1 -0
- package/umd/typings/src/prepare/preparePipeline.d.ts +16 -0
- package/umd/typings/src/prepare/prepareTemplates.d.ts +31 -0
- package/umd/typings/src/prepare/unpreparePipeline.d.ts +11 -0
- package/umd/typings/src/scripting/javascript/JavascriptExecutionToolsOptions.d.ts +1 -1
- package/umd/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
- package/umd/typings/src/scripting/javascript/utils/unknownToString.d.ts +2 -1
- package/umd/typings/src/storage/_common/PromptbookStorage.d.ts +25 -0
- package/umd/typings/src/storage/_common/PromptbookStorage.test-type.d.ts +5 -0
- package/umd/typings/src/storage/files-storage/FilesStorage.d.ts +30 -0
- package/umd/typings/src/storage/files-storage/FilesStorageOptions.d.ts +13 -0
- package/umd/typings/src/storage/files-storage/utils/nameToSubfolderPath.d.ts +7 -0
- package/umd/typings/src/storage/files-storage/utils/nameToSubfolderPath.test.d.ts +1 -0
- package/umd/typings/src/storage/local-storage/getLocalStorage.d.ts +9 -0
- package/umd/typings/src/storage/local-storage/getSessionStorage.d.ts +9 -0
- package/umd/typings/src/storage/memory/MemoryStorage.d.ts +34 -0
- package/umd/typings/src/storage/utils/PrefixStorage.d.ts +26 -0
- package/umd/typings/src/storage/utils/makePromptbookStorageFromWebStorage.d.ts +11 -0
- package/umd/typings/src/types/ModelRequirements.d.ts +71 -11
- package/umd/typings/src/types/ModelVariant.d.ts +14 -0
- package/umd/typings/src/types/PipelineJson/Expectations.d.ts +6 -2
- package/umd/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +70 -0
- package/umd/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +27 -0
- package/umd/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +10 -1
- package/umd/typings/src/types/PipelineJson/PersonaJson.d.ts +41 -0
- package/umd/typings/src/types/PipelineJson/PipelineJson.d.ts +31 -5
- package/umd/typings/src/types/PipelineJson/PreparationJson.d.ts +22 -0
- package/umd/typings/src/types/PipelineJson/PromptDialogJson.d.ts +8 -2
- package/umd/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +5 -1
- package/umd/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +23 -4
- package/umd/typings/src/types/PipelineJson/PromptTemplateParameterJson.d.ts +12 -2
- package/umd/typings/src/types/PipelineJson/ScriptJson.d.ts +7 -2
- package/umd/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +7 -2
- package/umd/typings/src/types/PipelineString.d.ts +1 -1
- package/umd/typings/src/types/Prompt.d.ts +54 -10
- package/umd/typings/src/types/execution-report/ExecutionReportJson.d.ts +4 -4
- package/umd/typings/src/types/execution-report/ExecutionReportStringOptions.d.ts +3 -3
- package/umd/typings/src/types/execution-report/countWorkingDuration.d.ts +1 -1
- package/umd/typings/src/types/typeAliases.d.ts +114 -15
- package/umd/typings/src/utils/FromtoItems.d.ts +3 -3
- package/umd/typings/src/utils/currentDate.d.ts +7 -0
- package/umd/typings/src/utils/deepClone.d.ts +9 -0
- package/umd/typings/src/utils/deepFreeze.d.ts +22 -0
- package/umd/typings/src/utils/emojis.d.ts +2 -2
- package/umd/typings/src/utils/{extractParameters.d.ts โ extractParameterNames.d.ts} +2 -2
- package/umd/typings/src/utils/extractParameterNames.test.d.ts +1 -0
- package/umd/typings/src/utils/formatNumber.d.ts +1 -1
- package/umd/typings/src/utils/isRunningInWhatever.d.ts +3 -0
- package/umd/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +3 -3
- package/umd/typings/src/utils/markdown/createMarkdownChart.d.ts +7 -10
- package/umd/typings/src/utils/markdown/createMarkdownTable.d.ts +1 -1
- package/umd/typings/src/utils/markdown/extractAllBlocksFromMarkdown-real.test.d.ts +1 -0
- package/umd/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +9 -2
- package/umd/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +1 -1
- package/umd/typings/src/utils/markdown/parseMarkdownSection.d.ts +3 -3
- package/umd/typings/src/utils/normalization/parseKeywords.d.ts +2 -1
- package/umd/typings/src/utils/organization/TODO_USE.d.ts +12 -0
- package/umd/typings/src/utils/organization/TODO_any.d.ts +6 -0
- package/umd/typings/src/utils/organization/TODO_object.d.ts +6 -0
- package/umd/typings/src/utils/organization/TODO_unknown.d.ts +6 -0
- package/umd/typings/src/utils/organization/___.d.ts +6 -0
- package/{esm/typings/src/utils โ umd/typings/src/utils/organization}/just.d.ts +5 -1
- package/umd/typings/src/utils/organization/keepUnused.d.ts +16 -0
- package/umd/typings/src/utils/organization/really_any.d.ts +6 -0
- package/umd/typings/src/utils/organization/really_unknown.d.ts +6 -0
- package/umd/typings/src/utils/random/randomSeed.d.ts +7 -0
- package/umd/typings/src/{execution/utils โ utils}/replaceParameters.d.ts +2 -4
- package/umd/typings/src/utils/replaceParameters.test.d.ts +1 -0
- package/umd/typings/src/utils/sets/difference.d.ts +3 -0
- package/umd/typings/src/utils/validators/email/isValidEmail.d.ts +2 -1
- package/umd/typings/src/utils/validators/filePath/isValidFilePath.d.ts +2 -1
- package/umd/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +2 -1
- package/umd/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.d.ts +2 -1
- package/umd/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.d.ts +2 -1
- package/umd/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +2 -1
- package/umd/typings/src/utils/validators/url/isValidUrl.d.ts +2 -1
- package/umd/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -1
- package/esm/typings/src/collection/constructors/justTestFsImport.d.ts +0 -7
- package/esm/typings/src/personas/personaToModelRequirements.d.ts +0 -6
- package/esm/typings/src/types/Parameters.d.ts +0 -14
- package/esm/typings/src/types/PipelineJson/KnowledgeJson.d.ts +0 -6
- package/esm/typings/src/types/PipelineJson/MaterialKnowledgePieceJson.d.ts +0 -28
- package/umd/typings/src/collection/constructors/justTestFsImport.d.ts +0 -7
- package/umd/typings/src/personas/personaToModelRequirements.d.ts +0 -6
- package/umd/typings/src/types/Parameters.d.ts +0 -14
- package/umd/typings/src/types/PipelineJson/KnowledgeJson.d.ts +0 -6
- package/umd/typings/src/types/PipelineJson/MaterialKnowledgePieceJson.d.ts +0 -28
- /package/esm/typings/src/conversion/utils/{extractParametersFromPromptTemplate.test.d.ts โ extractParameterNamesFromPromptTemplate.test.d.ts} +0 -0
- /package/esm/typings/src/{execution/addPromptResultUsage.test.d.ts โ conversion/utils/stringifyPipelineJson.test.d.ts} +0 -0
- /package/esm/typings/src/execution/utils/{replaceParameters.test.d.ts โ usageToHuman.test.d.ts} +0 -0
- /package/esm/typings/src/{utils/extractParameters.test.d.ts โ knowledge/prepare-knowledge/_common/prepareKnowledgePieces.test.d.ts} +0 -0
- /package/{umd/typings/src/conversion/utils/extractParametersFromPromptTemplate.test.d.ts โ esm/typings/src/personas/preparePersona.test.d.ts} +0 -0
- /package/esm/typings/src/{utils/postprocessing โ postprocessing/utils}/extractBlock.d.ts +0 -0
- /package/{umd/typings/src/execution/addPromptResultUsage.test.d.ts โ esm/typings/src/prepare/isPipelinePrepared.test.d.ts} +0 -0
- /package/{umd/typings/src/execution/utils/replaceParameters.test.d.ts โ esm/typings/src/storage/files-storage/utils/nameToSubfolderPath.test.d.ts} +0 -0
- /package/{umd/typings/src/utils/extractParameters.test.d.ts โ esm/typings/src/utils/extractParameterNames.test.d.ts} +0 -0
- /package/umd/typings/src/{utils/postprocessing โ postprocessing/utils}/extractBlock.d.ts +0 -0
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ import { OpenAiExecutionTools } from '@promptbook/openai';
|
|
|
43
43
|
const collection = await createCollectionFromDirectory('./promptbook-collection');
|
|
44
44
|
|
|
45
45
|
// โถ Get single Pipeline
|
|
46
|
-
const pipeline = await
|
|
46
|
+
const pipeline = await collection.getPipelineByUrl(`https://promptbook.studio/my-collection/write-article.ptbk.md`);
|
|
47
47
|
|
|
48
48
|
// โถ Prepare tools
|
|
49
49
|
const tools = {
|
|
@@ -71,6 +71,45 @@ const { isSuccessful, errors, outputParameters, executionReport } = result;
|
|
|
71
71
|
console.info(outputParameters);
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
+
## ๐งโโ๏ธ Connect to LLM providers automatically
|
|
75
|
+
|
|
76
|
+
You can just use `createLlmToolsFromEnv` function to create LLM tools from environment variables like `OPENAI_API_KEY` and `ANTHROPIC_CLAUDE_API_KEY` automatically.
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import { createPipelineExecutor, createCollectionFromDirectory, assertsExecutionSuccessful } from '@promptbook/core';
|
|
80
|
+
import { JavascriptExecutionTools } from '@promptbook/execute-javascript';
|
|
81
|
+
import { createLlmToolsFromEnv } from '@promptbook/node';
|
|
82
|
+
|
|
83
|
+
// โถ Create whole pipeline collection
|
|
84
|
+
const collection = await createCollectionFromDirectory('./promptbook-collection');
|
|
85
|
+
|
|
86
|
+
// โถ Get single Pipeline
|
|
87
|
+
const pipeline = await collection.getPipelineByUrl(`https://promptbook.studio/my-collection/write-article.ptbk.md`);
|
|
88
|
+
|
|
89
|
+
// โถ Prepare multiple tools
|
|
90
|
+
const tools = {
|
|
91
|
+
// Note: ๐งโโ๏ธ Just call `createLlmToolsFromEnv` to automatically connect to all configured providers
|
|
92
|
+
llm: createLlmToolsFromEnv(),
|
|
93
|
+
script: [new JavascriptExecutionTools()],
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// โถ Create executor - the function that will execute the Pipeline
|
|
97
|
+
const pipelineExecutor = createPipelineExecutor({ pipeline, tools });
|
|
98
|
+
|
|
99
|
+
// โถ Prepare input parameters
|
|
100
|
+
const inputParameters = { word: 'dog' };
|
|
101
|
+
|
|
102
|
+
// ๐โถ Execute the Pipeline
|
|
103
|
+
const result = await pipelineExecutor(inputParameters);
|
|
104
|
+
|
|
105
|
+
// โถ Fail if the execution was not successful
|
|
106
|
+
assertsExecutionSuccessful(result);
|
|
107
|
+
|
|
108
|
+
// โถ Handle the result
|
|
109
|
+
const { isSuccessful, errors, outputParameters, executionReport } = result;
|
|
110
|
+
console.info(outputParameters);
|
|
111
|
+
```
|
|
112
|
+
|
|
74
113
|
## ๐ Usage of multiple LLM providers
|
|
75
114
|
|
|
76
115
|
You can use multiple LLM providers in one Promptbook execution. The best model will be chosen automatically according to the prompt and the model's capabilities.
|
|
@@ -80,12 +119,14 @@ import { createPipelineExecutor, assertsExecutionSuccessful } from '@promptbook/
|
|
|
80
119
|
import { createCollectionFromDirectory } from '@promptbook/node';
|
|
81
120
|
import { JavascriptExecutionTools } from '@promptbook/execute-javascript';
|
|
82
121
|
import { OpenAiExecutionTools } from '@promptbook/openai';
|
|
122
|
+
import { AnthropicClaudeExecutionTools } from '@promptbook/anthropic-claude';
|
|
123
|
+
import { AzureOpenAiExecutionTools } from '@promptbook/azure-openai';
|
|
83
124
|
|
|
84
125
|
// โถ Create whole pipeline collection
|
|
85
126
|
const collection = await createCollectionFromDirectory('./promptbook-collection');
|
|
86
127
|
|
|
87
128
|
// โถ Get single Pipeline
|
|
88
|
-
const pipeline = await
|
|
129
|
+
const pipeline = await collection.getPipelineByUrl(`https://promptbook.studio/my-collection/write-article.ptbk.md`);
|
|
89
130
|
|
|
90
131
|
// โถ Prepare multiple tools
|
|
91
132
|
const tools = {
|
|
@@ -186,7 +227,7 @@ File `write-website-content.ptbk.md`:
|
|
|
186
227
|
> - PROMPTBOOK VERSION 0.0.1
|
|
187
228
|
> - INPUTโฏโฏPARAM `{rawTitle}` Automatically suggested a site name or empty text
|
|
188
229
|
> - INPUTโฏโฏPARAM `{rawAssigment}` Automatically generated site entry from image recognition
|
|
189
|
-
> - OUTPUTโฏPARAM `{
|
|
230
|
+
> - OUTPUTโฏPARAM `{websiteContent}` Web content
|
|
190
231
|
> - OUTPUTโฏPARAM `{keywords}` Keywords
|
|
191
232
|
>
|
|
192
233
|
> ## ๐ค Specifying the assigment
|
|
@@ -345,7 +386,7 @@ File `write-website-content.ptbk.md`:
|
|
|
345
386
|
> {contentBody}
|
|
346
387
|
> ```
|
|
347
388
|
>
|
|
348
|
-
> `-> {
|
|
389
|
+
> `-> {websiteContent}`
|
|
349
390
|
|
|
350
391
|
|
|
351
392
|
|
|
@@ -385,7 +426,7 @@ flowchart LR
|
|
|
385
426
|
templateCombineTheBeginning--"{contentBeginning}"-->templateCombineTheContent
|
|
386
427
|
templateWriteTheContent--"{contentBody}"-->templateCombineTheContent
|
|
387
428
|
|
|
388
|
-
templateCombineTheContent--"{
|
|
429
|
+
templateCombineTheContent--"{websiteContent}"-->output
|
|
389
430
|
output((Output)):::output
|
|
390
431
|
|
|
391
432
|
classDef input color: grey;
|
package/esm/index.es.js
CHANGED
|
@@ -82,6 +82,18 @@ function __generator(thisArg, body) {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
function __values(o) {
|
|
86
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
87
|
+
if (m) return m.call(o);
|
|
88
|
+
if (o && typeof o.length === "number") return {
|
|
89
|
+
next: function () {
|
|
90
|
+
if (o && i >= o.length) o = void 0;
|
|
91
|
+
return { value: o && o[i++], done: !o };
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
95
|
+
}
|
|
96
|
+
|
|
85
97
|
function __read(o, n) {
|
|
86
98
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
87
99
|
if (!m) return o;
|
|
@@ -97,12 +109,22 @@ function __read(o, n) {
|
|
|
97
109
|
finally { if (e) throw e.error; }
|
|
98
110
|
}
|
|
99
111
|
return ar;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function __spreadArray(to, from, pack) {
|
|
115
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
116
|
+
if (ar || !(i in from)) {
|
|
117
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
118
|
+
ar[i] = from[i];
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
100
122
|
}
|
|
101
123
|
|
|
102
124
|
/**
|
|
103
125
|
* Function computeUsage will create price per one token based on the string value found on openai page
|
|
104
126
|
*
|
|
105
|
-
* @private within the
|
|
127
|
+
* @private within the repository, used only as internal helper for `OPENAI_MODELS`
|
|
106
128
|
*/
|
|
107
129
|
function computeUsage(value) {
|
|
108
130
|
var _a = __read(value.split(' / '), 2), price = _a[0], tokens = _a[1];
|
|
@@ -456,6 +478,7 @@ var OPENAI_MODELS = [
|
|
|
456
478
|
* @see /other/playground/playground.ts
|
|
457
479
|
* TODO: [๐] Make better
|
|
458
480
|
* TODO: Change model titles to human eg: "gpt-4-turbo-2024-04-09" -> "GPT-4 Turbo (2024-04-09)"
|
|
481
|
+
* TODO: [๐ธ] Not all models are compatible with JSON mode, add this information here and use it
|
|
459
482
|
*/
|
|
460
483
|
|
|
461
484
|
/**
|
|
@@ -495,6 +518,168 @@ function getCurrentIsoDate() {
|
|
|
495
518
|
return new Date().toISOString();
|
|
496
519
|
}
|
|
497
520
|
|
|
521
|
+
/**
|
|
522
|
+
* @@@
|
|
523
|
+
*
|
|
524
|
+
* @returns The same object as the input, but deeply frozen
|
|
525
|
+
*
|
|
526
|
+
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
527
|
+
*/
|
|
528
|
+
function deepFreeze(objectValue) {
|
|
529
|
+
var e_1, _a;
|
|
530
|
+
var propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
531
|
+
try {
|
|
532
|
+
for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
|
|
533
|
+
var propertyName = propertyNames_1_1.value;
|
|
534
|
+
var value = objectValue[propertyName];
|
|
535
|
+
if (value && typeof value === 'object') {
|
|
536
|
+
deepFreeze(value);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
541
|
+
finally {
|
|
542
|
+
try {
|
|
543
|
+
if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
|
|
544
|
+
}
|
|
545
|
+
finally { if (e_1) throw e_1.error; }
|
|
546
|
+
}
|
|
547
|
+
return Object.freeze(objectValue);
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* TODO: [๐ผ] Export from `@promptbook/utils`
|
|
551
|
+
* TODO: [๐ง ] Is there a way how to meaningfully test this utility
|
|
552
|
+
*/
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* The maximum number of iterations for a loops
|
|
556
|
+
*/
|
|
557
|
+
var LOOP_LIMIT = 1000;
|
|
558
|
+
/**
|
|
559
|
+
* Nonce which is used for replacing things in strings
|
|
560
|
+
*/
|
|
561
|
+
var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
|
|
562
|
+
/**
|
|
563
|
+
* The names of the parameters that are reserved for special purposes
|
|
564
|
+
*/
|
|
565
|
+
deepFreeze([
|
|
566
|
+
'content',
|
|
567
|
+
'context',
|
|
568
|
+
'knowledge',
|
|
569
|
+
'samples',
|
|
570
|
+
'modelName',
|
|
571
|
+
'currentDate',
|
|
572
|
+
// <- TODO: Add more like 'date', 'modelName',...
|
|
573
|
+
// <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
|
|
574
|
+
]);
|
|
575
|
+
/**
|
|
576
|
+
* @@@
|
|
577
|
+
*/
|
|
578
|
+
var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
|
|
579
|
+
/**
|
|
580
|
+
* @@@
|
|
581
|
+
*/
|
|
582
|
+
var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
|
|
583
|
+
/*
|
|
584
|
+
TODO: !!! Just testing false-negative detection of [๐ก][๐ข][๐ต][โช] leak
|
|
585
|
+
*/
|
|
586
|
+
// [๐ก][๐ข][๐ต][โช]
|
|
587
|
+
/**
|
|
588
|
+
* TODO: [๐ผ] Export all to core
|
|
589
|
+
*/
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* This error type indicates that some limit was reached
|
|
593
|
+
*/
|
|
594
|
+
var LimitReachedError = /** @class */ (function (_super) {
|
|
595
|
+
__extends(LimitReachedError, _super);
|
|
596
|
+
function LimitReachedError(message) {
|
|
597
|
+
var _this = _super.call(this, message) || this;
|
|
598
|
+
_this.name = 'LimitReachedError';
|
|
599
|
+
Object.setPrototypeOf(_this, LimitReachedError.prototype);
|
|
600
|
+
return _this;
|
|
601
|
+
}
|
|
602
|
+
return LimitReachedError;
|
|
603
|
+
}(Error));
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Replaces parameters in template with values from parameters object
|
|
607
|
+
*
|
|
608
|
+
* @param template the template with parameters in {curly} braces
|
|
609
|
+
* @param parameters the object with parameters
|
|
610
|
+
* @returns the template with replaced parameters
|
|
611
|
+
* @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
|
|
612
|
+
*/
|
|
613
|
+
function replaceParameters(template, parameters) {
|
|
614
|
+
var e_1, _a;
|
|
615
|
+
try {
|
|
616
|
+
for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
617
|
+
var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
|
|
618
|
+
if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
|
|
619
|
+
throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
|
|
620
|
+
}
|
|
621
|
+
else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
|
|
622
|
+
// TODO: [๐ต]
|
|
623
|
+
throw new UnexpectedError("Parameter {".concat(parameterName, "} is restricted to use"));
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
628
|
+
finally {
|
|
629
|
+
try {
|
|
630
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
631
|
+
}
|
|
632
|
+
finally { if (e_1) throw e_1.error; }
|
|
633
|
+
}
|
|
634
|
+
var replacedTemplate = template;
|
|
635
|
+
var match;
|
|
636
|
+
var loopLimit = LOOP_LIMIT;
|
|
637
|
+
var _loop_1 = function () {
|
|
638
|
+
if (loopLimit-- < 0) {
|
|
639
|
+
throw new LimitReachedError('Loop limit reached during parameters replacement in `replaceParameters`');
|
|
640
|
+
}
|
|
641
|
+
var precol = match.groups.precol;
|
|
642
|
+
var parameterName = match.groups.parameterName;
|
|
643
|
+
if (parameterName === '') {
|
|
644
|
+
return "continue";
|
|
645
|
+
}
|
|
646
|
+
if (parameterName.indexOf('{') !== -1 || parameterName.indexOf('}') !== -1) {
|
|
647
|
+
throw new PipelineExecutionError('Parameter is already opened or not closed');
|
|
648
|
+
}
|
|
649
|
+
if (parameters[parameterName] === undefined) {
|
|
650
|
+
throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
|
|
651
|
+
}
|
|
652
|
+
var parameterValue = parameters[parameterName];
|
|
653
|
+
if (parameterValue === undefined) {
|
|
654
|
+
throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
|
|
655
|
+
}
|
|
656
|
+
parameterValue = parameterValue.toString();
|
|
657
|
+
if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
|
|
658
|
+
parameterValue = parameterValue
|
|
659
|
+
.split('\n')
|
|
660
|
+
.map(function (line, index) { return (index === 0 ? line : "".concat(precol).concat(line)); })
|
|
661
|
+
.join('\n');
|
|
662
|
+
}
|
|
663
|
+
replacedTemplate =
|
|
664
|
+
replacedTemplate.substring(0, match.index + precol.length) +
|
|
665
|
+
parameterValue +
|
|
666
|
+
replacedTemplate.substring(match.index + precol.length + parameterName.length + 2);
|
|
667
|
+
};
|
|
668
|
+
while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
|
|
669
|
+
.exec(replacedTemplate))) {
|
|
670
|
+
_loop_1();
|
|
671
|
+
}
|
|
672
|
+
// [๐ซ] Check if there are parameters that are not closed properly
|
|
673
|
+
if (/{\w+$/.test(replacedTemplate)) {
|
|
674
|
+
throw new PipelineExecutionError('Parameter is not closed');
|
|
675
|
+
}
|
|
676
|
+
// [๐ซ] Check if there are parameters that are not opened properly
|
|
677
|
+
if (/^\w+}/.test(replacedTemplate)) {
|
|
678
|
+
throw new PipelineExecutionError('Parameter is not opened');
|
|
679
|
+
}
|
|
680
|
+
return replacedTemplate;
|
|
681
|
+
}
|
|
682
|
+
|
|
498
683
|
/**
|
|
499
684
|
* Counts number of characters in the text
|
|
500
685
|
*/
|
|
@@ -914,35 +1099,46 @@ var OpenAiExecutionTools = /** @class */ (function () {
|
|
|
914
1099
|
*/
|
|
915
1100
|
OpenAiExecutionTools.prototype.callChatModel = function (prompt) {
|
|
916
1101
|
return __awaiter(this, void 0, void 0, function () {
|
|
917
|
-
var content, modelRequirements, expectFormat,
|
|
1102
|
+
var content, parameters, modelRequirements, expectFormat, modelName, modelSettings, rawPromptContent, rawRequest, start, complete, rawResponse, resultContent, usage;
|
|
918
1103
|
return __generator(this, function (_a) {
|
|
919
1104
|
switch (_a.label) {
|
|
920
1105
|
case 0:
|
|
921
1106
|
if (this.options.isVerbose) {
|
|
922
1107
|
console.info('๐ฌ OpenAI callChatModel call', { prompt: prompt });
|
|
923
1108
|
}
|
|
924
|
-
content = prompt.content, modelRequirements = prompt.modelRequirements, expectFormat = prompt.expectFormat;
|
|
1109
|
+
content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements, expectFormat = prompt.expectFormat;
|
|
925
1110
|
// TODO: [โ] Use here more modelRequirements
|
|
926
1111
|
if (modelRequirements.modelVariant !== 'CHAT') {
|
|
927
1112
|
throw new PipelineExecutionError('Use callChatModel only for CHAT variant');
|
|
928
1113
|
}
|
|
929
|
-
|
|
1114
|
+
modelName = modelRequirements.modelName || this.getDefaultChatModel().modelName;
|
|
930
1115
|
modelSettings = {
|
|
931
|
-
model:
|
|
1116
|
+
model: modelName,
|
|
932
1117
|
max_tokens: modelRequirements.maxTokens,
|
|
933
|
-
// <- TODO: Make some global max cap for maxTokens
|
|
1118
|
+
// <- TODO: [๐พ] Make some global max cap for maxTokens
|
|
1119
|
+
temperature: modelRequirements.temperature,
|
|
1120
|
+
// <- TODO: [๐] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
|
|
1121
|
+
// <- Note: [๐ง]
|
|
934
1122
|
};
|
|
935
1123
|
if (expectFormat === 'JSON') {
|
|
936
1124
|
modelSettings.response_format = {
|
|
937
1125
|
type: 'json_object',
|
|
938
1126
|
};
|
|
939
1127
|
}
|
|
940
|
-
|
|
1128
|
+
rawPromptContent = replaceParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
|
|
1129
|
+
rawRequest = __assign(__assign({}, modelSettings), { messages: __spreadArray(__spreadArray([], __read((modelRequirements.systemMessage === undefined
|
|
1130
|
+
? []
|
|
1131
|
+
: [
|
|
1132
|
+
{
|
|
1133
|
+
role: 'system',
|
|
1134
|
+
content: modelRequirements.systemMessage,
|
|
1135
|
+
},
|
|
1136
|
+
])), false), [
|
|
941
1137
|
{
|
|
942
1138
|
role: 'user',
|
|
943
|
-
content:
|
|
1139
|
+
content: rawPromptContent,
|
|
944
1140
|
},
|
|
945
|
-
], user: this.options.user });
|
|
1141
|
+
], false), user: this.options.user });
|
|
946
1142
|
start = getCurrentIsoDate();
|
|
947
1143
|
if (this.options.isVerbose) {
|
|
948
1144
|
console.info(colors.bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
|
@@ -969,14 +1165,16 @@ var OpenAiExecutionTools = /** @class */ (function () {
|
|
|
969
1165
|
}
|
|
970
1166
|
return [2 /*return*/, {
|
|
971
1167
|
content: resultContent,
|
|
972
|
-
modelName: rawResponse.model ||
|
|
1168
|
+
modelName: rawResponse.model || modelName,
|
|
973
1169
|
timing: {
|
|
974
1170
|
start: start,
|
|
975
1171
|
complete: complete,
|
|
976
1172
|
},
|
|
977
1173
|
usage: usage,
|
|
1174
|
+
rawPromptContent: rawPromptContent,
|
|
1175
|
+
rawRequest: rawRequest,
|
|
978
1176
|
rawResponse: rawResponse,
|
|
979
|
-
// <- [
|
|
1177
|
+
// <- [๐ฏ]
|
|
980
1178
|
}];
|
|
981
1179
|
}
|
|
982
1180
|
});
|
|
@@ -987,25 +1185,29 @@ var OpenAiExecutionTools = /** @class */ (function () {
|
|
|
987
1185
|
*/
|
|
988
1186
|
OpenAiExecutionTools.prototype.callCompletionModel = function (prompt) {
|
|
989
1187
|
return __awaiter(this, void 0, void 0, function () {
|
|
990
|
-
var content, modelRequirements,
|
|
1188
|
+
var content, parameters, modelRequirements, modelName, modelSettings, rawPromptContent, rawRequest, start, complete, rawResponse, resultContent, usage;
|
|
991
1189
|
return __generator(this, function (_a) {
|
|
992
1190
|
switch (_a.label) {
|
|
993
1191
|
case 0:
|
|
994
1192
|
if (this.options.isVerbose) {
|
|
995
1193
|
console.info('๐ OpenAI callCompletionModel call', { prompt: prompt });
|
|
996
1194
|
}
|
|
997
|
-
content = prompt.content, modelRequirements = prompt.modelRequirements;
|
|
1195
|
+
content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements;
|
|
998
1196
|
// TODO: [โ] Use here more modelRequirements
|
|
999
1197
|
if (modelRequirements.modelVariant !== 'COMPLETION') {
|
|
1000
1198
|
throw new PipelineExecutionError('Use callCompletionModel only for COMPLETION variant');
|
|
1001
1199
|
}
|
|
1002
|
-
|
|
1200
|
+
modelName = modelRequirements.modelName || this.getDefaultCompletionModel().modelName;
|
|
1003
1201
|
modelSettings = {
|
|
1004
|
-
model:
|
|
1005
|
-
max_tokens: modelRequirements.maxTokens || 2000,
|
|
1006
|
-
// <- TODO: Make some global max cap for maxTokens
|
|
1202
|
+
model: modelName,
|
|
1203
|
+
max_tokens: modelRequirements.maxTokens || 2000,
|
|
1204
|
+
// <- TODO: [๐พ] Make some global max cap for maxTokens
|
|
1205
|
+
temperature: modelRequirements.temperature,
|
|
1206
|
+
// <- TODO: [๐] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
|
|
1207
|
+
// <- Note: [๐ง]
|
|
1007
1208
|
};
|
|
1008
|
-
|
|
1209
|
+
rawPromptContent = replaceParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
|
|
1210
|
+
rawRequest = __assign(__assign({}, modelSettings), { prompt: rawPromptContent, user: this.options.user });
|
|
1009
1211
|
start = getCurrentIsoDate();
|
|
1010
1212
|
if (this.options.isVerbose) {
|
|
1011
1213
|
console.info(colors.bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
|
@@ -1029,14 +1231,16 @@ var OpenAiExecutionTools = /** @class */ (function () {
|
|
|
1029
1231
|
usage = computeOpenaiUsage(content, resultContent || '', rawResponse);
|
|
1030
1232
|
return [2 /*return*/, {
|
|
1031
1233
|
content: resultContent,
|
|
1032
|
-
modelName: rawResponse.model ||
|
|
1234
|
+
modelName: rawResponse.model || modelName,
|
|
1033
1235
|
timing: {
|
|
1034
1236
|
start: start,
|
|
1035
1237
|
complete: complete,
|
|
1036
1238
|
},
|
|
1037
1239
|
usage: usage,
|
|
1240
|
+
rawPromptContent: rawPromptContent,
|
|
1241
|
+
rawRequest: rawRequest,
|
|
1038
1242
|
rawResponse: rawResponse,
|
|
1039
|
-
// <- [
|
|
1243
|
+
// <- [๐ฏ]
|
|
1040
1244
|
}];
|
|
1041
1245
|
}
|
|
1042
1246
|
});
|
|
@@ -1047,23 +1251,23 @@ var OpenAiExecutionTools = /** @class */ (function () {
|
|
|
1047
1251
|
*/
|
|
1048
1252
|
OpenAiExecutionTools.prototype.callEmbeddingModel = function (prompt) {
|
|
1049
1253
|
return __awaiter(this, void 0, void 0, function () {
|
|
1050
|
-
var content, modelRequirements,
|
|
1254
|
+
var content, parameters, modelRequirements, modelName, rawPromptContent, rawRequest, start, complete, rawResponse, resultContent, usage;
|
|
1051
1255
|
return __generator(this, function (_a) {
|
|
1052
1256
|
switch (_a.label) {
|
|
1053
1257
|
case 0:
|
|
1054
1258
|
if (this.options.isVerbose) {
|
|
1055
1259
|
console.info('๐ OpenAI embedding call', { prompt: prompt });
|
|
1056
1260
|
}
|
|
1057
|
-
content = prompt.content, modelRequirements = prompt.modelRequirements;
|
|
1261
|
+
content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements;
|
|
1058
1262
|
// TODO: [โ] Use here more modelRequirements
|
|
1059
1263
|
if (modelRequirements.modelVariant !== 'EMBEDDING') {
|
|
1060
1264
|
throw new PipelineExecutionError('Use embed only for EMBEDDING variant');
|
|
1061
1265
|
}
|
|
1062
|
-
|
|
1266
|
+
modelName = modelRequirements.modelName || this.getDefaultEmbeddingModel().modelName;
|
|
1267
|
+
rawPromptContent = replaceParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
|
|
1063
1268
|
rawRequest = {
|
|
1064
|
-
input:
|
|
1065
|
-
model:
|
|
1066
|
-
// TODO: !!!! Test model 3 and dimensions
|
|
1269
|
+
input: rawPromptContent,
|
|
1270
|
+
model: modelName,
|
|
1067
1271
|
};
|
|
1068
1272
|
start = getCurrentIsoDate();
|
|
1069
1273
|
if (this.options.isVerbose) {
|
|
@@ -1084,14 +1288,16 @@ var OpenAiExecutionTools = /** @class */ (function () {
|
|
|
1084
1288
|
usage = computeOpenaiUsage(content, '', rawResponse);
|
|
1085
1289
|
return [2 /*return*/, {
|
|
1086
1290
|
content: resultContent,
|
|
1087
|
-
modelName: rawResponse.model ||
|
|
1291
|
+
modelName: rawResponse.model || modelName,
|
|
1088
1292
|
timing: {
|
|
1089
1293
|
start: start,
|
|
1090
1294
|
complete: complete,
|
|
1091
1295
|
},
|
|
1092
1296
|
usage: usage,
|
|
1297
|
+
rawPromptContent: rawPromptContent,
|
|
1298
|
+
rawRequest: rawRequest,
|
|
1093
1299
|
rawResponse: rawResponse,
|
|
1094
|
-
// <- [
|
|
1300
|
+
// <- [๐ฏ]
|
|
1095
1301
|
}];
|
|
1096
1302
|
}
|
|
1097
1303
|
});
|
|
@@ -1108,9 +1314,9 @@ var OpenAiExecutionTools = /** @class */ (function () {
|
|
|
1108
1314
|
});
|
|
1109
1315
|
if (model === undefined) {
|
|
1110
1316
|
throw new UnexpectedError(spaceTrim$1(function (block) {
|
|
1111
|
-
return "\n Cannot find model in OpenAI models with name ".concat(defaultModelName, " which should be used as default.\n\n Available models:\n ").concat(block(OPENAI_MODELS.map(function (_a) {
|
|
1317
|
+
return "\n Cannot find model in OpenAI models with name \"".concat(defaultModelName, "\" which should be used as default.\n\n Available models:\n ").concat(block(OPENAI_MODELS.map(function (_a) {
|
|
1112
1318
|
var modelName = _a.modelName;
|
|
1113
|
-
return "- ".concat(modelName);
|
|
1319
|
+
return "- \"".concat(modelName, "\"");
|
|
1114
1320
|
}).join('\n')), "\n\n ");
|
|
1115
1321
|
}));
|
|
1116
1322
|
}
|
|
@@ -1154,12 +1360,13 @@ var OpenAiExecutionTools = /** @class */ (function () {
|
|
|
1154
1360
|
* TODO: [๐ง ][๐งโโ๏ธ] Maybe there can be some wizzard for thoose who want to use just OpenAI
|
|
1155
1361
|
* TODO: Maybe Create some common util for callChatModel and callCompletionModel
|
|
1156
1362
|
* TODO: Maybe make custom OpenaiError
|
|
1363
|
+
* TODO: [๐ง ][๐] Maybe use `isDeterministic` from options
|
|
1157
1364
|
*/
|
|
1158
1365
|
|
|
1159
1366
|
/**
|
|
1160
1367
|
* The version of the Promptbook library
|
|
1161
1368
|
*/
|
|
1162
|
-
var PROMPTBOOK_VERSION = '0.61.0
|
|
1369
|
+
var PROMPTBOOK_VERSION = '0.61.0';
|
|
1163
1370
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
1164
1371
|
|
|
1165
1372
|
export { OPENAI_MODELS, OpenAiExecutionTools, PROMPTBOOK_VERSION };
|