2025-11-15 02:07:20 +02:00
|
|
|
import type { Message } from "@ai-sdk/react";
|
2025-07-27 10:05:37 -07:00
|
|
|
import { type ClassValue, clsx } from "clsx";
|
|
|
|
|
import { twMerge } from "tailwind-merge";
|
2025-04-07 23:47:06 -07:00
|
|
|
|
|
|
|
|
export function cn(...inputs: ClassValue[]) {
|
2025-07-27 10:05:37 -07:00
|
|
|
return twMerge(clsx(inputs));
|
2025-04-07 23:47:06 -07:00
|
|
|
}
|
2025-11-14 00:25:08 +02:00
|
|
|
|
|
|
|
|
export function getChatTitleFromMessages(messages: Message[]) {
|
|
|
|
|
const userMessages = messages.filter((msg) => msg.role === "user");
|
|
|
|
|
if (userMessages.length === 0) return "Untitled Chat";
|
|
|
|
|
return userMessages[0].content;
|
2025-11-14 00:42:19 +02:00
|
|
|
}
|
2025-12-24 18:03:22 -08:00
|
|
|
|
|
|
|
|
export const formatDate = (date: Date): string => {
|
|
|
|
|
return date.toLocaleDateString("en-US", {
|
|
|
|
|
year: "numeric",
|
|
|
|
|
month: "long",
|
|
|
|
|
day: "numeric",
|
|
|
|
|
});
|
|
|
|
|
};
|