stable POC version 1 - chat and topics
This commit is contained in:
@@ -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
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user