Admin AI settings silently reset the assistant prompt, which cannot be edited in the UI

Aperta Adatta ai principianti
#1,608 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
84/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
react, typescript
Ambito
frontend

Direzione di ricerca

Inizia da ui/src/pages/Admin/AiSettings/index.tsx e ispeziona il payload creato per salvare le impostazioni AI, quindi confrontalo con il campo prompt_config accettato dal backend. Aggiungi campi prompt modificabili e assicurati che il prompt esistente venga incluso quando salvi le altre impostazioni. Verifica che un prompt personalizzato rimanga invariato dopo il salvataggio del modulo Admin → AI Settings.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug

The AI assistant's prompt (prompt_config) can be stored and returned by the API, but there is no way to edit it, and saving AI settings silently overwrites whatever is stored with the built-in default.

SaveSiteAI substitutes the defaults whenever a request omits prompt_config:

https://github.com/apache/answer/blob/main/internal/service/siteinfo/siteinfo_service.go#L384-L389

if req.PromptConfig == nil {
    req.PromptConfig = &schema.AIPromptConfig{
        ZhCN: constant.DefaultAIPromptConfigZhCN,
        EnUS: constant.DefaultAIPromptConfigEnUS,
    }
}

The admin form in ui/src/pages/Admin/AiSettings/index.tsx builds its payload from enabled, chosen_provider and ai_providers only, so it never sends prompt_config. Every save from that page therefore resets the prompt.

Combined, this means:

  1. The prompt cannot be customised through the UI at all — there is no field for it.
  2. A prompt set directly through the API survives only until somebody saves the AI settings page, then reverts silently with no warning and no indication in the UI that anything changed.

The backend side is fully implemented: SiteAIReq accepts prompt_config, SaveSiteAI persists it, GetSiteAI returns it, and getPromptByLanguage reads it and falls back to the constant when empty. Only the form is missing.

Expected behavior

The prompt is editable in Admin → AI Settings, and saving other AI settings does not discard it.

Steps to reproduce
  1. Set a custom en_us prompt via PUT /answer/admin/api/ai-config with a prompt_config object.
  2. Confirm it is stored (GET /answer/admin/api/ai-config).
  3. In Admin → AI Settings, change nothing of substance and press Save.
  4. Read the config again — the prompt is back to DefaultAIPromptConfigEnUS.
Version

Reproduced on main (3b9f137) and on 2.0.2.

Additional context

This surfaced while running the assistant against a vector-search plugin. semantic_search returns a link for every result, but the default prompt never asks the model to cite sources, so whether an answer links the thread it came from is left to the model. Being able to ask for citations in the prompt is the natural fix — which needs the prompt to be editable and to stay edited.

Happy to send a PR: the change is frontend-only, since the backend already supports the field.

Lingua principale
Go
Stelle
15.7k
Fork
1.4k
Merge medio
5g 20h
PR unite (30g)
6

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/answer

Tutte le issue di apache/answer

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.