mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-22 07:01:44 +03:00
refactor(commands): dedupe model scan sorting
This commit is contained in:
+18
-26
@@ -50,19 +50,7 @@ function sortScanResults(results: ModelScanResult[]): ModelScanResult[] {
|
|||||||
return aToolLatency - bToolLatency;
|
return aToolLatency - bToolLatency;
|
||||||
}
|
}
|
||||||
|
|
||||||
const aCtx = a.contextLength ?? 0;
|
return compareScanMetadata(a, b);
|
||||||
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);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,22 +62,26 @@ function sortImageResults(results: ModelScanResult[]): ModelScanResult[] {
|
|||||||
return aLatency - bLatency;
|
return aLatency - bLatency;
|
||||||
}
|
}
|
||||||
|
|
||||||
const aCtx = a.contextLength ?? 0;
|
return compareScanMetadata(a, b);
|
||||||
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 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 {
|
function buildScanHint(result: ModelScanResult): string {
|
||||||
const toolLabel = result.tool.ok ? `tool ${formatMs(result.tool.latencyMs)}` : "tool fail";
|
const toolLabel = result.tool.ok ? `tool ${formatMs(result.tool.latencyMs)}` : "tool fail";
|
||||||
const imageLabel = result.image.skipped
|
const imageLabel = result.image.skipped
|
||||||
|
|||||||
Reference in New Issue
Block a user