mirror of
https://github.com/ArthurDanjou/artchat.git
synced 2026-01-14 20:59:51 +01:00
- Created a new article on "Understanding AI Agents, LLMs, and RAG" detailing the synergy between AI agents, LLMs, and Retrieval-Augmented Generation. - Added an introductory article on "What is Machine Learning?" covering types, model selection, workflow, and evaluation metrics. chore: setup ESLint and Nuxt configuration - Added ESLint configuration for code quality. - Initialized Nuxt configuration with various modules and settings for the application. chore: initialize package.json and TypeScript configuration - Created package.json for dependency management and scripts. - Added TypeScript configuration for the project. feat: implement API endpoints for activity and stats - Developed API endpoint to fetch user activity from Lanyard. - Created a stats endpoint to retrieve Wakatime coding statistics with caching. feat: add various assets and images - Included multiple images and assets for articles and projects. - Added placeholder files to maintain directory structure. refactor: define types for chat, lanyard, time, and wakatime - Created TypeScript types for chat messages, Lanyard activities, time formatting, and Wakatime statistics.
72 lines
2.8 KiB
TypeScript
72 lines
2.8 KiB
TypeScript
type TimeUnit = (n: number, past?: boolean) => string
|
|
type TimeFormatter = (n: string) => string
|
|
|
|
interface ActivityMessages {
|
|
justNow: string
|
|
past: TimeFormatter
|
|
future: TimeFormatter
|
|
month: TimeUnit
|
|
year: TimeUnit
|
|
day: TimeUnit
|
|
week: TimeUnit
|
|
hour: TimeUnit
|
|
minute: TimeUnit
|
|
second: TimeUnit
|
|
invalid: string
|
|
}
|
|
|
|
function createTimeUnit(singular: string, plural: string, pastSingular?: string, futureSingular?: string): TimeUnit {
|
|
return (n: number, past = true) => {
|
|
if (n === 1) {
|
|
return past ? (pastSingular || `last ${singular}`) : (futureSingular || `next ${singular}`)
|
|
}
|
|
return `${n} ${plural}`
|
|
}
|
|
}
|
|
|
|
function createSimpleTimeUnit(unit: string): TimeUnit {
|
|
return (n: number) => `${n} ${unit}${n > 1 ? 's' : ''}`
|
|
}
|
|
|
|
export const activityMessages: Record<'en' | 'fr' | 'es', ActivityMessages> = {
|
|
en: {
|
|
justNow: 'just now',
|
|
past: (n: string) => n.match(/\d/) ? `${n} ago` : n,
|
|
future: (n: string) => n.match(/\d/) ? `in ${n}` : n,
|
|
month: createTimeUnit('month', 'months'),
|
|
year: createTimeUnit('year', 'years'),
|
|
day: createTimeUnit('day', 'days', 'yesterday', 'tomorrow'),
|
|
week: createTimeUnit('week', 'weeks'),
|
|
hour: createSimpleTimeUnit('hour'),
|
|
minute: createSimpleTimeUnit('minute'),
|
|
second: createSimpleTimeUnit('second'),
|
|
invalid: '',
|
|
},
|
|
fr: {
|
|
justNow: 'à l\'instant',
|
|
past: (n: string) => n.match(/\d/) ? `il y a ${n}` : n,
|
|
future: (n: string) => n.match(/\d/) ? `dans ${n}` : n,
|
|
month: (n: number, past = true) => n === 1 ? (past ? 'le mois dernier' : 'le mois prochain') : `${n} mois`,
|
|
year: (n: number, past = true) => n === 1 ? (past ? 'l\'année dernière' : 'l\'année prochaine') : `${n} ans`,
|
|
day: (n: number, past = true) => n === 1 ? (past ? 'hier' : 'demain') : `${n} jours`,
|
|
week: (n: number, past = true) => n === 1 ? (past ? 'la semaine dernière' : 'la semaine prochaine') : `${n} semaines`,
|
|
hour: createSimpleTimeUnit('heure'),
|
|
minute: createSimpleTimeUnit('minute'),
|
|
second: createSimpleTimeUnit('seconde'),
|
|
invalid: '',
|
|
},
|
|
es: {
|
|
justNow: 'justo ahora',
|
|
past: (n: string) => n.match(/\d/) ? `hace ${n}` : n,
|
|
future: (n: string) => n.match(/\d/) ? `dentro de ${n}` : n,
|
|
month: (n: number, past = true) => n === 1 ? (past ? 'el mes pasado' : 'el próximo mes') : `${n} meses`,
|
|
year: (n: number, past = true) => n === 1 ? (past ? 'el año pasado' : 'el próximo año') : `${n} años`,
|
|
day: (n: number, past = true) => n === 1 ? (past ? 'ayer' : 'mañana') : `${n} días`,
|
|
week: (n: number, past = true) => n === 1 ? (past ? 'la semana pasada' : 'la próxima semana') : `${n} semanas`,
|
|
hour: createSimpleTimeUnit('hora'),
|
|
minute: createSimpleTimeUnit('minuto'),
|
|
second: createSimpleTimeUnit('segundo'),
|
|
invalid: '',
|
|
},
|
|
}
|