feat: implement RAG-enabled chat hook and admin file upload component
This commit is contained in:
@@ -193,13 +193,24 @@ export function useChat({ user, isAdmin }) {
|
||||
} catch (e) {
|
||||
console.error('[R42] chat error', e);
|
||||
setErrored(true);
|
||||
const isKey = /api key/i.test(e?.message || '');
|
||||
|
||||
let errorContent = STRINGS.errorGeneric;
|
||||
const errorMsg = e?.message || '';
|
||||
|
||||
if (e?.name === 'LLMTruncatedError') {
|
||||
errorContent = 'Mijn circuits zijn overbelast (Token Limiet bereikt). Kun je je vraag korter of specifieker maken?';
|
||||
} else if (e?.name === 'LLMValidationError') {
|
||||
errorContent = 'Mijn antwoord was helaas beschadigd of incorrect geformatteerd. Kun je het nog eens proberen?';
|
||||
} else if (/api key/i.test(errorMsg)) {
|
||||
errorContent = STRINGS.errorNoKey;
|
||||
}
|
||||
|
||||
setMessages(prev => [
|
||||
...prev,
|
||||
{
|
||||
id: `m_${Date.now()}_e`,
|
||||
role: 'error',
|
||||
content: isKey ? STRINGS.errorNoKey : STRINGS.errorGeneric,
|
||||
content: errorContent,
|
||||
ts: Date.now(),
|
||||
},
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user