@promptbook/azure-openai 0.92.0-3 → 0.92.0-31

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.
Files changed (172) hide show
  1. package/esm/index.es.js +64 -36
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/browser.index.d.ts +2 -0
  4. package/esm/typings/src/_packages/core.index.d.ts +22 -6
  5. package/esm/typings/src/_packages/deepseek.index.d.ts +2 -0
  6. package/esm/typings/src/_packages/google.index.d.ts +2 -0
  7. package/esm/typings/src/_packages/types.index.d.ts +4 -2
  8. package/esm/typings/src/_packages/utils.index.d.ts +2 -0
  9. package/esm/typings/src/cli/common/$provideLlmToolsForCli.d.ts +1 -1
  10. package/esm/typings/src/collection/PipelineCollection.d.ts +0 -2
  11. package/esm/typings/src/collection/SimplePipelineCollection.d.ts +1 -1
  12. package/esm/typings/src/commands/FOREACH/ForeachJson.d.ts +6 -6
  13. package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +0 -2
  14. package/esm/typings/src/commands/FORMFACTOR/formfactorCommandParser.d.ts +1 -1
  15. package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -1
  16. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +36 -28
  17. package/esm/typings/src/config.d.ts +41 -11
  18. package/esm/typings/src/constants.d.ts +43 -2
  19. package/esm/typings/src/conversion/archive/loadArchive.d.ts +2 -2
  20. package/esm/typings/src/errors/0-BoilerplateError.d.ts +2 -2
  21. package/esm/typings/src/executables/$provideExecutablesForNode.d.ts +1 -1
  22. package/esm/typings/src/executables/apps/locateLibreoffice.d.ts +2 -1
  23. package/esm/typings/src/executables/apps/locatePandoc.d.ts +2 -1
  24. package/esm/typings/src/executables/locateApp.d.ts +2 -2
  25. package/esm/typings/src/executables/platforms/locateAppOnLinux.d.ts +2 -1
  26. package/esm/typings/src/executables/platforms/locateAppOnMacOs.d.ts +2 -1
  27. package/esm/typings/src/executables/platforms/locateAppOnWindows.d.ts +2 -1
  28. package/esm/typings/src/execution/AbstractTaskResult.d.ts +1 -1
  29. package/esm/typings/src/execution/CommonToolsOptions.d.ts +5 -1
  30. package/esm/typings/src/execution/LlmExecutionToolsConstructor.d.ts +2 -1
  31. package/esm/typings/src/execution/PipelineExecutorResult.d.ts +4 -2
  32. package/esm/typings/src/execution/createPipelineExecutor/$OngoingTaskResult.d.ts +12 -9
  33. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +13 -10
  34. package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +12 -9
  35. package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +15 -3
  36. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +20 -14
  37. package/esm/typings/src/execution/createPipelineExecutor/computeCosineSimilarity.d.ts +13 -0
  38. package/esm/typings/src/execution/createPipelineExecutor/filterJustOutputParameters.d.ts +7 -6
  39. package/esm/typings/src/execution/createPipelineExecutor/getContextForTask.d.ts +5 -1
  40. package/esm/typings/src/execution/createPipelineExecutor/getExamplesForTask.d.ts +1 -1
  41. package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTask.d.ts +21 -5
  42. package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTask.d.ts +19 -5
  43. package/esm/typings/src/execution/createPipelineExecutor/knowledgePiecesToString.d.ts +9 -0
  44. package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +4 -4
  45. package/esm/typings/src/execution/utils/checkExpectations.d.ts +1 -1
  46. package/esm/typings/src/execution/utils/uncertainNumber.d.ts +3 -2
  47. package/esm/typings/src/formats/_common/{FormatDefinition.d.ts → FormatParser.d.ts} +8 -6
  48. package/esm/typings/src/formats/_common/FormatSubvalueParser.d.ts +66 -0
  49. package/esm/typings/src/formats/csv/CsvFormatParser.d.ts +17 -0
  50. package/esm/typings/src/formats/csv/CsvSettings.d.ts +2 -2
  51. package/esm/typings/src/formats/csv/utils/csvParse.d.ts +12 -0
  52. package/esm/typings/src/formats/csv/utils/isValidCsvString.d.ts +1 -1
  53. package/esm/typings/src/formats/index.d.ts +2 -2
  54. package/esm/typings/src/formats/json/{JsonFormatDefinition.d.ts → JsonFormatParser.d.ts} +6 -6
  55. package/esm/typings/src/formats/json/utils/isValidJsonString.d.ts +1 -1
  56. package/esm/typings/src/formats/json/utils/jsonParse.d.ts +8 -0
  57. package/esm/typings/src/formats/text/{TextFormatDefinition.d.ts → TextFormatParser.d.ts} +7 -7
  58. package/esm/typings/src/formats/xml/XmlFormatParser.d.ts +19 -0
  59. package/esm/typings/src/formats/xml/utils/isValidXmlString.d.ts +1 -1
  60. package/esm/typings/src/formfactors/_boilerplate/BoilerplateFormfactorDefinition.d.ts +3 -2
  61. package/esm/typings/src/formfactors/_common/AbstractFormfactorDefinition.d.ts +16 -7
  62. package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +3 -1
  63. package/esm/typings/src/formfactors/_common/string_formfactor_name.d.ts +2 -1
  64. package/esm/typings/src/formfactors/chatbot/ChatbotFormfactorDefinition.d.ts +2 -2
  65. package/esm/typings/src/formfactors/completion/CompletionFormfactorDefinition.d.ts +29 -0
  66. package/esm/typings/src/formfactors/generator/GeneratorFormfactorDefinition.d.ts +2 -1
  67. package/esm/typings/src/formfactors/generic/GenericFormfactorDefinition.d.ts +2 -2
  68. package/esm/typings/src/formfactors/index.d.ts +33 -8
  69. package/esm/typings/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +4 -2
  70. package/esm/typings/src/formfactors/sheets/SheetsFormfactorDefinition.d.ts +3 -2
  71. package/esm/typings/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +3 -2
  72. package/esm/typings/src/high-level-abstractions/index.d.ts +2 -2
  73. package/esm/typings/src/llm-providers/_common/register/$llmToolsMetadataRegister.d.ts +3 -3
  74. package/esm/typings/src/llm-providers/_common/register/$llmToolsRegister.d.ts +3 -3
  75. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +4 -4
  76. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +4 -3
  77. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +17 -4
  78. package/esm/typings/src/llm-providers/_common/register/LlmToolsConfiguration.d.ts +11 -4
  79. package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +27 -5
  80. package/esm/typings/src/llm-providers/_common/register/LlmToolsOptions.d.ts +9 -2
  81. package/esm/typings/src/llm-providers/_common/register/createLlmToolsFromConfiguration.d.ts +12 -3
  82. package/esm/typings/src/llm-providers/_common/utils/cache/CacheItem.d.ts +10 -5
  83. package/esm/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +5 -3
  84. package/esm/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +3 -3
  85. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +5 -5
  86. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  87. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +4 -0
  88. package/esm/typings/src/llm-providers/deepseek/deepseek-models.d.ts +23 -0
  89. package/esm/typings/src/llm-providers/google/google-models.d.ts +23 -0
  90. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +4 -0
  91. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
  92. package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +2 -2
  93. package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +2 -2
  94. package/esm/typings/src/migrations/migratePipeline.d.ts +9 -0
  95. package/esm/typings/src/other/templates/getBookTemplates.d.ts +2 -2
  96. package/esm/typings/src/personas/preparePersona.d.ts +1 -1
  97. package/esm/typings/src/pipeline/PipelineInterface/PipelineInterface.d.ts +3 -3
  98. package/esm/typings/src/pipeline/PipelineInterface/constants.d.ts +1 -1
  99. package/esm/typings/src/pipeline/PipelineInterface/getPipelineInterface.d.ts +1 -1
  100. package/esm/typings/src/pipeline/PipelineInterface/isPipelineImplementingInterface.d.ts +5 -4
  101. package/esm/typings/src/pipeline/PipelineInterface/isPipelineInterfacesEqual.d.ts +1 -1
  102. package/esm/typings/src/pipeline/PipelineJson/CommonTaskJson.d.ts +9 -6
  103. package/esm/typings/src/pipeline/PipelineJson/PersonaJson.d.ts +4 -2
  104. package/esm/typings/src/pipeline/PipelineJson/PipelineJson.d.ts +3 -2
  105. package/esm/typings/src/pipeline/PipelineString.d.ts +3 -1
  106. package/esm/typings/src/pipeline/book-notation.d.ts +2 -2
  107. package/esm/typings/src/postprocessing/utils/extractJsonBlock.d.ts +1 -1
  108. package/esm/typings/src/prepare/prepareTasks.d.ts +7 -4
  109. package/esm/typings/src/remote-server/openapi-types.d.ts +348 -6
  110. package/esm/typings/src/remote-server/openapi.d.ts +398 -4
  111. package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +2 -1
  112. package/esm/typings/src/scrapers/_boilerplate/BoilerplateScraper.d.ts +3 -3
  113. package/esm/typings/src/scrapers/_boilerplate/createBoilerplateScraper.d.ts +1 -1
  114. package/esm/typings/src/scrapers/_boilerplate/register-metadata.d.ts +1 -1
  115. package/esm/typings/src/scrapers/_common/Converter.d.ts +3 -1
  116. package/esm/typings/src/scrapers/_common/Scraper.d.ts +4 -3
  117. package/esm/typings/src/scrapers/_common/ScraperIntermediateSource.d.ts +4 -2
  118. package/esm/typings/src/scrapers/_common/register/$provideFilesystemForNode.d.ts +2 -1
  119. package/esm/typings/src/scrapers/_common/register/$provideScrapersForBrowser.d.ts +6 -3
  120. package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +3 -5
  121. package/esm/typings/src/scrapers/_common/register/$scrapersMetadataRegister.d.ts +3 -3
  122. package/esm/typings/src/scrapers/_common/register/$scrapersRegister.d.ts +3 -2
  123. package/esm/typings/src/scrapers/_common/register/ScraperAndConverterMetadata.d.ts +8 -5
  124. package/esm/typings/src/scrapers/_common/register/ScraperConstructor.d.ts +2 -1
  125. package/esm/typings/src/scrapers/_common/utils/getScraperIntermediateSource.d.ts +6 -5
  126. package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +3 -1
  127. package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +1 -1
  128. package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +2 -1
  129. package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +4 -1
  130. package/esm/typings/src/scrapers/markitdown/MarkitdownScraper.d.ts +1 -1
  131. package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +2 -1
  132. package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +3 -4
  133. package/esm/typings/src/scripting/javascript/postprocessing-functions.d.ts +5 -1
  134. package/esm/typings/src/storage/file-cache-storage/FileCacheStorage.d.ts +12 -5
  135. package/esm/typings/src/storage/file-cache-storage/FileCacheStorageOptions.d.ts +4 -2
  136. package/esm/typings/src/storage/file-cache-storage/utils/nameToSubfolderPath.d.ts +2 -1
  137. package/esm/typings/src/storage/local-storage/getIndexedDbStorage.d.ts +10 -0
  138. package/esm/typings/src/storage/local-storage/utils/makePromptbookStorageFromIndexedDb.d.ts +7 -0
  139. package/esm/typings/src/storage/local-storage/utils/makePromptbookStorageFromWebStorage.d.ts +2 -1
  140. package/esm/typings/src/types/IntermediateFilesStrategy.d.ts +2 -1
  141. package/esm/typings/src/types/ModelVariant.d.ts +5 -5
  142. package/esm/typings/src/types/typeAliases.d.ts +17 -13
  143. package/esm/typings/src/utils/$Register.d.ts +8 -7
  144. package/esm/typings/src/utils/editable/edit-pipeline-string/addPipelineCommand.d.ts +2 -2
  145. package/esm/typings/src/utils/editable/edit-pipeline-string/deflatePipeline.d.ts +4 -1
  146. package/esm/typings/src/utils/editable/utils/isFlatPipeline.d.ts +2 -1
  147. package/esm/typings/src/utils/environment/$getGlobalScope.d.ts +2 -1
  148. package/esm/typings/src/utils/expectation-counters/index.d.ts +1 -1
  149. package/esm/typings/src/utils/markdown/extractAllListItemsFromMarkdown.d.ts +1 -1
  150. package/esm/typings/src/utils/normalization/nameToUriPart.d.ts +4 -4
  151. package/esm/typings/src/utils/normalization/nameToUriParts.d.ts +4 -4
  152. package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +3 -3
  153. package/esm/typings/src/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +3 -3
  154. package/esm/typings/src/utils/normalization/normalizeTo_camelCase.d.ts +4 -4
  155. package/esm/typings/src/utils/normalization/normalizeTo_snake_case.d.ts +3 -3
  156. package/esm/typings/src/utils/normalization/removeDiacritics.d.ts +3 -3
  157. package/esm/typings/src/utils/normalization/searchKeywords.d.ts +4 -1
  158. package/esm/typings/src/utils/normalization/titleToName.d.ts +4 -4
  159. package/esm/typings/src/utils/organization/empty_object.d.ts +2 -2
  160. package/esm/typings/src/utils/organization/just_empty_object.d.ts +4 -4
  161. package/esm/typings/src/utils/parameters/mapAvailableToExpectedParameters.d.ts +7 -7
  162. package/esm/typings/src/utils/serialization/clonePipeline.d.ts +4 -3
  163. package/esm/typings/src/utils/serialization/deepClone.d.ts +5 -1
  164. package/esm/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +3 -3
  165. package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +5 -4
  166. package/esm/typings/src/version.d.ts +2 -1
  167. package/package.json +3 -2
  168. package/umd/index.umd.js +68 -40
  169. package/umd/index.umd.js.map +1 -1
  170. package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +0 -31
  171. package/esm/typings/src/formats/csv/CsvFormatDefinition.d.ts +0 -17
  172. package/esm/typings/src/formats/xml/XmlFormatDefinition.d.ts +0 -19
@@ -2,8 +2,8 @@
2
2
  * Organizational helper to better mark the place where to really use empty object `{}`
3
3
  *
4
4
  * Note: There are 2 similar types>
5
- * - `empty_object` @@@
6
- * - `just_empty_object` @@@
5
+ * - `empty_object` Type used for empty data objects allowing for potential future extensions
6
+ * - `just_empty_object` Type used when an object must remain permanently empty
7
7
  *
8
8
  * @private within the repository
9
9
  */
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Organizational helper to better @@@@
2
+ * Organizational helper to better distinguish different empty object use cases.
3
3
  *
4
- * Note: There are 2 similar types>
5
- * - `empty_object` @@@
6
- * - `just_empty_object` @@@
4
+ * Note: There are 2 similar types:
5
+ * - `empty_object` Type used for empty data objects with potential extensions
6
+ * - `just_empty_object` Type used specifically for objects that must remain empty
7
7
  *
8
8
  * Note: In most cases, you should use `empty_object`
9
9
  *
@@ -1,26 +1,26 @@
1
1
  import type { string_parameter_name } from '../../types/typeAliases';
2
2
  import type { string_parameter_value } from '../../types/typeAliases';
3
3
  /**
4
- * @@@
4
+ * Options for mapping available parameters to expected parameters in a pipeline task.
5
5
  */
6
6
  type MakeapAvailableToExpectedParametersOptions = {
7
7
  /**
8
- * @@@
8
+ * The set of expected parameter names (keys) for the task, all values are null.
9
9
  */
10
10
  readonly expectedParameters: Readonly<Record<string_parameter_name, null>>;
11
11
  /**
12
- * @@@
12
+ * The set of available parameters (name-value pairs) to map to the expected parameters.
13
13
  */
14
14
  readonly availableParameters: Readonly<Record<string_parameter_name, string_parameter_value>>;
15
15
  };
16
16
  /**
17
- * Maps available parameters to expected parameters
17
+ * Maps available parameters to expected parameters for a pipeline task.
18
18
  *
19
19
  * The strategy is:
20
- * 1) @@@
21
- * 2) @@@
20
+ * 1) First, match parameters by name where both available and expected.
21
+ * 2) Then, if there are unmatched expected and available parameters, map them by order.
22
22
  *
23
- * @throws {PipelineExecutionError} @@@
23
+ * @throws {PipelineExecutionError} If the number of unmatched expected and available parameters does not match, or mapping is ambiguous.
24
24
  * @private within the repository used in `createPipelineExecutor`
25
25
  */
26
26
  export declare function mapAvailableToExpectedParameters(options: MakeapAvailableToExpectedParametersOptions): Readonly<Record<string_parameter_name, string_parameter_value>>;
@@ -1,10 +1,11 @@
1
1
  import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
2
2
  /**
3
- * @@@
3
+ * Creates a deep clone of a PipelineJson object, copying all properties explicitly.
4
4
  *
5
- * Note: It is usefull @@@
5
+ * Note: It is useful for ensuring that modifications to the returned pipeline do not affect the original.
6
6
  *
7
- * @param pipeline
7
+ * @param pipeline The pipeline to clone.
8
+ * @returns A new PipelineJson object with the same properties as the input.
8
9
  * @public exported from `@promptbook/utils`
9
10
  */
10
11
  export declare function clonePipeline(pipeline: PipelineJson): PipelineJson;
@@ -1,7 +1,11 @@
1
1
  import type { WritableDeep } from 'type-fest';
2
2
  /**
3
- * @@@
3
+ * Creates a deep clone of the given object
4
4
  *
5
+ * Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
6
+ *
7
+ * @param objectValue The object to clone.
8
+ * @returns A deep, writable clone of the input object.
5
9
  * @public exported from `@promptbook/utils`
6
10
  */
7
11
  export declare function deepClone<TObject>(objectValue: TObject): WritableDeep<TObject>;
@@ -1,10 +1,10 @@
1
1
  import type { string_javascript_name } from '../../../types/typeAliases';
2
2
  import type { really_unknown } from '../../organization/really_unknown';
3
3
  /**
4
- * @@@
4
+ * Checks if the given value is a valid JavaScript identifier name.
5
5
  *
6
- * @param javascriptName @@@
7
- * @returns @@@
6
+ * @param javascriptName The value to check for JavaScript identifier validity.
7
+ * @returns `true` if the value is a valid JavaScript name, false otherwise.
8
8
  * @public exported from `@promptbook/utils`
9
9
  */
10
10
  export declare function isValidJavascriptName(javascriptName: really_unknown): javascriptName is string_javascript_name;
@@ -1,10 +1,11 @@
1
1
  import type { string_parameter_name } from '../../../types/typeAliases';
2
2
  /**
3
- * Function `validateParameterName` will @@@
3
+ * Function `validateParameterName` will normalize and validate a parameter name for use in pipelines.
4
+ * It removes diacritics, emojis, and quotes, normalizes to camelCase, and checks for reserved names and invalid characters.
4
5
  *
5
- * @param parameterName @@@
6
- * @returns @@@
7
- * @throws {ParseError} @@@
6
+ * @param parameterName The parameter name to validate and normalize.
7
+ * @returns The validated and normalized parameter name.
8
+ * @throws {ParseError} If the parameter name is empty, reserved, or contains invalid characters.
8
9
  * @private within the repository
9
10
  */
10
11
  export declare function validateParameterName(parameterName: string): string_parameter_name;
@@ -14,7 +14,8 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
14
14
  */
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
- * @@@
17
+ * Represents the version string of the Promptbook engine.
18
+ * It follows semantic versioning (e.g., `0.92.0-30`).
18
19
  *
19
20
  * @generated
20
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/azure-openai",
3
- "version": "0.92.0-3",
3
+ "version": "0.92.0-31",
4
4
  "description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -51,10 +51,11 @@
51
51
  "module": "./esm/index.es.js",
52
52
  "typings": "./esm/typings/src/_packages/azure-openai.index.d.ts",
53
53
  "peerDependencies": {
54
- "@promptbook/core": "0.92.0-3"
54
+ "@promptbook/core": "0.92.0-31"
55
55
  },
56
56
  "dependencies": {
57
57
  "@azure/openai": "1.0.0-beta.12",
58
+ "bottleneck": "^2.19.5",
58
59
  "colors": "1.4.0",
59
60
  "crypto": "1.0.1",
60
61
  "spacetrim": "0.11.59"
package/umd/index.umd.js CHANGED
@@ -1,11 +1,12 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@azure/openai'), require('colors'), require('crypto'), require('spacetrim')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@azure/openai', 'colors', 'crypto', 'spacetrim'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-azure-openai"] = {}, global.openai, global.colors, global.crypto, global.spaceTrim));
5
- })(this, (function (exports, openai, colors, crypto, spaceTrim) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@azure/openai'), require('bottleneck'), require('colors'), require('crypto'), require('spacetrim')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@azure/openai', 'bottleneck', 'colors', 'crypto', 'spacetrim'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-azure-openai"] = {}, global.openai, global.Bottleneck, global.colors, global.crypto, global.spaceTrim));
5
+ })(this, (function (exports, openai, Bottleneck, colors, crypto, spaceTrim) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
+ var Bottleneck__default = /*#__PURE__*/_interopDefaultLegacy(Bottleneck);
9
10
  var colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
10
11
  var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
11
12
 
@@ -23,7 +24,7 @@
23
24
  * @generated
24
25
  * @see https://github.com/webgptorg/promptbook
25
26
  */
26
- const PROMPTBOOK_ENGINE_VERSION = '0.92.0-3';
27
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0-31';
27
28
  /**
28
29
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
30
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -85,7 +86,7 @@
85
86
  const CONNECTION_TIMEOUT_MS = 7 * 1000;
86
87
  // <- TODO: [🧜‍♂️]
87
88
  /**
88
- * @@@
89
+ * Default settings for parsing and generating CSV files in Promptbook.
89
90
  *
90
91
  * @public exported from `@promptbook/core`
91
92
  */
@@ -95,6 +96,14 @@
95
96
  newline: '\n',
96
97
  skipEmptyLines: true,
97
98
  });
99
+ /**
100
+ * Default rate limits (requests per minute)
101
+ *
102
+ * Note: Adjust based on the provider tier you are have
103
+ *
104
+ * @public exported from `@promptbook/core`
105
+ */
106
+ const DEFAULT_MAX_REQUESTS_PER_MINUTE = 60;
98
107
  /**
99
108
  * Note: [💞] Ignore a discrepancy between file name and entity name
100
109
  * TODO: [🧠][🧜‍♂️] Maybe join remoteServerUrl and path into single value
@@ -545,10 +554,10 @@
545
554
  */
546
555
 
547
556
  /**
548
- * @@@
557
+ * Removes diacritic marks (accents) from characters in a string.
549
558
  *
550
- * @param input @@@
551
- * @returns @@@
559
+ * @param input The string containing diacritics to be normalized.
560
+ * @returns The string with diacritics removed or normalized.
552
561
  * @public exported from `@promptbook/utils`
553
562
  */
554
563
  function removeDiacritics(input) {
@@ -694,14 +703,18 @@
694
703
  /**
695
704
  * Make UncertainNumber
696
705
  *
697
- * @param value
706
+ * @param value value of the uncertain number, if `NaN` or `undefined`, it will be set to 0 and `isUncertain=true`
707
+ * @param isUncertain if `true`, the value is uncertain, otherwise depends on the value
698
708
  *
699
709
  * @private utility for initializating UncertainNumber
700
710
  */
701
- function uncertainNumber(value) {
711
+ function uncertainNumber(value, isUncertain) {
702
712
  if (value === null || value === undefined || Number.isNaN(value)) {
703
713
  return UNCERTAIN_ZERO_VALUE;
704
714
  }
715
+ if (isUncertain === true) {
716
+ return { value, isUncertain };
717
+ }
705
718
  return { value };
706
719
  }
707
720
 
@@ -919,8 +932,12 @@
919
932
  */
920
933
 
921
934
  /**
922
- * @@@
935
+ * Creates a deep clone of the given object
936
+ *
937
+ * Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
923
938
  *
939
+ * @param objectValue The object to clone.
940
+ * @returns A deep, writable clone of the input object.
924
941
  * @public exported from `@promptbook/utils`
925
942
  */
926
943
  function deepClone(objectValue) {
@@ -982,13 +999,13 @@
982
999
  */
983
1000
  const REPLACING_NONCE = 'ptbkauk42kV2dzao34faw7FudQUHYPtW';
984
1001
  /**
985
- * @@@
1002
+ * Placeholder value indicating a parameter is missing its value.
986
1003
  *
987
1004
  * @private within the repository
988
1005
  */
989
1006
  const RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
990
1007
  /**
991
- * @@@
1008
+ * Placeholder value indicating a parameter is restricted and cannot be used directly.
992
1009
  *
993
1010
  * @private within the repository
994
1011
  */
@@ -1151,10 +1168,12 @@
1151
1168
  throw new PipelineExecutionError('Parameter is already opened or not closed');
1152
1169
  }
1153
1170
  if (parameters[parameterName] === undefined) {
1171
+ console.log('!!! templateParameters 1', { parameterName, template, parameters });
1154
1172
  throw new PipelineExecutionError(`Parameter \`{${parameterName}}\` is not defined`);
1155
1173
  }
1156
1174
  let parameterValue = parameters[parameterName];
1157
1175
  if (parameterValue === undefined) {
1176
+ console.log('!!! templateParameters 2', { parameterName, template, parameters });
1158
1177
  throw new PipelineExecutionError(`Parameter \`{${parameterName}}\` is not defined`);
1159
1178
  }
1160
1179
  parameterValue = valueToString(parameterValue);
@@ -1195,7 +1214,7 @@
1195
1214
  /**
1196
1215
  * List of available OpenAI models with pricing
1197
1216
  *
1198
- * Note: Done at 2024-05-20
1217
+ * Note: Done at 2025-05-06
1199
1218
  *
1200
1219
  * @see https://platform.openai.com/docs/models/
1201
1220
  * @see https://openai.com/api/pricing/
@@ -1224,7 +1243,7 @@
1224
1243
  modelDescription: 'Legacy completion model with strong performance on text generation tasks. Optimized for complex instructions and longer outputs.',
1225
1244
  pricing: {
1226
1245
  prompt: computeUsage(`$2.00 / 1M tokens`),
1227
- output: computeUsage(`$2.00 / 1M tokens`), // <- not sure
1246
+ output: computeUsage(`$2.00 / 1M tokens`),
1228
1247
  },
1229
1248
  },
1230
1249
  /**/
@@ -1366,8 +1385,8 @@
1366
1385
  modelName: 'gpt-3.5-turbo',
1367
1386
  modelDescription: 'Latest version of GPT-3.5 Turbo with improved performance and instruction following capabilities. Default 4K context window with options for 16K.',
1368
1387
  pricing: {
1369
- prompt: computeUsage(`$3.00 / 1M tokens`),
1370
- output: computeUsage(`$6.00 / 1M tokens`), // <- Not sure, refer to gpt-3.5-turbo in Fine-tuning models
1388
+ prompt: computeUsage(`$0.50 / 1M tokens`),
1389
+ output: computeUsage(`$1.50 / 1M tokens`),
1371
1390
  },
1372
1391
  },
1373
1392
  /**/
@@ -1391,7 +1410,7 @@
1391
1410
  modelDescription: 'Efficient legacy completion model with a good balance of performance and speed. Suitable for straightforward text generation tasks.',
1392
1411
  pricing: {
1393
1412
  prompt: computeUsage(`$0.40 / 1M tokens`),
1394
- output: computeUsage(`$0.40 / 1M tokens`), // <- Not sure
1413
+ output: computeUsage(`$0.40 / 1M tokens`),
1395
1414
  },
1396
1415
  },
1397
1416
  /**/
@@ -1445,7 +1464,7 @@
1445
1464
  modelDescription: 'Preview version of GPT-4 Turbo that points to the latest model version. Features improved instruction following, 128K token context window and lower latency.',
1446
1465
  pricing: {
1447
1466
  prompt: computeUsage(`$10.00 / 1M tokens`),
1448
- output: computeUsage(`$30.00 / 1M tokens`), // <- Not sure, just for gpt-4-turbo
1467
+ output: computeUsage(`$30.00 / 1M tokens`),
1449
1468
  },
1450
1469
  },
1451
1470
  /**/
@@ -1456,7 +1475,7 @@
1456
1475
  modelName: 'text-embedding-3-large',
1457
1476
  modelDescription: "OpenAI's most capable text embedding model designed for high-quality embeddings for complex similarity tasks and information retrieval.",
1458
1477
  pricing: {
1459
- prompt: computeUsage(`$0.13 / 1M tokens`),
1478
+ prompt: computeUsage(`$0.13 / 1M tokens`),
1460
1479
  // TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
1461
1480
  output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
1462
1481
  },
@@ -1549,8 +1568,8 @@
1549
1568
  modelName: 'gpt-4o-mini',
1550
1569
  modelDescription: 'Smaller, more cost-effective version of GPT-4o with good performance across text, vision, and audio tasks at reduced complexity.',
1551
1570
  pricing: {
1552
- prompt: computeUsage(`$3.00 / 1M tokens`),
1553
- output: computeUsage(`$9.00 / 1M tokens`),
1571
+ prompt: computeUsage(`$0.15 / 1M tokens`),
1572
+ output: computeUsage(`$0.60 / 1M tokens`),
1554
1573
  },
1555
1574
  },
1556
1575
  /**/
@@ -1596,10 +1615,10 @@
1596
1615
  modelVariant: 'CHAT',
1597
1616
  modelTitle: 'o1',
1598
1617
  modelName: 'o1',
1618
+ modelDescription: "OpenAI's advanced reasoning model focused on logic and problem-solving. Designed for complex analytical tasks with rigorous step-by-step reasoning. 128K context window.",
1599
1619
  pricing: {
1600
- prompt: computeUsage(`$3.00 / 1M tokens`),
1601
- output: computeUsage(`$12.00 / 1M tokens`),
1602
- // <- TODO: !! Unsure, check the pricing
1620
+ prompt: computeUsage(`$15.00 / 1M tokens`),
1621
+ output: computeUsage(`$60.00 / 1M tokens`),
1603
1622
  },
1604
1623
  },
1605
1624
  /**/
@@ -1608,7 +1627,7 @@
1608
1627
  modelVariant: 'CHAT',
1609
1628
  modelTitle: 'o3-mini',
1610
1629
  modelName: 'o3-mini',
1611
- modelDescription: 'Compact and efficient reasoning model specializing in problem-solving with a focus on research and analysis tasks.',
1630
+ modelDescription: 'Cost-effective reasoning model optimized for academic and scientific problem-solving. Efficient performance on STEM tasks with deep mathematical and scientific knowledge. 128K context window.',
1612
1631
  pricing: {
1613
1632
  prompt: computeUsage(`$3.00 / 1M tokens`),
1614
1633
  output: computeUsage(`$12.00 / 1M tokens`),
@@ -1675,6 +1694,10 @@
1675
1694
  * OpenAI Azure API client.
1676
1695
  */
1677
1696
  this.client = null;
1697
+ // TODO: Allow configuring rate limits via options
1698
+ this.limiter = new Bottleneck__default["default"]({
1699
+ minTime: 60000 / (this.options.maxRequestsPerMinute || DEFAULT_MAX_REQUESTS_PER_MINUTE),
1700
+ });
1678
1701
  }
1679
1702
  get title() {
1680
1703
  return 'Azure OpenAI';
@@ -1752,7 +1775,9 @@
1752
1775
  console.info(colors__default["default"].bgWhite('messages'), JSON.stringify(messages, null, 4));
1753
1776
  }
1754
1777
  const rawRequest = [modelName, messages, modelSettings];
1755
- const rawResponse = await this.withTimeout(client.getChatCompletions(...rawRequest)).catch((error) => {
1778
+ const rawResponse = await this.limiter
1779
+ .schedule(() => this.withTimeout(client.getChatCompletions(...rawRequest)))
1780
+ .catch((error) => {
1756
1781
  if (this.options.isVerbose) {
1757
1782
  console.info(colors__default["default"].bgRed('error'), error);
1758
1783
  }
@@ -1848,7 +1873,9 @@
1848
1873
  [rawPromptContent],
1849
1874
  modelSettings,
1850
1875
  ];
1851
- const rawResponse = await this.withTimeout(client.getCompletions(...rawRequest)).catch((error) => {
1876
+ const rawResponse = await this.limiter
1877
+ .schedule(() => this.withTimeout(client.getCompletions(...rawRequest)))
1878
+ .catch((error) => {
1852
1879
  if (this.options.isVerbose) {
1853
1880
  console.info(colors__default["default"].bgRed('error'), error);
1854
1881
  }
@@ -1983,7 +2010,8 @@
1983
2010
  }
1984
2011
 
1985
2012
  /**
1986
- * @@@
2013
+ * Safely retrieves the global scope object (window in browser, global in Node.js)
2014
+ * regardless of the JavaScript environment in which the code is running
1987
2015
  *
1988
2016
  * Note: `$` is used to indicate that this function is not a pure function - it access global scope
1989
2017
  *
@@ -1994,10 +2022,10 @@
1994
2022
  }
1995
2023
 
1996
2024
  /**
1997
- * @@@
2025
+ * Normalizes a text string to SCREAMING_CASE (all uppercase with underscores).
1998
2026
  *
1999
- * @param text @@@
2000
- * @returns @@@
2027
+ * @param text The text string to be converted to SCREAMING_CASE format.
2028
+ * @returns The normalized text in SCREAMING_CASE format.
2001
2029
  * @example 'HELLO_WORLD'
2002
2030
  * @example 'I_LOVE_PROMPTBOOK'
2003
2031
  * @public exported from `@promptbook/utils`
@@ -2049,10 +2077,10 @@
2049
2077
  */
2050
2078
 
2051
2079
  /**
2052
- * @@@
2080
+ * Normalizes a text string to snake_case format.
2053
2081
  *
2054
- * @param text @@@
2055
- * @returns @@@
2082
+ * @param text The text string to be converted to snake_case format.
2083
+ * @returns The normalized text in snake_case format.
2056
2084
  * @example 'hello_world'
2057
2085
  * @example 'i_love_promptbook'
2058
2086
  * @public exported from `@promptbook/utils`
@@ -2062,11 +2090,11 @@
2062
2090
  }
2063
2091
 
2064
2092
  /**
2065
- * Register is @@@
2093
+ * Global registry for storing and managing registered entities of a given type.
2066
2094
  *
2067
2095
  * Note: `$` is used to indicate that this function is not a pure function - it accesses and adds variables in global scope.
2068
2096
  *
2069
- * @private internal utility, exported are only signleton instances of this class
2097
+ * @private internal utility, exported are only singleton instances of this class
2070
2098
  */
2071
2099
  class $Register {
2072
2100
  constructor(registerName) {
@@ -2110,10 +2138,10 @@
2110
2138
  }
2111
2139
 
2112
2140
  /**
2113
- * @@@
2141
+ * Register for LLM tools.
2114
2142
  *
2115
2143
  * Note: `$` is used to indicate that this interacts with the global scope
2116
- * @singleton Only one instance of each register is created per build, but thare can be more @@@
2144
+ * @singleton Only one instance of each register is created per build, but there can be more instances across different builds or environments.
2117
2145
  * @public exported from `@promptbook/core`
2118
2146
  */
2119
2147
  const $llmToolsRegister = new $Register('llm_execution_tools_constructors');