mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-17 14:55:23 +00:00
refac
This commit is contained in:
parent
d720e027ad
commit
66f00ce4bf
1 changed files with 30 additions and 27 deletions
|
|
@ -39,11 +39,13 @@ def prompt_variables_template(template: str, variables: dict[str, str]) -> str:
|
||||||
|
|
||||||
|
|
||||||
def prompt_template(template: str, user: Optional[Any] = None) -> str:
|
def prompt_template(template: str, user: Optional[Any] = None) -> str:
|
||||||
if hasattr(user, "model_dump"):
|
|
||||||
user = user.model_dump()
|
|
||||||
|
|
||||||
USER_VARIABLES = {}
|
USER_VARIABLES = {}
|
||||||
|
|
||||||
|
if user:
|
||||||
|
if hasattr(user, "model_dump"):
|
||||||
|
user = user.model_dump()
|
||||||
|
|
||||||
if isinstance(user, dict):
|
if isinstance(user, dict):
|
||||||
birth_date = user.get("date_of_birth")
|
birth_date = user.get("date_of_birth")
|
||||||
age = None
|
age = None
|
||||||
|
|
@ -58,7 +60,10 @@ def prompt_template(template: str, user: Optional[Any] = None) -> str:
|
||||||
age = (
|
age = (
|
||||||
today.year
|
today.year
|
||||||
- birth_date.year
|
- birth_date.year
|
||||||
- ((today.month, today.day) < (birth_date.month, birth_date.day))
|
- (
|
||||||
|
(today.month, today.day)
|
||||||
|
< (birth_date.month, birth_date.day)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
@ -72,8 +77,6 @@ def prompt_template(template: str, user: Optional[Any] = None) -> str:
|
||||||
"age": str(age),
|
"age": str(age),
|
||||||
}
|
}
|
||||||
|
|
||||||
print(USER_VARIABLES)
|
|
||||||
|
|
||||||
# Get the current date
|
# Get the current date
|
||||||
current_date = datetime.now()
|
current_date = datetime.now()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue