from pathlib import Path # Clean BOM for path in Path("app").rglob("*.py"): text = path.read_text(encoding="utf-8-sig") text = text.replace("\ufeff", "") path.write_text(text, encoding="utf-8") print("BOM cleanup completed.") hf_path = Path("app/deployment/hf_status.py") text = hf_path.read_text(encoding="utf-8-sig") text = text.replace("\ufeff", "") product_app_html = r''' def get_product_app_html() -> str: return """ GraphResearcher App
Ready
Tip: ask follow-ups like “explain it simply” or “how is it different?” The app sends recent chat context with your question.
""" ''' if "def get_product_app_html" not in text: text += product_app_html print("Added get_product_app_html.") else: print("get_product_app_html already exists.") hf_path.write_text(text, encoding="utf-8") # Patch main.py main_path = Path("app/main.py") main_text = main_path.read_text(encoding="utf-8-sig") main_text = main_text.replace("\ufeff", "") if "from app.deployment.hf_status import get_product_app_html" not in main_text: main_text = "from app.deployment.hf_status import get_product_app_html\n" + main_text # Ensure HTMLResponse import if "HTMLResponse" not in main_text: lines = main_text.splitlines() inserted = False for i, line in enumerate(lines): if line.startswith("from fastapi.responses import"): lines[i] = line + ", HTMLResponse" inserted = True break if not inserted: lines.insert(0, "from fastapi.responses import HTMLResponse") main_text = "\n".join(lines) + "\n" if "# Product ChatGPT-style app UI endpoint" not in main_text: main_text += ''' # Product ChatGPT-style app UI endpoint @app.get("/app", response_class=HTMLResponse) def product_app_page(): return get_product_app_html() ''' print("Added /app route.") else: print("/app route already exists.") main_path.write_text(main_text, encoding="utf-8") print("Phase 25 ChatGPT-style product app UI added.")