MyPharmaAI / utils /helpers.py
Ajey95
Initial clean commit of MyPharma AI
c1bc991
raw
history blame
2.69 kB
# utils/helpers.py
"""
Helper utility functions
"""
import json
import os
import random
from datetime import datetime
def load_quotes():
"""Load inspirational quotes from Gita/Vedas"""
quotes_file = 'data/quotes.json'
default_quotes = [
"विद्या ददाति विनयं - Knowledge gives humility",
"योग: कर्मसु कौशलम् - Yoga is skill in action",
"श्रेयान्स्वधर्मो विगुण: - Better is one's own dharma though imperfectly performed",
"कर्मण्येवाधिकारस्ते - You have the right to perform action",
"विद्या धनं सर्व धन प्रधानम् - Knowledge is the supreme wealth",
"सत्यमेव जयते - Truth alone triumphs",
"तमसो मा ज्योतिर्गमय - Lead me from darkness to light",
"अहिंसा परमो धर्म: - Non-violence is the supreme virtue"
]
if not os.path.exists(quotes_file):
os.makedirs('data', exist_ok=True)
with open(quotes_file, 'w', encoding='utf-8') as f:
json.dump(default_quotes, f, indent=2, ensure_ascii=False)
return default_quotes
try:
with open(quotes_file, 'r', encoding='utf-8') as f:
return json.load(f)
except:
return default_quotes
def get_greeting():
"""Get time-appropriate greeting"""
hour = datetime.now().hour
if 5 <= hour < 12:
return "🌅 सुप्रभात (Good Morning)! Ready for some विद्या (learning)?"
elif 12 <= hour < 17:
return "☀️ नमस्कार (Good Afternoon)! Let's continue your studies!"
elif 17 <= hour < 21:
return "🌆 शुभ संध्या (Good Evening)! Time for some focused study?"
else:
return "🌙 शुभ रात्रि (Good Night)! Late night study session?"
def format_indian_text(text, add_emojis=True):
"""Format text with Indian cultural elements"""
if add_emojis:
# Add relevant emojis based on content
if any(word in text.lower() for word in ['drug', 'medicine', 'pharmaceutical']):
text = f"💊 {text}"
elif any(word in text.lower() for word in ['study', 'learn', 'education']):
text = f"📚 {text}"
elif any(word in text.lower() for word in ['quiz', 'test', 'exam']):
text = f"❓ {text}"
elif any(word in text.lower() for word in ['memory', 'remember', 'mnemonic']):
text = f"🧠 {text}"
return text