(model: z.infer<typeof ModelItem>, existing: ExistingModel | undefined)
| 91 | } |
| 92 | |
| 93 | function formatToml(model: z.infer<typeof ModelItem>, existing: ExistingModel | undefined) { |
| 94 | const ep = pickEndpoint(model); |
| 95 | const pricing = ep?.pricing; |
| 96 | |
| 97 | const supported = model.supportedParameters ?? []; |
| 98 | |
| 99 | const nowISO = new Date().toISOString().slice(0, 10); |
| 100 | const rdRaw = model.trainingDate ? String(model.trainingDate) : nowISO; |
| 101 | const releaseDate = rdRaw.slice(0, 10); |
| 102 | const lastUpdated = releaseDate; |
| 103 | const knowledge = model.trainingDate |
| 104 | ? String(model.trainingDate).slice(0, 7) |
| 105 | : undefined; |
| 106 | |
| 107 | const attachment = false; // Not exposed by Helicone registry |
| 108 | const temperature = boolFromParams(supported, ["temperature"]); |
| 109 | const toolCall = boolFromParams(supported, ["tools", "tool_choice"]); |
| 110 | const reasoning = boolFromParams(supported, [ |
| 111 | "reasoning", |
| 112 | "include_reasoning", |
| 113 | ]); |
| 114 | |
| 115 | const inputMods = sanitizeModalities(model.inputModalities); |
| 116 | const outputMods = sanitizeModalities(model.outputModalities); |
| 117 | |
| 118 | const lines: string[] = []; |
| 119 | if (existing?.base_model !== undefined) { |
| 120 | lines.push(`base_model = "${existing.base_model}"`); |
| 121 | } |
| 122 | if (existing?.base_model_omit !== undefined) { |
| 123 | lines.push( |
| 124 | `base_model_omit = [${existing.base_model_omit.map((item) => `"${item}"`).join(", ")}]`, |
| 125 | ); |
| 126 | } |
| 127 | lines.push(`name = "${model.name.replaceAll('"', '\\"')}"`); |
| 128 | lines.push(`release_date = "${releaseDate}"`); |
| 129 | lines.push(`last_updated = "${lastUpdated}"`); |
| 130 | lines.push(`attachment = ${attachment}`); |
| 131 | lines.push(`reasoning = ${reasoning}`); |
| 132 | lines.push(`temperature = ${temperature}`); |
| 133 | lines.push(`tool_call = ${toolCall}`); |
| 134 | if (knowledge) lines.push(`knowledge = "${knowledge}"`); |
| 135 | lines.push(`open_weights = false`); |
| 136 | lines.push(""); |
| 137 | |
| 138 | if ( |
| 139 | pricing && |
| 140 | (pricing.prompt ?? |
| 141 | pricing.completion ?? |
| 142 | pricing.cacheRead ?? |
| 143 | pricing.cacheWrite ?? |
| 144 | (reasoning && pricing.reasoning)) !== undefined |
| 145 | ) { |
| 146 | lines.push(`[cost]`); |
| 147 | if (pricing.prompt !== undefined) lines.push(`input = ${pricing.prompt}`); |
| 148 | if (pricing.completion !== undefined) |
| 149 | lines.push(`output = ${pricing.completion}`); |
| 150 | if (reasoning && pricing.reasoning !== undefined) |
no test coverage detected