import { apiFetch } from "@/core/api"; import { getBackendBaseURL } from "@/core/config"; export interface PromptPrefixSettings { enabled: boolean; switch_label: string; prompt_prefix: string; } export interface PromptPrefixUpdate { enabled?: boolean; switch_label?: string; prompt_prefix?: string; } export async function loadPromptPrefixSettings(): Promise { const response = await apiFetch( `${getBackendBaseURL()}/api/system-settings/prompt-prefix`, ); if (!response.ok) { throw new Error(`Failed to load prompt prefix settings: ${response.status}`); } return (await response.json()) as PromptPrefixSettings; } export async function updatePromptPrefixSettings( body: PromptPrefixUpdate, ): Promise { const response = await apiFetch( `${getBackendBaseURL()}/api/system-settings/prompt-prefix`, { method: "PUT", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body), }, ); if (!response.ok) { const detail = await response .json() .catch(() => ({ detail: "Failed to update prompt prefix" })); throw new Error(detail.detail ?? "Failed to update prompt prefix"); } return (await response.json()) as PromptPrefixSettings; }