enhance rag retrieval + summary

This commit is contained in:
Adrien
2026-04-07 22:39:28 +02:00
parent 0cf318f0a7
commit aee6a9dfba
34 changed files with 2306 additions and 279 deletions
+45
View File
@@ -10,11 +10,14 @@ export interface Topic {
}
export interface SourceReference {
bookId: string | null
bookTitle: string
page: number | null
}
export interface TopicSummary {
id: string
summaryNumber: number
topicId: string
topicName: string
summary: string
@@ -22,12 +25,20 @@ export interface TopicSummary {
generatedAt: string
}
export interface SavedSummaryItem {
id: string
summaryNumber: number
generatedAt: string
}
export const useTopicStore = defineStore('topics', () => {
const topics = ref<Topic[]>([])
const activeSummary = ref<TopicSummary | null>(null)
const activeSummaryTopicId = ref<string | null>(null)
const summaryList = ref<SavedSummaryItem[]>([])
const loading = ref(false)
const summaryLoading = ref(false)
const summaryListLoading = ref(false)
const error = ref<string | null>(null)
async function fetchTopics() {
@@ -43,6 +54,36 @@ export const useTopicStore = defineStore('topics', () => {
}
}
async function fetchSummaries(topicId: string) {
summaryListLoading.value = true
summaryList.value = []
error.value = null
try {
const response = await api.get<SavedSummaryItem[]>(`/topics/${topicId}/summaries`)
summaryList.value = response.data
} catch (err: any) {
error.value = err.message
} finally {
summaryListLoading.value = false
}
}
async function fetchSummaryDetail(topicId: string, summaryId: string): Promise<TopicSummary | null> {
summaryLoading.value = true
activeSummary.value = null
error.value = null
try {
const response = await api.get<TopicSummary>(`/topics/${topicId}/summaries/${summaryId}`)
activeSummary.value = response.data
return response.data
} catch (err: any) {
error.value = err.message
return null
} finally {
summaryLoading.value = false
}
}
async function generateSummary(topicId: string): Promise<TopicSummary | null> {
summaryLoading.value = true
activeSummaryTopicId.value = topicId
@@ -65,10 +106,14 @@ export const useTopicStore = defineStore('topics', () => {
topics,
activeSummary,
activeSummaryTopicId,
summaryList,
loading,
summaryLoading,
summaryListLoading,
error,
fetchTopics,
fetchSummaries,
fetchSummaryDetail,
generateSummary
}
})