## Context The chat page currently has a single-panel layout: message list + input. The system prompt is absent (no system message in ChatHistory), and model parameters like temperature use Semantic Kernel defaults. For prompt engineering and debugging, these need to be editable in the UI without restarting the server. ## Goals / Non-Goals **Goals:** - Tabbed UI: Chat, System Prompt, Model Settings — all on the same page - System prompt and model settings sent with each chat request - Backend applies them to SK's ChatHistory and OpenAIPromptExecutionSettings - Settings persist in the browser session (survive tab switches, not page reloads) **Non-Goals:** - Persisting settings to disk or server (future — save/load prompt profiles) - Phase 2 prompt templates and few-shot examples (scoped in proposal, not implemented here) - Changing the SSE streaming contract ## Decisions ### Tabbed layout using MudTabs - Use `MudTabs` with `MudTabPanel` for each section: Chat, System Prompt, Model Settings - **Alternative considered**: MudDrawer panels or separate pages. Rejected because tabs keep everything on one page — switching between prompt and chat should be instant with no navigation. - The Chat tab contains the existing message list and input (unchanged) - System Prompt tab: a `MudTextField` with `Lines="10"` for multi-line editing - Model Settings tab: `MudNumericField` or `MudSlider` for Temperature (0.0–2.0), TopP (0.0–1.0), MaxTokens (1–4096) ### Settings sent per-request, not stored server-side - `ChatRequest` gains optional `SystemPrompt` (string?) and `Settings` (ModelSettings?) properties - Backend treats them as nullable — if absent, defaults apply (no system prompt, SK default temperature) - This keeps the API stateless and avoids server-side session management - **Alternative considered**: Server-side settings endpoint. Rejected — adds complexity for a single-user debugging tool. ### ModelSettings as a shared DTO - New `ModelSettings.cs` in Shared/Models with `Temperature` (double?), `TopP` (double?), `MaxTokens` (int?) - All fields nullable — only set values override defaults - Maps directly to `OpenAIPromptExecutionSettings` properties on the backend ### System prompt applied as ChatHistory system message - `chatHistory.AddSystemMessage(request.SystemPrompt)` as the first entry before user/assistant messages - SK and OpenAI APIs treat the system message as behavioral instructions for the model ### Tab state persists in component fields - `_systemPrompt` and `_modelSettings` are component-level fields, not per-tab - Switching tabs doesn't reset values (MudTabs preserves panel content by default) - Values are lost on page refresh — acceptable for a debugging tool ## Risks / Trade-offs - **[Tab switch loses scroll position]** → MudTabs renders all panels but hides inactive ones, so scroll position in the chat tab is preserved - **[Large system prompts inflate request size]** → Acceptable for single-user debugging; no size limit enforced - **[Temperature/TopP interaction]** → Standard OpenAI behavior: setting both is allowed but not recommended. Show a note in the UI, don't enforce.