mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 12:37:40 +00:00
refactor(models): reuse list format helpers in scan
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
|||||||
stylePromptMessage,
|
stylePromptMessage,
|
||||||
stylePromptTitle,
|
stylePromptTitle,
|
||||||
} from "../../terminal/prompt-style.js";
|
} from "../../terminal/prompt-style.js";
|
||||||
|
import { pad, truncate } from "./list.format.js";
|
||||||
import { formatMs, formatTokenK, updateConfig } from "./shared.js";
|
import { formatMs, formatTokenK, updateConfig } from "./shared.js";
|
||||||
|
|
||||||
const MODEL_PAD = 42;
|
const MODEL_PAD = 42;
|
||||||
@@ -33,18 +34,6 @@ function guardPromptCancel<T>(value: T | symbol, runtime: RuntimeEnv): T {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
const pad = (value: string, size: number) => value.padEnd(size);
|
|
||||||
|
|
||||||
const truncate = (value: string, max: number) => {
|
|
||||||
if (value.length <= max) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
if (max <= 3) {
|
|
||||||
return value.slice(0, max);
|
|
||||||
}
|
|
||||||
return `${value.slice(0, max - 3)}...`;
|
|
||||||
};
|
|
||||||
|
|
||||||
function sortScanResults(results: ModelScanResult[]): ModelScanResult[] {
|
function sortScanResults(results: ModelScanResult[]): ModelScanResult[] {
|
||||||
return results.slice().toSorted((a, b) => {
|
return results.slice().toSorted((a, b) => {
|
||||||
const aImage = a.image.ok ? 1 : 0;
|
const aImage = a.image.ok ? 1 : 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user