"""Formatting utilities for the Gradio UI."""
from typing import List
from src.config.constants import MAX_LOG_LINES
def html_for(log_data: list[str]) -> str:
"""Generate HTML for displaying the log lines in a scrollable container."""
logs = reversed(log_data[-MAX_LOG_LINES:])
output = "".join(f"
{line}
" for line in logs)
return (
"📜 Live Agent Logs
"
"" + output + "
"
)
def format_deals_table(deals: List[List[str]]) -> str:
"""Formats accepted deals as an HTML table with styled links."""
html = """
🛍️ Best Deals Found
Description |
Price |
AI Estimate |
Discount |
URL |
"""
for desc, price, estimate, discount, url in deals:
html += f"""
{desc} |
{price} |
{estimate} |
{discount} |
Link |
"""
html += """
"""
return html
def get_server_timezone() -> str:
"""Get the server's timezone information."""
import datetime
current_time = datetime.datetime.now()
try:
timezone_name = current_time.astimezone().tzinfo.tzname(current_time)
except AttributeError:
timezone_name = "Unknown"
return (
f"Server Time: {current_time.strftime('%Y-%m-%d %H:%M:%S')} "
f"(Timezone: {timezone_name})"
)