| 150 | * ------------------------------------------------------------------------------------------------ */ |
| 151 | type ChatMessage = { role: "user" | "assistant" | "system"; content: string }; |
| 152 | function formatMessagesForRetool(msgs: ChatMessage[]) { |
| 153 | let out = ""; |
| 154 | for (const m of msgs) { |
| 155 | const role = m.role === "user" ? "Human" : "Assistant"; |
| 156 | out += `\n\n${role}: ${m.content}`; |
| 157 | } |
| 158 | if (msgs.length && msgs[msgs.length - 1].role === "assistant") out += "\n\nHuman: "; |
| 159 | return out; |
| 160 | } |
| 161 | |
| 162 | function getBestAccount(modelId: string) { |
| 163 | const rec = AVAILABLE_MODELS.find((m) => m.id === modelId); |