@common_ch/common 1.0.302 → 1.0.304

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.
@@ -19,6 +19,7 @@ export type ContentGemini = {
19
19
  parts: IPart[];
20
20
  aiOptionId: string | AiOptionDoc;
21
21
  attachments?: Attachment[];
22
+ createdAt: string;
22
23
  };
23
24
  export type Attachment = {
24
25
  contentType: string;
@@ -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?: ToolName[]): number;
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 = pricingTable_1.pricingTableChat[model];
7
- if (!pricing)
8
- throw new Error(`No pricing found for model: ${model}`);
9
- let cost = (promptTokens / 1000000) * pricing.prompt +
10
- (cacheToken / 1000000) * pricing.cache +
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]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@common_ch/common",
3
- "version": "1.0.302",
3
+ "version": "1.0.304",
4
4
  "main": "./build/index.js",
5
5
  "types": "./build/index.d.ts",
6
6
  "files": [