// Expert API helpers extracted from ConfigPage.tsx // Used by both ConfigPage and ExpertSelector import type { ExpertItem } from '../types' export async function getSelectedExpert(sessionId: string): Promise<{ expert_name: string | null; expert: ExpertItem | null }> { const resp = await fetch(`/api/experts/selected?session_id=${encodeURIComponent(sessionId)}`) if (!resp.ok) return { expert_name: null, expert: null } return resp.json() } export async function selectExpert(sessionId: string, expertName: string | null): Promise<{ success: boolean; error?: string }> { const resp = await fetch('/api/experts/select', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ session_id: sessionId, expert_name: expertName }), }) const data = await resp.json().catch(() => ({})) if (!resp.ok || !data.success) return { success: false, error: data.error || '切换专家失败' } return { success: true } }