MCPcopy
hub / github.com/anomalyco/models.dev / formatToml

Function formatToml

packages/core/src/sync/index.ts:735–831  ·  view source on GitHub ↗
(model: z.infer<typeof SyncedAuthoredModel>)

Source from the content-addressed store, hash-verified

733}
734
735export function formatToml(model: z.infer<typeof SyncedAuthoredModel>) {
736 const lines: string[] = [];
737
738 if (model.base_model !== undefined) lines.push(`base_model = ${quote(model.base_model)}`);
739 if (model.base_model_omit !== undefined) {
740 lines.push(`base_model_omit = [${model.base_model_omit.map(quote).join(", ")}]`);
741 }
742 if (model.name !== undefined) lines.push(`name = ${quote(model.name)}`);
743 if (model.description !== undefined) lines.push(`description = ${quote(model.description)}`);
744 if (model.family !== undefined) lines.push(`family = ${quote(model.family)}`);
745 if (model.release_date !== undefined) lines.push(`release_date = ${quote(model.release_date)}`);
746 if (model.last_updated !== undefined) lines.push(`last_updated = ${quote(model.last_updated)}`);
747 if (model.attachment !== undefined) lines.push(`attachment = ${model.attachment}`);
748 if (model.reasoning !== undefined) lines.push(`reasoning = ${model.reasoning}`);
749 if (model.temperature !== undefined) lines.push(`temperature = ${model.temperature}`);
750 if (model.tool_call !== undefined) lines.push(`tool_call = ${model.tool_call}`);
751 if (model.structured_output !== undefined) {
752 lines.push(`structured_output = ${model.structured_output}`);
753 }
754 if (model.knowledge !== undefined) lines.push(`knowledge = ${quote(model.knowledge)}`);
755 if (model.open_weights !== undefined) lines.push(`open_weights = ${model.open_weights}`);
756 if (model.status !== undefined) lines.push(`status = ${quote(model.status)}`);
757 if (model.reasoning_options?.length === 0) lines.push("reasoning_options = []");
758
759 if (model.interleaved !== undefined) {
760 lines.push("");
761 if (model.interleaved === true) {
762 lines.push("interleaved = true");
763 } else {
764 lines.push("[interleaved]");
765 lines.push(`field = ${quote(model.interleaved.field)}`);
766 }
767 }
768
769 for (const option of model.reasoning_options ?? []) {
770 lines.push("", "[[reasoning_options]]");
771 lines.push(`type = ${quote(option.type)}`);
772 if (option.type === "effort") {
773 const values = sortReasoningValues(option.values).map(formatReasoningValue).join(", ");
774 lines.push(`values = [${values}]`);
775 }
776 if (option.type === "budget_tokens") {
777 if (option.min !== undefined) lines.push(`min = ${formatInteger(option.min)}`);
778 if (option.max !== undefined) lines.push(`max = ${formatInteger(option.max)}`);
779 }
780 }
781
782 if (model.cost !== undefined) {
783 lines.push("", "[cost]");
784 lines.push(`input = ${formatNumber(model.cost.input)}`);
785 lines.push(`output = ${formatNumber(model.cost.output)}`);
786 if (model.cost.reasoning !== undefined) {
787 lines.push(`reasoning = ${formatNumber(model.cost.reasoning)}`);
788 }
789 if (model.cost.cache_read !== undefined) {
790 lines.push(`cache_read = ${formatNumber(model.cost.cache_read)}`);
791 }
792 if (model.cost.cache_write !== undefined) {

Callers 3

syncProviderFunction · 0.70
formatMetadataTomlFunction · 0.70
sync.test.tsFile · 0.50

Calls 4

quoteFunction · 0.85
sortReasoningValuesFunction · 0.85
formatIntegerFunction · 0.85
formatNumberFunction · 0.70

Tested by

no test coverage detected