Skip to content

refactor(gui-personalization): extract endpoint to a module + fix model defaults - #578

Merged
ArmenSl merged 1 commit into
feature/gui_personalizationfrom
fix/gui-personalization-cleanup
Jul 21, 2026
Merged

refactor(gui-personalization): extract endpoint to a module + fix model defaults#578
ArmenSl merged 1 commit into
feature/gui_personalizationfrom
fix/gui-personalization-cleanup

Conversation

@ArmenSl

@ArmenSl ArmenSl commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Cleanup on top of #577, addressing the organization + correctness review. Targets feature/gui_personalization so it lands before #577 merges to development.

Organization (the main concern)

The new /personalize-gui-page endpoint inlined ~150 lines into generation_router.py — validation, a ~40-line LLM system prompt, the OpenAI call and response parsing — which breaks the codebase's own pattern (agent_personalization.py holds that logic; the router just calls it).

  • New services/utils/gui_personalization_utils.py — mirrors agent_personalization: the system prompt is a module constant, and personalize_gui_page() owns validation → prompt → LLM call → parse.
  • The router endpoint is now thin — resolve API key, asyncio.to_thread(run_gui_personalization, …), shape the response; @handle_endpoint_errors maps ValidationError/GenerationError.

Correctness

  • Model defaults were inconsistent and invalidgpt-5.4-mini (×7) and gpt-5.6-luna, neither a real OpenAI id (would 404 at runtime). Consolidated to a single DEFAULT_OPENAI_MODEL = "gpt-5" constant, used everywhere.
  • Removed a leftover print("calling now") debug statement.
  • Removed two dead … and False branches in replace_reply_batch (a disabled translate_text_api experiment).

Tests

  • test_gui_personalization.py — 10 tests (LLM mocked, offline): input validation, default-vs-explicit model, response parsing, and error mapping (missing key → ValidationError, unparseable/invalid response → GenerationError).
  • Full converter round-trips + agent-personalization + agent-converter suites still pass (94 tests).

Deliberately left

  • The translate-before-style reorder in replace_reply_batch — appears intentional; flag for @Aran30 to confirm.
  • Pre-existing gpt-5.5 default at generation_router.py:172 (a different, older endpoint) — out of this PR's scope.
  • The now-unused translate_text_api helper is left in place (removing it is separate).

… cleanup

Addresses review feedback on #577 (organization + correctness):

- Extract the ~150-line /personalize-gui-page endpoint body into a new
  services/utils/gui_personalization_utils.py, mirroring the
  agent_personalization pattern: the ~40-line LLM system prompt is now a
  module constant, and personalize_gui_page() owns validation, prompt
  building, the OpenAI call and response parsing. The router endpoint is
  now a thin validate -> delegate -> shape-response handler.
- Consolidate the OpenAI model default into one DEFAULT_OPENAI_MODEL =
  'gpt-5' constant. Removes the inconsistent/invalid defaults the PR
  introduced (gpt-5.4-mini x7, gpt-5.6-luna) that would 404 at runtime.
- Remove a leftover print('calling now') debug statement.
- Remove two dead '... and False' branches in replace_reply_batch.
- Add test_gui_personalization.py (10 tests, LLM mocked) covering
  validation, model selection, response parsing and error mapping.

Left as-is: the translate-before-style reorder in replace_reply_batch
(appears intentional); pre-existing gpt-5.5 default at generation_router
line 172 (out of scope).
@ArmenSl
ArmenSl merged commit 5e34dd3 into feature/gui_personalization Jul 21, 2026
@ArmenSl
ArmenSl deleted the fix/gui-personalization-cleanup branch July 21, 2026 10:42
ArmenSl added a commit that referenced this pull request Jul 22, 2026
- Bump setup.cfg 7.12.0 -> 7.13.0 and add v7.13.0 release notes.
- Frontend submodule bump 360dcfa6 -> b14dadec: the GUI-personalization
  UI (user-profile form editor, per-profile page variants + switching,
  web-app version selection in the generation dialog) plus review
  cleanups. All GUI-personalization work; no multilingual changes.
- Backend: the GUI-personalization feature (#577), the extract-to-service
  cleanup (#578), and the user-profile OCL/parsing fixes + regression
  tests (#579) are already on development.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant