added RAG, Multiuser, TG bot
This commit is contained in:
@@ -1,42 +1,42 @@
|
||||
from datetime import datetime
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.memory.service import MemoryService
|
||||
|
||||
WEEKDAY_RU = (
|
||||
"понедельник",
|
||||
"вторник",
|
||||
"среда",
|
||||
"четверг",
|
||||
"пятница",
|
||||
"суббота",
|
||||
"воскресенье",
|
||||
)
|
||||
|
||||
DEFAULT_TIMEZONE = "Europe/Moscow"
|
||||
|
||||
|
||||
def resolve_timezone(db: Session) -> str:
|
||||
profile = MemoryService(db).get_profile()
|
||||
tz = (profile.get("timezone") or "").strip()
|
||||
return tz or DEFAULT_TIMEZONE
|
||||
|
||||
|
||||
def format_datetime_context(db: Session) -> str:
|
||||
tz_name = resolve_timezone(db)
|
||||
try:
|
||||
tz = ZoneInfo(tz_name)
|
||||
except Exception:
|
||||
tz = ZoneInfo(DEFAULT_TIMEZONE)
|
||||
tz_name = DEFAULT_TIMEZONE
|
||||
|
||||
now = datetime.now(tz)
|
||||
weekday = WEEKDAY_RU[now.weekday()]
|
||||
lines = [
|
||||
"[Текущее время]",
|
||||
f"Сейчас: {now.strftime('%Y-%m-%d %H:%M')} ({weekday}), часовой пояс {tz_name}.",
|
||||
"Учитывай время при ответах о «сегодня», «утром», «вечером» и расписании.",
|
||||
]
|
||||
return "\n".join(lines)
|
||||
from datetime import datetime
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.memory.service import MemoryService
|
||||
|
||||
WEEKDAY_RU = (
|
||||
"понедельник",
|
||||
"вторник",
|
||||
"среда",
|
||||
"четверг",
|
||||
"пятница",
|
||||
"суббота",
|
||||
"воскресенье",
|
||||
)
|
||||
|
||||
DEFAULT_TIMEZONE = "Europe/Moscow"
|
||||
|
||||
|
||||
def resolve_timezone(db: Session, user_id: int) -> str:
|
||||
profile = MemoryService(db, user_id).get_profile()
|
||||
tz = (profile.get("timezone") or "").strip()
|
||||
return tz or DEFAULT_TIMEZONE
|
||||
|
||||
|
||||
def format_datetime_context(db: Session, user_id: int) -> str:
|
||||
tz_name = resolve_timezone(db, user_id)
|
||||
try:
|
||||
tz = ZoneInfo(tz_name)
|
||||
except Exception:
|
||||
tz = ZoneInfo(DEFAULT_TIMEZONE)
|
||||
tz_name = DEFAULT_TIMEZONE
|
||||
|
||||
now = datetime.now(tz)
|
||||
weekday = WEEKDAY_RU[now.weekday()]
|
||||
lines = [
|
||||
"[Текущее время]",
|
||||
f"Сейчас: {now.strftime('%Y-%m-%d %H:%M')} ({weekday}), часовой пояс {tz_name}.",
|
||||
"Учитывай время при ответах о «сегодня», «утром», «вечером» и расписании.",
|
||||
]
|
||||
return "\n".join(lines)
|
||||
|
||||
Reference in New Issue
Block a user