mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-25 08:33:53 +08:00
fix: 时间被固定
This commit is contained in:
@@ -73,6 +73,10 @@ class Dialogue:
|
|||||||
if system_message:
|
if system_message:
|
||||||
# 基础系统提示
|
# 基础系统提示
|
||||||
enhanced_system_prompt = system_message.content
|
enhanced_system_prompt = system_message.content
|
||||||
|
# 替换时间占位符
|
||||||
|
enhanced_system_prompt = enhanced_system_prompt.replace(
|
||||||
|
"{{current_time}}", datetime.now().strftime("%H:%M")
|
||||||
|
)
|
||||||
|
|
||||||
# 添加说话人个性化描述
|
# 添加说话人个性化描述
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -120,7 +120,6 @@ class PromptManager:
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
current_time = now.strftime("%H:%M")
|
|
||||||
today_date = now.strftime("%Y-%m-%d")
|
today_date = now.strftime("%Y-%m-%d")
|
||||||
today_weekday = WEEKDAY_MAP[now.strftime("%A")]
|
today_weekday = WEEKDAY_MAP[now.strftime("%A")]
|
||||||
today_lunar = cnlunar.Lunar(now, godType="8char")
|
today_lunar = cnlunar.Lunar(now, godType="8char")
|
||||||
@@ -130,7 +129,7 @@ class PromptManager:
|
|||||||
today_lunar.lunarDayCn,
|
today_lunar.lunarDayCn,
|
||||||
)
|
)
|
||||||
|
|
||||||
return current_time, today_date, today_weekday, lunar_date
|
return today_date, today_weekday, lunar_date
|
||||||
|
|
||||||
def _get_location_info(self, client_ip: str) -> str:
|
def _get_location_info(self, client_ip: str) -> str:
|
||||||
"""获取位置信息"""
|
"""获取位置信息"""
|
||||||
@@ -199,7 +198,7 @@ class PromptManager:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# 获取最新的时间信息(不缓存)
|
# 获取最新的时间信息(不缓存)
|
||||||
current_time, today_date, today_weekday, lunar_date = (
|
today_date, today_weekday, lunar_date = (
|
||||||
self._get_current_time_info()
|
self._get_current_time_info()
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -224,7 +223,7 @@ class PromptManager:
|
|||||||
template = Template(self.base_prompt_template)
|
template = Template(self.base_prompt_template)
|
||||||
enhanced_prompt = template.render(
|
enhanced_prompt = template.render(
|
||||||
base_prompt=user_prompt,
|
base_prompt=user_prompt,
|
||||||
current_time=current_time,
|
current_time="{{current_time}}",
|
||||||
today_date=today_date,
|
today_date=today_date,
|
||||||
today_weekday=today_weekday,
|
today_weekday=today_weekday,
|
||||||
lunar_date=lunar_date,
|
lunar_date=lunar_date,
|
||||||
|
|||||||
Reference in New Issue
Block a user