ai-speedometer 1.3.1 → 1.3.3
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/README.md +15 -1
- package/cli.js +17 -8
- package/dist/ai-speedometer +41 -41
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -17,6 +17,12 @@ npm install -g ai-speedometer
|
|
|
17
17
|
- **Tokens/Second** - Real-time throughput
|
|
18
18
|
- **Token Counts** - Input, output, and total tokens used
|
|
19
19
|
|
|
20
|
+
## New Features
|
|
21
|
+
|
|
22
|
+
- **REST API Default** - REST API benchmarking is now the default method for better compatibility
|
|
23
|
+
- **Headless Mode** - Run benchmarks without interactive CLI using command-line arguments
|
|
24
|
+
- **Streaming Support** - Full streaming support now available in REST API benchmarks
|
|
25
|
+
|
|
20
26
|
## Quick Setup
|
|
21
27
|
|
|
22
28
|
1. **Set Model**
|
|
@@ -41,7 +47,8 @@ npm install -g ai-speedometer
|
|
|
41
47
|
4. **Run Benchmark**
|
|
42
48
|
```bash
|
|
43
49
|
ai-speedometer
|
|
44
|
-
# Select "Run Benchmark (
|
|
50
|
+
# Select "Run Benchmark (REST API)" → Choose models → Press ENTER
|
|
51
|
+
# Note: REST API is now the default benchmark method
|
|
45
52
|
```
|
|
46
53
|
|
|
47
54
|
## Usage
|
|
@@ -55,6 +62,13 @@ aispeed
|
|
|
55
62
|
|
|
56
63
|
# Debug mode
|
|
57
64
|
ai-speedometer --debug
|
|
65
|
+
|
|
66
|
+
# Headless mode - run benchmark directly
|
|
67
|
+
ai-speedometer --bench openai:gpt-4
|
|
68
|
+
# With custom API key
|
|
69
|
+
ai-speedometer --bench openai:gpt-4 --api-key "sk-your-key"
|
|
70
|
+
# Use AI SDK instead of REST API
|
|
71
|
+
ai-speedometer --bench openai:gpt-4 --ai-sdk
|
|
58
72
|
```
|
|
59
73
|
|
|
60
74
|
## Configuration Files
|
package/cli.js
CHANGED
|
@@ -36,6 +36,7 @@ function parseCliArgs() {
|
|
|
36
36
|
bench: null,
|
|
37
37
|
apiKey: null,
|
|
38
38
|
useAiSdk: false,
|
|
39
|
+
formatted: false,
|
|
39
40
|
help: false
|
|
40
41
|
};
|
|
41
42
|
|
|
@@ -50,6 +51,8 @@ function parseCliArgs() {
|
|
|
50
51
|
parsed.apiKey = args[++i];
|
|
51
52
|
} else if (arg === '--ai-sdk') {
|
|
52
53
|
parsed.useAiSdk = true;
|
|
54
|
+
} else if (arg === '--formatted') {
|
|
55
|
+
parsed.formatted = true;
|
|
53
56
|
} else if (arg === '--help' || arg === '-h') {
|
|
54
57
|
parsed.help = true;
|
|
55
58
|
}
|
|
@@ -69,6 +72,7 @@ function showHelp() {
|
|
|
69
72
|
console.log(' --bench <provider:model> ' + colorText('Run benchmark in headless mode', 'dim'));
|
|
70
73
|
console.log(' --api-key <key> ' + colorText('Override API key (optional)', 'dim'));
|
|
71
74
|
console.log(' --ai-sdk ' + colorText('Use AI SDK instead of REST API', 'dim'));
|
|
75
|
+
console.log(' --formatted ' + colorText('Format JSON output for human readability', 'dim'));
|
|
72
76
|
console.log(' --debug ' + colorText('Enable debug logging', 'dim'));
|
|
73
77
|
console.log(' --help, -h ' + colorText('Show this help message', 'dim'));
|
|
74
78
|
console.log('');
|
|
@@ -76,6 +80,7 @@ function showHelp() {
|
|
|
76
80
|
console.log(' ai-speedometer --bench openai:gpt-4');
|
|
77
81
|
console.log(' ai-speedometer --bench anthropic:claude-3-opus --api-key "sk-..."');
|
|
78
82
|
console.log(' ai-speedometer --bench openai:gpt-4 --ai-sdk');
|
|
83
|
+
console.log(' ai-speedometer --bench openai:gpt-4 --formatted');
|
|
79
84
|
console.log('');
|
|
80
85
|
}
|
|
81
86
|
|
|
@@ -179,7 +184,7 @@ function showHeader() {
|
|
|
179
184
|
}
|
|
180
185
|
|
|
181
186
|
// Configuration management - now using ai-benchmark-config.json for custom providers
|
|
182
|
-
async function loadConfig() {
|
|
187
|
+
async function loadConfig(includeAllProviders = false) {
|
|
183
188
|
try {
|
|
184
189
|
// Check if we need to migrate from old config
|
|
185
190
|
const oldConfigFile = 'ai-benchmark-config.json';
|
|
@@ -212,7 +217,8 @@ async function loadConfig() {
|
|
|
212
217
|
}
|
|
213
218
|
|
|
214
219
|
// Load providers from both auth.json (verified) and ai-benchmark-config.json (custom)
|
|
215
|
-
|
|
220
|
+
// Include all models.dev providers if includeAllProviders is true (for headless mode)
|
|
221
|
+
const providers = await getAllAvailableProviders(includeAllProviders);
|
|
216
222
|
|
|
217
223
|
return {
|
|
218
224
|
providers,
|
|
@@ -1826,9 +1832,11 @@ async function benchmarkSingleModelRest(model) {
|
|
|
1826
1832
|
if (isFirstChunk && !firstTokenTime) {
|
|
1827
1833
|
firstTokenTime = Date.now();
|
|
1828
1834
|
isFirstChunk = false;
|
|
1829
|
-
// Show live TTFT result
|
|
1835
|
+
// Show live TTFT result (only in interactive mode, not headless)
|
|
1830
1836
|
const ttftSeconds = ((firstTokenTime - startTime) / 1000).toFixed(2);
|
|
1831
|
-
|
|
1837
|
+
if (!cliArgs.bench) {
|
|
1838
|
+
console.log(colorText(`TTFT received at ${ttftSeconds}s for ${model.name}`, 'green'));
|
|
1839
|
+
}
|
|
1832
1840
|
}
|
|
1833
1841
|
|
|
1834
1842
|
buffer += decoder.decode(value, { stream: true });
|
|
@@ -2175,8 +2183,8 @@ async function runHeadlessBenchmark(benchSpec, apiKey, useAiSdk) {
|
|
|
2175
2183
|
process.exit(1);
|
|
2176
2184
|
}
|
|
2177
2185
|
|
|
2178
|
-
// Load all available providers
|
|
2179
|
-
const config = await loadConfig();
|
|
2186
|
+
// Load all available providers (include all models.dev providers for headless mode)
|
|
2187
|
+
const config = await loadConfig(true);
|
|
2180
2188
|
|
|
2181
2189
|
// Find the provider (case-insensitive search)
|
|
2182
2190
|
const provider = config.providers.find(p =>
|
|
@@ -2281,10 +2289,11 @@ async function runHeadlessBenchmark(benchSpec, apiKey, useAiSdk) {
|
|
|
2281
2289
|
outputTokens: result.tokenCount,
|
|
2282
2290
|
promptTokens: result.promptTokens,
|
|
2283
2291
|
totalTokens: result.totalTokens,
|
|
2292
|
+
is_estimated: !!(result.usedEstimateForOutput || result.usedEstimateForInput),
|
|
2284
2293
|
error: result.error || null
|
|
2285
2294
|
};
|
|
2286
2295
|
|
|
2287
|
-
console.log(JSON.stringify(jsonOutput, null, 2));
|
|
2296
|
+
console.log(JSON.stringify(jsonOutput, null, cliArgs.formatted ? 2 : 0));
|
|
2288
2297
|
process.exit(result.success ? 0 : 1);
|
|
2289
2298
|
} catch (error) {
|
|
2290
2299
|
console.error(colorText('Error: ' + error.message, 'red'));
|
|
@@ -2296,7 +2305,7 @@ async function runHeadlessBenchmark(benchSpec, apiKey, useAiSdk) {
|
|
|
2296
2305
|
}
|
|
2297
2306
|
|
|
2298
2307
|
// Start the CLI
|
|
2299
|
-
if (
|
|
2308
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
2300
2309
|
// Check if help flag
|
|
2301
2310
|
if (cliArgs.help) {
|
|
2302
2311
|
showHelp();
|