@common_ch/common 1.0.268 → 1.0.270

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,2 @@
1
+ import { AiOptionNamesEnum } from "../../enums/ai";
2
+ export declare function calculateCostChat(model: AiOptionNamesEnum, promptTokens: number, completionTokens: number): number;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculateCostChat = calculateCostChat;
4
+ const pricingTable_1 = require("./pricingTable");
5
+ function calculateCostChat(model, promptTokens, completionTokens) {
6
+ const pricing = pricingTable_1.pricingTableChat[model];
7
+ if (!pricing)
8
+ throw new Error(`No pricing found for model: ${model}`);
9
+ const cost = (promptTokens / 1000000) * pricing.prompt +
10
+ (completionTokens / 1000000) * pricing.completion;
11
+ return parseFloat(cost.toFixed(6));
12
+ }
@@ -0,0 +1,18 @@
1
+ interface ModelPricingChat {
2
+ prompt: number;
3
+ completion: number;
4
+ }
5
+ interface ModelPricingImage {
6
+ imageGen?: number;
7
+ }
8
+ interface ModelPricingAudio {
9
+ audioIn?: number;
10
+ }
11
+ interface ModelPricingTTS {
12
+ audioOut?: number;
13
+ }
14
+ export declare const pricingTableChat: Record<string, ModelPricingChat>;
15
+ export declare const pricingTableImage: Record<string, ModelPricingImage>;
16
+ export declare const pricingTableAudio: Record<string, ModelPricingAudio>;
17
+ export declare const pricingTableTTS: Record<string, ModelPricingTTS>;
18
+ export {};
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pricingTableTTS = exports.pricingTableAudio = exports.pricingTableImage = exports.pricingTableChat = void 0;
4
+ exports.pricingTableChat = {
5
+ // --- GPT-5 family ---
6
+ 'gpt-5-mini': { prompt: 0.15, completion: 0.6 },
7
+ 'gpt-5-nano': { prompt: 0.05, completion: 0.2 },
8
+ 'gpt-5': { prompt: 10, completion: 30 },
9
+ // --- GPT-4 family ---
10
+ 'gpt-4o': { prompt: 2.5, completion: 10 },
11
+ 'gpt-4.1': { prompt: 5, completion: 15 },
12
+ 'gpt-4.1-mini': { prompt: 0.15, completion: 0.6 },
13
+ 'gpt-4.1-nano': { prompt: 0.05, completion: 0.2 },
14
+ 'gpt-4o-mini': { prompt: 0.3, completion: 1.2 },
15
+ // --- GPT-3.5 family ---
16
+ 'gpt-3.5-turbo': { prompt: 0.5, completion: 1.5 },
17
+ };
18
+ exports.pricingTableImage = {
19
+ // --- Images ---
20
+ 'dall-e-3': { imageGen: 0.04 }, // $0.04 per image (standard)
21
+ };
22
+ exports.pricingTableAudio = {
23
+ // --- Audio / Whisper ---
24
+ 'whisper-1': { audioIn: 0.006 }, // $0.006 / minute
25
+ 'whisper-large': { audioIn: 0.006 }, // whisper-1
26
+ };
27
+ exports.pricingTableTTS = {
28
+ // --- Text-to-Speech ---
29
+ 'tts-1': { audioOut: 0.015 }, // $0.015 / minute
30
+ };
@@ -0,0 +1,12 @@
1
+ type EstimateResult = {
2
+ file: string;
3
+ ext: string;
4
+ sizeMB: number;
5
+ sizeGB: number;
6
+ costPerDayUSD: number;
7
+ costPerMonthUSD: number;
8
+ };
9
+ export declare function estimateStorageCost(filePath: string, storagePricePerGBPerDay?: number): EstimateResult | {
10
+ error: string;
11
+ };
12
+ export {};
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.estimateStorageCost = estimateStorageCost;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ function estimateStorageCost(filePath, storagePricePerGBPerDay = 0.10) {
10
+ var _a;
11
+ if (!fs_1.default.existsSync(filePath)) {
12
+ return { error: "File not found" };
13
+ }
14
+ const fileSizeBytes = fs_1.default.statSync(filePath).size;
15
+ const fileSizeMB = fileSizeBytes / (1024 * 1024);
16
+ const fileSizeGB = fileSizeBytes / (1024 * 1024 * 1024);
17
+ const ext = path_1.default.extname(filePath).toLowerCase();
18
+ const multipliers = {
19
+ ".pdf": 2.0,
20
+ ".doc": 2.0,
21
+ ".docx": 2.0,
22
+ ".xls": 2.0,
23
+ ".xlsx": 2.0,
24
+ ".csv": 1.5,
25
+ ".txt": 1.2,
26
+ ".json": 1.5,
27
+ ".md": 1.2,
28
+ ".js": 1.5,
29
+ ".ts": 1.5,
30
+ ".tsx": 1.5,
31
+ ".py": 1.5,
32
+ ".java": 1.5,
33
+ ".cpp": 1.5,
34
+ ".c": 1.5,
35
+ ".cs": 1.5,
36
+ ".go": 1.5,
37
+ ".rb": 1.5,
38
+ ".php": 1.5,
39
+ ".html": 1.3,
40
+ ".css": 1.3,
41
+ ".jpg": 1.0,
42
+ ".jpeg": 1.0,
43
+ ".png": 1.0,
44
+ ".gif": 1.0,
45
+ ".svg": 1.0,
46
+ ".mp3": 1.0,
47
+ ".wav": 1.0,
48
+ ".mp4": 1.0,
49
+ ".mov": 1.0,
50
+ ".avi": 1.0,
51
+ };
52
+ const multiplier = (_a = multipliers[ext]) !== null && _a !== void 0 ? _a : 1.0;
53
+ const costPerDay = fileSizeGB * storagePricePerGBPerDay * multiplier;
54
+ const costPerMonth = costPerDay * 30;
55
+ return {
56
+ file: path_1.default.basename(filePath),
57
+ ext,
58
+ sizeMB: Number(fileSizeMB.toFixed(2)),
59
+ sizeGB: Number(fileSizeGB.toFixed(4)),
60
+ costPerDayUSD: Number(costPerDay.toFixed(5)),
61
+ costPerMonthUSD: Number(costPerMonth.toFixed(5)),
62
+ };
63
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@common_ch/common",
3
- "version": "1.0.268",
3
+ "version": "1.0.270",
4
4
  "main": "./build/index.js",
5
5
  "types": "./build/index.d.ts",
6
6
  "files": [