Replaces the Gemini service integration with support for Open WebUI. This change simplifies the AI backend by leveraging an existing solution, allowing for more flexible API connections and reducing direct dependency on specific AI models. Updated dependencies, including React, to their latest versions to incorporate performance improvements and bug fixes. Refactored color schemes and typography in the HTML to better align with the application's theme. Adjusted type definitions for improved clarity and compatibility with the new backend integration.
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { Language } from './types';
|
|
|
|
export function formatConversationalTime(date: Date): string {
|
|
const now = new Date();
|
|
const diff = now.getTime() - date.getTime();
|
|
const minutes = Math.floor(diff / 60000);
|
|
const hours = Math.floor(diff / 3600000);
|
|
const days = Math.floor(diff / 86400000);
|
|
|
|
if (minutes < 1) return 'just now';
|
|
if (minutes < 60) return `${minutes}m ago`;
|
|
if (hours < 6) return `${hours}h ago`;
|
|
if (days === 0) return 'today';
|
|
if (days === 1) return 'yesterday';
|
|
if (days < 7) return `${days} days ago`;
|
|
|
|
return new Intl.DateTimeFormat('en-US', {
|
|
month: 'short',
|
|
day: 'numeric',
|
|
hour: 'numeric',
|
|
minute: '2-digit'
|
|
}).format(date);
|
|
}
|
|
|
|
export function detectLanguage(text: string): Language {
|
|
// Simple heuristic: check for common Spanish words
|
|
const spanishCommon = /\b(el|la|los|las|en|y|que|es|por|para|con|un|una)\b/i;
|
|
return spanishCommon.test(text) ? Language.ES : Language.EN;
|
|
}
|
|
|
|
export function generateId(): string {
|
|
return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
|
}
|