Route Afia through the platform AI relay when no local API key is set.
Deploy Ladill Frontdesk / deploy (push) Successful in 45s

Frontdesk now calls ladill.com/api/afia/chat using IDENTITY_API_KEY_FRONTDESK
so production does not need a separate OpenAI key in the frontdesk .env.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-06-28 07:45:39 +00:00
co-authored by Cursor
parent cc3d4e9a63
commit 7f51392857
5 changed files with 106 additions and 4 deletions
+5 -1
View File
@@ -110,7 +110,11 @@ Alpine.data('afia', (config = {}) => ({
body: JSON.stringify({ message: text, history }),
});
const data = await res.json();
this.messages.push({ role: 'assistant', text: data.reply || data.message || 'Sorry, I could not respond.' });
if (! res.ok) {
this.messages.push({ role: 'assistant', text: data.message || data.reply || 'Sorry, I could not respond.' });
} else {
this.messages.push({ role: 'assistant', text: data.reply || data.message || 'Sorry, I could not respond.' });
}
} catch (e) {
this.messages.push({ role: 'assistant', text: 'Network error — please try again.' });
}