@promptbook/openai 0.69.0-7 → 0.69.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.
Files changed (73) hide show
  1. package/README.md +4 -1
  2. package/esm/index.es.js +67 -7
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/promptbook-collection/index.d.ts +0 -3
  5. package/esm/typings/src/_packages/core.index.d.ts +12 -0
  6. package/esm/typings/src/_packages/types.index.d.ts +6 -0
  7. package/esm/typings/src/_packages/utils.index.d.ts +4 -4
  8. package/esm/typings/src/cli/cli-commands/make.d.ts +1 -1
  9. package/esm/typings/src/collection/constructors/createCollectionFromUrl.d.ts +1 -1
  10. package/esm/typings/src/commands/FOREACH/ForeachCommand.d.ts +1 -1
  11. package/esm/typings/src/commands/FOREACH/ForeachJson.d.ts +6 -5
  12. package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +1 -2
  13. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +1 -1
  14. package/esm/typings/src/config.d.ts +11 -4
  15. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +1 -1
  16. package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +3 -3
  17. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +6 -5
  18. package/esm/typings/src/errors/AbstractFormatError.d.ts +11 -0
  19. package/esm/typings/src/execution/PipelineExecutor.d.ts +1 -0
  20. package/esm/typings/src/execution/PipelineExecutorResult.d.ts +5 -6
  21. package/esm/typings/src/execution/createPipelineExecutor/$OngoingTemplateResult.d.ts +45 -0
  22. package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorSettings.d.ts +10 -0
  23. package/esm/typings/src/execution/createPipelineExecutor/00-createPipelineExecutor.d.ts +3 -0
  24. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +5 -2
  25. package/esm/typings/src/execution/createPipelineExecutor/20-executeTemplate.d.ts +3 -0
  26. package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +15 -0
  27. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +74 -0
  28. package/esm/typings/src/execution/embeddingVectorToString.d.ts +1 -1
  29. package/esm/typings/src/execution/utils/checkExpectations.d.ts +2 -0
  30. package/esm/typings/src/execution/utils/usageToHuman.d.ts +3 -4
  31. package/esm/typings/src/formats/_common/FormatDefinition.d.ts +14 -15
  32. package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +31 -0
  33. package/esm/typings/src/formats/csv/{ListFormatDefinition.d.ts → CsvFormatDefinition.d.ts} +6 -3
  34. package/esm/typings/src/formats/csv/CsvFormatError.d.ts +10 -0
  35. package/esm/typings/src/formats/csv/CsvSettings.d.ts +13 -0
  36. package/esm/typings/src/formats/index.d.ts +1 -1
  37. package/esm/typings/src/formats/json/JsonFormatDefinition.d.ts +4 -3
  38. package/esm/typings/src/formats/text/TextFormatDefinition.d.ts +19 -0
  39. package/esm/typings/src/formats/xml/XmlFormatDefinition.d.ts +4 -3
  40. package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +1 -1
  41. package/esm/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +1 -1
  42. package/esm/typings/src/llm-providers/_common/utils/cache/CacheItem.d.ts +1 -1
  43. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  44. package/esm/typings/src/llm-providers/anthropic-claude/createAnthropicClaudeExecutionTools.d.ts +2 -2
  45. package/esm/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +2 -2
  46. package/esm/typings/src/llm-providers/openai/playground/playground.d.ts +1 -1
  47. package/esm/typings/src/personas/preparePersona.d.ts +1 -1
  48. package/esm/typings/src/prepare/isPipelinePrepared.d.ts +1 -1
  49. package/esm/typings/src/prepare/prepareTemplates.d.ts +1 -1
  50. package/esm/typings/src/types/PipelineJson/ParameterJson.d.ts +1 -1
  51. package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +1 -1
  52. package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +0 -3
  53. package/esm/typings/src/types/execution-report/executionReportJsonToString.d.ts +2 -1
  54. package/esm/typings/src/types/typeAliases.d.ts +1 -1
  55. package/esm/typings/src/utils/expectation-counters/index.d.ts +3 -0
  56. package/esm/typings/src/utils/organization/{f.d.ts → empty_object.d.ts} +5 -1
  57. package/esm/typings/src/utils/organization/just_empty_object.d.ts +12 -0
  58. package/esm/typings/src/utils/{extractParameterNames.d.ts → parameters/extractParameterNames.d.ts} +2 -2
  59. package/esm/typings/src/utils/parameters/mapAvailableToExpectedParameters.d.ts +27 -0
  60. package/esm/typings/src/utils/{replaceParameters.d.ts → parameters/replaceParameters.d.ts} +2 -2
  61. package/esm/typings/src/utils/serialization/checkSerializableAsJson.d.ts +1 -1
  62. package/esm/typings/src/utils/serialization/isSerializableAsJson.d.ts +1 -1
  63. package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +10 -0
  64. package/package.json +17 -13
  65. package/umd/index.umd.js +67 -7
  66. package/umd/index.umd.js.map +1 -1
  67. package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatCell.d.ts +0 -30
  68. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempt.d.ts +0 -30
  69. package/esm/typings/src/formats/list/ListFormatDefinition.d.ts +0 -16
  70. /package/esm/typings/src/utils/{extractParameterNames.test.d.ts → parameters/extractParameterNames.test.d.ts} +0 -0
  71. /package/esm/typings/src/{execution/utils/usageToHuman.test.d.ts → utils/parameters/mapAvailableToExpectedParameters.test.d.ts} +0 -0
  72. /package/esm/typings/src/utils/{replaceParameters.test.d.ts → parameters/replaceParameters.test.d.ts} +0 -0
  73. /package/esm/typings/src/{personas/preparePersona.test.d.ts → utils/validators/parameterName/validateParameterName.test.d.ts} +0 -0
@@ -13,7 +13,7 @@ export type CacheItem = {
13
13
  /**
14
14
  * @@@
15
15
  */
16
- promptbookVersion: string_promptbook_version;
16
+ promptbookVersion?: string_promptbook_version;
17
17
  /**
18
18
  * @@@
19
19
  */
@@ -16,7 +16,7 @@ export declare const ANTHROPIC_CLAUDE_MODELS: Array<AvailableModel & {
16
16
  }>;
17
17
  /**
18
18
  * Note: [🤖] Add models of new variant
19
- * TODO: [🧠] !!! Add embedding models OR Anthropic has only chat+completion models?
19
+ * TODO: [🧠][main] !!! Add embedding models OR Anthropic has only chat+completion models?
20
20
  * TODO: [🧠] Some mechanism to propagate unsureness
21
21
  * TODO: [🧠][👮‍♀️] Put here more info like description, isVision, trainingDateCutoff, languages, strengths ( Top-level performance, intelligence, fluency, and understanding), contextWindow,...
22
22
  * TODO: [🎰] Some mechanism to auto-update available models
@@ -11,8 +11,8 @@ export declare const createAnthropicClaudeExecutionTools: ((options: AnthropicCl
11
11
  className: string;
12
12
  };
13
13
  /**
14
- * TODO: [🧠] !!!! Make anonymous this with all LLM providers
15
- * TODO: [🧠][🧱] !!!! Maybe change all `new AnthropicClaudeExecutionTools` -> `createAnthropicClaudeExecutionTools` in manual
14
+ * TODO: [🧠][main] !!!! Make anonymous this with all LLM providers
15
+ * TODO: [🧠][🧱][main] !!!! Maybe change all `new AnthropicClaudeExecutionTools` -> `createAnthropicClaudeExecutionTools` in manual
16
16
  * TODO: [🧠] Maybe auto-detect usage in browser and determine default value of `isProxied`
17
17
  * TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
18
18
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ts-node
2
2
  export {};
3
3
  /**
4
- * TODO: !!! Playground with WebGPT / Promptbook.studio anonymous server
5
- * TODO: !!! Test here that `systemMessage`, `temperature` and `seed` are working correctly
4
+ * TODO: [main] !!! Playground with WebGPT / Promptbook.studio anonymous server
5
+ * TODO: [main] !!! Test here that `systemMessage`, `temperature` and `seed` are working correctly
6
6
  */
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ts-node
2
2
  export {};
3
3
  /**
4
- * TODO: !!! Test here that `systemMessage`, `temperature` and `seed` are working correctly
4
+ * TODO: [main] !!! Test here that `systemMessage`, `temperature` and `seed` are working correctly
5
5
  */
@@ -9,7 +9,7 @@ import type { string_persona_description } from '../types/typeAliases';
9
9
  */
10
10
  export declare function preparePersona(personaDescription: string_persona_description, options: PrepareOptions): Promise<PersonaPreparedJson['modelRequirements']>;
11
11
  /**
12
- * TODO: [🔃] !!!!! If the persona was prepared with different version or different set of models, prepare it once again
12
+ * TODO: [🔃][main] !!!!! If the persona was prepared with different version or different set of models, prepare it once again
13
13
  * TODO: [🏢] !! Check validity of `modelName` in pipeline
14
14
  * TODO: [🏢] !! Check validity of `systemMessage` in pipeline
15
15
  * TODO: [🏢] !! Check validity of `temperature` in pipeline
@@ -6,7 +6,7 @@ import type { PipelineJson } from '../types/PipelineJson/PipelineJson';
6
6
  */
7
7
  export declare function isPipelinePrepared(pipeline: PipelineJson): boolean;
8
8
  /**
9
- * TODO: [🔃] !!!!! If the pipeline was prepared with different version or different set of models, prepare it once again
9
+ * TODO: [🔃][main] !!!!! If the pipeline was prepared with different version or different set of models, prepare it once again
10
10
  * TODO: [🐠] Maybe base this on `makeValidator`
11
11
  * TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
12
12
  * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
@@ -23,7 +23,7 @@ export {};
23
23
  /**
24
24
  * TODO: [🧠] Add context to each template (if missing)
25
25
  * TODO: [🧠] What is better name `prepareTemplate` or `prepareTemplateAndParameters`
26
- * TODO: [♨] !!! Prepare index the samples and maybe templates
26
+ * TODO: [♨][main] !!! Prepare index the samples and maybe templates
27
27
  * TODO: Write tests for `preparePipeline`
28
28
  * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
29
29
  * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
@@ -33,7 +33,7 @@ export type ParameterJson = {
33
33
  readonly sampleValues?: Array<string_parameter_value>;
34
34
  };
35
35
  /**
36
- * TODO: [🧠] !!!!!! Should be here registered subparameter from foreach or not?
36
+ * TODO: [🧠] Should be here registered subparameters from foreach or not?
37
37
  * TODO: [♈] Probbably move expectations from templates to parameters
38
38
  * TODO: [🍙] Make some standard order of json properties
39
39
  */
@@ -42,7 +42,7 @@ export type PipelineJson = {
42
42
  /**
43
43
  * Version of the .ptbk.json file
44
44
  */
45
- readonly promptbookVersion: string_semantic_version;
45
+ readonly promptbookVersion?: string_semantic_version;
46
46
  /**
47
47
  * Description of the promptbook
48
48
  * It can use multiple paragraphs of simple markdown formatting like **bold**, *italic*, [link](https://example.com), ... BUT not code blocks and structure
@@ -39,6 +39,3 @@ export type ExecutionReportJson = {
39
39
  */
40
40
  readonly promptExecutions: Array<ExecutionPromptReportJson>;
41
41
  };
42
- /**
43
- * TODO: !!!!!! FOREACH in report
44
- */
@@ -1,3 +1,4 @@
1
+ import type { ReadonlyDeep } from 'type-fest';
1
2
  import type { ExecutionReportJson } from './ExecutionReportJson';
2
3
  import type { ExecutionReportString } from './ExecutionReportString';
3
4
  import type { ExecutionReportStringOptions } from './ExecutionReportStringOptions';
@@ -6,7 +7,7 @@ import type { ExecutionReportStringOptions } from './ExecutionReportStringOption
6
7
  *
7
8
  * @public exported from `@promptbook/core`
8
9
  */
9
- export declare function executionReportJsonToString(executionReportJson: ExecutionReportJson, options?: Partial<ExecutionReportStringOptions>): ExecutionReportString;
10
+ export declare function executionReportJsonToString(executionReportJson: ReadonlyDeep<ExecutionReportJson>, options?: Partial<ExecutionReportStringOptions>): ExecutionReportString;
10
11
  /**
11
12
  * TODO: Add mermaid chart for every report
12
13
  * TODO: [🧠] Allow to filter out some parts of the report by options
@@ -592,7 +592,7 @@ export type number_megabytes = number_positive;
592
592
  export type number_gigabytes = number_positive;
593
593
  export type number_terabytes = number_positive;
594
594
  /**.
595
- * TODO: !!! Change "For example" to @example
595
+ * TODO: [main] !!! Change "For example" to @example
596
596
  * TODO: !! Change to branded types
597
597
  * TODO: Delete type aliases that are not exported or used internally
598
598
  */
@@ -6,3 +6,6 @@ import type { ExpectationUnit } from '../../types/PipelineJson/Expectations';
6
6
  * @public exported from `@promptbook/utils`
7
7
  */
8
8
  export declare const CountUtils: Record<ExpectationUnit, (text: string) => ExpectationAmount>;
9
+ /**
10
+ * TODO: [🧠][🤠] This should be probbably as part of `TextFormatDefinition`
11
+ */
@@ -1,6 +1,10 @@
1
1
  /**
2
2
  * Organizational helper to better mark the place where to really use empty object `{}`
3
3
  *
4
+ * Note: There are 2 similar types>
5
+ * - `empty_object` @@@
6
+ * - `just_empty_object` @@@
7
+ *
4
8
  * @private within the repository
5
9
  */
6
- export type really_empty_object = Record<string, never>;
10
+ export type empty_object = {};
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Organizational helper to better @@@@
3
+ *
4
+ * Note: There are 2 similar types>
5
+ * - `empty_object` @@@
6
+ * - `just_empty_object` @@@
7
+ *
8
+ * Note: In most cases, you should use `empty_object`
9
+ *
10
+ * @private within the repository
11
+ */
12
+ export type just_empty_object = Record<string, never>;
@@ -1,5 +1,5 @@
1
- import type { string_parameter_name } from '../types/typeAliases';
2
- import type { string_template } from '../types/typeAliases';
1
+ import type { string_parameter_name } from '../../types/typeAliases';
2
+ import type { string_template } from '../../types/typeAliases';
3
3
  /**
4
4
  * Parses the template and returns the list of all parameter names
5
5
  *
@@ -0,0 +1,27 @@
1
+ import type { string_parameter_name } from '../../types/typeAliases';
2
+ import type { string_parameter_value } from '../../types/typeAliases';
3
+ /**
4
+ * @@@
5
+ */
6
+ type MakeapAvailableToExpectedParametersOptions = {
7
+ /**
8
+ * @@@
9
+ */
10
+ readonly expectedParameters: Readonly<Record<string_parameter_name, null>>;
11
+ /**
12
+ * @@@
13
+ */
14
+ readonly availableParameters: Readonly<Record<string_parameter_name, string_parameter_value>>;
15
+ };
16
+ /**
17
+ * Maps available parameters to expected parameters
18
+ *
19
+ * The strategy is:
20
+ * 1) @@@
21
+ * 2) @@@
22
+ *
23
+ * @throws {PipelineExecutionError} @@@
24
+ * @private within the repository used in `createPipelineExecutor`
25
+ */
26
+ export declare function mapAvailableToExpectedParameters(options: MakeapAvailableToExpectedParametersOptions): Readonly<Record<string_parameter_name, string_parameter_value>>;
27
+ export {};
@@ -1,5 +1,5 @@
1
- import type { Parameters } from '../types/typeAliases';
2
- import type { string_template } from '../types/typeAliases';
1
+ import type { Parameters } from '../../types/typeAliases';
2
+ import type { string_template } from '../../types/typeAliases';
3
3
  /**
4
4
  * Replaces parameters in template with values from parameters object
5
5
  *
@@ -22,6 +22,6 @@ import type { string_name } from '../../types/typeAliases';
22
22
  export declare function checkSerializableAsJson(name: string_name, value: unknown): void;
23
23
  /**
24
24
  * TODO: [🧠][🛣] More elegant way to tracking than passing `name`
25
- * TODO: [🧠] !!! In-memory cache of same values to prevent multiple checks
25
+ * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
26
26
  * Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
27
27
  */
@@ -19,6 +19,6 @@
19
19
  */
20
20
  export declare function isSerializableAsJson(value: unknown): boolean;
21
21
  /**
22
- * TODO: [🧠] !!! In-memory cache of same values to prevent multiple checks
22
+ * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
23
23
  * TODO: [🧠][💺] Can be done this on type-level?
24
24
  */
@@ -0,0 +1,10 @@
1
+ import type { string_parameter_name } from '../../../types/typeAliases';
2
+ /**
3
+ * Function `validateParameterName` will @@@
4
+ *
5
+ * @param parameterName @@@
6
+ * @returns @@@
7
+ * @throws {ParseError} @@@
8
+ * @private within the repository
9
+ */
10
+ export declare function validateParameterName(parameterName: string): string_parameter_name;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/openai",
3
- "version": "0.69.0-7",
3
+ "version": "0.69.0",
4
4
  "description": "Supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -12,21 +12,25 @@
12
12
  "Pavol Hejný <me@pavolhejny.com> (https://www.pavolhejny.com/)"
13
13
  ],
14
14
  "keywords": [
15
- "autogpt",
16
- "openai",
17
- "gpt-3",
18
- "gpt-4",
19
- "chatgpt",
20
15
  "ai",
16
+ "llm",
17
+ "prompt",
18
+ "template",
19
+ "language-model",
20
+ "chatgpt",
21
+ "autogpt",
21
22
  "machine-learning",
22
23
  "natural-language-processing",
23
24
  "nlp",
24
- "prompt",
25
- "template",
26
- "pipeline",
27
- "automation",
28
- "text-generation",
29
- "language-model"
25
+ "openai",
26
+ "gpt-3",
27
+ "gpt-4",
28
+ "gpt-4o",
29
+ "gpt-4o-mini",
30
+ "o1",
31
+ "o1-mini",
32
+ "o1-preview",
33
+ "anthropic"
30
34
  ],
31
35
  "license": "CC-BY-4.0",
32
36
  "bugs": {
@@ -47,7 +51,7 @@
47
51
  "module": "./esm/index.es.js",
48
52
  "typings": "./esm/typings/src/_packages/openai.index.d.ts",
49
53
  "peerDependencies": {
50
- "@promptbook/core": "0.69.0-7"
54
+ "@promptbook/core": "0.69.0"
51
55
  },
52
56
  "dependencies": {
53
57
  "colors": "1.4.0",
package/umd/index.umd.js CHANGED
@@ -14,8 +14,8 @@
14
14
  /**
15
15
  * The version of the Promptbook library
16
16
  */
17
- var PROMPTBOOK_VERSION = '0.69.0-6';
18
- // TODO: !!!! List here all the versions and annotate + put into script
17
+ var PROMPTBOOK_VERSION = '0.69.0-21';
18
+ // TODO: [main] !!!! List here all the versions and annotate + put into script
19
19
 
20
20
  /*! *****************************************************************************
21
21
  Copyright (c) Microsoft Corporation.
@@ -348,7 +348,7 @@
348
348
  }
349
349
  /**
350
350
  * TODO: [🧠][🛣] More elegant way to tracking than passing `name`
351
- * TODO: [🧠] !!! In-memory cache of same values to prevent multiple checks
351
+ * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
352
352
  * Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
353
353
  */
354
354
 
@@ -413,6 +413,18 @@
413
413
  * @private within the repository
414
414
  */
415
415
  var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
416
+ // <- TODO: [🧜‍♂️]
417
+ /**
418
+ * @@@
419
+ *
420
+ * @public exported from `@promptbook/core`
421
+ */
422
+ Object.freeze({
423
+ delimiter: ',',
424
+ quoteChar: '"',
425
+ newline: '\n',
426
+ skipEmptyLines: true,
427
+ });
416
428
  /**
417
429
  * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
418
430
  */
@@ -1205,6 +1217,7 @@
1205
1217
  prompt: computeUsage("$5.00 / 1M tokens"),
1206
1218
  output: computeUsage("$15.00 / 1M tokens"),
1207
1219
  },
1220
+ //TODO: [main] !!! Add gpt-4o-mini-2024-07-18 and all others to be up to date
1208
1221
  },
1209
1222
  /**/
1210
1223
  /**/
@@ -1219,6 +1232,51 @@
1219
1232
  },
1220
1233
  /**/
1221
1234
  /**/
1235
+ {
1236
+ modelVariant: 'CHAT',
1237
+ modelTitle: 'o1-preview',
1238
+ modelName: 'o1-preview',
1239
+ pricing: {
1240
+ prompt: computeUsage("$15.00 / 1M tokens"),
1241
+ output: computeUsage("$60.00 / 1M tokens"),
1242
+ },
1243
+ },
1244
+ /**/
1245
+ /**/
1246
+ {
1247
+ modelVariant: 'CHAT',
1248
+ modelTitle: 'o1-preview-2024-09-12',
1249
+ modelName: 'o1-preview-2024-09-12',
1250
+ // <- TODO: [main] !!! Some better system to organize theese date suffixes and versions
1251
+ pricing: {
1252
+ prompt: computeUsage("$15.00 / 1M tokens"),
1253
+ output: computeUsage("$60.00 / 1M tokens"),
1254
+ },
1255
+ },
1256
+ /**/
1257
+ /**/
1258
+ {
1259
+ modelVariant: 'CHAT',
1260
+ modelTitle: 'o1-mini',
1261
+ modelName: 'o1-mini',
1262
+ pricing: {
1263
+ prompt: computeUsage("$3.00 / 1M tokens"),
1264
+ output: computeUsage("$12.00 / 1M tokens"),
1265
+ },
1266
+ },
1267
+ /**/
1268
+ /**/
1269
+ {
1270
+ modelVariant: 'CHAT',
1271
+ modelTitle: 'o1-mini-2024-09-12',
1272
+ modelName: 'o1-mini-2024-09-12',
1273
+ pricing: {
1274
+ prompt: computeUsage("$3.00 / 1M tokens"),
1275
+ output: computeUsage("$12.00 / 1M tokens"),
1276
+ },
1277
+ },
1278
+ /**/
1279
+ /**/
1222
1280
  {
1223
1281
  modelVariant: 'CHAT',
1224
1282
  modelTitle: 'gpt-3.5-turbo-16k-0613',
@@ -1425,7 +1483,7 @@
1425
1483
  resultContent = rawResponse.choices[0].message.content;
1426
1484
  // eslint-disable-next-line prefer-const
1427
1485
  complete = getCurrentIsoDate();
1428
- usage = computeOpenAiUsage(content, resultContent || '', rawResponse);
1486
+ usage = computeOpenAiUsage(content || '', resultContent || '', rawResponse);
1429
1487
  if (resultContent === null) {
1430
1488
  throw new PipelineExecutionError('No response message from OpenAI');
1431
1489
  }
@@ -1497,7 +1555,7 @@
1497
1555
  resultContent = rawResponse.choices[0].text;
1498
1556
  // eslint-disable-next-line prefer-const
1499
1557
  complete = getCurrentIsoDate();
1500
- usage = computeOpenAiUsage(content, resultContent || '', rawResponse);
1558
+ usage = computeOpenAiUsage(content || '', resultContent || '', rawResponse);
1501
1559
  return [2 /*return*/, $asDeeplyFrozenSerializableJson('OpenAiExecutionTools CompletionPromptResult', {
1502
1560
  content: resultContent,
1503
1561
  modelName: rawResponse.model || modelName,
@@ -1557,7 +1615,9 @@
1557
1615
  resultContent = rawResponse.data[0].embedding;
1558
1616
  // eslint-disable-next-line prefer-const
1559
1617
  complete = getCurrentIsoDate();
1560
- usage = computeOpenAiUsage(content, '', rawResponse);
1618
+ usage = computeOpenAiUsage(content || '', '',
1619
+ // <- Note: Embedding does not have result content
1620
+ rawResponse);
1561
1621
  return [2 /*return*/, $asDeeplyFrozenSerializableJson('OpenAiExecutionTools EmbeddingPromptResult', {
1562
1622
  content: resultContent,
1563
1623
  modelName: rawResponse.model || modelName,
@@ -1628,7 +1688,7 @@
1628
1688
  * @public exported from `@promptbook/openai`
1629
1689
  */
1630
1690
  var createOpenAiExecutionTools = Object.assign(function (options) {
1631
- // TODO: [🧠] !!!! If browser, auto add `dangerouslyAllowBrowser`
1691
+ // TODO: [🧠][main] !!!! If browser, auto add `dangerouslyAllowBrowser`
1632
1692
  if (($isRunningInBrowser() || $isRunningInWebWorker()) && !options.dangerouslyAllowBrowser) {
1633
1693
  options = __assign(__assign({}, options), { dangerouslyAllowBrowser: true });
1634
1694
  }