Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
fc1a66ea
"docs/git@developer.sourcefind.cn:chenpangpang/diffusers.git" did not exist on "98c42134a5615e1c26f2cca70ff9a4c142850f65"
Commit
fc1a66ea
authored
Jun 16, 2024
by
Timothy J. Baek
Browse files
feat: current_time, current_datetime
parent
5d0b77e6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletion
+19
-1
backend/utils/task.py
backend/utils/task.py
+5
-1
src/lib/utils/index.ts
src/lib/utils/index.ts
+14
-0
No files found.
backend/utils/task.py
View file @
fc1a66ea
...
@@ -13,9 +13,13 @@ def prompt_template(
...
@@ -13,9 +13,13 @@ def prompt_template(
# Format the date to YYYY-MM-DD
# Format the date to YYYY-MM-DD
formatted_date
=
current_date
.
strftime
(
"%Y-%m-%d"
)
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_DATE}}"
,
formatted_date
)
template
=
template
.
replace
(
"{{CURRENT_TIME}}"
,
formatted_time
)
template
=
template
.
replace
(
"{{CURRENT_DATETIME}}"
,
f
"
{
formatted_date
}
{
formatted_time
}
"
)
if
user_name
:
if
user_name
:
# Replace {{USER_NAME}} in the template with the user's name
# Replace {{USER_NAME}} in the template with the user's name
...
...
src/lib/utils/index.ts
View file @
fc1a66ea
...
@@ -487,9 +487,23 @@ export const promptTemplate = (
...
@@ -487,9 +487,23 @@ export const promptTemplate = (
'
-
'
+
'
-
'
+
String
(
currentDate
.
getDate
()).
padStart
(
2
,
'
0
'
);
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
// Replace {{CURRENT_DATE}} in the template with the formatted date
template
=
template
.
replace
(
'
{{CURRENT_DATE}}
'
,
formattedDate
);
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
)
{
if
(
user_name
)
{
// Replace {{USER_NAME}} in the template with the user's name
// Replace {{USER_NAME}} in the template with the user's name
template
=
template
.
replace
(
'
{{USER_NAME}}
'
,
user_name
);
template
=
template
.
replace
(
'
{{USER_NAME}}
'
,
user_name
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment