Skip to content

Commit

Permalink
truncate title
Browse files Browse the repository at this point in the history
  • Loading branch information
colegottdank committed Dec 10, 2024
1 parent a459a36 commit f442c66
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion bifrost/app/comparison/[comparison]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,32 @@ const getComparisonTitle = (
) => {
const modelADisplay = getDisplayName(modelA, providerA);
const modelBDisplay = getDisplayName(modelB, providerB);
return `${modelADisplay} vs ${modelBDisplay} - Model Comparison & Performance Analysis - Helicone`;

const suffix = " Comparison | Helicone";
const vsText = " vs ";
const maxTotalLength = 60;
const availableSpace = maxTotalLength - suffix.length - vsText.length;

if (modelADisplay.length + modelBDisplay.length > availableSpace) {
const ratio =
modelADisplay.length / (modelADisplay.length + modelBDisplay.length);
const maxLengthA = Math.floor(availableSpace * ratio);
const maxLengthB = availableSpace - maxLengthA;

const truncatedModelA =
modelADisplay.length > maxLengthA
? `${modelADisplay.substring(0, maxLengthA - 3)}...`
: modelADisplay;
const truncatedModelB =
modelBDisplay.length > maxLengthB
? `${modelBDisplay.substring(0, maxLengthB - 3)}...`
: modelBDisplay;

return `${truncatedModelA}${vsText}${truncatedModelB}${suffix}`;
}

// If total length is fine, use full names
return `${modelADisplay}${vsText}${modelBDisplay}${suffix}`;
};

const getComparisonDescription = (
Expand Down

0 comments on commit f442c66

Please sign in to comment.