litellm/ui/litellm-dashboard/src/utils/textUtils.ts
yuneng-jiang b9759b4bfa
[Feature] UI - Add LiteLLM Params to Edit Model (#16496)
* Add LiteLLM Params to Edit Model

* Fixed tests
2025-11-11 18:52:11 -08:00

24 lines
612 B
TypeScript

export const formatLabel = (text: string): string => {
if (!text) {
return text;
}
const withSpaces = text.replace(/_/g, " ");
return withSpaces.replace(/\b\w/g, (char) => char.toUpperCase());
};
export function truncateString(str: string, maxLength: number) {
return str.length > maxLength ? str.substring(0, maxLength) + "..." : str;
}
export const formItemValidateJSON = (_: any, value: string) => {
if (!value) {
return Promise.resolve();
}
try {
JSON.parse(value);
return Promise.resolve();
} catch (error) {
return Promise.reject("Please enter valid JSON");
}
};