mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-06 23:32:12 +03:00
feat(api): aggregate combo model metadata in catalog (#2166)
Integrated into release/v3.8.0 — adds target-based metadata aggregation for combo entries in /v1/models using least-common-denominator approach (context_length, max_output_tokens, capabilities, modalities).
This commit is contained in:
@@ -1,34 +1,41 @@
|
||||
import Database from 'better-sqlite3';
|
||||
import path from 'path';
|
||||
import os from 'os';
|
||||
import Database from "better-sqlite3";
|
||||
import path from "path";
|
||||
import os from "os";
|
||||
|
||||
const SQLITE_FILE = path.join(process.cwd(), 'data', 'storage.sqlite');
|
||||
const SQLITE_FILE = path.join(process.cwd(), "data", "storage.sqlite");
|
||||
|
||||
console.log('Checking database at:', SQLITE_FILE);
|
||||
console.log("Checking database at:", SQLITE_FILE);
|
||||
|
||||
const db = new Database(SQLITE_FILE, { readonly: true });
|
||||
|
||||
try {
|
||||
const rows = db.prepare(`
|
||||
const rows = db
|
||||
.prepare(
|
||||
`
|
||||
SELECT api_key_id, api_key_name, COUNT(*) as count, MAX(timestamp) as last_used
|
||||
FROM usage_history
|
||||
GROUP BY api_key_id, api_key_name
|
||||
ORDER BY count DESC
|
||||
`).all();
|
||||
`
|
||||
)
|
||||
.all();
|
||||
|
||||
console.log('Top Usage Entries:');
|
||||
console.table(rows);
|
||||
console.log("Top Usage Entries:");
|
||||
console.table(rows);
|
||||
|
||||
const keys = db.prepare(`
|
||||
const keys = db
|
||||
.prepare(
|
||||
`
|
||||
SELECT id, name, key_prefix, machine_id
|
||||
FROM api_keys
|
||||
`).all();
|
||||
|
||||
console.log('All API Keys:');
|
||||
console.table(keys);
|
||||
`
|
||||
)
|
||||
.all();
|
||||
|
||||
console.log("All API Keys:");
|
||||
console.table(keys);
|
||||
} catch (err) {
|
||||
console.error('Error:', err.message);
|
||||
console.error("Error:", err.message);
|
||||
} finally {
|
||||
db.close();
|
||||
db.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user