mirror of
https://github.com/open-webui/open-webui
synced 2024-11-17 14:02:51 +00:00
feat: current_time, current_datetime
This commit is contained in:
parent
5d0b77e64a
commit
fc1a66ea76
@ -13,9 +13,13 @@ def prompt_template(
|
||||
|
||||
# Format the date to YYYY-MM-DD
|
||||
formatted_date = current_date.strftime("%Y-%m-%d")
|
||||
formatted_time = current_date.strftime("%I:%M:%S %p")
|
||||
|
||||
# Replace {{CURRENT_DATE}} in the template with the formatted date
|
||||
template = template.replace("{{CURRENT_DATE}}", formatted_date)
|
||||
template = template.replace("{{CURRENT_TIME}}", formatted_time)
|
||||
template = template.replace(
|
||||
"{{CURRENT_DATETIME}}", f"{formatted_date} {formatted_time}"
|
||||
)
|
||||
|
||||
if user_name:
|
||||
# Replace {{USER_NAME}} in the template with the user's name
|
||||
|
@ -487,9 +487,23 @@ export const promptTemplate = (
|
||||
'-' +
|
||||
String(currentDate.getDate()).padStart(2, '0');
|
||||
|
||||
// Format the time to HH:MM:SS AM/PM
|
||||
const currentTime = currentDate.toLocaleTimeString('en-US', {
|
||||
hour: 'numeric',
|
||||
minute: 'numeric',
|
||||
second: 'numeric',
|
||||
hour12: true
|
||||
});
|
||||
|
||||
// Replace {{CURRENT_DATETIME}} in the template with the formatted datetime
|
||||
template = template.replace('{{CURRENT_DATETIME}}', `${formattedDate} ${currentTime}`);
|
||||
|
||||
// Replace {{CURRENT_DATE}} in the template with the formatted date
|
||||
template = template.replace('{{CURRENT_DATE}}', formattedDate);
|
||||
|
||||
// Replace {{CURRENT_TIME}} in the template with the formatted time
|
||||
template = template.replace('{{CURRENT_TIME}}', currentTime);
|
||||
|
||||
if (user_name) {
|
||||
// Replace {{USER_NAME}} in the template with the user's name
|
||||
template = template.replace('{{USER_NAME}}', user_name);
|
||||
|
Loading…
Reference in New Issue
Block a user