Spaces:
Running on Zero
Running on Zero
Download beta_frontend.py from mendeld/ac: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/spaces/mendeld/ac/resolve/main/beta_frontend.py
- Command line
-
hf download hf://spaces/mendeld/ac/beta_frontend.py
-
curl -L -o beta_frontend.py https://huggingface.co/spaces/mendeld/ac/resolve/main/beta_frontend.py
1.17 kB
| """Add the AC Beta controls to the existing stable fixed-height chat shell.""" | |
| from pathlib import Path | |
| HERE=Path(__file__).parent | |
| def enhance_frontend(page: str, *, is_admin: bool) -> str: | |
| page=page.replace('</style>', '<style></style>\n</style>',1) if False else page | |
| css=(HERE/'beta_ui.css').read_text(encoding='utf-8') | |
| js=(HERE/'beta_ui.js').read_text(encoding='utf-8') | |
| page=page.replace('</head>', '<style>'+css+'</style></head>',1) | |
| page=page.replace('</body>', '<script>'+js+'</script></body>',1) | |
| # Separate Head Admin browser archives from public/guest archives on the | |
| # same origin. This must happen before any page script executes. | |
| if is_admin: | |
| css_google=(HERE/'google_dashboard_ui.css').read_text(encoding='utf-8') | |
| js_google=(HERE/'google_dashboard_ui.js').read_text(encoding='utf-8') | |
| page=page.replace('</head>', '<style>'+css_google+'</style></head>',1) | |
| page=page.replace('</body>', '<script>'+js_google+'</script></body>',1) | |
| for key in ('ac_archive','ac_current_history','ac_current_chat_id'): | |
| page=page.replace(key, key.replace('ac_', 'ac_admin_', 1)) | |
| return page | |