@promptbook/azure-openai 0.61.0-9 โ 0.61.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 +8 -6
- package/esm/index.es.js +256 -27
- 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 +7 -2
- 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 +1 -1
- 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 +30 -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/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 +30 -0
- package/esm/typings/src/llm-providers/_common/getLlmToolsForCli.d.ts +10 -0
- package/esm/typings/src/llm-providers/_common/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +11 -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 +16 -0
- package/esm/typings/src/llm-providers/_common/utils/count-total-cost/LlmExecutionToolsWithTotalCost.d.ts +11 -0
- package/esm/typings/src/llm-providers/_common/utils/count-total-cost/countTotalCost.d.ts +14 -0
- package/esm/typings/src/llm-providers/_common/utils/count-total-cost/limitTotalCost.d.ts +32 -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/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 +17 -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.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 +4 -3
- package/umd/index.umd.js +259 -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 +7 -2
- 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 +1 -1
- 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 +30 -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/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 +30 -0
- package/umd/typings/src/llm-providers/_common/getLlmToolsForCli.d.ts +10 -0
- package/umd/typings/src/llm-providers/_common/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +11 -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 +16 -0
- package/umd/typings/src/llm-providers/_common/utils/count-total-cost/LlmExecutionToolsWithTotalCost.d.ts +11 -0
- package/umd/typings/src/llm-providers/_common/utils/count-total-cost/countTotalCost.d.ts +14 -0
- package/umd/typings/src/llm-providers/_common/utils/count-total-cost/limitTotalCost.d.ts +32 -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/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 +17 -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 โ knowledge/prepare-knowledge/_common/prepareKnowledgePieces.test.d.ts} +0 -0
- /package/esm/typings/src/{utils/extractParameters.test.d.ts โ personas/preparePersona.test.d.ts} +0 -0
- /package/esm/typings/src/{utils/postprocessing โ postprocessing/utils}/extractBlock.d.ts +0 -0
- /package/{umd/typings/src/conversion/utils/extractParametersFromPromptTemplate.test.d.ts โ esm/typings/src/prepare/isPipelinePrepared.test.d.ts} +0 -0
- /package/{umd/typings/src/execution/addPromptResultUsage.test.d.ts โ esm/typings/src/storage/files-storage/utils/nameToSubfolderPath.test.d.ts} +0 -0
- /package/{umd/typings/src/execution/utils/replaceParameters.test.d.ts โ esm/typings/src/utils/extractParameterNames.test.d.ts} +0 -0
- /package/{umd/typings/src/utils/extractParameters.test.d.ts โ esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown-real.test.d.ts} +0 -0
- /package/umd/typings/src/{utils/postprocessing โ postprocessing/utils}/extractBlock.d.ts +0 -0
package/README.md
CHANGED
|
@@ -39,13 +39,13 @@ npm i @promptbook/azure-openai
|
|
|
39
39
|
import { createPipelineExecutor, assertsExecutionSuccessful } from '@promptbook/core';
|
|
40
40
|
import { createCollectionFromDirectory } from '@promptbook/node';
|
|
41
41
|
import { JavascriptExecutionTools } from '@promptbook/execute-javascript';
|
|
42
|
-
import {
|
|
42
|
+
import { AzureOpenAiExecutionTools } from '@promptbook/azure-openai';
|
|
43
43
|
|
|
44
44
|
// โถ Create whole pipeline collection
|
|
45
45
|
const collection = await createCollectionFromDirectory('./promptbook-collection');
|
|
46
46
|
|
|
47
47
|
// โถ Get single Pipeline
|
|
48
|
-
const pipeline = await
|
|
48
|
+
const pipeline = await collection.getPipelineByUrl(`https://promptbook.studio/my-collection/write-article.ptbk.md`);
|
|
49
49
|
|
|
50
50
|
// โถ Prepare tools
|
|
51
51
|
const tools = {
|
|
@@ -83,13 +83,15 @@ You can use multiple LLM providers in one Promptbook execution. The best model w
|
|
|
83
83
|
import { createPipelineExecutor, assertsExecutionSuccessful } from '@promptbook/core';
|
|
84
84
|
import { createCollectionFromDirectory } from '@promptbook/node';
|
|
85
85
|
import { JavascriptExecutionTools } from '@promptbook/execute-javascript';
|
|
86
|
+
import { AzureOpenAiExecutionTools } from '@promptbook/azure-openai';
|
|
86
87
|
import { OpenAiExecutionTools } from '@promptbook/openai';
|
|
88
|
+
import { AnthropicClaudeExecutionTools } from '@promptbook/anthropic-claude';
|
|
87
89
|
|
|
88
90
|
// โถ Create whole pipeline collection
|
|
89
91
|
const collection = await createCollectionFromDirectory('./promptbook-collection');
|
|
90
92
|
|
|
91
93
|
// โถ Get single Pipeline
|
|
92
|
-
const pipeline = await
|
|
94
|
+
const pipeline = await collection.getPipelineByUrl(`https://promptbook.studio/my-collection/write-article.ptbk.md`);
|
|
93
95
|
|
|
94
96
|
// โถ Prepare multiple tools
|
|
95
97
|
const tools = {
|
|
@@ -188,7 +190,7 @@ File `write-website-content.ptbk.md`:
|
|
|
188
190
|
> - PROMPTBOOK VERSION 0.0.1
|
|
189
191
|
> - INPUTโฏโฏPARAM `{rawTitle}` Automatically suggested a site name or empty text
|
|
190
192
|
> - INPUTโฏโฏPARAM `{rawAssigment}` Automatically generated site entry from image recognition
|
|
191
|
-
> - OUTPUTโฏPARAM `{
|
|
193
|
+
> - OUTPUTโฏPARAM `{websiteContent}` Web content
|
|
192
194
|
> - OUTPUTโฏPARAM `{keywords}` Keywords
|
|
193
195
|
>
|
|
194
196
|
> ## ๐ค Specifying the assigment
|
|
@@ -347,7 +349,7 @@ File `write-website-content.ptbk.md`:
|
|
|
347
349
|
> {contentBody}
|
|
348
350
|
> ```
|
|
349
351
|
>
|
|
350
|
-
> `-> {
|
|
352
|
+
> `-> {websiteContent}`
|
|
351
353
|
|
|
352
354
|
|
|
353
355
|
|
|
@@ -387,7 +389,7 @@ flowchart LR
|
|
|
387
389
|
templateCombineTheBeginning--"{contentBeginning}"-->templateCombineTheContent
|
|
388
390
|
templateWriteTheContent--"{contentBody}"-->templateCombineTheContent
|
|
389
391
|
|
|
390
|
-
templateCombineTheContent--"{
|
|
392
|
+
templateCombineTheContent--"{websiteContent}"-->output
|
|
391
393
|
output((Output)):::output
|
|
392
394
|
|
|
393
395
|
classDef input color: grey;
|
package/esm/index.es.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OpenAIClient, AzureKeyCredential } from '@azure/openai';
|
|
2
2
|
import colors from 'colors';
|
|
3
|
+
import { spaceTrim } from 'spacetrim';
|
|
3
4
|
|
|
4
5
|
/*! *****************************************************************************
|
|
5
6
|
Copyright (c) Microsoft Corporation.
|
|
@@ -81,6 +82,18 @@ function __generator(thisArg, body) {
|
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
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
|
+
|
|
84
97
|
function __read(o, n) {
|
|
85
98
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
86
99
|
if (!m) return o;
|
|
@@ -96,6 +109,16 @@ function __read(o, n) {
|
|
|
96
109
|
finally { if (e) throw e.error; }
|
|
97
110
|
}
|
|
98
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));
|
|
99
122
|
}
|
|
100
123
|
|
|
101
124
|
/**
|
|
@@ -468,10 +491,186 @@ function getCurrentIsoDate() {
|
|
|
468
491
|
return new Date().toISOString();
|
|
469
492
|
}
|
|
470
493
|
|
|
494
|
+
/**
|
|
495
|
+
* @@@
|
|
496
|
+
*
|
|
497
|
+
* @returns The same object as the input, but deeply frozen
|
|
498
|
+
*
|
|
499
|
+
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
500
|
+
*/
|
|
501
|
+
function deepFreeze(objectValue) {
|
|
502
|
+
var e_1, _a;
|
|
503
|
+
var propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
504
|
+
try {
|
|
505
|
+
for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
|
|
506
|
+
var propertyName = propertyNames_1_1.value;
|
|
507
|
+
var value = objectValue[propertyName];
|
|
508
|
+
if (value && typeof value === 'object') {
|
|
509
|
+
deepFreeze(value);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
514
|
+
finally {
|
|
515
|
+
try {
|
|
516
|
+
if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
|
|
517
|
+
}
|
|
518
|
+
finally { if (e_1) throw e_1.error; }
|
|
519
|
+
}
|
|
520
|
+
return Object.freeze(objectValue);
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* TODO: [๐ผ] Export from `@promptbook/utils`
|
|
524
|
+
* TODO: [๐ง ] Is there a way how to meaningfully test this utility
|
|
525
|
+
*/
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* The maximum number of iterations for a loops
|
|
529
|
+
*/
|
|
530
|
+
var LOOP_LIMIT = 1000;
|
|
531
|
+
/**
|
|
532
|
+
* Nonce which is used for replacing things in strings
|
|
533
|
+
*/
|
|
534
|
+
var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
|
|
535
|
+
/**
|
|
536
|
+
* The names of the parameters that are reserved for special purposes
|
|
537
|
+
*/
|
|
538
|
+
deepFreeze([
|
|
539
|
+
'content',
|
|
540
|
+
'context',
|
|
541
|
+
'knowledge',
|
|
542
|
+
'samples',
|
|
543
|
+
'modelName',
|
|
544
|
+
'currentDate',
|
|
545
|
+
// <- TODO: Add more like 'date', 'modelName',...
|
|
546
|
+
// <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
|
|
547
|
+
]);
|
|
548
|
+
/**
|
|
549
|
+
* @@@
|
|
550
|
+
*/
|
|
551
|
+
var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
|
|
552
|
+
/**
|
|
553
|
+
* @@@
|
|
554
|
+
*/
|
|
555
|
+
var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
|
|
556
|
+
/*
|
|
557
|
+
TODO: !!! Just testing false-negative detection of [๐ก][๐ข][๐ต][โช] leak
|
|
558
|
+
*/
|
|
559
|
+
// [๐ก][๐ข][๐ต][โช]
|
|
560
|
+
/**
|
|
561
|
+
* TODO: [๐ผ] Export all to core
|
|
562
|
+
*/
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* This error type indicates that some limit was reached
|
|
566
|
+
*/
|
|
567
|
+
var LimitReachedError = /** @class */ (function (_super) {
|
|
568
|
+
__extends(LimitReachedError, _super);
|
|
569
|
+
function LimitReachedError(message) {
|
|
570
|
+
var _this = _super.call(this, message) || this;
|
|
571
|
+
_this.name = 'LimitReachedError';
|
|
572
|
+
Object.setPrototypeOf(_this, LimitReachedError.prototype);
|
|
573
|
+
return _this;
|
|
574
|
+
}
|
|
575
|
+
return LimitReachedError;
|
|
576
|
+
}(Error));
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* This error type indicates that the error should not happen and its last check before crashing with some other error
|
|
580
|
+
*/
|
|
581
|
+
var UnexpectedError = /** @class */ (function (_super) {
|
|
582
|
+
__extends(UnexpectedError, _super);
|
|
583
|
+
function UnexpectedError(message) {
|
|
584
|
+
var _this = _super.call(this, spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
|
|
585
|
+
_this.name = 'UnexpectedError';
|
|
586
|
+
Object.setPrototypeOf(_this, UnexpectedError.prototype);
|
|
587
|
+
return _this;
|
|
588
|
+
}
|
|
589
|
+
return UnexpectedError;
|
|
590
|
+
}(Error));
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Replaces parameters in template with values from parameters object
|
|
594
|
+
*
|
|
595
|
+
* @param template the template with parameters in {curly} braces
|
|
596
|
+
* @param parameters the object with parameters
|
|
597
|
+
* @returns the template with replaced parameters
|
|
598
|
+
* @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
|
|
599
|
+
*/
|
|
600
|
+
function replaceParameters(template, parameters) {
|
|
601
|
+
var e_1, _a;
|
|
602
|
+
try {
|
|
603
|
+
for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
604
|
+
var _d = __read(_c.value, 2), parameterName = _d[0], parameterValue = _d[1];
|
|
605
|
+
if (parameterValue === RESERVED_PARAMETER_MISSING_VALUE) {
|
|
606
|
+
throw new UnexpectedError("Parameter {".concat(parameterName, "} has missing value"));
|
|
607
|
+
}
|
|
608
|
+
else if (parameterValue === RESERVED_PARAMETER_RESTRICTED) {
|
|
609
|
+
// TODO: [๐ต]
|
|
610
|
+
throw new UnexpectedError("Parameter {".concat(parameterName, "} is restricted to use"));
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
615
|
+
finally {
|
|
616
|
+
try {
|
|
617
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
618
|
+
}
|
|
619
|
+
finally { if (e_1) throw e_1.error; }
|
|
620
|
+
}
|
|
621
|
+
var replacedTemplate = template;
|
|
622
|
+
var match;
|
|
623
|
+
var loopLimit = LOOP_LIMIT;
|
|
624
|
+
var _loop_1 = function () {
|
|
625
|
+
if (loopLimit-- < 0) {
|
|
626
|
+
throw new LimitReachedError('Loop limit reached during parameters replacement in `replaceParameters`');
|
|
627
|
+
}
|
|
628
|
+
var precol = match.groups.precol;
|
|
629
|
+
var parameterName = match.groups.parameterName;
|
|
630
|
+
if (parameterName === '') {
|
|
631
|
+
return "continue";
|
|
632
|
+
}
|
|
633
|
+
if (parameterName.indexOf('{') !== -1 || parameterName.indexOf('}') !== -1) {
|
|
634
|
+
throw new PipelineExecutionError('Parameter is already opened or not closed');
|
|
635
|
+
}
|
|
636
|
+
if (parameters[parameterName] === undefined) {
|
|
637
|
+
throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
|
|
638
|
+
}
|
|
639
|
+
var parameterValue = parameters[parameterName];
|
|
640
|
+
if (parameterValue === undefined) {
|
|
641
|
+
throw new PipelineExecutionError("Parameter {".concat(parameterName, "} is not defined"));
|
|
642
|
+
}
|
|
643
|
+
parameterValue = parameterValue.toString();
|
|
644
|
+
if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
|
|
645
|
+
parameterValue = parameterValue
|
|
646
|
+
.split('\n')
|
|
647
|
+
.map(function (line, index) { return (index === 0 ? line : "".concat(precol).concat(line)); })
|
|
648
|
+
.join('\n');
|
|
649
|
+
}
|
|
650
|
+
replacedTemplate =
|
|
651
|
+
replacedTemplate.substring(0, match.index + precol.length) +
|
|
652
|
+
parameterValue +
|
|
653
|
+
replacedTemplate.substring(match.index + precol.length + parameterName.length + 2);
|
|
654
|
+
};
|
|
655
|
+
while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
|
|
656
|
+
.exec(replacedTemplate))) {
|
|
657
|
+
_loop_1();
|
|
658
|
+
}
|
|
659
|
+
// [๐ซ] Check if there are parameters that are not closed properly
|
|
660
|
+
if (/{\w+$/.test(replacedTemplate)) {
|
|
661
|
+
throw new PipelineExecutionError('Parameter is not closed');
|
|
662
|
+
}
|
|
663
|
+
// [๐ซ] Check if there are parameters that are not opened properly
|
|
664
|
+
if (/^\w+}/.test(replacedTemplate)) {
|
|
665
|
+
throw new PipelineExecutionError('Parameter is not opened');
|
|
666
|
+
}
|
|
667
|
+
return replacedTemplate;
|
|
668
|
+
}
|
|
669
|
+
|
|
471
670
|
/**
|
|
472
671
|
* Function computeUsage will create price per one token based on the string value found on openai page
|
|
473
672
|
*
|
|
474
|
-
* @private within the
|
|
673
|
+
* @private within the repository, used only as internal helper for `OPENAI_MODELS`
|
|
475
674
|
*/
|
|
476
675
|
function computeUsage(value) {
|
|
477
676
|
var _a = __read(value.split(' / '), 2), price = _a[0], tokens = _a[1];
|
|
@@ -825,6 +1024,7 @@ var OPENAI_MODELS = [
|
|
|
825
1024
|
* @see /other/playground/playground.ts
|
|
826
1025
|
* TODO: [๐] Make better
|
|
827
1026
|
* TODO: Change model titles to human eg: "gpt-4-turbo-2024-04-09" -> "GPT-4 Turbo (2024-04-09)"
|
|
1027
|
+
* TODO: [๐ธ] Not all models are compatible with JSON mode, add this information here and use it
|
|
828
1028
|
*/
|
|
829
1029
|
|
|
830
1030
|
/**
|
|
@@ -860,41 +1060,54 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
|
|
|
860
1060
|
AzureOpenAiExecutionTools.prototype.callChatModel = function (prompt) {
|
|
861
1061
|
var _a, _b;
|
|
862
1062
|
return __awaiter(this, void 0, void 0, function () {
|
|
863
|
-
var content, modelRequirements, modelName, modelSettings, messages, start, complete, rawResponse, resultContent, usage, error_1;
|
|
864
|
-
|
|
865
|
-
|
|
1063
|
+
var content, parameters, modelRequirements, modelName, modelSettings, rawPromptContent, messages, start, complete, rawRequest, rawResponse, resultContent, usage, error_1;
|
|
1064
|
+
var _c;
|
|
1065
|
+
return __generator(this, function (_d) {
|
|
1066
|
+
switch (_d.label) {
|
|
866
1067
|
case 0:
|
|
867
1068
|
if (this.options.isVerbose) {
|
|
868
1069
|
console.info('๐ฌ OpenAI callChatModel call');
|
|
869
1070
|
}
|
|
870
|
-
content = prompt.content, modelRequirements = prompt.modelRequirements;
|
|
1071
|
+
content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements;
|
|
871
1072
|
// TODO: [โ] Use here more modelRequirements
|
|
872
1073
|
if (modelRequirements.modelVariant !== 'CHAT') {
|
|
873
1074
|
throw new PipelineExecutionError('Use callChatModel only for CHAT variant');
|
|
874
1075
|
}
|
|
875
|
-
|
|
1076
|
+
_d.label = 1;
|
|
876
1077
|
case 1:
|
|
877
|
-
|
|
1078
|
+
_d.trys.push([1, 3, , 4]);
|
|
878
1079
|
modelName = prompt.modelRequirements.modelName || this.options.deploymentName;
|
|
879
1080
|
modelSettings = {
|
|
880
1081
|
maxTokens: modelRequirements.maxTokens,
|
|
881
|
-
// <- TODO: Make some global max cap for maxTokens
|
|
1082
|
+
// <- TODO: [๐พ] Make some global max cap for maxTokens
|
|
1083
|
+
temperature: modelRequirements.temperature,
|
|
882
1084
|
user: this.options.user,
|
|
1085
|
+
// <- TODO: [๐] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
|
|
1086
|
+
// <- Note: [๐ง]
|
|
883
1087
|
};
|
|
884
|
-
|
|
1088
|
+
rawPromptContent = replaceParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
|
|
1089
|
+
messages = __spreadArray(__spreadArray([], __read((modelRequirements.systemMessage === undefined
|
|
1090
|
+
? []
|
|
1091
|
+
: [
|
|
1092
|
+
{
|
|
1093
|
+
role: 'system',
|
|
1094
|
+
content: modelRequirements.systemMessage,
|
|
1095
|
+
},
|
|
1096
|
+
])), false), [
|
|
885
1097
|
{
|
|
886
1098
|
role: 'user',
|
|
887
|
-
content:
|
|
1099
|
+
content: rawPromptContent,
|
|
888
1100
|
},
|
|
889
|
-
];
|
|
1101
|
+
], false);
|
|
890
1102
|
start = getCurrentIsoDate();
|
|
891
1103
|
complete = void 0;
|
|
892
1104
|
if (this.options.isVerbose) {
|
|
893
1105
|
console.info(colors.bgWhite('messages'), JSON.stringify(messages, null, 4));
|
|
894
1106
|
}
|
|
895
|
-
|
|
1107
|
+
rawRequest = [modelName, messages, modelSettings];
|
|
1108
|
+
return [4 /*yield*/, (_c = this.client).getChatCompletions.apply(_c, __spreadArray([], __read(rawRequest), false))];
|
|
896
1109
|
case 2:
|
|
897
|
-
rawResponse =
|
|
1110
|
+
rawResponse = _d.sent();
|
|
898
1111
|
if (this.options.isVerbose) {
|
|
899
1112
|
console.info(colors.bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
|
|
900
1113
|
}
|
|
@@ -924,11 +1137,13 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
|
|
|
924
1137
|
complete: complete,
|
|
925
1138
|
},
|
|
926
1139
|
usage: usage,
|
|
1140
|
+
rawPromptContent: rawPromptContent,
|
|
1141
|
+
rawRequest: rawRequest,
|
|
927
1142
|
rawResponse: rawResponse,
|
|
928
|
-
// <- [
|
|
1143
|
+
// <- [๐ฏ]
|
|
929
1144
|
}];
|
|
930
1145
|
case 3:
|
|
931
|
-
error_1 =
|
|
1146
|
+
error_1 = _d.sent();
|
|
932
1147
|
throw this.transformAzureError(error_1);
|
|
933
1148
|
case 4: return [2 /*return*/];
|
|
934
1149
|
}
|
|
@@ -941,35 +1156,46 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
|
|
|
941
1156
|
AzureOpenAiExecutionTools.prototype.callCompletionModel = function (prompt) {
|
|
942
1157
|
var _a, _b;
|
|
943
1158
|
return __awaiter(this, void 0, void 0, function () {
|
|
944
|
-
var content, modelRequirements, modelName, modelSettings, start, complete, rawResponse, resultContent, usage, error_2;
|
|
945
|
-
|
|
946
|
-
|
|
1159
|
+
var content, parameters, modelRequirements, modelName, modelSettings, start, complete, rawPromptContent, rawRequest, rawResponse, resultContent, usage, error_2;
|
|
1160
|
+
var _c;
|
|
1161
|
+
return __generator(this, function (_d) {
|
|
1162
|
+
switch (_d.label) {
|
|
947
1163
|
case 0:
|
|
948
1164
|
if (this.options.isVerbose) {
|
|
949
1165
|
console.info('๐ OpenAI callCompletionModel call');
|
|
950
1166
|
}
|
|
951
|
-
content = prompt.content, modelRequirements = prompt.modelRequirements;
|
|
1167
|
+
content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements;
|
|
952
1168
|
// TODO: [โ] Use here more modelRequirements
|
|
953
1169
|
if (modelRequirements.modelVariant !== 'COMPLETION') {
|
|
954
1170
|
throw new PipelineExecutionError('Use callCompletionModel only for COMPLETION variant');
|
|
955
1171
|
}
|
|
956
|
-
|
|
1172
|
+
_d.label = 1;
|
|
957
1173
|
case 1:
|
|
958
|
-
|
|
1174
|
+
_d.trys.push([1, 3, , 4]);
|
|
959
1175
|
modelName = prompt.modelRequirements.modelName || this.options.deploymentName;
|
|
960
1176
|
modelSettings = {
|
|
961
1177
|
maxTokens: modelRequirements.maxTokens || 2000,
|
|
962
|
-
// <- TODO: Make some global max cap for maxTokens
|
|
1178
|
+
// <- TODO: [๐พ] Make some global max cap for maxTokens
|
|
1179
|
+
temperature: modelRequirements.temperature,
|
|
963
1180
|
user: this.options.user,
|
|
1181
|
+
// <- TODO: [๐] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
|
|
1182
|
+
// <- Note: [๐ง]
|
|
964
1183
|
};
|
|
965
1184
|
start = getCurrentIsoDate();
|
|
966
1185
|
complete = void 0;
|
|
967
1186
|
if (this.options.isVerbose) {
|
|
968
1187
|
console.info(colors.bgWhite('content'), JSON.stringify(content, null, 4));
|
|
1188
|
+
console.info(colors.bgWhite('parameters'), JSON.stringify(parameters, null, 4));
|
|
969
1189
|
}
|
|
970
|
-
|
|
1190
|
+
rawPromptContent = replaceParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
|
|
1191
|
+
rawRequest = [
|
|
1192
|
+
modelName,
|
|
1193
|
+
[rawPromptContent],
|
|
1194
|
+
modelSettings,
|
|
1195
|
+
];
|
|
1196
|
+
return [4 /*yield*/, (_c = this.client).getCompletions.apply(_c, __spreadArray([], __read(rawRequest), false))];
|
|
971
1197
|
case 2:
|
|
972
|
-
rawResponse =
|
|
1198
|
+
rawResponse = _d.sent();
|
|
973
1199
|
if (this.options.isVerbose) {
|
|
974
1200
|
console.info(colors.bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
|
|
975
1201
|
}
|
|
@@ -996,11 +1222,13 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
|
|
|
996
1222
|
complete: complete,
|
|
997
1223
|
},
|
|
998
1224
|
usage: usage,
|
|
1225
|
+
rawPromptContent: rawPromptContent,
|
|
1226
|
+
rawRequest: rawRequest,
|
|
999
1227
|
rawResponse: rawResponse,
|
|
1000
|
-
// <- [
|
|
1228
|
+
// <- [๐ฏ]
|
|
1001
1229
|
}];
|
|
1002
1230
|
case 3:
|
|
1003
|
-
error_2 =
|
|
1231
|
+
error_2 = _d.sent();
|
|
1004
1232
|
throw this.transformAzureError(error_2);
|
|
1005
1233
|
case 4: return [2 /*return*/];
|
|
1006
1234
|
}
|
|
@@ -1042,12 +1270,13 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
|
|
|
1042
1270
|
/**
|
|
1043
1271
|
* TODO: Maybe Create some common util for callChatModel and callCompletionModel
|
|
1044
1272
|
* TODO: Maybe make custom AzureOpenaiError
|
|
1273
|
+
* TODO: [๐ง ][๐] Maybe use `isDeterministic` from options
|
|
1045
1274
|
*/
|
|
1046
1275
|
|
|
1047
1276
|
/**
|
|
1048
1277
|
* The version of the Promptbook library
|
|
1049
1278
|
*/
|
|
1050
|
-
var PROMPTBOOK_VERSION = '0.61.0-
|
|
1279
|
+
var PROMPTBOOK_VERSION = '0.61.0-30';
|
|
1051
1280
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
1052
1281
|
|
|
1053
1282
|
export { AzureOpenAiExecutionTools, PROMPTBOOK_VERSION };
|