(model: MergedModel)
| 475 | // --------------------------------------------------------------------------- |
| 476 | |
| 477 | function formatToml(model: MergedModel): string { |
| 478 | const lines: string[] = []; |
| 479 | |
| 480 | lines.push(`name = "${model.name.replace(/"/g, '\\"')}"`); |
| 481 | if (model.family) lines.push(`family = "${model.family}"`); |
| 482 | lines.push(`release_date = "${model.release_date}"`); |
| 483 | lines.push(`last_updated = "${model.last_updated}"`); |
| 484 | lines.push(`attachment = ${model.attachment}`); |
| 485 | lines.push(`reasoning = ${model.reasoning}`); |
| 486 | lines.push(`temperature = ${model.temperature}`); |
| 487 | lines.push(`tool_call = ${model.tool_call}`); |
| 488 | if (model.structured_output !== undefined) lines.push(`structured_output = ${model.structured_output}`); |
| 489 | if (model.knowledge) lines.push(`knowledge = "${model.knowledge}"`); |
| 490 | lines.push(`open_weights = ${model.open_weights}`); |
| 491 | if (model.status) lines.push(`status = "${model.status}"`); |
| 492 | |
| 493 | if (model.interleaved !== undefined) { |
| 494 | lines.push(""); |
| 495 | if (model.interleaved === true) { |
| 496 | lines.push(`interleaved = true`); |
| 497 | } else if (typeof model.interleaved === "object") { |
| 498 | lines.push(`[interleaved]`); |
| 499 | lines.push(`field = "${model.interleaved.field}"`); |
| 500 | } |
| 501 | } |
| 502 | |
| 503 | if (model.cost) { |
| 504 | lines.push(""); |
| 505 | lines.push(`[cost]`); |
| 506 | lines.push(`input = ${model.cost.input}`); |
| 507 | lines.push(`output = ${model.cost.output}`); |
| 508 | if (model.cost.cache_read !== undefined) lines.push(`cache_read = ${model.cost.cache_read}`); |
| 509 | if (model.cost.cache_write !== undefined) lines.push(`cache_write = ${model.cost.cache_write}`); |
| 510 | |
| 511 | if (model.cost.context_over_200k) { |
| 512 | lines.push(""); |
| 513 | lines.push(`[[cost.tiers]]`); |
| 514 | lines.push(`tier = { size = ${formatInlineNumber(getLongContextMin(model.cost.context_over_200k))} }`); |
| 515 | lines.push(`input = ${model.cost.context_over_200k.input}`); |
| 516 | lines.push(`output = ${model.cost.context_over_200k.output}`); |
| 517 | if (model.cost.context_over_200k.cache_read !== undefined) |
| 518 | lines.push(`cache_read = ${model.cost.context_over_200k.cache_read}`); |
| 519 | if (model.cost.context_over_200k.cache_write !== undefined) |
| 520 | lines.push(`cache_write = ${model.cost.context_over_200k.cache_write}`); |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | lines.push(""); |
| 525 | lines.push(`[limit]`); |
| 526 | lines.push(`context = ${formatNumber(model.limit.context)}`); |
| 527 | lines.push(`output = ${formatNumber(model.limit.output)}`); |
| 528 | |
| 529 | lines.push(""); |
| 530 | lines.push(`[modalities]`); |
| 531 | lines.push(`input = [${model.modalities.input.map((m) => `"${m}"`).join(", ")}]`); |
| 532 | lines.push(`output = [${model.modalities.output.map((m) => `"${m}"`).join(", ")}]`); |
| 533 | |
| 534 | return lines.join("\n") + "\n"; |
no test coverage detected