Draft: improve deployability, admin UX, and OpenAI compatibility#69
Open
leolionart wants to merge 37 commits intoAmm1rr:masterfrom
Open
Draft: improve deployability, admin UX, and OpenAI compatibility#69leolionart wants to merge 37 commits intoAmm1rr:masterfrom
leolionart wants to merge 37 commits intoAmm1rr:masterfrom
Conversation
…nfig UI - Admin UI at /admin with 3 tabs: Dashboard, Configuration, Logs - cURL import: paste Chrome DevTools cURL to auto-extract Gemini cookies - Real-time log viewer via SSE with level filtering and search - Stats dashboard with uptime, request counts, endpoint breakdown - Config management: model selection, proxy settings, manual cookie entry - New services: curl_parser, log_broadcaster, stats_collector - Dark theme, responsive, vanilla JS (no framework dependencies) - Added sse-starlette and jinja2 dependencies Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Auto-build on push to master with multi-platform support (amd64/arm64) - Push to ghcr.io/leolionart/webai-to-api with latest + sha tags - Use GHA cache for faster subsequent builds - Update docker-compose.yml to pull from GHCR instead of local build - Add docker-compose.dev.yml for local development builds Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- SVG favicon (inline data URI, no extra file needed) - API Reference section with auto-detected Base URL and copy button - Endpoint table listing all API routes (method, path, description) - Per-row Copy button copies full URL for easy config in n8n/Claude Code - Color-coded method badges (POST green, GET blue) - Fix docker-compose.dev.yml volume mount for paths with spaces Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Config was lost on container restart because it was written inside the ephemeral container filesystem. Now uses a named Docker volume mounted at /app/data with CONFIG_PATH env var pointing to /app/data/config.conf. - Add CONFIG_PATH environment variable support in config.py - Auto-copy bundled config.conf to data dir on first start - Use named volume (webai_data) in docker-compose.yml - Cookies and settings now survive container restarts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add OpenAI-compatible GET /v1/models endpoint for client discovery - Classify init errors with error_code (auth_expired, no_cookies, network, disabled) - Show actionable step-by-step guidance when connection fails - Always refresh cookie status after import regardless of success - Add error_code to all admin API responses Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
OpenAI-compatible clients expect base URL ending with /v1. Dashboard now shows both OpenAI Base URL (/v1) and Server URL. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove Server URL (redundant), keep only Base URL with /v1 - Show full URLs in endpoint table for direct copy-paste - Remove /docs and /translate from listing (noise for clients) - Clarify format in descriptions (OpenAI / Google AI / simple JSON) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gemini-webapi rotates __Secure-1PSIDTS in-memory every ~9 min but never writes updated values to disk. On server restart the original (potentially expired) cookies were reloaded from config.conf. Add a background asyncio task (_persist_cookies_loop) that checks every 10 minutes whether the in-memory cookie values differ from config.conf and writes any changes to disk. Start/stop the task in the FastAPI lifespan alongside session manager initialisation.
docker-compose.yml: remove env_file/.env dependency (ENVIRONMENT var was never used by the hardcoded uvicorn command); keep only PYTHONPATH and CONFIG_PATH which are actually needed. Remove docker-compose.override.yml: it was auto-loaded on every `docker compose up`, had incorrect sync paths (./app doesn't exist), and served no purpose for regular users. Makefile: drop `include .env` (fails when file missing); switch to `docker compose` v2 CLI; add logs/pull/restart targets; add up-dev for local builds. Docker.md: rewrite as a clear step-by-step guide focused on what users actually need — copy config.conf, add cookies, `docker compose up -d`. Documents cookie auto-persistence, port change, and local build. README.md: expand Docker section with inline quick-start instead of just pointing to Docker.md.
docker-compose.yml: replace named volume with bind mount ./config.conf so config is visible and editable directly in the deploy folder. README: rewrite deploy guide around the admin UI — users start the server with an empty config.conf, then paste cookies via the dashboard (supports cURL import). Remove all manual file-editing instructions.
Hardcoded model names (gemini-2.5-flash, gemini-3.0-pro, etc.) were rejected by gemini-webapi which only accepts its own internal names. Update GeminiModels enum, admin config list, config defaults, and docs to use the actual accepted model names: - gemini-2.0-exp-advanced (most capable) - gemini-2.0-flash-exp (default, fast) - gemini-1.5-pro - gemini-1.5-flash
gemini-webapi 1.8.3 → 1.19.2 in requirements.txt. Model names updated to match what the library and Gemini web actually support: - gemini-3.0-pro (most capable) - gemini-3.0-flash (default) - gemini-3.0-flash-thinking
…ini-webapi 1.19.2 Old lockfile had pydantic==2.10.6 but gemini-webapi 1.19.2 requires pydantic~=2.12.5 and orjson~=3.11.7 which was missing entirely. Replace full lockfile with direct dependencies only, let pip resolve transitive deps at build time.
- Full visual redesign using M3 dark color system + Gemini gradient - Add Plus Jakarta Sans (Google Sans equivalent) + JetBrains Mono fonts - Add Material Symbols icons to stat cards, nav tabs, section headers - Implement Gemini shimmer animation on wordmark via CSS background-clip - M3 surface tint elevation system (no box-shadows for depth) - Staggered entrance animations on stat cards and sections - Animated Gemini gradient underline on active tab (scaleX transition) - Pulse dot animation on connection status badge - M3-style chips, outlined text fields, filled tonal buttons - Custom styled scrollbars and select dropdowns - Responsive: icon-only tabs on mobile (<768px) - fix: implement proper SSE streaming for Home Assistant compatibility - fix: add copyText() fallback for HTTP non-secure clipboard access Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
gemini-webapi auto-reinits its session after zombie/parse errors (~2-3s). Without retry logic every such error was returned immediately to the client (HA, CLIProxyAPI) as a 500, even though a retry would have succeeded. Changes: - models/gemini.py: add retry loop (2 retries, 3s + 5s delays) around generate_content() for retryable transient errors only; non-retryable errors (AuthError etc.) still propagate immediately - endpoints/chat.py: categorize exceptions into auth / stream / unexpected so logs clearly distinguish the error type; return 401 for auth errors, 503 for exhausted stream retries, 500 for unexpected errors Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add image_utils.py: base64/URL decode, temp file mgmt, serialize response images - Add files.py: POST/GET/DELETE /v1/files for multipart image/PDF upload - Add responses.py: POST /v1/responses (OpenAI Responses API for Home Assistant) - Update chat.py: _resolve_model() with alias table, _extract_multimodal_content() supporting both Chat Completions and Responses API input formats - Update gemini.py: return images[] and thoughts in response - Update schemas: OpenAIChatRequest.model accepts any string, add ContentPart - Update admin UI: API reference table, cURL examples, HA step-by-step guide, guide-steps CSS with numbered circles
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- New TelegramNotifier singleton service with per-error-type cooldown to prevent notification spam on cascading failures - Config section [Telegram]: enabled, bot_token, chat_id, cooldown_seconds - Error hooks in /gemini, /gemini-chat, /v1/chat/completions endpoints (auth, 503, 500 error types) - Admin API: GET/POST /api/admin/config/telegram + /test endpoint - Admin UI: Telegram section in Config tab with Save + Send Test buttons - Bot token masked in API responses for security
- Rewrite Telegram section using form-group/config-row/config-label pattern matching existing sections (Proxy, Model, Manual Cookies) - Remove all inline styles; use help-text, btn-tonal btn-small, code preview - Detect when CONFIG_PATH is a directory (Docker volume misconfiguration) and log a clear actionable error instead of silent write failure
When a Docker volume mounts a file path that doesn't exist on the host, Docker creates a directory there. Detect and remove it automatically so no manual host preparation is needed before docker compose up.
- Change docker-compose volumes from file-mount (./config.conf:/app/data/config.conf) to directory-mount (./data:/app/data) — Docker no longer creates a directory at the config path; app creates the file inside ./data/ on first run - Add version display (vX.Y.Z chip) in admin header, sourced from pyproject.toml via tomllib and exposed through /api/admin/status
Add notify_types setting to filter which error categories trigger Telegram alerts (auth, 503, 500). Default to auth-only to reduce noise from transient stream errors. Includes M3-styled checkboxes in admin UI and centralized type filtering in TelegramNotifier.
Prevent Playwright MCP debug files from being tracked. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR proposes a broad maintenance sync from my fork that focuses on improving deployability, admin usability, and OpenAI-compatible client support.
Main areas included:
/v1/modelssupport and clearer error handling for OpenAI-compatible clients/v1/responsessupport for broader client compatibilityWhy this may be useful
I have been actively maintaining this fork in real-world usage, and these changes came from practical issues:
Scope note
This is intentionally submitted as a draft because the change set is large.
If you prefer, I can split this into smaller follow-up PRs by theme, for example:
/v1/models+ error handling improvements/v1/responses+ file uploadI wanted to send the full maintained branch first so you can evaluate whether the direction is useful before I spend time splitting it further.