modified: blueprints/chat.py

modified:   services/llm_service.py
	modified:   services/rag_service.py
	modified:   static/js/chat.js
This commit is contained in:
SimolZimol
2026-05-22 17:27:07 +02:00
parent 3f13f740d6
commit 718e38e9d5
4 changed files with 72 additions and 37 deletions

View File

@@ -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();