Add Test Connection button to AI settings with plain-English error messages

- POST /settings/ai/test sends a minimal text prompt to verify the provider
- Returns ok/message — maps HTTP status codes to human-readable explanations
- 405 → "URL pointing at wrong place, check custom URL has no path suffix"
- 401 → invalid key, 404 → wrong path, 429 → rate limited, etc.
- Test button appears once a key is saved; result shown inline below buttons

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
megaproxy 2026-04-22 19:28:20 +00:00
parent e676e698ff
commit 1ece0908af
4 changed files with 8732 additions and 2 deletions

View file

@ -37,6 +37,11 @@ export async function clearAiSettings(): Promise<void> {
await api.delete("/settings/ai");
}
export async function testAiSettings(): Promise<{ ok: boolean; message: string }> {
const { data } = await api.post("/settings/ai/test");
return data;
}
export async function parseReceipt(txnId: string, attachmentId: string): Promise<ParsedReceipt> {
const { data } = await api.post(`/transactions/${txnId}/attachments/${attachmentId}/parse`);
return data;