| import { type ClassValue, clsx } from "clsx"; | |
| export function cn(...inputs: ClassValue[]) { | |
| return clsx(inputs); | |
| } | |
| export function formatTimestamp(date: Date = new Date()): string { | |
| return date.toLocaleTimeString([], { | |
| hour: "2-digit", | |
| minute: "2-digit", | |
| }); | |
| } | |
| export function exportConversation(messages: any[]): void { | |
| const content = messages | |
| .map( | |
| (m) => | |
| `[${m.timestamp}] ${m.role.toUpperCase()}: ${m.content}\n` | |
| ) | |
| .join("\n"); | |
| const blob = new Blob([content], { type: "text/plain" }); | |
| const url = URL.createObjectURL(blob); | |
| const a = document.createElement("a"); | |
| a.href = url; | |
| a.download = `medos-conversation-${new Date().toISOString().split("T")[0]}.txt`; | |
| document.body.appendChild(a); | |
| a.click(); | |
| document.body.removeChild(a); | |
| URL.revokeObjectURL(url); | |
| } | |