@cellaware/utils 5.0.4 → 5.0.6

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.
@@ -7,7 +7,7 @@ const STATUS_SERVICE_UNAVAILABLE = 503;
7
7
  const RETRY_SLEEP_MS = 3000;
8
8
  const MAX_RETRIES = 3;
9
9
  async function functionFetch(url, req) {
10
- let res = new Response(null, { status: STATUS_SERVICE_UNAVAILABLE });
10
+ let res = new Response(null, { status: STATUS_SERVICE_UNAVAILABLE, statusText: 'Service Unavailable' });
11
11
  let retryNum = 0;
12
12
  do {
13
13
  if (retryNum > 0) {
package/dist/llm/cost.js CHANGED
@@ -4,45 +4,52 @@ export function getLLMCostPerToken(modelName) {
4
4
  let outputCost = 0.0;
5
5
  switch (modelName) {
6
6
  case 'gpt-4.1':
7
- inputCost = 0.002;
8
- outputCost = 0.080;
7
+ inputCost = 2.00;
8
+ outputCost = 8.00;
9
9
  break;
10
10
  case 'gpt-4.1-mini':
11
- inputCost = 0.0004;
12
- outputCost = 0.0016;
11
+ inputCost = 0.40;
12
+ outputCost = 1.60;
13
13
  break;
14
14
  case 'gpt-4.1-nano':
15
- inputCost = 0.0001;
16
- outputCost = 0.0004;
15
+ inputCost = 0.10;
16
+ outputCost = 0.40;
17
+ break;
18
+ case 'gpt-4o':
19
+ inputCost = 2.50;
20
+ outputCost = 10.00;
21
+ break;
22
+ case 'gpt-4o-mini':
23
+ inputCost = 0.15;
24
+ outputCost = 0.60;
17
25
  break;
18
26
  case 'o1':
19
- inputCost = 0.015;
20
- outputCost = 0.060;
27
+ inputCost = 15.00;
28
+ outputCost = 60.00;
21
29
  break;
22
30
  case 'o1-mini':
23
- inputCost = 0.003;
24
- outputCost = 0.012;
31
+ inputCost = 1.10;
32
+ outputCost = 4.40;
25
33
  break;
26
- case 'o3-mini':
27
- inputCost = 0.0011;
28
- outputCost = 0.0044;
34
+ case 'o3':
35
+ inputCost = 10.00;
36
+ outputCost = 40.00;
29
37
  break;
30
- case 'gpt-4o':
31
- inputCost = 0.0025;
32
- outputCost = 0.010;
38
+ case 'o3-mini':
39
+ inputCost = 1.10;
40
+ outputCost = 4.40;
33
41
  break;
34
- case 'gpt-4o-mini':
35
- inputCost = 0.00015;
36
- outputCost = 0.0006;
42
+ case 'o4-mini':
43
+ inputCost = 1.10;
44
+ outputCost = 4.40;
37
45
  break;
38
46
  default:
39
- inputCost = 0.0;
40
- outputCost = 0.0;
41
- break;
47
+ throw new Error(`LLM: Model '${modelName}' cost is not configured`);
42
48
  }
43
- // OpenAI model costs are measured in thousands of tokens -- therefore we need to divide each figure by 1000 before returning.
44
- inputCost /= 1000.0;
45
- outputCost /= 1000.0;
49
+ // OpenAI model costs are measured in millions of tokens -- therefore we need to divide each figure by 1,000,000 before returning.
50
+ const unit = 1_000_000.0;
51
+ inputCost /= unit;
52
+ outputCost /= unit;
46
53
  return { inputCost, outputCost };
47
54
  }
48
55
  export function getLLMTransactionCost(tokenUsage, modelName) {
@@ -1,4 +1,4 @@
1
- export type ModelName = 'gpt-4.1' | 'gpt-4.1-mini' | 'gpt-4.1-nano' | 'o1' | 'o1-mini' | 'o3-mini' | 'gpt-4o' | 'gpt-4o-mini';
1
+ export type ModelName = 'gpt-4.1' | 'gpt-4.1-mini' | 'gpt-4.1-nano' | 'gpt-4o' | 'gpt-4o-mini' | 'o1' | 'o1-mini' | 'o3' | 'o3-mini' | 'o4-mini';
2
2
  export type ReasoningEffort = 'low' | 'medium' | 'high';
3
3
  export interface OpenAIModelOptions {
4
4
  reasoning_effort?: ReasoningEffort;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cellaware/utils",
3
- "version": "5.0.4",
3
+ "version": "5.0.6",
4
4
  "description": "Cellaware Utilities for Node.js",
5
5
  "author": "Cellaware Technologies",
6
6
  "type": "module",