@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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { string_url } from '../../../types/typeAliases';
|
|
2
|
+
import type { really_unknown } from '../../organization/really_unknown';
|
|
2
3
|
/**
|
|
3
4
|
* Tests if given string is valid URL.
|
|
4
5
|
*
|
|
@@ -7,4 +8,4 @@ import type { string_url } from '../../../types/typeAliases';
|
|
|
7
8
|
* - `isValidUrl` which tests any URL
|
|
8
9
|
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
9
10
|
*/
|
|
10
|
-
export declare function isValidUrl(url:
|
|
11
|
+
export declare function isValidUrl(url: really_unknown): url is string_url;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { string_uuid } from '../../../types/typeAliases';
|
|
2
|
+
import type { really_unknown } from '../../organization/really_unknown';
|
|
2
3
|
/**
|
|
3
4
|
* Checks if value is valid uuid
|
|
4
5
|
*/
|
|
5
|
-
export declare function isValidUuid(value:
|
|
6
|
+
export declare function isValidUuid(value: really_unknown): value is string_uuid;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/openai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.62.0-0",
|
|
4
4
|
"description": "Supercharge your use of large language models",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"colors": "1.4.0",
|
|
38
38
|
"openai": "4.46.1",
|
|
39
|
-
"spacetrim": "0.11.
|
|
39
|
+
"spacetrim": "0.11.39"
|
|
40
40
|
},
|
|
41
41
|
"funding": [
|
|
42
42
|
{
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
}
|
|
50
50
|
],
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@promptbook/core": "0.
|
|
52
|
+
"@promptbook/core": "0.62.0-0"
|
|
53
53
|
},
|
|
54
54
|
"main": "./umd/index.umd.js",
|
|
55
55
|
"module": "./esm/index.es.js",
|
package/umd/index.umd.js
CHANGED
|
@@ -90,6 +90,18 @@
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
function __values(o) {
|
|
94
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
95
|
+
if (m) return m.call(o);
|
|
96
|
+
if (o && typeof o.length === "number") return {
|
|
97
|
+
next: function () {
|
|
98
|
+
if (o && i >= o.length) o = void 0;
|
|
99
|
+
return { value: o && o[i++], done: !o };
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
103
|
+
}
|
|
104
|
+
|
|
93
105
|
function __read(o, n) {
|
|
94
106
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
95
107
|
if (!m) return o;
|
|
@@ -105,12 +117,22 @@
|
|
|
105
117
|
finally { if (e) throw e.error; }
|
|
106
118
|
}
|
|
107
119
|
return ar;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function __spreadArray(to, from, pack) {
|
|
123
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
124
|
+
if (ar || !(i in from)) {
|
|
125
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
126
|
+
ar[i] = from[i];
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
108
130
|
}
|
|
109
131
|
|
|
110
132
|
/**
|
|
111
133
|
* Function computeUsage will create price per one token based on the string value found on openai page
|
|
112
134
|
*
|
|
113
|
-
* @private within the
|
|
135
|
+
* @private within the repository, used only as internal helper for `OPENAI_MODELS`
|
|
114
136
|
*/
|
|
115
137
|
function computeUsage(value) {
|
|
116
138
|
var _a = __read(value.split(' / '), 2), price = _a[0], tokens = _a[1];
|
|
@@ -464,6 +486,7 @@
|
|
|
464
486
|
* @see /other/playground/playground.ts
|
|
465
487
|
* TODO: [๐] Make better
|
|
466
488
|
* TODO: Change model titles to human eg: "gpt-4-turbo-2024-04-09" -> "GPT-4 Turbo (2024-04-09)"
|
|
489
|
+
* TODO: [๐ธ] Not all models are compatible with JSON mode, add this information here and use it
|
|
467
490
|
*/
|
|
468
491
|
|
|
469
492
|
/**
|
|
@@ -503,6 +526,168 @@
|
|
|
503
526
|
return new Date().toISOString();
|
|
504
527
|
}
|
|
505
528
|
|
|
529
|
+
/**
|
|
530
|
+
* @@@
|
|
531
|
+
*
|
|
532
|
+
* @returns The same object as the input, but deeply frozen
|
|
533
|
+
*
|
|
534
|
+
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
535
|
+
*/
|
|
536
|
+
function deepFreeze(objectValue) {
|
|
537
|
+
var e_1, _a;
|
|
538
|
+
var propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
539
|
+
try {
|
|
540
|
+
for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
|
|
541
|
+
var propertyName = propertyNames_1_1.value;
|
|
542
|
+
var value = objectValue[propertyName];
|
|
543
|
+
if (value && typeof value === 'object') {
|
|
544
|
+
deepFreeze(value);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
549
|
+
finally {
|
|
550
|
+
try {
|
|
551
|
+
if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
|
|
552
|
+
}
|
|
553
|
+
finally { if (e_1) throw e_1.error; }
|
|
554
|
+
}
|
|
555
|
+
return Object.freeze(objectValue);
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* TODO: [๐ผ] Export from `@promptbook/utils`
|
|
559
|
+
* TODO: [๐ง ] Is there a way how to meaningfully test this utility
|
|
560
|
+
*/
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* The maximum number of iterations for a loops
|
|
564
|
+
*/
|
|
565
|
+
var LOOP_LIMIT = 1000;
|
|
566
|
+
/**
|
|
567
|
+
* Nonce which is used for replacing things in strings
|
|
568
|
+
*/
|
|
569
|
+
var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
|
|
570
|
+
/**
|
|
571
|
+
* The names of the parameters that are reserved for special purposes
|
|
572
|
+
*/
|
|
573
|
+
deepFreeze([
|
|
574
|
+
'content',
|
|
575
|
+
'context',
|
|
576
|
+
'knowledge',
|
|
577
|
+
'samples',
|
|
578
|
+
'modelName',
|
|
579
|
+
'currentDate',
|
|
580
|
+
// <- TODO: Add more like 'date', 'modelName',...
|
|
581
|
+
// <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
|
|
582
|
+
]);
|
|
583
|
+
/**
|
|
584
|
+
* @@@
|
|
585
|
+
*/
|
|
586
|
+
var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
|
|
587
|
+
/**
|
|
588
|
+
* @@@
|
|
589
|
+
*/
|
|
590
|
+
var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
|
|
591
|
+
/*
|
|
592
|
+
TODO: !!! Just testing false-negative detection of [๐ก][๐ข][๐ต][โช] leak
|
|
593
|
+
*/
|
|
594
|
+
// [๐ก][๐ข][๐ต][โช]
|
|
595
|
+
/**
|
|
596
|
+
* TODO: [๐ผ] Export all to core
|
|
597
|
+
*/
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* This error type indicates that some limit was reached
|
|
601
|
+
*/
|
|
602
|
+
var LimitReachedError = /** @class */ (function (_super) {
|
|
603
|
+
__extends(LimitReachedError, _super);
|
|
604
|
+
function LimitReachedError(message) {
|
|
605
|
+
var _this = _super.call(this, message) || this;
|
|
606
|
+
_this.name = 'LimitReachedError';
|
|
607
|
+
Object.setPrototypeOf(_this, LimitReachedError.prototype);
|
|
608
|
+
return _this;
|
|
609
|
+
}
|
|
610
|
+
return LimitReachedError;
|
|
611
|
+
}(Error));
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Replaces parameters in template with values from parameters object
|
|
615
|
+
*
|
|
616
|
+
* @param template the template with parameters in {curly} braces
|
|
617
|
+
* @param parameters the object with parameters
|
|
618
|
+
* @returns the template with replaced parameters
|
|
619
|
+
* @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
|
|
620
|
+
*/
|
|
621
|
+
function replaceParameters(template, parameters) {
|
|
622
|
+
var e_1, _a;
|
|
623
|
+
try {
|
|
624
|
+
for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
625
|
+
var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
|
|
626
|
+
if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
|
|
627
|
+
throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
|
|
628
|
+
}
|
|
629
|
+
else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
|
|
630
|
+
// TODO: [๐ต]
|
|
631
|
+
throw new UnexpectedError("Parameter {".concat(parameterName, "} is restricted to use"));
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
636
|
+
finally {
|
|
637
|
+
try {
|
|
638
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
639
|
+
}
|
|
640
|
+
finally { if (e_1) throw e_1.error; }
|
|
641
|
+
}
|
|
642
|
+
var replacedTemplate = template;
|
|
643
|
+
var match;
|
|
644
|
+
var loopLimit = LOOP_LIMIT;
|
|
645
|
+
var _loop_1 = function () {
|
|
646
|
+
if (loopLimit-- < 0) {
|
|
647
|
+
throw new LimitReachedError('Loop limit reached during parameters replacement in `replaceParameters`');
|
|
648
|
+
}
|
|
649
|
+
var precol = match.groups.precol;
|
|
650
|
+
var parameterName = match.groups.parameterName;
|
|
651
|
+
if (parameterName === '') {
|
|
652
|
+
return "continue";
|
|
653
|
+
}
|
|
654
|
+
if (parameterName.indexOf('{') !== -1 || parameterName.indexOf('}') !== -1) {
|
|
655
|
+
throw new PipelineExecutionError('Parameter is already opened or not closed');
|
|
656
|
+
}
|
|
657
|
+
if (parameters[parameterName] === undefined) {
|
|
658
|
+
throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
|
|
659
|
+
}
|
|
660
|
+
var parameterValue = parameters[parameterName];
|
|
661
|
+
if (parameterValue === undefined) {
|
|
662
|
+
throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
|
|
663
|
+
}
|
|
664
|
+
parameterValue = parameterValue.toString();
|
|
665
|
+
if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
|
|
666
|
+
parameterValue = parameterValue
|
|
667
|
+
.split('\n')
|
|
668
|
+
.map(function (line, index) { return (index === 0 ? line : "".concat(precol).concat(line)); })
|
|
669
|
+
.join('\n');
|
|
670
|
+
}
|
|
671
|
+
replacedTemplate =
|
|
672
|
+
replacedTemplate.substring(0, match.index + precol.length) +
|
|
673
|
+
parameterValue +
|
|
674
|
+
replacedTemplate.substring(match.index + precol.length + parameterName.length + 2);
|
|
675
|
+
};
|
|
676
|
+
while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
|
|
677
|
+
.exec(replacedTemplate))) {
|
|
678
|
+
_loop_1();
|
|
679
|
+
}
|
|
680
|
+
// [๐ซ] Check if there are parameters that are not closed properly
|
|
681
|
+
if (/{\w+$/.test(replacedTemplate)) {
|
|
682
|
+
throw new PipelineExecutionError('Parameter is not closed');
|
|
683
|
+
}
|
|
684
|
+
// [๐ซ] Check if there are parameters that are not opened properly
|
|
685
|
+
if (/^\w+}/.test(replacedTemplate)) {
|
|
686
|
+
throw new PipelineExecutionError('Parameter is not opened');
|
|
687
|
+
}
|
|
688
|
+
return replacedTemplate;
|
|
689
|
+
}
|
|
690
|
+
|
|
506
691
|
/**
|
|
507
692
|
* Counts number of characters in the text
|
|
508
693
|
*/
|
|
@@ -922,35 +1107,46 @@
|
|
|
922
1107
|
*/
|
|
923
1108
|
OpenAiExecutionTools.prototype.callChatModel = function (prompt) {
|
|
924
1109
|
return __awaiter(this, void 0, void 0, function () {
|
|
925
|
-
var content, modelRequirements, expectFormat,
|
|
1110
|
+
var content, parameters, modelRequirements, expectFormat, modelName, modelSettings, rawPromptContent, rawRequest, start, complete, rawResponse, resultContent, usage;
|
|
926
1111
|
return __generator(this, function (_a) {
|
|
927
1112
|
switch (_a.label) {
|
|
928
1113
|
case 0:
|
|
929
1114
|
if (this.options.isVerbose) {
|
|
930
1115
|
console.info('๐ฌ OpenAI callChatModel call', { prompt: prompt });
|
|
931
1116
|
}
|
|
932
|
-
content = prompt.content, modelRequirements = prompt.modelRequirements, expectFormat = prompt.expectFormat;
|
|
1117
|
+
content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements, expectFormat = prompt.expectFormat;
|
|
933
1118
|
// TODO: [โ] Use here more modelRequirements
|
|
934
1119
|
if (modelRequirements.modelVariant !== 'CHAT') {
|
|
935
1120
|
throw new PipelineExecutionError('Use callChatModel only for CHAT variant');
|
|
936
1121
|
}
|
|
937
|
-
|
|
1122
|
+
modelName = modelRequirements.modelName || this.getDefaultChatModel().modelName;
|
|
938
1123
|
modelSettings = {
|
|
939
|
-
model:
|
|
1124
|
+
model: modelName,
|
|
940
1125
|
max_tokens: modelRequirements.maxTokens,
|
|
941
|
-
// <- TODO: Make some global max cap for maxTokens
|
|
1126
|
+
// <- TODO: [๐พ] Make some global max cap for maxTokens
|
|
1127
|
+
temperature: modelRequirements.temperature,
|
|
1128
|
+
// <- TODO: [๐] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
|
|
1129
|
+
// <- Note: [๐ง]
|
|
942
1130
|
};
|
|
943
1131
|
if (expectFormat === 'JSON') {
|
|
944
1132
|
modelSettings.response_format = {
|
|
945
1133
|
type: 'json_object',
|
|
946
1134
|
};
|
|
947
1135
|
}
|
|
948
|
-
|
|
1136
|
+
rawPromptContent = replaceParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
|
|
1137
|
+
rawRequest = __assign(__assign({}, modelSettings), { messages: __spreadArray(__spreadArray([], __read((modelRequirements.systemMessage === undefined
|
|
1138
|
+
? []
|
|
1139
|
+
: [
|
|
1140
|
+
{
|
|
1141
|
+
role: 'system',
|
|
1142
|
+
content: modelRequirements.systemMessage,
|
|
1143
|
+
},
|
|
1144
|
+
])), false), [
|
|
949
1145
|
{
|
|
950
1146
|
role: 'user',
|
|
951
|
-
content:
|
|
1147
|
+
content: rawPromptContent,
|
|
952
1148
|
},
|
|
953
|
-
], user: this.options.user });
|
|
1149
|
+
], false), user: this.options.user });
|
|
954
1150
|
start = getCurrentIsoDate();
|
|
955
1151
|
if (this.options.isVerbose) {
|
|
956
1152
|
console.info(colors__default["default"].bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
|
@@ -977,14 +1173,16 @@
|
|
|
977
1173
|
}
|
|
978
1174
|
return [2 /*return*/, {
|
|
979
1175
|
content: resultContent,
|
|
980
|
-
modelName: rawResponse.model ||
|
|
1176
|
+
modelName: rawResponse.model || modelName,
|
|
981
1177
|
timing: {
|
|
982
1178
|
start: start,
|
|
983
1179
|
complete: complete,
|
|
984
1180
|
},
|
|
985
1181
|
usage: usage,
|
|
1182
|
+
rawPromptContent: rawPromptContent,
|
|
1183
|
+
rawRequest: rawRequest,
|
|
986
1184
|
rawResponse: rawResponse,
|
|
987
|
-
// <- [
|
|
1185
|
+
// <- [๐ฏ]
|
|
988
1186
|
}];
|
|
989
1187
|
}
|
|
990
1188
|
});
|
|
@@ -995,25 +1193,29 @@
|
|
|
995
1193
|
*/
|
|
996
1194
|
OpenAiExecutionTools.prototype.callCompletionModel = function (prompt) {
|
|
997
1195
|
return __awaiter(this, void 0, void 0, function () {
|
|
998
|
-
var content, modelRequirements,
|
|
1196
|
+
var content, parameters, modelRequirements, modelName, modelSettings, rawPromptContent, rawRequest, start, complete, rawResponse, resultContent, usage;
|
|
999
1197
|
return __generator(this, function (_a) {
|
|
1000
1198
|
switch (_a.label) {
|
|
1001
1199
|
case 0:
|
|
1002
1200
|
if (this.options.isVerbose) {
|
|
1003
1201
|
console.info('๐ OpenAI callCompletionModel call', { prompt: prompt });
|
|
1004
1202
|
}
|
|
1005
|
-
content = prompt.content, modelRequirements = prompt.modelRequirements;
|
|
1203
|
+
content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements;
|
|
1006
1204
|
// TODO: [โ] Use here more modelRequirements
|
|
1007
1205
|
if (modelRequirements.modelVariant !== 'COMPLETION') {
|
|
1008
1206
|
throw new PipelineExecutionError('Use callCompletionModel only for COMPLETION variant');
|
|
1009
1207
|
}
|
|
1010
|
-
|
|
1208
|
+
modelName = modelRequirements.modelName || this.getDefaultCompletionModel().modelName;
|
|
1011
1209
|
modelSettings = {
|
|
1012
|
-
model:
|
|
1013
|
-
max_tokens: modelRequirements.maxTokens || 2000,
|
|
1014
|
-
// <- TODO: Make some global max cap for maxTokens
|
|
1210
|
+
model: modelName,
|
|
1211
|
+
max_tokens: modelRequirements.maxTokens || 2000,
|
|
1212
|
+
// <- TODO: [๐พ] Make some global max cap for maxTokens
|
|
1213
|
+
temperature: modelRequirements.temperature,
|
|
1214
|
+
// <- TODO: [๐] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
|
|
1215
|
+
// <- Note: [๐ง]
|
|
1015
1216
|
};
|
|
1016
|
-
|
|
1217
|
+
rawPromptContent = replaceParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
|
|
1218
|
+
rawRequest = __assign(__assign({}, modelSettings), { prompt: rawPromptContent, user: this.options.user });
|
|
1017
1219
|
start = getCurrentIsoDate();
|
|
1018
1220
|
if (this.options.isVerbose) {
|
|
1019
1221
|
console.info(colors__default["default"].bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
|
@@ -1037,14 +1239,16 @@
|
|
|
1037
1239
|
usage = computeOpenaiUsage(content, resultContent || '', rawResponse);
|
|
1038
1240
|
return [2 /*return*/, {
|
|
1039
1241
|
content: resultContent,
|
|
1040
|
-
modelName: rawResponse.model ||
|
|
1242
|
+
modelName: rawResponse.model || modelName,
|
|
1041
1243
|
timing: {
|
|
1042
1244
|
start: start,
|
|
1043
1245
|
complete: complete,
|
|
1044
1246
|
},
|
|
1045
1247
|
usage: usage,
|
|
1248
|
+
rawPromptContent: rawPromptContent,
|
|
1249
|
+
rawRequest: rawRequest,
|
|
1046
1250
|
rawResponse: rawResponse,
|
|
1047
|
-
// <- [
|
|
1251
|
+
// <- [๐ฏ]
|
|
1048
1252
|
}];
|
|
1049
1253
|
}
|
|
1050
1254
|
});
|
|
@@ -1055,23 +1259,23 @@
|
|
|
1055
1259
|
*/
|
|
1056
1260
|
OpenAiExecutionTools.prototype.callEmbeddingModel = function (prompt) {
|
|
1057
1261
|
return __awaiter(this, void 0, void 0, function () {
|
|
1058
|
-
var content, modelRequirements,
|
|
1262
|
+
var content, parameters, modelRequirements, modelName, rawPromptContent, rawRequest, start, complete, rawResponse, resultContent, usage;
|
|
1059
1263
|
return __generator(this, function (_a) {
|
|
1060
1264
|
switch (_a.label) {
|
|
1061
1265
|
case 0:
|
|
1062
1266
|
if (this.options.isVerbose) {
|
|
1063
1267
|
console.info('๐ OpenAI embedding call', { prompt: prompt });
|
|
1064
1268
|
}
|
|
1065
|
-
content = prompt.content, modelRequirements = prompt.modelRequirements;
|
|
1269
|
+
content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements;
|
|
1066
1270
|
// TODO: [โ] Use here more modelRequirements
|
|
1067
1271
|
if (modelRequirements.modelVariant !== 'EMBEDDING') {
|
|
1068
1272
|
throw new PipelineExecutionError('Use embed only for EMBEDDING variant');
|
|
1069
1273
|
}
|
|
1070
|
-
|
|
1274
|
+
modelName = modelRequirements.modelName || this.getDefaultEmbeddingModel().modelName;
|
|
1275
|
+
rawPromptContent = replaceParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
|
|
1071
1276
|
rawRequest = {
|
|
1072
|
-
input:
|
|
1073
|
-
model:
|
|
1074
|
-
// TODO: !!!! Test model 3 and dimensions
|
|
1277
|
+
input: rawPromptContent,
|
|
1278
|
+
model: modelName,
|
|
1075
1279
|
};
|
|
1076
1280
|
start = getCurrentIsoDate();
|
|
1077
1281
|
if (this.options.isVerbose) {
|
|
@@ -1092,14 +1296,16 @@
|
|
|
1092
1296
|
usage = computeOpenaiUsage(content, '', rawResponse);
|
|
1093
1297
|
return [2 /*return*/, {
|
|
1094
1298
|
content: resultContent,
|
|
1095
|
-
modelName: rawResponse.model ||
|
|
1299
|
+
modelName: rawResponse.model || modelName,
|
|
1096
1300
|
timing: {
|
|
1097
1301
|
start: start,
|
|
1098
1302
|
complete: complete,
|
|
1099
1303
|
},
|
|
1100
1304
|
usage: usage,
|
|
1305
|
+
rawPromptContent: rawPromptContent,
|
|
1306
|
+
rawRequest: rawRequest,
|
|
1101
1307
|
rawResponse: rawResponse,
|
|
1102
|
-
// <- [
|
|
1308
|
+
// <- [๐ฏ]
|
|
1103
1309
|
}];
|
|
1104
1310
|
}
|
|
1105
1311
|
});
|
|
@@ -1116,9 +1322,9 @@
|
|
|
1116
1322
|
});
|
|
1117
1323
|
if (model === undefined) {
|
|
1118
1324
|
throw new UnexpectedError(spaceTrim__default["default"](function (block) {
|
|
1119
|
-
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) {
|
|
1325
|
+
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) {
|
|
1120
1326
|
var modelName = _a.modelName;
|
|
1121
|
-
return "- ".concat(modelName);
|
|
1327
|
+
return "- \"".concat(modelName, "\"");
|
|
1122
1328
|
}).join('\n')), "\n\n ");
|
|
1123
1329
|
}));
|
|
1124
1330
|
}
|
|
@@ -1162,12 +1368,13 @@
|
|
|
1162
1368
|
* TODO: [๐ง ][๐งโโ๏ธ] Maybe there can be some wizzard for thoose who want to use just OpenAI
|
|
1163
1369
|
* TODO: Maybe Create some common util for callChatModel and callCompletionModel
|
|
1164
1370
|
* TODO: Maybe make custom OpenaiError
|
|
1371
|
+
* TODO: [๐ง ][๐] Maybe use `isDeterministic` from options
|
|
1165
1372
|
*/
|
|
1166
1373
|
|
|
1167
1374
|
/**
|
|
1168
1375
|
* The version of the Promptbook library
|
|
1169
1376
|
*/
|
|
1170
|
-
var PROMPTBOOK_VERSION = '0.61.0
|
|
1377
|
+
var PROMPTBOOK_VERSION = '0.61.0';
|
|
1171
1378
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
1172
1379
|
|
|
1173
1380
|
exports.OPENAI_MODELS = OPENAI_MODELS;
|