MCPcopy Create free account
hub / github.com/Noumena-Network/code / formatModelAndBilling

Function formatModelAndBilling

src/utils/logoV2Utils.ts:274–307  ·  view source on GitHub ↗
(
  modelName: string,
  billingType: string,
  availableWidth: number,
)

Source from the content-addressed store, hash-verified

272 * Determines how to display model and billing information based on available width
273 */
274export function formatModelAndBilling(
275 modelName: string,
276 billingType: string,
277 availableWidth: number,
278): {
279 shouldSplit: boolean
280 truncatedModel: string
281 truncatedBilling: string
282} {
283 const separator = ' · '
284 const combinedWidth =
285 stringWidth(modelName) + separator.length + stringWidth(billingType)
286 const shouldSplit = combinedWidth > availableWidth
287
288 if (shouldSplit) {
289 return {
290 shouldSplit: true,
291 truncatedModel: truncate(modelName, availableWidth),
292 truncatedBilling: truncate(billingType, availableWidth),
293 }
294 }
295
296 return {
297 shouldSplit: false,
298 truncatedModel: truncate(
299 modelName,
300 Math.max(
301 availableWidth - stringWidth(billingType) - separator.length,
302 10,
303 ),
304 ),
305 truncatedBilling: billingType,
306 }
307}
308
309/**
310 * Gets recent release notes for Logo v2 display

Callers 1

CondensedLogoFunction · 0.85

Calls 2

maxMethod · 0.80
truncateFunction · 0.70

Tested by

no test coverage detected