modified: blueprints/chat.py
modified: services/llm_service.py modified: services/rag_service.py modified: static/js/chat.js
This commit is contained in:
@@ -28,20 +28,32 @@ export class Chat {
|
||||
// Typing indicator
|
||||
const typingId = this._appendTyping();
|
||||
|
||||
const res = await fetch(`/api/chat/sessions/${sessionId}/ask`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ message, context_ids: contextIds }),
|
||||
});
|
||||
try {
|
||||
const res = await fetch(`/api/chat/sessions/${sessionId}/ask`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ message, context_ids: contextIds }),
|
||||
});
|
||||
|
||||
this._removeTyping(typingId);
|
||||
this._removeTyping(typingId);
|
||||
|
||||
const data = await res.json();
|
||||
let data;
|
||||
try {
|
||||
data = await res.json();
|
||||
} catch {
|
||||
this._appendBubble('assistant', 'Server error — could not parse response.', true);
|
||||
this._scrollBottom();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!res.ok) {
|
||||
this._appendBubble('assistant', `Error: ${data.error || 'Unknown error'}`, true);
|
||||
} else {
|
||||
this._appendBubble('assistant', data.reply);
|
||||
if (!res.ok) {
|
||||
this._appendBubble('assistant', `Error: ${data.error || 'Unknown error'}`, true);
|
||||
} else {
|
||||
this._appendBubble('assistant', data.reply);
|
||||
}
|
||||
} catch (err) {
|
||||
this._removeTyping(typingId);
|
||||
this._appendBubble('assistant', `Network error: ${err.message}`, true);
|
||||
}
|
||||
|
||||
this._scrollBottom();
|
||||
|
||||
Reference in New Issue
Block a user