init (#20881)
This commit is contained in:
@@ -69,6 +69,7 @@ def prompt_template(template: str, user: Optional[Any] = None) -> str:
|
|||||||
|
|
||||||
USER_VARIABLES = {
|
USER_VARIABLES = {
|
||||||
"name": str(user.get("name")),
|
"name": str(user.get("name")),
|
||||||
|
"email": str(user.get("email")),
|
||||||
"location": str(user_info.get("location")),
|
"location": str(user_info.get("location")),
|
||||||
"bio": str(user.get("bio")),
|
"bio": str(user.get("bio")),
|
||||||
"gender": str(user.get("gender")),
|
"gender": str(user.get("gender")),
|
||||||
@@ -92,6 +93,9 @@ def prompt_template(template: str, user: Optional[Any] = None) -> str:
|
|||||||
template = template.replace("{{CURRENT_WEEKDAY}}", formatted_weekday)
|
template = template.replace("{{CURRENT_WEEKDAY}}", formatted_weekday)
|
||||||
|
|
||||||
template = template.replace("{{USER_NAME}}", USER_VARIABLES.get("name", "Unknown"))
|
template = template.replace("{{USER_NAME}}", USER_VARIABLES.get("name", "Unknown"))
|
||||||
|
template = template.replace(
|
||||||
|
"{{USER_EMAIL}}", USER_VARIABLES.get("email", "Unknown")
|
||||||
|
)
|
||||||
template = template.replace("{{USER_BIO}}", USER_VARIABLES.get("bio", "Unknown"))
|
template = template.replace("{{USER_BIO}}", USER_VARIABLES.get("bio", "Unknown"))
|
||||||
template = template.replace(
|
template = template.replace(
|
||||||
"{{USER_GENDER}}", USER_VARIABLES.get("gender", "Unknown")
|
"{{USER_GENDER}}", USER_VARIABLES.get("gender", "Unknown")
|
||||||
|
|||||||
@@ -147,6 +147,14 @@
|
|||||||
text = text.replaceAll('{{USER_NAME}}', name);
|
text = text.replaceAll('{{USER_NAME}}', name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (text.includes('{{USER_EMAIL}}')) {
|
||||||
|
const email = sessionUser?.email || '';
|
||||||
|
|
||||||
|
if (email) {
|
||||||
|
text = text.replaceAll('{{USER_EMAIL}}', email);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (text.includes('{{USER_BIO}}')) {
|
if (text.includes('{{USER_BIO}}')) {
|
||||||
const bio = sessionUser?.bio || '';
|
const bio = sessionUser?.bio || '';
|
||||||
|
|
||||||
|
|||||||
@@ -221,6 +221,14 @@
|
|||||||
text = text.replaceAll('{{USER_NAME}}', name);
|
text = text.replaceAll('{{USER_NAME}}', name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (text.includes('{{USER_EMAIL}}')) {
|
||||||
|
const email = sessionUser?.email || '';
|
||||||
|
|
||||||
|
if (email) {
|
||||||
|
text = text.replaceAll('{{USER_EMAIL}}', email);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (text.includes('{{USER_BIO}}')) {
|
if (text.includes('{{USER_BIO}}')) {
|
||||||
const bio = sessionUser?.bio || '';
|
const bio = sessionUser?.bio || '';
|
||||||
|
|
||||||
|
|||||||
@@ -973,9 +973,10 @@ export const blobToFile = (blob, fileName) => {
|
|||||||
return file;
|
return file;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getPromptVariables = (user_name, user_location) => {
|
export const getPromptVariables = (user_name, user_location, user_email = '') => {
|
||||||
return {
|
return {
|
||||||
'{{USER_NAME}}': user_name,
|
'{{USER_NAME}}': user_name,
|
||||||
|
'{{USER_EMAIL}}': user_email || 'Unknown',
|
||||||
'{{USER_LOCATION}}': user_location || 'Unknown',
|
'{{USER_LOCATION}}': user_location || 'Unknown',
|
||||||
'{{CURRENT_DATETIME}}': getCurrentDateTime(),
|
'{{CURRENT_DATETIME}}': getCurrentDateTime(),
|
||||||
'{{CURRENT_DATE}}': getFormattedDate(),
|
'{{CURRENT_DATE}}': getFormattedDate(),
|
||||||
|
|||||||
Reference in New Issue
Block a user