@pydantic/genai-prices 0.0.20 → 0.0.22

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.
package/package.json CHANGED
@@ -1,10 +1,31 @@
1
1
  {
2
2
  "name": "@pydantic/genai-prices",
3
- "version": "0.0.20",
4
- "description": "Calculate prices for calling LLM inference APIs (JS/TS version of genai-prices)",
3
+ "version": "0.0.22",
4
+ "description": "Calculate prices for calling LLM inference APIs",
5
+ "author": "Pydantic Team",
6
+ "type": "module",
5
7
  "main": "./dist/index.cjs",
6
8
  "module": "./dist/index.js",
7
9
  "types": "./dist/index.d.ts",
10
+ "homepage": "https://github.com/pydantic/genai-prices/",
11
+ "bugs": {
12
+ "url": "https://github.com/pydantic/genai-prices/issues"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "keywords": [
18
+ "pydantic",
19
+ "genai",
20
+ "prices",
21
+ "llm",
22
+ "inference",
23
+ "api"
24
+ ],
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/pydantic/genai-prices"
28
+ },
8
29
  "exports": {
9
30
  ".": {
10
31
  "import": {
@@ -17,50 +38,56 @@
17
38
  }
18
39
  }
19
40
  },
20
- "files": [
21
- "dist",
22
- "LICENSE"
23
- ],
24
41
  "bin": {
25
42
  "genai-prices": "dist/cli.js"
26
43
  },
27
44
  "scripts": {
28
45
  "build": "vite build && npm run build:cli",
29
- "build:cli": "tsc src/cli.ts --outDir dist --module nodenext --esModuleInterop --skipLibCheck",
30
- "postbuild": "if ! head -n1 dist/cli.js | grep -q '^#!/usr/bin/env node$'; then echo '#!/usr/bin/env node' | cat - dist/cli.js > dist/cli.tmp && mv dist/cli.tmp dist/cli.js; fi && chmod +x dist/cli.js",
46
+ "build:cli": "vite build --config vite.config-cli.ts",
31
47
  "dev": "vite build --watch",
32
- "typecheck": "tsc",
48
+ "typecheck": "tsc --noEmit",
49
+ "lint": "eslint",
50
+ "format": "eslint --fix --quiet",
33
51
  "test": "vitest run",
52
+ "test:watch": "vitest",
34
53
  "test:ui": "vitest --ui",
35
- "prepare": "npm run build"
54
+ "browser-example": "vite --config src/examples/browser/vite.browser-preview.ts",
55
+ "node-example": "tsx ./src/examples/node-script.ts",
56
+ "prepare": "npm run build",
57
+ "knip": "knip"
36
58
  },
37
- "repository": {
38
- "type": "git",
39
- "url": "git+https://github.com/pydantic/genai-prices.git"
40
- },
41
- "author": "Pydantic Team",
42
- "license": "MIT",
43
59
  "dependencies": {
44
- "node-fetch": "^3.3.2",
45
60
  "yargs": "^17.7.2"
46
61
  },
47
62
  "devDependencies": {
48
- "@types/node": "^20.0.0",
63
+ "@eslint/js": "^9.22.0",
64
+ "@types/node": "^22.17.0",
49
65
  "@types/yargs": "^17.0.24",
66
+ "@typescript-eslint/utils": "^8.26.1",
50
67
  "@vitest/ui": "^3.2.4",
51
- "typescript": "^5.0.0",
52
- "vite": "^5.1.3",
53
- "vite-plugin-dts": "^4.5.3",
68
+ "eslint": "^9.22.0",
69
+ "eslint-config-prettier": "^10.1.1",
70
+ "eslint-plugin-perfectionist": "^4.10.1",
71
+ "eslint-plugin-prettier": "^5.2.3",
72
+ "eslint-plugin-turbo": "^2.4.4",
73
+ "globals": "^16.0.0",
74
+ "knip": "^5.62.0",
75
+ "neostandard": "^0.12.1",
76
+ "prettier": "^3.6.2",
77
+ "tsx": "^4.20.3",
78
+ "typescript": "^5.9.2",
79
+ "typescript-eslint": "^8.26.1",
80
+ "vite": "^7.1.1",
81
+ "vite-plugin-dts": "^4.5.4",
54
82
  "vitest": "^3.2.4"
55
83
  },
56
84
  "engines": {
57
85
  "node": ">=20"
58
86
  },
59
- "browser": {
60
- "node-fetch": false
61
- },
62
- "type": "module",
63
- "optionalDependencies": {
64
- "@rollup/rollup-linux-x64-gnu": "^4.9.5"
65
- }
87
+ "files": [
88
+ "dist",
89
+ "LICENSE",
90
+ "README.md"
91
+ ],
92
+ "license": "MIT"
66
93
  }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- import { Usage, PriceCalculationResult } from '../types.js';
2
- export type { Usage, PriceCalculation, PriceCalculationResult } from '../types.js';
3
- export interface CalcPriceOptions {
4
- providerId?: string;
5
- providerApiUrl?: string;
6
- timestamp?: Date;
7
- }
8
- export declare function calcPriceAsync(usage: Usage, modelRef: string, options?: CalcPriceOptions): Promise<PriceCalculationResult>;
@@ -1,24 +0,0 @@
1
- import { getProvidersAsync } from '../dataLoader.js';
2
- import { matchProvider, matchModel } from '../matcher.js';
3
- import { calcPrice as calcModelPrice, getActiveModelPrice } from '../priceCalc.js';
4
- export async function calcPriceAsync(usage, modelRef, options = {}) {
5
- const providers = await getProvidersAsync();
6
- const provider = matchProvider(providers, modelRef, options.providerId, options.providerApiUrl);
7
- if (!provider)
8
- return null;
9
- const model = matchModel(provider.models, modelRef);
10
- if (!model)
11
- return null;
12
- const timestamp = options.timestamp || new Date();
13
- const model_price = getActiveModelPrice(model, timestamp);
14
- const priceResult = calcModelPrice(usage, model_price);
15
- return {
16
- input_price: priceResult.input_price,
17
- output_price: priceResult.output_price,
18
- total_price: priceResult.total_price,
19
- provider,
20
- model,
21
- model_price,
22
- auto_update_timestamp: undefined,
23
- };
24
- }
package/dist/cli.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/dist/data.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { Provider } from './types.js';
2
- export declare const data: Provider[];