mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-30 11:26:46 +00:00
refactor(commands): dedupe model scan sorting
This commit is contained in:
@@ -50,19 +50,7 @@ function sortScanResults(results: ModelScanResult[]): ModelScanResult[] {
|
||||
return aToolLatency - bToolLatency;
|
||||
}
|
||||
|
||||
const aCtx = a.contextLength ?? 0;
|
||||
const bCtx = b.contextLength ?? 0;
|
||||
if (aCtx !== bCtx) {
|
||||
return bCtx - aCtx;
|
||||
}
|
||||
|
||||
const aParams = a.inferredParamB ?? 0;
|
||||
const bParams = b.inferredParamB ?? 0;
|
||||
if (aParams !== bParams) {
|
||||
return bParams - aParams;
|
||||
}
|
||||
|
||||
return a.modelRef.localeCompare(b.modelRef);
|
||||
return compareScanMetadata(a, b);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -74,22 +62,26 @@ function sortImageResults(results: ModelScanResult[]): ModelScanResult[] {
|
||||
return aLatency - bLatency;
|
||||
}
|
||||
|
||||
const aCtx = a.contextLength ?? 0;
|
||||
const bCtx = b.contextLength ?? 0;
|
||||
if (aCtx !== bCtx) {
|
||||
return bCtx - aCtx;
|
||||
}
|
||||
|
||||
const aParams = a.inferredParamB ?? 0;
|
||||
const bParams = b.inferredParamB ?? 0;
|
||||
if (aParams !== bParams) {
|
||||
return bParams - aParams;
|
||||
}
|
||||
|
||||
return a.modelRef.localeCompare(b.modelRef);
|
||||
return compareScanMetadata(a, b);
|
||||
});
|
||||
}
|
||||
|
||||
function compareScanMetadata(a: ModelScanResult, b: ModelScanResult): number {
|
||||
const aCtx = a.contextLength ?? 0;
|
||||
const bCtx = b.contextLength ?? 0;
|
||||
if (aCtx !== bCtx) {
|
||||
return bCtx - aCtx;
|
||||
}
|
||||
|
||||
const aParams = a.inferredParamB ?? 0;
|
||||
const bParams = b.inferredParamB ?? 0;
|
||||
if (aParams !== bParams) {
|
||||
return bParams - aParams;
|
||||
}
|
||||
|
||||
return a.modelRef.localeCompare(b.modelRef);
|
||||
}
|
||||
|
||||
function buildScanHint(result: ModelScanResult): string {
|
||||
const toolLabel = result.tool.ok ? `tool ${formatMs(result.tool.latencyMs)}` : "tool fail";
|
||||
const imageLabel = result.image.skipped
|
||||
|
||||
Reference in New Issue
Block a user