mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-02-19 03:00:49 +08:00
fix(usage): aggregate openai provider credential stats
This commit is contained in:
@@ -155,11 +155,40 @@ export function CredentialStatsCard({
|
|||||||
addConfigRow(c.apiKey, c.prefix, c.prefix?.trim() || `Codex #${i + 1}`, 'codex', `codex:${i}`));
|
addConfigRow(c.apiKey, c.prefix, c.prefix?.trim() || `Codex #${i + 1}`, 'codex', `codex:${i}`));
|
||||||
vertexConfigs.forEach((c, i) =>
|
vertexConfigs.forEach((c, i) =>
|
||||||
addConfigRow(c.apiKey, c.prefix, c.prefix?.trim() || `Vertex #${i + 1}`, 'vertex', `vertex:${i}`));
|
addConfigRow(c.apiKey, c.prefix, c.prefix?.trim() || `Vertex #${i + 1}`, 'vertex', `vertex:${i}`));
|
||||||
openaiProviders.forEach((p, pi) => {
|
// OpenAI compatibility providers — one row per provider, merged across all apiKey entries (prefix counted once).
|
||||||
p.apiKeyEntries?.forEach((entry, ei) => {
|
openaiProviders.forEach((provider, providerIndex) => {
|
||||||
const name = p.prefix?.trim() || (p.apiKeyEntries.length > 1 ? `${p.name} #${ei + 1}` : p.name);
|
const prefix = provider.prefix;
|
||||||
addConfigRow(entry.apiKey, p.prefix, name, 'openai', `openai:${pi}:${ei}`);
|
const displayName = prefix?.trim() || provider.name || `OpenAI #${providerIndex + 1}`;
|
||||||
|
|
||||||
|
const candidates = new Set<string>();
|
||||||
|
buildCandidateUsageSourceIds({ prefix }).forEach((id) => candidates.add(id));
|
||||||
|
(provider.apiKeyEntries || []).forEach((entry) => {
|
||||||
|
buildCandidateUsageSourceIds({ apiKey: entry.apiKey }).forEach((id) => candidates.add(id));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let success = 0;
|
||||||
|
let failure = 0;
|
||||||
|
candidates.forEach((id) => {
|
||||||
|
const bucket = bySource[id];
|
||||||
|
if (bucket) {
|
||||||
|
success += bucket.success;
|
||||||
|
failure += bucket.failure;
|
||||||
|
consumedSourceIds.add(id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const total = success + failure;
|
||||||
|
if (total > 0) {
|
||||||
|
result.push({
|
||||||
|
key: `openai:${providerIndex}`,
|
||||||
|
displayName,
|
||||||
|
type: 'openai',
|
||||||
|
success,
|
||||||
|
failure,
|
||||||
|
total,
|
||||||
|
successRate: (success / total) * 100,
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Build source → auth file name mapping for remaining unmatched entries.
|
// Build source → auth file name mapping for remaining unmatched entries.
|
||||||
|
|||||||
Reference in New Issue
Block a user