refac: prompt variables

This commit is contained in:
Timothy Jaeryang Baek
2025-01-29 21:56:51 -08:00
parent d6c82939e6
commit cc99673906
8 changed files with 49 additions and 18 deletions

View File

@@ -766,6 +766,19 @@ export const blobToFile = (blob, fileName) => {
return file;
};
export const getPromptVariables = (user_name, user_location) => {
return {
'{{USER_NAME}}': user_name,
'{{USER_LOCATION}}': user_location || 'Unknown',
'{{CURRENT_DATETIME}}': getCurrentDateTime(),
'{{CURRENT_DATE}}': getFormattedDate(),
'{{CURRENT_TIME}}': getFormattedTime(),
'{{CURRENT_WEEKDAY}}': getWeekday(),
'{{CURRENT_TIMEZONE}}': getUserTimezone(),
'{{USER_LANGUAGE}}': localStorage.getItem('locale') || 'en-US'
};
};
/**
* @param {string} template - The template string containing placeholders.
* @returns {string} The template string with the placeholders replaced by the prompt.