@promptbook/azure-openai 0.94.0-2 → 0.94.0-4

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.
@@ -0,0 +1,44 @@
1
+ import type { AvailableModel } from '../../execution/AvailableModel';
2
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
3
+ import type { Usage } from '../../execution/Usage';
4
+ import type { string_markdown } from '../../types/typeAliases';
5
+ import type { string_markdown_text } from '../../types/typeAliases';
6
+ import type { string_title } from '../../types/typeAliases';
7
+ import { computeOpenAiUsage } from '../openai/computeOpenAiUsage';
8
+ import { OpenAiCompatibleExecutionTools } from '../openai/OpenAiCompatibleExecutionTools';
9
+ import type { OllamaExecutionToolsOptions } from './OllamaExecutionToolsOptions';
10
+ /**
11
+ * Execution Tools for calling Ollama API
12
+ *
13
+ * @public exported from `@promptbook/ollama`
14
+ */
15
+ export declare class OllamaExecutionTools extends OpenAiCompatibleExecutionTools implements LlmExecutionTools {
16
+ constructor(ollamaOptions: OllamaExecutionToolsOptions);
17
+ get title(): string_title & string_markdown_text;
18
+ get description(): string_markdown;
19
+ /**
20
+ * List all available models (non dynamically)
21
+ *
22
+ * Note: Purpose of this is to provide more information about models than standard listing from API
23
+ */
24
+ protected get HARDCODED_MODELS(): ReadonlyArray<AvailableModel>;
25
+ /**
26
+ * Computes the usage of the Ollama API based on the response from Ollama
27
+ */
28
+ protected computeUsage(...args: Parameters<typeof computeOpenAiUsage>): Usage;
29
+ /**
30
+ * Default model for chat variant.
31
+ */
32
+ protected getDefaultChatModel(): AvailableModel;
33
+ /**
34
+ * Default model for completion variant.
35
+ */
36
+ protected getDefaultCompletionModel(): AvailableModel;
37
+ /**
38
+ * Default model for completion variant.
39
+ */
40
+ protected getDefaultEmbeddingModel(): AvailableModel;
41
+ }
42
+ /**
43
+ * TODO: [🛄] Some way how to re-wrap the errors from `OpenAiCompatibleExecutionTools`
44
+ */
@@ -4,7 +4,7 @@ import type { OpenAiExecutionToolsOptions } from '../openai/OpenAiExecutionTools
4
4
  *
5
5
  * @public exported from `@promptbook/ollama`
6
6
  */
7
- export declare const DEFAULT_OLLAMA_BASE_URL = "http://localhost:11434";
7
+ export declare const DEFAULT_OLLAMA_BASE_URL = "http://localhost:11434/v1";
8
8
  /**
9
9
  * Options for `createOllamaExecutionTools`
10
10
  *
@@ -5,7 +5,7 @@ import type { OllamaExecutionToolsOptions } from './OllamaExecutionToolsOptions'
5
5
  *
6
6
  * @public exported from `@promptbook/ollama`
7
7
  */
8
- export declare const createOllamaExecutionTools: ((ollamaOptions: OllamaExecutionToolsOptions) => LlmExecutionTools) & {
8
+ export declare const createOllamaExecutionTools: ((options: OllamaExecutionToolsOptions) => LlmExecutionTools) & {
9
9
  packageName: string;
10
10
  className: string;
11
11
  };
@@ -0,0 +1,14 @@
1
+ import type { AvailableModel } from '../../execution/AvailableModel';
2
+ /**
3
+ * List of available models in Ollama library
4
+ *
5
+ * Note: Done at 2025-05-19
6
+ *
7
+ * @see https://ollama.com/library
8
+ * @public exported from `@promptbook/ollama`
9
+ */
10
+ export declare const OLLAMA_MODELS: ReadonlyArray<AvailableModel>;
11
+ /**
12
+ * TODO: [🚸] Not all models are compatible with JSON mode, add this information here and use it
13
+ * Note: [💞] Ignore a discrepancy between file name and entity name
14
+ */
@@ -0,0 +1,91 @@
1
+ import OpenAI from 'openai';
2
+ import type { AvailableModel } from '../../execution/AvailableModel';
3
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
4
+ import type { ChatPromptResult } from '../../execution/PromptResult';
5
+ import type { CompletionPromptResult } from '../../execution/PromptResult';
6
+ import type { EmbeddingPromptResult } from '../../execution/PromptResult';
7
+ import type { Usage } from '../../execution/Usage';
8
+ import type { Prompt } from '../../types/Prompt';
9
+ import type { string_markdown } from '../../types/typeAliases';
10
+ import type { string_markdown_text } from '../../types/typeAliases';
11
+ import type { string_model_name } from '../../types/typeAliases';
12
+ import type { string_title } from '../../types/typeAliases';
13
+ import { computeOpenAiUsage } from './computeOpenAiUsage';
14
+ import type { OpenAiExecutionToolsOptions } from './OpenAiExecutionToolsOptions';
15
+ /**
16
+ * Execution Tools for calling OpenAI API or other OpeenAI compatible provider
17
+ *
18
+ * @public exported from `@promptbook/openai`
19
+ */
20
+ export declare abstract class OpenAiCompatibleExecutionTools implements LlmExecutionTools {
21
+ protected readonly options: OpenAiExecutionToolsOptions;
22
+ /**
23
+ * OpenAI API client.
24
+ */
25
+ private client;
26
+ /**
27
+ * Rate limiter instance
28
+ */
29
+ private limiter;
30
+ /**
31
+ * Creates OpenAI compatible Execution Tools.
32
+ *
33
+ * @param options which are relevant are directly passed to the OpenAI compatible client
34
+ */
35
+ constructor(options: OpenAiExecutionToolsOptions);
36
+ abstract get title(): string_title & string_markdown_text;
37
+ abstract get description(): string_markdown;
38
+ getClient(): Promise<OpenAI>;
39
+ /**
40
+ * Check the `options` passed to `constructor`
41
+ */
42
+ checkConfiguration(): Promise<void>;
43
+ /**
44
+ * List all available OpenAI compatible models that can be used
45
+ */
46
+ listModels(): Promise<ReadonlyArray<AvailableModel>>;
47
+ /**
48
+ * Calls OpenAI compatible API to use a chat model.
49
+ */
50
+ callChatModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements' | 'format'>): Promise<ChatPromptResult>;
51
+ /**
52
+ * Calls OpenAI API to use a complete model.
53
+ */
54
+ callCompletionModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements'>): Promise<CompletionPromptResult>;
55
+ /**
56
+ * Calls OpenAI compatible API to use a embedding model
57
+ */
58
+ callEmbeddingModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements'>): Promise<EmbeddingPromptResult>;
59
+ /**
60
+ * Get the model that should be used as default
61
+ */
62
+ protected getDefaultModel(defaultModelName: string_model_name): AvailableModel;
63
+ /**
64
+ * List all available models (non dynamically)
65
+ *
66
+ * Note: Purpose of this is to provide more information about models than standard listing from API
67
+ */
68
+ protected abstract get HARDCODED_MODELS(): ReadonlyArray<AvailableModel>;
69
+ /**
70
+ * Computes the usage of the OpenAI API based on the response from OpenAI Compatible API
71
+ */
72
+ protected abstract computeUsage(...args: Parameters<typeof computeOpenAiUsage>): Usage;
73
+ /**
74
+ * Default model for chat variant.
75
+ */
76
+ protected abstract getDefaultChatModel(): AvailableModel;
77
+ /**
78
+ * Default model for completion variant.
79
+ */
80
+ protected abstract getDefaultCompletionModel(): AvailableModel;
81
+ /**
82
+ * Default model for completion variant.
83
+ */
84
+ protected abstract getDefaultEmbeddingModel(): AvailableModel;
85
+ }
86
+ /**
87
+ * TODO: [🛄] Some way how to re-wrap the errors from `OpenAiCompatibleExecutionTools`
88
+ * TODO: [🛄] Maybe make custom `OpenAiCompatibleError`
89
+ * TODO: [🧠][🈁] Maybe use `isDeterministic` from options
90
+ * TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
91
+ */
@@ -1,79 +1,38 @@
1
- import OpenAI from 'openai';
2
1
  import type { AvailableModel } from '../../execution/AvailableModel';
3
2
  import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
4
- import type { ChatPromptResult } from '../../execution/PromptResult';
5
- import type { CompletionPromptResult } from '../../execution/PromptResult';
6
- import type { EmbeddingPromptResult } from '../../execution/PromptResult';
7
- import type { Prompt } from '../../types/Prompt';
8
3
  import type { string_markdown } from '../../types/typeAliases';
9
4
  import type { string_markdown_text } from '../../types/typeAliases';
10
5
  import type { string_title } from '../../types/typeAliases';
11
- import type { OpenAiExecutionToolsOptions } from './OpenAiExecutionToolsOptions';
6
+ import { computeOpenAiUsage } from './computeOpenAiUsage';
7
+ import { OpenAiCompatibleExecutionTools } from './OpenAiCompatibleExecutionTools';
12
8
  /**
13
9
  * Execution Tools for calling OpenAI API
14
10
  *
15
11
  * @public exported from `@promptbook/openai`
16
12
  */
17
- export declare class OpenAiExecutionTools implements LlmExecutionTools {
18
- protected readonly options: OpenAiExecutionToolsOptions;
19
- /**
20
- * OpenAI API client.
21
- */
22
- private client;
23
- /**
24
- * Rate limiter instance
25
- */
26
- private limiter;
27
- /**
28
- * Creates OpenAI Execution Tools.
29
- *
30
- * @param options which are relevant are directly passed to the OpenAI client
31
- */
32
- constructor(options: OpenAiExecutionToolsOptions);
13
+ export declare class OpenAiExecutionTools extends OpenAiCompatibleExecutionTools implements LlmExecutionTools {
33
14
  get title(): string_title & string_markdown_text;
34
15
  get description(): string_markdown;
35
- getClient(): Promise<OpenAI>;
36
- /**
37
- * Check the `options` passed to `constructor`
38
- */
39
- checkConfiguration(): Promise<void>;
40
16
  /**
41
- * List all available OpenAI models that can be used
42
- */
43
- listModels(): Promise<ReadonlyArray<AvailableModel>>;
44
- /**
45
- * Calls OpenAI API to use a chat model.
46
- */
47
- callChatModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements' | 'format'>): Promise<ChatPromptResult>;
48
- /**
49
- * Calls OpenAI API to use a complete model.
50
- */
51
- callCompletionModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements'>): Promise<CompletionPromptResult>;
52
- /**
53
- * Calls OpenAI API to use a embedding model
17
+ * List all available models (non dynamically)
18
+ *
19
+ * Note: Purpose of this is to provide more information about models than standard listing from API
54
20
  */
55
- callEmbeddingModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements'>): Promise<EmbeddingPromptResult>;
21
+ protected get HARDCODED_MODELS(): ReadonlyArray<AvailableModel>;
56
22
  /**
57
- * Get the model that should be used as default
23
+ * Computes the usage of the OpenAI API based on the response from OpenAI
58
24
  */
59
- private getDefaultModel;
25
+ protected computeUsage: typeof computeOpenAiUsage;
60
26
  /**
61
27
  * Default model for chat variant.
62
28
  */
63
- private getDefaultChatModel;
29
+ protected getDefaultChatModel(): AvailableModel;
64
30
  /**
65
31
  * Default model for completion variant.
66
32
  */
67
- private getDefaultCompletionModel;
33
+ protected getDefaultCompletionModel(): AvailableModel;
68
34
  /**
69
35
  * Default model for completion variant.
70
36
  */
71
- private getDefaultEmbeddingModel;
37
+ protected getDefaultEmbeddingModel(): AvailableModel;
72
38
  }
73
- /**
74
- * TODO: [🧠][🧙‍♂️] Maybe there can be some wizzard for thoose who want to use just OpenAI
75
- * TODO: Maybe Create some common util for callChatModel and callCompletionModel
76
- * TODO: Maybe make custom OpenAiError
77
- * TODO: [🧠][🈁] Maybe use `isDeterministic` from options
78
- * TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
79
- */
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
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.94.0-1`).
18
+ * It follows semantic versioning (e.g., `0.94.0-3`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/azure-openai",
3
- "version": "0.94.0-2",
3
+ "version": "0.94.0-4",
4
4
  "description": "Promptbook: Run AI apps in plain human language across multiple models and platforms",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -63,7 +63,7 @@
63
63
  "module": "./esm/index.es.js",
64
64
  "typings": "./esm/typings/src/_packages/azure-openai.index.d.ts",
65
65
  "peerDependencies": {
66
- "@promptbook/core": "0.94.0-2"
66
+ "@promptbook/core": "0.94.0-4"
67
67
  },
68
68
  "dependencies": {
69
69
  "@azure/openai": "1.0.0-beta.12",
package/umd/index.umd.js CHANGED
@@ -24,7 +24,7 @@
24
24
  * @generated
25
25
  * @see https://github.com/webgptorg/promptbook
26
26
  */
27
- const PROMPTBOOK_ENGINE_VERSION = '0.94.0-2';
27
+ const PROMPTBOOK_ENGINE_VERSION = '0.94.0-4';
28
28
  /**
29
29
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
30
30
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1200,11 +1200,11 @@
1200
1200
  }
1201
1201
 
1202
1202
  /**
1203
- * Function computeUsage will create price per one token based on the string value found on openai page
1203
+ * Create price per one token based on the string value found on openai page
1204
1204
  *
1205
1205
  * @private within the repository, used only as internal helper for `OPENAI_MODELS`
1206
1206
  */
1207
- function computeUsage(value) {
1207
+ function pricing(value) {
1208
1208
  const [price, tokens] = value.split(' / ');
1209
1209
  return parseFloat(price.replace('$', '')) / parseFloat(tokens.replace('M tokens', '')) / 1000000;
1210
1210
  }
@@ -1240,8 +1240,8 @@
1240
1240
  modelName: 'davinci-002',
1241
1241
  modelDescription: 'Legacy completion model with strong performance on text generation tasks. Optimized for complex instructions and longer outputs.',
1242
1242
  pricing: {
1243
- prompt: computeUsage(`$2.00 / 1M tokens`),
1244
- output: computeUsage(`$2.00 / 1M tokens`),
1243
+ prompt: pricing(`$2.00 / 1M tokens`),
1244
+ output: pricing(`$2.00 / 1M tokens`),
1245
1245
  },
1246
1246
  },
1247
1247
  /**/
@@ -1258,8 +1258,8 @@
1258
1258
  modelName: 'gpt-3.5-turbo-16k',
1259
1259
  modelDescription: 'GPT-3.5 Turbo with extended 16k token context length for handling longer conversations and documents.',
1260
1260
  pricing: {
1261
- prompt: computeUsage(`$3.00 / 1M tokens`),
1262
- output: computeUsage(`$4.00 / 1M tokens`),
1261
+ prompt: pricing(`$3.00 / 1M tokens`),
1262
+ output: pricing(`$4.00 / 1M tokens`),
1263
1263
  },
1264
1264
  },
1265
1265
  /**/
@@ -1282,8 +1282,8 @@
1282
1282
  modelName: 'gpt-4',
1283
1283
  modelDescription: 'GPT-4 is a powerful language model with enhanced reasoning, instruction-following capabilities, and 8K context window. Optimized for complex tasks requiring deep understanding.',
1284
1284
  pricing: {
1285
- prompt: computeUsage(`$30.00 / 1M tokens`),
1286
- output: computeUsage(`$60.00 / 1M tokens`),
1285
+ prompt: pricing(`$30.00 / 1M tokens`),
1286
+ output: pricing(`$60.00 / 1M tokens`),
1287
1287
  },
1288
1288
  },
1289
1289
  /**/
@@ -1294,8 +1294,8 @@
1294
1294
  modelName: 'gpt-4-32k',
1295
1295
  modelDescription: 'Extended context version of GPT-4 with a 32K token window for processing very long inputs and generating comprehensive responses for complex tasks.',
1296
1296
  pricing: {
1297
- prompt: computeUsage(`$60.00 / 1M tokens`),
1298
- output: computeUsage(`$120.00 / 1M tokens`),
1297
+ prompt: pricing(`$60.00 / 1M tokens`),
1298
+ output: pricing(`$120.00 / 1M tokens`),
1299
1299
  },
1300
1300
  },
1301
1301
  /**/
@@ -1317,8 +1317,8 @@
1317
1317
  modelName: 'gpt-4-turbo-2024-04-09',
1318
1318
  modelDescription: 'Latest stable GPT-4 Turbo model from April 2024 with enhanced reasoning and context handling capabilities. Offers 128K context window and improved performance.',
1319
1319
  pricing: {
1320
- prompt: computeUsage(`$10.00 / 1M tokens`),
1321
- output: computeUsage(`$30.00 / 1M tokens`),
1320
+ prompt: pricing(`$10.00 / 1M tokens`),
1321
+ output: pricing(`$30.00 / 1M tokens`),
1322
1322
  },
1323
1323
  },
1324
1324
  /**/
@@ -1329,8 +1329,8 @@
1329
1329
  modelName: 'gpt-3.5-turbo-1106',
1330
1330
  modelDescription: 'November 2023 version of GPT-3.5 Turbo with improved instruction following and a 16K token context window.',
1331
1331
  pricing: {
1332
- prompt: computeUsage(`$1.00 / 1M tokens`),
1333
- output: computeUsage(`$2.00 / 1M tokens`),
1332
+ prompt: pricing(`$1.00 / 1M tokens`),
1333
+ output: pricing(`$2.00 / 1M tokens`),
1334
1334
  },
1335
1335
  },
1336
1336
  /**/
@@ -1341,8 +1341,8 @@
1341
1341
  modelName: 'gpt-4-turbo',
1342
1342
  modelDescription: 'More capable model than GPT-4 with improved instruction following, function calling and a 128K token context window for handling very large documents.',
1343
1343
  pricing: {
1344
- prompt: computeUsage(`$10.00 / 1M tokens`),
1345
- output: computeUsage(`$30.00 / 1M tokens`),
1344
+ prompt: pricing(`$10.00 / 1M tokens`),
1345
+ output: pricing(`$30.00 / 1M tokens`),
1346
1346
  },
1347
1347
  },
1348
1348
  /**/
@@ -1353,8 +1353,8 @@
1353
1353
  modelName: 'gpt-3.5-turbo-instruct-0914',
1354
1354
  modelDescription: 'September 2023 version of GPT-3.5 Turbo optimized for completion-style instruction following with a 4K context window.',
1355
1355
  pricing: {
1356
- prompt: computeUsage(`$1.50 / 1M tokens`),
1357
- output: computeUsage(`$2.00 / 1M tokens`), // <- For gpt-3.5-turbo-instruct
1356
+ prompt: pricing(`$1.50 / 1M tokens`),
1357
+ output: pricing(`$2.00 / 1M tokens`), // <- For gpt-3.5-turbo-instruct
1358
1358
  },
1359
1359
  },
1360
1360
  /**/
@@ -1365,8 +1365,8 @@
1365
1365
  modelName: 'gpt-3.5-turbo-instruct',
1366
1366
  modelDescription: 'Optimized version of GPT-3.5 for completion-style API with good instruction following and a 4K token context window.',
1367
1367
  pricing: {
1368
- prompt: computeUsage(`$1.50 / 1M tokens`),
1369
- output: computeUsage(`$2.00 / 1M tokens`),
1368
+ prompt: pricing(`$1.50 / 1M tokens`),
1369
+ output: pricing(`$2.00 / 1M tokens`),
1370
1370
  },
1371
1371
  },
1372
1372
  /**/
@@ -1383,8 +1383,8 @@
1383
1383
  modelName: 'gpt-3.5-turbo',
1384
1384
  modelDescription: 'Latest version of GPT-3.5 Turbo with improved performance and instruction following capabilities. Default 4K context window with options for 16K.',
1385
1385
  pricing: {
1386
- prompt: computeUsage(`$0.50 / 1M tokens`),
1387
- output: computeUsage(`$1.50 / 1M tokens`),
1386
+ prompt: pricing(`$0.50 / 1M tokens`),
1387
+ output: pricing(`$1.50 / 1M tokens`),
1388
1388
  },
1389
1389
  },
1390
1390
  /**/
@@ -1395,8 +1395,8 @@
1395
1395
  modelName: 'gpt-3.5-turbo-0301',
1396
1396
  modelDescription: 'March 2023 version of GPT-3.5 Turbo with a 4K token context window. Legacy model maintained for backward compatibility.',
1397
1397
  pricing: {
1398
- prompt: computeUsage(`$1.50 / 1M tokens`),
1399
- output: computeUsage(`$2.00 / 1M tokens`),
1398
+ prompt: pricing(`$1.50 / 1M tokens`),
1399
+ output: pricing(`$2.00 / 1M tokens`),
1400
1400
  },
1401
1401
  },
1402
1402
  /**/
@@ -1407,8 +1407,8 @@
1407
1407
  modelName: 'babbage-002',
1408
1408
  modelDescription: 'Efficient legacy completion model with a good balance of performance and speed. Suitable for straightforward text generation tasks.',
1409
1409
  pricing: {
1410
- prompt: computeUsage(`$0.40 / 1M tokens`),
1411
- output: computeUsage(`$0.40 / 1M tokens`),
1410
+ prompt: pricing(`$0.40 / 1M tokens`),
1411
+ output: pricing(`$0.40 / 1M tokens`),
1412
1412
  },
1413
1413
  },
1414
1414
  /**/
@@ -1419,8 +1419,8 @@
1419
1419
  modelName: 'gpt-4-1106-preview',
1420
1420
  modelDescription: 'November 2023 preview version of GPT-4 Turbo with improved instruction following and a 128K token context window.',
1421
1421
  pricing: {
1422
- prompt: computeUsage(`$10.00 / 1M tokens`),
1423
- output: computeUsage(`$30.00 / 1M tokens`),
1422
+ prompt: pricing(`$10.00 / 1M tokens`),
1423
+ output: pricing(`$30.00 / 1M tokens`),
1424
1424
  },
1425
1425
  },
1426
1426
  /**/
@@ -1431,8 +1431,8 @@
1431
1431
  modelName: 'gpt-4-0125-preview',
1432
1432
  modelDescription: 'January 2024 preview version of GPT-4 Turbo with improved reasoning capabilities and a 128K token context window.',
1433
1433
  pricing: {
1434
- prompt: computeUsage(`$10.00 / 1M tokens`),
1435
- output: computeUsage(`$30.00 / 1M tokens`),
1434
+ prompt: pricing(`$10.00 / 1M tokens`),
1435
+ output: pricing(`$30.00 / 1M tokens`),
1436
1436
  },
1437
1437
  },
1438
1438
  /**/
@@ -1449,8 +1449,8 @@
1449
1449
  modelName: 'gpt-3.5-turbo-0125',
1450
1450
  modelDescription: 'January 2024 version of GPT-3.5 Turbo with improved reasoning capabilities and a 16K token context window.',
1451
1451
  pricing: {
1452
- prompt: computeUsage(`$0.50 / 1M tokens`),
1453
- output: computeUsage(`$1.50 / 1M tokens`),
1452
+ prompt: pricing(`$0.50 / 1M tokens`),
1453
+ output: pricing(`$1.50 / 1M tokens`),
1454
1454
  },
1455
1455
  },
1456
1456
  /**/
@@ -1461,8 +1461,8 @@
1461
1461
  modelName: 'gpt-4-turbo-preview',
1462
1462
  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.',
1463
1463
  pricing: {
1464
- prompt: computeUsage(`$10.00 / 1M tokens`),
1465
- output: computeUsage(`$30.00 / 1M tokens`),
1464
+ prompt: pricing(`$10.00 / 1M tokens`),
1465
+ output: pricing(`$30.00 / 1M tokens`),
1466
1466
  },
1467
1467
  },
1468
1468
  /**/
@@ -1473,7 +1473,7 @@
1473
1473
  modelName: 'text-embedding-3-large',
1474
1474
  modelDescription: "OpenAI's most capable text embedding model designed for high-quality embeddings for complex similarity tasks and information retrieval.",
1475
1475
  pricing: {
1476
- prompt: computeUsage(`$0.13 / 1M tokens`),
1476
+ prompt: pricing(`$0.13 / 1M tokens`),
1477
1477
  // TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
1478
1478
  output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
1479
1479
  },
@@ -1486,7 +1486,7 @@
1486
1486
  modelName: 'text-embedding-3-small',
1487
1487
  modelDescription: 'Cost-effective embedding model with good performance for simpler tasks like text similarity and retrieval. Good balance of quality and efficiency.',
1488
1488
  pricing: {
1489
- prompt: computeUsage(`$0.02 / 1M tokens`),
1489
+ prompt: pricing(`$0.02 / 1M tokens`),
1490
1490
  // TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
1491
1491
  output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
1492
1492
  },
@@ -1499,8 +1499,8 @@
1499
1499
  modelName: 'gpt-3.5-turbo-0613',
1500
1500
  modelDescription: 'June 2023 version of GPT-3.5 Turbo with function calling capabilities and a 4K token context window.',
1501
1501
  pricing: {
1502
- prompt: computeUsage(`$1.50 / 1M tokens`),
1503
- output: computeUsage(`$2.00 / 1M tokens`),
1502
+ prompt: pricing(`$1.50 / 1M tokens`),
1503
+ output: pricing(`$2.00 / 1M tokens`),
1504
1504
  },
1505
1505
  },
1506
1506
  /**/
@@ -1511,7 +1511,7 @@
1511
1511
  modelName: 'text-embedding-ada-002',
1512
1512
  modelDescription: 'Legacy text embedding model suitable for text similarity and retrieval augmented generation use cases. Replaced by newer embedding-3 models.',
1513
1513
  pricing: {
1514
- prompt: computeUsage(`$0.1 / 1M tokens`),
1514
+ prompt: pricing(`$0.1 / 1M tokens`),
1515
1515
  // TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
1516
1516
  output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
1517
1517
  },
@@ -1542,8 +1542,8 @@
1542
1542
  modelName: 'gpt-4o-2024-05-13',
1543
1543
  modelDescription: 'May 2024 version of GPT-4o with enhanced multimodal capabilities, improved reasoning, and optimized for vision, audio and chat at lower latencies.',
1544
1544
  pricing: {
1545
- prompt: computeUsage(`$5.00 / 1M tokens`),
1546
- output: computeUsage(`$15.00 / 1M tokens`),
1545
+ prompt: pricing(`$5.00 / 1M tokens`),
1546
+ output: pricing(`$15.00 / 1M tokens`),
1547
1547
  },
1548
1548
  },
1549
1549
  /**/
@@ -1554,8 +1554,8 @@
1554
1554
  modelName: 'gpt-4o',
1555
1555
  modelDescription: "OpenAI's most advanced multimodal model optimized for performance, speed, and cost. Capable of vision, reasoning, and high quality text generation.",
1556
1556
  pricing: {
1557
- prompt: computeUsage(`$5.00 / 1M tokens`),
1558
- output: computeUsage(`$15.00 / 1M tokens`),
1557
+ prompt: pricing(`$5.00 / 1M tokens`),
1558
+ output: pricing(`$15.00 / 1M tokens`),
1559
1559
  },
1560
1560
  },
1561
1561
  /**/
@@ -1566,8 +1566,8 @@
1566
1566
  modelName: 'gpt-4o-mini',
1567
1567
  modelDescription: 'Smaller, more cost-effective version of GPT-4o with good performance across text, vision, and audio tasks at reduced complexity.',
1568
1568
  pricing: {
1569
- prompt: computeUsage(`$0.15 / 1M tokens`),
1570
- output: computeUsage(`$0.60 / 1M tokens`),
1569
+ prompt: pricing(`$0.15 / 1M tokens`),
1570
+ output: pricing(`$0.60 / 1M tokens`),
1571
1571
  },
1572
1572
  },
1573
1573
  /**/
@@ -1578,8 +1578,8 @@
1578
1578
  modelName: 'o1-preview',
1579
1579
  modelDescription: 'Advanced reasoning model with exceptional performance on complex logical, mathematical, and analytical tasks. Built for deep reasoning and specialized professional tasks.',
1580
1580
  pricing: {
1581
- prompt: computeUsage(`$15.00 / 1M tokens`),
1582
- output: computeUsage(`$60.00 / 1M tokens`),
1581
+ prompt: pricing(`$15.00 / 1M tokens`),
1582
+ output: pricing(`$60.00 / 1M tokens`),
1583
1583
  },
1584
1584
  },
1585
1585
  /**/
@@ -1591,8 +1591,8 @@
1591
1591
  modelDescription: 'September 2024 version of O1 preview with specialized reasoning capabilities for complex tasks requiring precise analytical thinking.',
1592
1592
  // <- TODO: [💩] Some better system to organize these date suffixes and versions
1593
1593
  pricing: {
1594
- prompt: computeUsage(`$15.00 / 1M tokens`),
1595
- output: computeUsage(`$60.00 / 1M tokens`),
1594
+ prompt: pricing(`$15.00 / 1M tokens`),
1595
+ output: pricing(`$60.00 / 1M tokens`),
1596
1596
  },
1597
1597
  },
1598
1598
  /**/
@@ -1603,8 +1603,8 @@
1603
1603
  modelName: 'o1-mini',
1604
1604
  modelDescription: 'Smaller, cost-effective version of the O1 model with good performance on reasoning tasks while maintaining efficiency for everyday analytical use.',
1605
1605
  pricing: {
1606
- prompt: computeUsage(`$3.00 / 1M tokens`),
1607
- output: computeUsage(`$12.00 / 1M tokens`),
1606
+ prompt: pricing(`$3.00 / 1M tokens`),
1607
+ output: pricing(`$12.00 / 1M tokens`),
1608
1608
  },
1609
1609
  },
1610
1610
  /**/
@@ -1615,8 +1615,8 @@
1615
1615
  modelName: 'o1',
1616
1616
  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.",
1617
1617
  pricing: {
1618
- prompt: computeUsage(`$15.00 / 1M tokens`),
1619
- output: computeUsage(`$60.00 / 1M tokens`),
1618
+ prompt: pricing(`$15.00 / 1M tokens`),
1619
+ output: pricing(`$60.00 / 1M tokens`),
1620
1620
  },
1621
1621
  },
1622
1622
  /**/
@@ -1627,8 +1627,8 @@
1627
1627
  modelName: 'o3-mini',
1628
1628
  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.',
1629
1629
  pricing: {
1630
- prompt: computeUsage(`$3.00 / 1M tokens`),
1631
- output: computeUsage(`$12.00 / 1M tokens`),
1630
+ prompt: pricing(`$3.00 / 1M tokens`),
1631
+ output: pricing(`$12.00 / 1M tokens`),
1632
1632
  // <- TODO: !! Unsure, check the pricing
1633
1633
  },
1634
1634
  },
@@ -1640,8 +1640,8 @@
1640
1640
  modelName: 'o1-mini-2024-09-12',
1641
1641
  modelDescription: "September 2024 version of O1-mini with balanced reasoning capabilities and cost-efficiency. Good for analytical tasks that don't require the full O1 model.",
1642
1642
  pricing: {
1643
- prompt: computeUsage(`$3.00 / 1M tokens`),
1644
- output: computeUsage(`$12.00 / 1M tokens`),
1643
+ prompt: pricing(`$3.00 / 1M tokens`),
1644
+ output: pricing(`$12.00 / 1M tokens`),
1645
1645
  },
1646
1646
  },
1647
1647
  /**/
@@ -1652,8 +1652,8 @@
1652
1652
  modelName: 'gpt-3.5-turbo-16k-0613',
1653
1653
  modelDescription: 'June 2023 version of GPT-3.5 Turbo with extended 16k token context window for processing longer conversations and documents.',
1654
1654
  pricing: {
1655
- prompt: computeUsage(`$3.00 / 1M tokens`),
1656
- output: computeUsage(`$4.00 / 1M tokens`),
1655
+ prompt: pricing(`$3.00 / 1M tokens`),
1656
+ output: pricing(`$4.00 / 1M tokens`),
1657
1657
  },
1658
1658
  },
1659
1659
  /**/