stable POC version 1 - chat and topics

This commit is contained in:
Adrien
2026-04-02 21:04:33 +02:00
parent 618e28b354
commit bcc80d250b
74 changed files with 11692 additions and 278 deletions
+18 -1
View File
@@ -6,7 +6,7 @@ export interface ChatMessage {
id: string
role: 'USER' | 'ASSISTANT'
content: string
sources: Array<{ bookTitle: string; page: number | null }>
sources: Array<{ bookTitle: string; page: number | null; chunkText?: string }>
createdAt: string
}
@@ -91,6 +91,21 @@ export const useChatStore = defineStore('chat', () => {
}
}
function leaveSession(): void {
session.value = null
messages.value = []
error.value = null
}
async function fetchSessionsByTopic(topicId: string): Promise<ChatSession[]> {
try {
const response = await api.get<ChatSession[]>('/chat/sessions', { params: { topicId } })
return response.data
} catch {
return []
}
}
async function deleteSession(): Promise<boolean> {
if (!session.value) return false
loading.value = true
@@ -117,6 +132,8 @@ export const useChatStore = defineStore('chat', () => {
createSession,
loadMessages,
sendMessage,
leaveSession,
fetchSessionsByTopic,
deleteSession
}
})