@promptbook/openai 0.60.1 → 0.61.0-1
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 +23 -21
- package/esm/index.es.js +38 -20
- package/esm/index.es.js.map +1 -1
- package/esm/typings/promptbook-collection/index.d.ts +61 -4
- package/esm/typings/src/_packages/core.index.d.ts +8 -8
- package/esm/typings/src/_packages/markdown-utils.d.ts +17 -0
- package/esm/typings/src/_packages/types.index.d.ts +11 -6
- package/esm/typings/src/_packages/utils.index.d.ts +23 -19
- package/esm/typings/src/cli/cli-commands/hello.d.ts +7 -0
- package/esm/typings/src/cli/cli-commands/make.d.ts +7 -0
- package/esm/typings/src/cli/cli-commands/prettify.d.ts +7 -0
- package/esm/typings/src/collection/collectionToJson.d.ts +3 -0
- package/esm/typings/src/collection/collectionToJson.test.d.ts +6 -0
- package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +2 -1
- package/esm/typings/src/commands/BLOCK/BlockCommand.d.ts +11 -0
- package/esm/typings/src/commands/BLOCK/BlockTypes.d.ts +13 -0
- package/esm/typings/src/commands/BLOCK/blockCommandParser.d.ts +9 -0
- package/esm/typings/src/commands/EXPECT/ExpectAmountCommand.d.ts +14 -0
- package/esm/typings/src/commands/EXPECT/ExpectCommand.d.ts +9 -0
- package/esm/typings/src/commands/EXPECT/ExpectFormatCommand.d.ts +7 -0
- package/esm/typings/src/commands/EXPECT/expectCommandParser.d.ts +9 -0
- package/esm/typings/src/commands/JOKER/JokerCommand.d.ts +11 -0
- package/esm/typings/src/commands/JOKER/jokerCommandParser.d.ts +9 -0
- package/esm/typings/src/commands/KNOWLEDGE/KnowledgeCommand.d.ts +12 -0
- package/esm/typings/src/commands/KNOWLEDGE/knowledgeCommandParser.d.ts +9 -0
- package/esm/typings/src/commands/MODEL/ModelCommand.d.ts +13 -0
- package/esm/typings/src/commands/MODEL/modelCommandParser.d.ts +9 -0
- package/esm/typings/src/commands/PARAMETER/ParameterCommand.d.ts +15 -0
- package/esm/typings/src/commands/PARAMETER/parameterCommandParser.d.ts +9 -0
- package/esm/typings/src/commands/PERSONA/PersonaCommand.d.ts +11 -0
- package/esm/typings/src/commands/PERSONA/personaCommandParser.d.ts +9 -0
- package/esm/typings/src/commands/POSTPROCESS/PostprocessCommand.d.ts +11 -0
- package/esm/typings/src/commands/POSTPROCESS/postprocessCommandParser.d.ts +9 -0
- package/esm/typings/src/commands/PROMPTBOOK_VERSION/PromptbookVersionCommand.d.ts +11 -0
- package/esm/typings/src/commands/PROMPTBOOK_VERSION/promptbookVersionCommandParser.d.ts +9 -0
- package/esm/typings/src/commands/URL/UrlCommand.d.ts +10 -0
- package/esm/typings/src/commands/URL/urlCommandParser.d.ts +9 -0
- package/esm/typings/src/commands/X_ACTION/ActionCommand.d.ts +9 -0
- package/esm/typings/src/commands/X_ACTION/actionCommand.test.d.ts +1 -0
- package/esm/typings/src/commands/X_ACTION/actionCommandParser.d.ts +9 -0
- package/esm/typings/src/commands/X_INSTRUMENT/InstrumentCommand.d.ts +9 -0
- package/esm/typings/src/commands/X_INSTRUMENT/instrumentCommand.test.d.ts +1 -0
- package/esm/typings/src/commands/X_INSTRUMENT/instrumentCommandParser.d.ts +9 -0
- package/esm/typings/src/commands/_BOILERPLATE/BoilerplateCommand.d.ts +10 -0
- package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommand.test.d.ts +1 -0
- package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +12 -0
- package/esm/typings/src/commands/_common/parseCommand.d.ts +12 -0
- package/esm/typings/src/commands/_common/parseCommand.test.d.ts +1 -0
- package/esm/typings/src/commands/_common/types/Command.d.ts +6 -0
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +36 -0
- package/esm/typings/src/commands/_common/types/CommandUsagePlaces.d.ts +9 -0
- package/esm/typings/src/commands/index.d.ts +4 -0
- package/esm/typings/src/config.d.ts +4 -0
- package/esm/typings/src/conversion/pipelineJsonToString.d.ts +2 -0
- package/esm/typings/src/conversion/pipelineStringToJson.d.ts +2 -3
- package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +4 -2
- package/esm/typings/src/conversion/utils/extractParametersFromPromptTemplate.d.ts +2 -2
- package/esm/typings/src/conversion/utils/extractVariables.d.ts +1 -1
- package/esm/typings/src/conversion/validation/validatePipeline-logicErrors.test.d.ts +3 -0
- package/esm/typings/src/errors/NotYetImplementedError.d.ts +7 -0
- package/esm/typings/src/errors/{SyntaxError.d.ts → ParsingError.d.ts} +2 -2
- package/{umd/typings/src/errors/ExecutionError.d.ts → esm/typings/src/errors/PipelineExecutionError.d.ts} +2 -2
- package/esm/typings/src/errors/_ExpectError.d.ts +2 -2
- package/esm/typings/src/execution/ExecutionTools.d.ts +4 -3
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +24 -5
- package/esm/typings/src/execution/PromptResult.d.ts +2 -2
- package/esm/typings/src/execution/assertsExecutionSuccessful.d.ts +1 -1
- package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.d.ts +1 -1
- package/esm/typings/src/execution/utils/checkExpectations.d.ts +1 -1
- package/esm/typings/src/execution/utils/replaceParameters.d.ts +1 -1
- package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +5 -0
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +5 -5
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -0
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +5 -0
- package/esm/typings/src/llm-providers/langtail/LangtailExecutionTools.d.ts +5 -0
- package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +5 -0
- package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +10 -0
- package/esm/typings/src/llm-providers/mocked/fakeTextToExpectations.d.ts +1 -1
- package/esm/typings/src/llm-providers/mocked/test/fakeTextToExpectations.test.d.ts +1 -0
- package/esm/typings/src/llm-providers/mocked/test/faked-completion.test.d.ts +1 -0
- package/esm/typings/src/llm-providers/mocked/test/mocked-chat.test.d.ts +5 -0
- package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +14 -1
- package/esm/typings/src/llm-providers/multiple/joinLlmExecutionTools.d.ts +16 -0
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +6 -1
- package/esm/typings/src/llm-providers/openai/computeOpenaiUsage.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -0
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +13 -3
- package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -0
- package/esm/typings/src/personas/personaToModelRequirements.d.ts +6 -0
- package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +2 -1
- package/esm/typings/src/types/Arrayable.d.ts +10 -0
- package/esm/typings/src/types/PipelineJson/Expectations.d.ts +28 -0
- package/esm/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +16 -0
- package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +8 -2
- package/esm/typings/src/types/PipelineJson/PromptDialogJson.d.ts +7 -0
- package/esm/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +6 -142
- package/esm/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +77 -0
- package/esm/typings/src/types/PipelineJson/ScriptJson.d.ts +14 -0
- package/esm/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +7 -0
- package/esm/typings/src/types/Prompt.d.ts +3 -3
- package/esm/typings/src/types/TaskProgress.d.ts +2 -2
- package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +3 -3
- package/esm/typings/src/types/typeAliases.d.ts +50 -6
- package/esm/typings/src/utils/arrayableToArray.d.ts +11 -0
- package/esm/typings/src/utils/arrayableToArray.test.d.ts +1 -0
- package/esm/typings/src/utils/emojis.d.ts +1 -0
- package/esm/typings/src/utils/expectation-counters/countCharacters.d.ts +1 -1
- package/esm/typings/src/utils/expectation-counters/countLines.d.ts +1 -1
- package/esm/typings/src/utils/expectation-counters/countPages.d.ts +1 -1
- package/esm/typings/src/utils/expectation-counters/countParagraphs.d.ts +1 -1
- package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +1 -1
- package/esm/typings/src/utils/expectation-counters/countWords.d.ts +1 -1
- package/esm/typings/src/utils/expectation-counters/index.d.ts +2 -2
- package/esm/typings/src/utils/markdown/flattenMarkdown.d.ts +14 -0
- package/esm/typings/src/utils/markdown/flattenMarkdown.test.d.ts +1 -0
- package/esm/typings/src/utils/markdown/parseMarkdownSection.d.ts +30 -0
- package/esm/typings/src/utils/markdown/parseMarkdownSection.test.d.ts +1 -0
- package/esm/typings/src/utils/markdown/prettifyMarkdown.d.ts +1 -0
- package/esm/typings/src/utils/markdown/splitMarkdownIntoSections.d.ts +12 -0
- package/esm/typings/src/utils/markdown/splitMarkdownIntoSections.test.d.ts +1 -0
- package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +8 -1
- package/esm/typings/src/utils/normalization/normalizeTo_PascalCase.d.ts +8 -1
- package/esm/typings/src/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +13 -1
- package/esm/typings/src/utils/normalization/normalizeTo_camelCase.d.ts +8 -1
- package/esm/typings/src/utils/normalization/normalizeTo_snake_case.d.ts +8 -1
- package/esm/typings/src/{conversion/utils → utils}/parseNumber.d.ts +1 -1
- package/esm/typings/src/utils/parseNumber.test.d.ts +1 -0
- package/esm/typings/src/utils/sets/difference.d.ts +2 -0
- package/esm/typings/src/utils/sets/intersection.d.ts +2 -0
- package/esm/typings/src/utils/sets/union.d.ts +2 -0
- package/esm/typings/src/utils/validators/email/isValidEmail.d.ts +5 -0
- package/esm/typings/src/utils/validators/email/isValidEmail.test.d.ts +1 -0
- package/esm/typings/src/utils/validators/filePath/isValidFilePath.d.ts +7 -0
- package/esm/typings/src/utils/validators/filePath/isValidFilePath.test.d.ts +1 -0
- package/esm/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +2 -0
- package/esm/typings/src/utils/validators/javascriptName/isValidJavascriptName.test.d.ts +1 -0
- package/esm/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.d.ts +12 -0
- package/esm/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.test.d.ts +1 -0
- package/esm/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.d.ts +9 -0
- package/esm/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.test.d.ts +1 -0
- package/esm/typings/src/utils/validators/url/isHostnameOnPrivateNetwork.d.ts +9 -0
- package/esm/typings/src/utils/validators/url/isHostnameOnPrivateNetwork.test.d.ts +1 -0
- package/esm/typings/src/utils/validators/url/isUrlOnPrivateNetwork.d.ts +12 -0
- package/esm/typings/src/utils/validators/url/isUrlOnPrivateNetwork.test.d.ts +1 -0
- package/esm/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +12 -0
- package/esm/typings/src/utils/validators/url/isValidPipelineUrl.test.d.ts +1 -0
- package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +3 -0
- package/esm/typings/src/utils/validators/uuid/isValidUuid.d.ts +5 -0
- package/esm/typings/src/utils/validators/uuid/isValidUuid.test.d.ts +1 -0
- package/esm/typings/src/version.d.ts +3 -2
- package/package.json +2 -2
- package/umd/index.umd.js +38 -20
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/promptbook-collection/index.d.ts +61 -4
- package/umd/typings/src/_packages/core.index.d.ts +8 -8
- package/umd/typings/src/_packages/markdown-utils.d.ts +17 -0
- package/umd/typings/src/_packages/types.index.d.ts +11 -6
- package/umd/typings/src/_packages/utils.index.d.ts +23 -19
- package/umd/typings/src/cli/cli-commands/hello.d.ts +7 -0
- package/umd/typings/src/cli/cli-commands/make.d.ts +7 -0
- package/umd/typings/src/cli/cli-commands/prettify.d.ts +7 -0
- package/umd/typings/src/collection/collectionToJson.d.ts +3 -0
- package/umd/typings/src/collection/collectionToJson.test.d.ts +6 -0
- package/umd/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +2 -1
- package/umd/typings/src/commands/BLOCK/BlockCommand.d.ts +11 -0
- package/umd/typings/src/commands/BLOCK/BlockTypes.d.ts +13 -0
- package/umd/typings/src/commands/BLOCK/blockCommand.test.d.ts +1 -0
- package/umd/typings/src/commands/BLOCK/blockCommandParser.d.ts +9 -0
- package/umd/typings/src/commands/EXPECT/ExpectAmountCommand.d.ts +14 -0
- package/umd/typings/src/commands/EXPECT/ExpectCommand.d.ts +9 -0
- package/umd/typings/src/commands/EXPECT/ExpectFormatCommand.d.ts +7 -0
- package/umd/typings/src/commands/EXPECT/expectCommand.test.d.ts +1 -0
- package/umd/typings/src/commands/EXPECT/expectCommandParser.d.ts +9 -0
- package/umd/typings/src/commands/JOKER/JokerCommand.d.ts +11 -0
- package/umd/typings/src/commands/JOKER/jokerCommand.test.d.ts +1 -0
- package/umd/typings/src/commands/JOKER/jokerCommandParser.d.ts +9 -0
- package/umd/typings/src/commands/KNOWLEDGE/KnowledgeCommand.d.ts +12 -0
- package/umd/typings/src/commands/KNOWLEDGE/knowledgeCommand.test.d.ts +1 -0
- package/umd/typings/src/commands/KNOWLEDGE/knowledgeCommandParser.d.ts +9 -0
- package/umd/typings/src/commands/MODEL/ModelCommand.d.ts +13 -0
- package/umd/typings/src/commands/MODEL/modelCommand.test.d.ts +1 -0
- package/umd/typings/src/commands/MODEL/modelCommandParser.d.ts +9 -0
- package/umd/typings/src/commands/PARAMETER/ParameterCommand.d.ts +15 -0
- package/umd/typings/src/commands/PARAMETER/parameterCommand.test.d.ts +1 -0
- package/umd/typings/src/commands/PARAMETER/parameterCommandParser.d.ts +9 -0
- package/umd/typings/src/commands/PERSONA/PersonaCommand.d.ts +11 -0
- package/umd/typings/src/commands/PERSONA/personaCommand.test.d.ts +1 -0
- package/umd/typings/src/commands/PERSONA/personaCommandParser.d.ts +9 -0
- package/umd/typings/src/commands/POSTPROCESS/PostprocessCommand.d.ts +11 -0
- package/umd/typings/src/commands/POSTPROCESS/postprocessCommand.test.d.ts +1 -0
- package/umd/typings/src/commands/POSTPROCESS/postprocessCommandParser.d.ts +9 -0
- package/umd/typings/src/commands/PROMPTBOOK_VERSION/PromptbookVersionCommand.d.ts +11 -0
- package/umd/typings/src/commands/PROMPTBOOK_VERSION/promptbookVersionCommand.test.d.ts +1 -0
- package/umd/typings/src/commands/PROMPTBOOK_VERSION/promptbookVersionCommandParser.d.ts +9 -0
- package/umd/typings/src/commands/URL/UrlCommand.d.ts +10 -0
- package/umd/typings/src/commands/URL/urlCommand.test.d.ts +1 -0
- package/umd/typings/src/commands/URL/urlCommandParser.d.ts +9 -0
- package/umd/typings/src/commands/X_ACTION/ActionCommand.d.ts +9 -0
- package/umd/typings/src/commands/X_ACTION/actionCommand.test.d.ts +1 -0
- package/umd/typings/src/commands/X_ACTION/actionCommandParser.d.ts +9 -0
- package/umd/typings/src/commands/X_INSTRUMENT/InstrumentCommand.d.ts +9 -0
- package/umd/typings/src/commands/X_INSTRUMENT/instrumentCommand.test.d.ts +1 -0
- package/umd/typings/src/commands/X_INSTRUMENT/instrumentCommandParser.d.ts +9 -0
- package/umd/typings/src/commands/_BOILERPLATE/BoilerplateCommand.d.ts +10 -0
- package/umd/typings/src/commands/_BOILERPLATE/boilerplateCommand.test.d.ts +1 -0
- package/umd/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +12 -0
- package/umd/typings/src/commands/_common/parseCommand.d.ts +12 -0
- package/umd/typings/src/commands/_common/parseCommand.test.d.ts +1 -0
- package/umd/typings/src/commands/_common/types/Command.d.ts +6 -0
- package/umd/typings/src/commands/_common/types/CommandParser.d.ts +36 -0
- package/umd/typings/src/commands/_common/types/CommandUsagePlaces.d.ts +9 -0
- package/umd/typings/src/commands/index.d.ts +4 -0
- package/umd/typings/src/config.d.ts +4 -0
- package/umd/typings/src/conversion/pipelineJsonToString.d.ts +2 -0
- package/umd/typings/src/conversion/pipelineStringToJson.d.ts +2 -3
- package/umd/typings/src/conversion/pipelineStringToJsonSync.d.ts +4 -2
- package/umd/typings/src/conversion/utils/extractParametersFromPromptTemplate.d.ts +2 -2
- package/umd/typings/src/conversion/utils/extractVariables.d.ts +1 -1
- package/umd/typings/src/conversion/validation/validatePipeline-logicErrors.test.d.ts +3 -0
- package/umd/typings/src/errors/NotYetImplementedError.d.ts +7 -0
- package/umd/typings/src/errors/{SyntaxError.d.ts → ParsingError.d.ts} +2 -2
- package/{esm/typings/src/errors/ExecutionError.d.ts → umd/typings/src/errors/PipelineExecutionError.d.ts} +2 -2
- package/umd/typings/src/errors/_ExpectError.d.ts +2 -2
- package/umd/typings/src/execution/ExecutionTools.d.ts +4 -3
- package/umd/typings/src/execution/LlmExecutionTools.d.ts +24 -5
- package/umd/typings/src/execution/PromptResult.d.ts +2 -2
- package/umd/typings/src/execution/assertsExecutionSuccessful.d.ts +1 -1
- package/umd/typings/src/execution/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.d.ts +1 -1
- package/umd/typings/src/execution/utils/checkExpectations.d.ts +1 -1
- package/umd/typings/src/execution/utils/replaceParameters.d.ts +1 -1
- package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +5 -0
- package/umd/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +5 -5
- package/umd/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -0
- package/umd/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +5 -0
- package/umd/typings/src/llm-providers/langtail/LangtailExecutionTools.d.ts +5 -0
- package/umd/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +5 -0
- package/umd/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +10 -0
- package/umd/typings/src/llm-providers/mocked/fakeTextToExpectations.d.ts +1 -1
- package/umd/typings/src/llm-providers/mocked/test/fakeTextToExpectations.test.d.ts +1 -0
- package/umd/typings/src/llm-providers/mocked/test/faked-completion.test.d.ts +1 -0
- package/umd/typings/src/llm-providers/mocked/test/mocked-chat.test.d.ts +5 -0
- package/umd/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +14 -1
- package/umd/typings/src/llm-providers/multiple/joinLlmExecutionTools.d.ts +16 -0
- package/umd/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +6 -1
- package/umd/typings/src/llm-providers/openai/computeOpenaiUsage.d.ts +1 -1
- package/umd/typings/src/llm-providers/openai/openai-models.d.ts +1 -0
- package/umd/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +13 -3
- package/umd/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -0
- package/umd/typings/src/personas/personaToModelRequirements.d.ts +6 -0
- package/umd/typings/src/scripting/javascript/utils/preserve.d.ts +2 -1
- package/umd/typings/src/types/Arrayable.d.ts +10 -0
- package/umd/typings/src/types/PipelineJson/Expectations.d.ts +28 -0
- package/umd/typings/src/types/PipelineJson/LlmTemplateJson.d.ts +16 -0
- package/umd/typings/src/types/PipelineJson/PipelineJson.d.ts +8 -2
- package/umd/typings/src/types/PipelineJson/PromptDialogJson.d.ts +7 -0
- package/umd/typings/src/types/PipelineJson/PromptTemplateJson.d.ts +6 -142
- package/umd/typings/src/types/PipelineJson/PromptTemplateJsonCommon.d.ts +77 -0
- package/umd/typings/src/types/PipelineJson/ScriptJson.d.ts +14 -0
- package/umd/typings/src/types/PipelineJson/SimpleTemplateJson.d.ts +7 -0
- package/umd/typings/src/types/Prompt.d.ts +3 -3
- package/umd/typings/src/types/TaskProgress.d.ts +2 -2
- package/umd/typings/src/types/execution-report/ExecutionReportJson.d.ts +3 -3
- package/umd/typings/src/types/typeAliases.d.ts +50 -6
- package/umd/typings/src/utils/arrayableToArray.d.ts +11 -0
- package/umd/typings/src/utils/arrayableToArray.test.d.ts +1 -0
- package/umd/typings/src/utils/emojis.d.ts +1 -0
- package/umd/typings/src/utils/expectation-counters/countCharacters.d.ts +1 -1
- package/umd/typings/src/utils/expectation-counters/countLines.d.ts +1 -1
- package/umd/typings/src/utils/expectation-counters/countPages.d.ts +1 -1
- package/umd/typings/src/utils/expectation-counters/countParagraphs.d.ts +1 -1
- package/umd/typings/src/utils/expectation-counters/countSentences.d.ts +1 -1
- package/umd/typings/src/utils/expectation-counters/countWords.d.ts +1 -1
- package/umd/typings/src/utils/expectation-counters/index.d.ts +2 -2
- package/umd/typings/src/utils/markdown/flattenMarkdown.d.ts +14 -0
- package/umd/typings/src/utils/markdown/flattenMarkdown.test.d.ts +1 -0
- package/umd/typings/src/utils/markdown/parseMarkdownSection.d.ts +30 -0
- package/umd/typings/src/utils/markdown/parseMarkdownSection.test.d.ts +1 -0
- package/umd/typings/src/utils/markdown/prettifyMarkdown.d.ts +1 -0
- package/umd/typings/src/utils/markdown/splitMarkdownIntoSections.d.ts +12 -0
- package/umd/typings/src/utils/markdown/splitMarkdownIntoSections.test.d.ts +1 -0
- package/umd/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +8 -1
- package/umd/typings/src/utils/normalization/normalizeTo_PascalCase.d.ts +8 -1
- package/umd/typings/src/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +13 -1
- package/umd/typings/src/utils/normalization/normalizeTo_camelCase.d.ts +8 -1
- package/umd/typings/src/utils/normalization/normalizeTo_snake_case.d.ts +8 -1
- package/umd/typings/src/{conversion/utils → utils}/parseNumber.d.ts +1 -1
- package/umd/typings/src/utils/parseNumber.test.d.ts +1 -0
- package/umd/typings/src/utils/sets/difference.d.ts +2 -0
- package/umd/typings/src/utils/sets/intersection.d.ts +2 -0
- package/umd/typings/src/utils/sets/union.d.ts +2 -0
- package/umd/typings/src/utils/validators/email/isValidEmail.d.ts +5 -0
- package/umd/typings/src/utils/validators/email/isValidEmail.test.d.ts +1 -0
- package/umd/typings/src/utils/validators/filePath/isValidFilePath.d.ts +7 -0
- package/umd/typings/src/utils/validators/filePath/isValidFilePath.test.d.ts +1 -0
- package/umd/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +2 -0
- package/umd/typings/src/utils/validators/javascriptName/isValidJavascriptName.test.d.ts +1 -0
- package/umd/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.d.ts +12 -0
- package/umd/typings/src/utils/validators/semanticVersion/isValidPromptbookVersion.test.d.ts +1 -0
- package/umd/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.d.ts +9 -0
- package/umd/typings/src/utils/validators/semanticVersion/isValidSemanticVersion.test.d.ts +1 -0
- package/umd/typings/src/utils/validators/url/isHostnameOnPrivateNetwork.d.ts +9 -0
- package/umd/typings/src/utils/validators/url/isHostnameOnPrivateNetwork.test.d.ts +1 -0
- package/umd/typings/src/utils/validators/url/isUrlOnPrivateNetwork.d.ts +12 -0
- package/umd/typings/src/utils/validators/url/isUrlOnPrivateNetwork.test.d.ts +1 -0
- package/umd/typings/src/utils/validators/url/isValidPipelineUrl.d.ts +12 -0
- package/umd/typings/src/utils/validators/url/isValidPipelineUrl.test.d.ts +1 -0
- package/umd/typings/src/utils/validators/url/isValidUrl.d.ts +3 -0
- package/umd/typings/src/utils/validators/uuid/isValidUuid.d.ts +5 -0
- package/umd/typings/src/utils/validators/uuid/isValidUuid.test.d.ts +1 -0
- package/umd/typings/src/version.d.ts +3 -2
- package/esm/typings/src/cli/actions/hello.d.ts +0 -7
- package/esm/typings/src/cli/actions/make.d.ts +0 -7
- package/esm/typings/src/cli/actions/prettify.d.ts +0 -7
- package/esm/typings/src/conversion/utils/parseCommand.d.ts +0 -11
- package/esm/typings/src/conversion/utils/parseCommand.test.d.ts +0 -4
- package/esm/typings/src/errors/TemplateError.d.ts +0 -9
- package/esm/typings/src/llm-providers/mocked/mocked-chat.test.d.ts +0 -4
- package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionToolsOptions.d.ts +0 -24
- package/esm/typings/src/types/Command.d.ts +0 -101
- package/esm/typings/src/types/ExecutionTypes.d.ts +0 -13
- package/esm/typings/src/utils/markdown-json/MarkdownStructure.d.ts +0 -25
- package/esm/typings/src/utils/markdown-json/countMarkdownStructureDeepness.d.ts +0 -7
- package/esm/typings/src/utils/markdown-json/markdownToMarkdownStructure.d.ts +0 -13
- package/umd/typings/src/cli/actions/hello.d.ts +0 -7
- package/umd/typings/src/cli/actions/make.d.ts +0 -7
- package/umd/typings/src/cli/actions/prettify.d.ts +0 -7
- package/umd/typings/src/conversion/utils/parseCommand.d.ts +0 -11
- package/umd/typings/src/conversion/utils/parseCommand.test.d.ts +0 -4
- package/umd/typings/src/errors/TemplateError.d.ts +0 -9
- package/umd/typings/src/llm-providers/mocked/mocked-chat.test.d.ts +0 -4
- package/umd/typings/src/llm-providers/multiple/MultipleLlmExecutionToolsOptions.d.ts +0 -24
- package/umd/typings/src/types/Command.d.ts +0 -101
- package/umd/typings/src/types/ExecutionTypes.d.ts +0 -13
- package/umd/typings/src/utils/markdown-json/MarkdownStructure.d.ts +0 -25
- package/umd/typings/src/utils/markdown-json/countMarkdownStructureDeepness.d.ts +0 -7
- package/umd/typings/src/utils/markdown-json/markdownToMarkdownStructure.d.ts +0 -13
- /package/esm/typings/src/{conversion/utils/parseNumber.test.d.ts → commands/BLOCK/blockCommand.test.d.ts} +0 -0
- /package/esm/typings/src/{llm-providers/mocked/fakeTextToExpectations.test.d.ts → commands/EXPECT/expectCommand.test.d.ts} +0 -0
- /package/esm/typings/src/{llm-providers/mocked/faked-completion.test.d.ts → commands/JOKER/jokerCommand.test.d.ts} +0 -0
- /package/esm/typings/src/{utils/markdown-json/countMarkdownStructureDeepness.test.d.ts → commands/KNOWLEDGE/knowledgeCommand.test.d.ts} +0 -0
- /package/esm/typings/src/{utils/markdown-json/markdownToMarkdownStructure.test.d.ts → commands/MODEL/modelCommand.test.d.ts} +0 -0
- /package/{umd/typings/src/conversion/utils/parseNumber.test.d.ts → esm/typings/src/commands/PARAMETER/parameterCommand.test.d.ts} +0 -0
- /package/{umd/typings/src/llm-providers/mocked/fakeTextToExpectations.test.d.ts → esm/typings/src/commands/PERSONA/personaCommand.test.d.ts} +0 -0
- /package/{umd/typings/src/llm-providers/mocked/faked-completion.test.d.ts → esm/typings/src/commands/POSTPROCESS/postprocessCommand.test.d.ts} +0 -0
- /package/{umd/typings/src/utils/markdown-json/countMarkdownStructureDeepness.test.d.ts → esm/typings/src/commands/PROMPTBOOK_VERSION/promptbookVersionCommand.test.d.ts} +0 -0
- /package/{umd/typings/src/utils/markdown-json/markdownToMarkdownStructure.test.d.ts → esm/typings/src/commands/URL/urlCommand.test.d.ts} +0 -0
- /package/esm/typings/src/llm-providers/mocked/{joker.test.d.ts → test/joker.test.d.ts} +0 -0
- /package/esm/typings/src/llm-providers/mocked/{mocked-completion.test.d.ts → test/mocked-completion.test.d.ts} +0 -0
- /package/umd/typings/src/llm-providers/mocked/{joker.test.d.ts → test/joker.test.d.ts} +0 -0
- /package/umd/typings/src/llm-providers/mocked/{mocked-completion.test.d.ts → test/mocked-completion.test.d.ts} +0 -0
|
@@ -4,5 +4,6 @@ import type { string_html } from '../../types/typeAliases';
|
|
|
4
4
|
*
|
|
5
5
|
* @param content raw html code
|
|
6
6
|
* @returns formatted html code
|
|
7
|
+
* @private withing the package because of HUGE size of prettier dependency
|
|
7
8
|
*/
|
|
8
9
|
export declare function prettifyMarkdown<TContent extends string_html>(content: TContent): TContent;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { string_markdown } from '../../types/typeAliases';
|
|
2
|
+
import type { string_markdown_section } from '../../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* Splits the markdown into sections by headings
|
|
5
|
+
*/
|
|
6
|
+
export declare function splitMarkdownIntoSections(markdown: string_markdown): Array<string_markdown_section>;
|
|
7
|
+
/**
|
|
8
|
+
* Note: [🕞] In past (commit 42086e1603cbed506482997c00a8ee979af0a247) there was much more
|
|
9
|
+
* sophisticated implementation of this function through parsing markdown into JSON structure
|
|
10
|
+
* and flattening the actual structure
|
|
11
|
+
* NOW we are working just with markdown string and its good enough
|
|
12
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Semantic helper for kebab-case strings
|
|
3
|
+
*
|
|
4
|
+
* @example 'hello-world'
|
|
5
|
+
* @example 'i-love-promptbook'
|
|
6
|
+
*/
|
|
7
|
+
export type string_kebab_case = string;
|
|
8
|
+
export declare function normalizeToKebabCase(text: string): string_kebab_case;
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Semantic helper for PascalCase strings
|
|
3
|
+
*
|
|
4
|
+
* @example 'HelloWorld'
|
|
5
|
+
* @example 'ILovePromptbook'
|
|
6
|
+
*/
|
|
7
|
+
export type string_PascalCase = string;
|
|
8
|
+
export declare function normalizeTo_PascalCase(text: string): string_PascalCase;
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
export declare function normalizeTo_SCREAMING_CASE(sentence: string): string;
|
|
2
1
|
/**
|
|
2
|
+
* Semantic helper for SCREAMING_CASE strings
|
|
3
|
+
*
|
|
4
|
+
* @example 'HELLO_WORLD'
|
|
5
|
+
* @example 'I_LOVE_PROMPTBOOK'
|
|
6
|
+
*/
|
|
7
|
+
export type string_SCREAMING_CASE = string;
|
|
8
|
+
export declare function normalizeTo_SCREAMING_CASE(text: string): string_SCREAMING_CASE;
|
|
9
|
+
/**
|
|
10
|
+
* TODO: Tests
|
|
11
|
+
* > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'Moje tabule' })).toEqual('/VtG7sR9rRJqwNEdM2/Moje tabule');
|
|
12
|
+
* > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'ěščřžžýáíúů' })).toEqual('/VtG7sR9rRJqwNEdM2/escrzyaieuu');
|
|
13
|
+
* > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj');
|
|
14
|
+
* > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj_ahojAhoj ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj-ahoj-ahoj-ahoj');
|
|
3
15
|
* TODO: [🌺] Use some intermediate util splitWords
|
|
4
16
|
*/
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Semantic helper for camelCase strings
|
|
3
|
+
*
|
|
4
|
+
* @example 'helloWorld'
|
|
5
|
+
* @example 'iLovePromptbook'
|
|
6
|
+
*/
|
|
7
|
+
export type string_camelCase = string;
|
|
8
|
+
export declare function normalizeTo_camelCase(text: string, _isFirstLetterCapital?: boolean): string_camelCase;
|
|
2
9
|
/**
|
|
3
10
|
* TODO: [🌺] Use some intermediate util splitWords
|
|
4
11
|
*/
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Semantic helper for snake_case strings
|
|
3
|
+
*
|
|
4
|
+
* @example 'hello_world'
|
|
5
|
+
* @example 'i_love_promptbook'
|
|
6
|
+
*/
|
|
7
|
+
export type string_snake_case = string;
|
|
8
|
+
export declare function normalizeTo_snake_case(text: string): string_snake_case;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Create difference set of two sets.
|
|
3
|
+
*
|
|
4
|
+
* @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
3
5
|
*/
|
|
4
6
|
export declare function difference<TItem>(a: Set<TItem>, b: Set<TItem>, isEqual?: (a: TItem, b: TItem) => boolean): Set<TItem>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Creates a new set with all elements that are present in all sets
|
|
3
|
+
*
|
|
4
|
+
* @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
3
5
|
*/
|
|
4
6
|
export declare function intersection<TItem>(...sets: Array<Set<TItem>>): Set<TItem>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Creates a new set with all elements that are present in either set
|
|
3
|
+
*
|
|
4
|
+
* @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
3
5
|
*/
|
|
4
6
|
export declare function union<TItem>(...sets: Array<Set<TItem>>): Set<TItem>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { string_file_path } from '../../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Tests if given string is valid URL.
|
|
4
|
+
*
|
|
5
|
+
* Note: This does not check if the file exists only if the path is valid
|
|
6
|
+
*/
|
|
7
|
+
export declare function isValidFilePath(filePath: unknown): filePath is string_file_path;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { string_promptbook_version } from '../../../version';
|
|
2
|
+
/**
|
|
3
|
+
* Tests if given string is valid promptbook version
|
|
4
|
+
* It looks into list of known promptbook versions.
|
|
5
|
+
*
|
|
6
|
+
* @see https://www.npmjs.com/package/promptbook?activeTab=versions
|
|
7
|
+
* Note: When you are using for example promptbook 2.0.0 and there already is promptbook 3.0.0 it don`t know about it.
|
|
8
|
+
* Note: There are two simmilar functions:
|
|
9
|
+
* - `isValidSemanticVersion` which tests any semantic version
|
|
10
|
+
* - `isValidPromptbookVersion` *(this one)* which tests just Promptbook versions
|
|
11
|
+
*/
|
|
12
|
+
export declare function isValidPromptbookVersion(version: unknown): version is string_promptbook_version;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { string_semantic_version } from '../../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Tests if given string is valid semantic version
|
|
4
|
+
*
|
|
5
|
+
* Note: There are two simmilar functions:
|
|
6
|
+
* - `isValidSemanticVersion` which tests any semantic version
|
|
7
|
+
* - `isValidPromptbookVersion` *(this one)* which tests just Promptbook versions
|
|
8
|
+
*/
|
|
9
|
+
export declare function isValidSemanticVersion(version: unknown): version is string_semantic_version;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { string_hostname } from '../../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if an URL is reserved for private networks or localhost.
|
|
4
|
+
*
|
|
5
|
+
* Note: There are two simmilar functions:
|
|
6
|
+
* - `isUrlOnPrivateNetwork` which tests full URL
|
|
7
|
+
* - `isHostnameOnPrivateNetwork` *(this one)* which tests just hostname
|
|
8
|
+
*/
|
|
9
|
+
export declare function isHostnameOnPrivateNetwork(hostname: string_hostname): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { string_url } from '../../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if an IP address or hostname is reserved for private networks or localhost.
|
|
4
|
+
*
|
|
5
|
+
* Note: There are two simmilar functions:
|
|
6
|
+
* - `isUrlOnPrivateNetwork` *(this one)* which tests full URL
|
|
7
|
+
* - `isHostnameOnPrivateNetwork` which tests just hostname
|
|
8
|
+
*
|
|
9
|
+
* @param {string} ipAddress - The IP address to check.
|
|
10
|
+
* @returns {boolean} Returns true if the IP address is reserved for private networks or localhost, otherwise false.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isUrlOnPrivateNetwork(url: URL | string_url): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { string_pipeline_url } from '../../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Tests if given string is valid pipeline URL URL.
|
|
4
|
+
*
|
|
5
|
+
* Note: There are two simmilar functions:
|
|
6
|
+
* - `isValidUrl` which tests any URL
|
|
7
|
+
* - `isValidPipelineUrl` *(this one)* which tests just pipeline URL
|
|
8
|
+
*/
|
|
9
|
+
export declare function isValidPipelineUrl(url: unknown): url is string_pipeline_url;
|
|
10
|
+
/**
|
|
11
|
+
* TODO: [🐠] Maybe more info why the URL is invalid
|
|
12
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,5 +3,8 @@ import type { string_url } from '../../../types/typeAliases';
|
|
|
3
3
|
* Tests if given string is valid URL.
|
|
4
4
|
*
|
|
5
5
|
* Note: Dataurl are considered perfectly valid.
|
|
6
|
+
* Note: There are two simmilar functions:
|
|
7
|
+
* - `isValidUrl` which tests any URL
|
|
8
|
+
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
6
9
|
*/
|
|
7
10
|
export declare function isValidUrl(url: unknown): url is string_url;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { string_semantic_version } from './types/typeAliases';
|
|
2
2
|
/**
|
|
3
3
|
* The version of the Promptbook library
|
|
4
4
|
*/
|
|
5
|
-
export declare const PROMPTBOOK_VERSION:
|
|
5
|
+
export declare const PROMPTBOOK_VERSION: string_promptbook_version;
|
|
6
|
+
export type string_promptbook_version = string_semantic_version;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/openai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.61.0-1",
|
|
4
4
|
"description": "Supercharge your use of large language models",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
}
|
|
50
50
|
],
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@promptbook/core": "0.
|
|
52
|
+
"@promptbook/core": "0.61.0-1"
|
|
53
53
|
},
|
|
54
54
|
"main": "./umd/index.umd.js",
|
|
55
55
|
"module": "./esm/index.es.js",
|
package/umd/index.umd.js
CHANGED
|
@@ -455,6 +455,7 @@
|
|
|
455
455
|
/**/
|
|
456
456
|
];
|
|
457
457
|
/**
|
|
458
|
+
* Note: [🤖] Add models of new variant
|
|
458
459
|
* TODO: [🧠] Some mechanism to propagate unsureness
|
|
459
460
|
* TODO: [🕚][👮♀️] Make this list dynamic - dynamically can be listed modelNames but not modelVariant, legacy status, context length and pricing
|
|
460
461
|
* TODO: [🧠][👮♀️] Put here more info like description, isVision, trainingDateCutoff, languages, strengths ( Top-level performance, intelligence, fluency, and understanding), contextWindow,...
|
|
@@ -468,15 +469,15 @@
|
|
|
468
469
|
/**
|
|
469
470
|
* This error indicates errors during the execution of the pipeline
|
|
470
471
|
*/
|
|
471
|
-
var
|
|
472
|
-
__extends(
|
|
473
|
-
function
|
|
472
|
+
var PipelineExecutionError = /** @class */ (function (_super) {
|
|
473
|
+
__extends(PipelineExecutionError, _super);
|
|
474
|
+
function PipelineExecutionError(message) {
|
|
474
475
|
var _this = _super.call(this, message) || this;
|
|
475
|
-
_this.name = '
|
|
476
|
-
Object.setPrototypeOf(_this,
|
|
476
|
+
_this.name = 'PipelineExecutionError';
|
|
477
|
+
Object.setPrototypeOf(_this, PipelineExecutionError.prototype);
|
|
477
478
|
return _this;
|
|
478
479
|
}
|
|
479
|
-
return
|
|
480
|
+
return PipelineExecutionError;
|
|
480
481
|
}(Error));
|
|
481
482
|
|
|
482
483
|
/**
|
|
@@ -855,17 +856,17 @@
|
|
|
855
856
|
* @param promptContent The content of the prompt
|
|
856
857
|
* @param resultContent The content of the result (for embedding prompts or failed prompts pass empty string)
|
|
857
858
|
* @param rawResponse The raw response from OpenAI API
|
|
858
|
-
* @throws {
|
|
859
|
+
* @throws {PipelineExecutionError} If the usage is not defined in the response from OpenAI
|
|
859
860
|
* @private internal util of `OpenAiExecutionTools`
|
|
860
861
|
*/
|
|
861
862
|
function computeOpenaiUsage(promptContent, // <- Note: Intentionally using [] to access type properties to bring jsdoc from Prompt/PromptResult to consumer
|
|
862
863
|
resultContent, rawResponse) {
|
|
863
864
|
var _a, _b;
|
|
864
865
|
if (rawResponse.usage === undefined) {
|
|
865
|
-
throw new
|
|
866
|
+
throw new PipelineExecutionError('The usage is not defined in the response from OpenAI');
|
|
866
867
|
}
|
|
867
868
|
if (((_a = rawResponse.usage) === null || _a === void 0 ? void 0 : _a.prompt_tokens) === undefined) {
|
|
868
|
-
throw new
|
|
869
|
+
throw new PipelineExecutionError('In OpenAI response `usage.prompt_tokens` not defined');
|
|
869
870
|
}
|
|
870
871
|
var inputTokens = rawResponse.usage.prompt_tokens;
|
|
871
872
|
var outputTokens = ((_b = rawResponse.usage) === null || _b === void 0 ? void 0 : _b.completion_tokens) || 0;
|
|
@@ -902,6 +903,20 @@
|
|
|
902
903
|
delete openAiOptions.user;
|
|
903
904
|
this.client = new OpenAI__default["default"](__assign({}, openAiOptions));
|
|
904
905
|
}
|
|
906
|
+
Object.defineProperty(OpenAiExecutionTools.prototype, "title", {
|
|
907
|
+
get: function () {
|
|
908
|
+
return 'OpenAI';
|
|
909
|
+
},
|
|
910
|
+
enumerable: false,
|
|
911
|
+
configurable: true
|
|
912
|
+
});
|
|
913
|
+
Object.defineProperty(OpenAiExecutionTools.prototype, "description", {
|
|
914
|
+
get: function () {
|
|
915
|
+
return 'Use all models provided by OpenAI';
|
|
916
|
+
},
|
|
917
|
+
enumerable: false,
|
|
918
|
+
configurable: true
|
|
919
|
+
});
|
|
905
920
|
/**
|
|
906
921
|
* Calls OpenAI API to use a chat model.
|
|
907
922
|
*/
|
|
@@ -917,7 +932,7 @@
|
|
|
917
932
|
content = prompt.content, modelRequirements = prompt.modelRequirements, expectFormat = prompt.expectFormat;
|
|
918
933
|
// TODO: [☂] Use here more modelRequirements
|
|
919
934
|
if (modelRequirements.modelVariant !== 'CHAT') {
|
|
920
|
-
throw new
|
|
935
|
+
throw new PipelineExecutionError('Use callChatModel only for CHAT variant');
|
|
921
936
|
}
|
|
922
937
|
model = modelRequirements.modelName || this.getDefaultChatModel().modelName;
|
|
923
938
|
modelSettings = {
|
|
@@ -947,18 +962,18 @@
|
|
|
947
962
|
console.info(colors__default["default"].bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
|
|
948
963
|
}
|
|
949
964
|
if (!rawResponse.choices[0]) {
|
|
950
|
-
throw new
|
|
965
|
+
throw new PipelineExecutionError('No choises from OpenAI');
|
|
951
966
|
}
|
|
952
967
|
if (rawResponse.choices.length > 1) {
|
|
953
968
|
// TODO: This should be maybe only warning
|
|
954
|
-
throw new
|
|
969
|
+
throw new PipelineExecutionError('More than one choise from OpenAI');
|
|
955
970
|
}
|
|
956
971
|
resultContent = rawResponse.choices[0].message.content;
|
|
957
972
|
// eslint-disable-next-line prefer-const
|
|
958
973
|
complete = getCurrentIsoDate();
|
|
959
974
|
usage = computeOpenaiUsage(content, resultContent || '', rawResponse);
|
|
960
975
|
if (resultContent === null) {
|
|
961
|
-
throw new
|
|
976
|
+
throw new PipelineExecutionError('No response message from OpenAI');
|
|
962
977
|
}
|
|
963
978
|
return [2 /*return*/, {
|
|
964
979
|
content: resultContent,
|
|
@@ -990,7 +1005,7 @@
|
|
|
990
1005
|
content = prompt.content, modelRequirements = prompt.modelRequirements;
|
|
991
1006
|
// TODO: [☂] Use here more modelRequirements
|
|
992
1007
|
if (modelRequirements.modelVariant !== 'COMPLETION') {
|
|
993
|
-
throw new
|
|
1008
|
+
throw new PipelineExecutionError('Use callCompletionModel only for COMPLETION variant');
|
|
994
1009
|
}
|
|
995
1010
|
model = modelRequirements.modelName || this.getDefaultCompletionModel().modelName;
|
|
996
1011
|
modelSettings = {
|
|
@@ -1010,11 +1025,11 @@
|
|
|
1010
1025
|
console.info(colors__default["default"].bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
|
|
1011
1026
|
}
|
|
1012
1027
|
if (!rawResponse.choices[0]) {
|
|
1013
|
-
throw new
|
|
1028
|
+
throw new PipelineExecutionError('No choises from OpenAI');
|
|
1014
1029
|
}
|
|
1015
1030
|
if (rawResponse.choices.length > 1) {
|
|
1016
1031
|
// TODO: This should be maybe only warning
|
|
1017
|
-
throw new
|
|
1032
|
+
throw new PipelineExecutionError('More than one choise from OpenAI');
|
|
1018
1033
|
}
|
|
1019
1034
|
resultContent = rawResponse.choices[0].text;
|
|
1020
1035
|
// eslint-disable-next-line prefer-const
|
|
@@ -1038,7 +1053,7 @@
|
|
|
1038
1053
|
/**
|
|
1039
1054
|
* Calls OpenAI API to use a embedding model
|
|
1040
1055
|
*/
|
|
1041
|
-
OpenAiExecutionTools.prototype.
|
|
1056
|
+
OpenAiExecutionTools.prototype.callEmbeddingModel = function (prompt) {
|
|
1042
1057
|
return __awaiter(this, void 0, void 0, function () {
|
|
1043
1058
|
var content, modelRequirements, model, rawRequest, start, complete, rawResponse, resultContent, usage;
|
|
1044
1059
|
return __generator(this, function (_a) {
|
|
@@ -1050,7 +1065,7 @@
|
|
|
1050
1065
|
content = prompt.content, modelRequirements = prompt.modelRequirements;
|
|
1051
1066
|
// TODO: [☂] Use here more modelRequirements
|
|
1052
1067
|
if (modelRequirements.modelVariant !== 'EMBEDDING') {
|
|
1053
|
-
throw new
|
|
1068
|
+
throw new PipelineExecutionError('Use embed only for EMBEDDING variant');
|
|
1054
1069
|
}
|
|
1055
1070
|
model = modelRequirements.modelName || this.getDefaultEmbeddingModel().modelName;
|
|
1056
1071
|
rawRequest = {
|
|
@@ -1069,7 +1084,7 @@
|
|
|
1069
1084
|
console.info(colors__default["default"].bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
|
|
1070
1085
|
}
|
|
1071
1086
|
if (rawResponse.data.length !== 1) {
|
|
1072
|
-
throw new
|
|
1087
|
+
throw new PipelineExecutionError("Expected exactly 1 data item in response, got ".concat(rawResponse.data.length));
|
|
1073
1088
|
}
|
|
1074
1089
|
resultContent = rawResponse.data[0].embedding;
|
|
1075
1090
|
// eslint-disable-next-line prefer-const
|
|
@@ -1090,6 +1105,7 @@
|
|
|
1090
1105
|
});
|
|
1091
1106
|
});
|
|
1092
1107
|
};
|
|
1108
|
+
// <- Note: [🤖] callXxxModel
|
|
1093
1109
|
/**
|
|
1094
1110
|
* Get the model that should be used as default
|
|
1095
1111
|
*/
|
|
@@ -1126,6 +1142,7 @@
|
|
|
1126
1142
|
OpenAiExecutionTools.prototype.getDefaultEmbeddingModel = function () {
|
|
1127
1143
|
return this.getDefaultModel('text-embedding-3-large');
|
|
1128
1144
|
};
|
|
1145
|
+
// <- Note: [🤖] getDefaultXxxModel
|
|
1129
1146
|
/**
|
|
1130
1147
|
* List all available OpenAI models that can be used
|
|
1131
1148
|
*/
|
|
@@ -1150,7 +1167,8 @@
|
|
|
1150
1167
|
/**
|
|
1151
1168
|
* The version of the Promptbook library
|
|
1152
1169
|
*/
|
|
1153
|
-
var PROMPTBOOK_VERSION = '0.
|
|
1170
|
+
var PROMPTBOOK_VERSION = '0.61.0-0';
|
|
1171
|
+
// TODO: !!!! List here all the versions and annotate + put into script
|
|
1154
1172
|
|
|
1155
1173
|
exports.OPENAI_MODELS = OPENAI_MODELS;
|
|
1156
1174
|
exports.OpenAiExecutionTools = OpenAiExecutionTools;
|