From 29175405a6f98ce7eac4a463b54b051dc9992b83 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sun, 22 Sep 2024 12:24:05 +0200 Subject: [PATCH] Add weekday, timezone, language variables to system prompts --- src/lib/utils/index.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/lib/utils/index.ts b/src/lib/utils/index.ts index 631c17ba7..bb553c57e 100644 --- a/src/lib/utils/index.ts +++ b/src/lib/utils/index.ts @@ -664,6 +664,15 @@ export const promptTemplate = ( hour12: true }); + // Get the current weekday + const currentWeekday = getWeekday(); + + // Get the user's timezone + const currentTimezone = getUserTimezone(); + + // Get the user's language + const userLanguage = localStorage.getItem('locale') || 'en-US'; + // Replace {{CURRENT_DATETIME}} in the template with the formatted datetime template = template.replace('{{CURRENT_DATETIME}}', `${formattedDate} ${currentTime}`); @@ -673,6 +682,15 @@ export const promptTemplate = ( // Replace {{CURRENT_TIME}} in the template with the formatted time template = template.replace('{{CURRENT_TIME}}', currentTime); + // Replace {{CURRENT_WEEKDAY}} in the template with the current weekday + template = template.replace('{{CURRENT_WEEKDAY}}', currentWeekday); + + // Replace {{CURRENT_TIMEZONE}} in the template with the user's timezone + template = template.replace('{{CURRENT_TIMEZONE}}', currentTimezone); + + // Replace {{USER_LANGUAGE}} in the template with the user's language + template = template.replace('{{USER_LANGUAGE}}', userLanguage); + if (user_name) { // Replace {{USER_NAME}} in the template with the user's name template = template.replace('{{USER_NAME}}', user_name);