@common_ch/common 1.0.302 → 1.0.303
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.
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import { AiOptionNamesEnum } from "../../enums/ai";
|
|
2
2
|
import { ToolName } from "./pricingTable";
|
|
3
|
-
export declare function calculateCostChat(model: AiOptionNamesEnum, promptTokens: number, cacheToken: number, completionTokens: number, toolsUsed
|
|
3
|
+
export declare function calculateCostChat(model: AiOptionNamesEnum, promptTokens: number, cacheToken: number, completionTokens: number, toolsUsed: ToolName[] | undefined, pricing: {
|
|
4
|
+
inputPrice: number;
|
|
5
|
+
outputPrice: number;
|
|
6
|
+
cachePrice: number;
|
|
7
|
+
}): number;
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.calculateCostChat = calculateCostChat;
|
|
4
4
|
const pricingTable_1 = require("./pricingTable");
|
|
5
|
-
function calculateCostChat(model, promptTokens, cacheToken, completionTokens, toolsUsed = []) {
|
|
6
|
-
const pricing =
|
|
7
|
-
if (!pricing)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
(
|
|
11
|
-
(completionTokens / 1000000) * pricing.completion;
|
|
5
|
+
function calculateCostChat(model, promptTokens, cacheToken, completionTokens, toolsUsed = [], pricing) {
|
|
6
|
+
// const pricing = pricingTableChat[model];
|
|
7
|
+
// if (!pricing) throw new Error(`No pricing found for model: ${model}`);
|
|
8
|
+
let cost = (promptTokens / 1000000) * pricing.inputPrice +
|
|
9
|
+
(cacheToken / 1000000) * pricing.cachePrice +
|
|
10
|
+
(completionTokens / 1000000) * pricing.outputPrice;
|
|
12
11
|
let multiplier = 1;
|
|
13
12
|
for (const tool of toolsUsed) {
|
|
14
13
|
if (pricingTable_1.toolOverhead[tool]) {
|