You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@answer.apache.org by "Andy-Sverdlov-LucaNet (via GitHub)" <gi...@apache.org> on 2026/09/10 17:18:24 UTC
[PR] fix(ui): add the AI prompt to admin settings and stop resetting it [answer]
Andy-Sverdlov-LucaNet opened a new pull request, #1609:
URL: https://github.com/apache/answer/pull/1609
Fixes #1608
## Proposed Changes
- Add a **Prompt** field to Admin → AI Settings, prefilled from the stored `prompt_config.en_us`, so the assistant's prompt can be edited in the UI at all.
- Send `prompt_config` in the save payload, which stops `SaveSiteAI` from replacing the stored prompt with `DefaultAIPromptConfigEnUS` on every save.
- Preserve `zh_cn` from the loaded config rather than dropping it, so editing the English prompt does not clear the Chinese one.
- Add `prompt_config` to the `AiConfig` type and `ui.admin.ai_settings.prompt` label/help text to `i18n/en_US.yaml`.
## Why
`SaveSiteAI` substitutes the defaults when a request omits `prompt_config`, and the admin form built its payload from `enabled`, `chosen_provider` and `ai_providers` only. So the prompt was unreachable from the UI, and a prompt set through the API reverted silently the next time anyone saved the model or the API key.
This is frontend-only: the backend already accepts, persists and returns `prompt_config`, and `getPromptByLanguage` already falls back to the constant when the stored prompt is empty. Leaving the field empty therefore restores the default.
## Verification
Against `main` (3b9f137):
- `tsc --noEmit` clean, with the changed file confirmed present in the compilation
- `eslint` clean on the changed component
- `i18n/en_US.yaml` parses and the key resolves at `ui.admin.ai_settings.prompt`
- Built into a running image and exercised end to end: the field renders prefilled with the stored prompt, an edit survives Save and a page reload, and the saved value is the one served back by `GET /answer/admin/api/ai-config`
## Note
The prompt is a format template — `getPromptByLanguage` does `fmt.Sprintf(promptTemplate, question)` — so it must contain exactly one `%s`, where the user's question is substituted. This PR does not validate that, matching current behaviour for prompts set through the API. Happy to add validation (here or separately) if maintainers would prefer it, since removing `%s` fails quietly: the question simply never reaches the model.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@answer.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@answer.apache.org
For additional commands, e-mail: issues-help@answer.apache.org