mirror of
https://github.com/JefferyHcool/BiliNote.git
synced 2026-06-15 04:31:41 +08:00
feat(extension): 侧边栏接入思维导图(markmap)与 RAG 问答(P3 + P4)
任务完成(status === SUCCESS)后,侧边栏顶部出现 Markdown / 思维导图 / AI 问答 三个 tab: - 思维导图:用 markmap-lib + markmap-view 把 markdown 转成可缩放思维导图 - AI 问答: · 进入 tab 自动调 /api/chat/index 触发后台索引,按 2s 间隔轮询 /api/chat/status · 索引完成后开放输入框;调 /api/chat/ask 时带上 settings 里的默认 provider/model + 完整 history · Cmd/Ctrl + Enter 发送 · 回答用 markdown-it 渲染,user 气泡用纯文本 - 切换任务时清空对话历史并重新检查索引 logic/api.ts 补 indexChatTask / getChatStatus / askChat 三件套。 依赖新增:markmap-lib, markmap-view(生产依赖) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -132,6 +132,36 @@ export async function downloadTranscriberModel(modelSize: WhisperModelSize, tran
|
||||
})
|
||||
}
|
||||
|
||||
// ---- RAG Chat ----
|
||||
export interface ChatMessage {
|
||||
role: 'user' | 'assistant' | 'system'
|
||||
content: string
|
||||
}
|
||||
|
||||
export async function indexChatTask(taskId: string): Promise<void> {
|
||||
await request('/api/chat/index', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ task_id: taskId }),
|
||||
})
|
||||
}
|
||||
|
||||
export async function getChatStatus(taskId: string): Promise<{ status: 'idle' | 'indexing' | 'indexed' | 'failed', indexed: boolean }> {
|
||||
return request(`/api/chat/status?task_id=${encodeURIComponent(taskId)}`)
|
||||
}
|
||||
|
||||
export async function askChat(payload: {
|
||||
task_id: string
|
||||
question: string
|
||||
history: ChatMessage[]
|
||||
provider_id: string
|
||||
model_name: string
|
||||
}): Promise<unknown> {
|
||||
return request('/api/chat/ask', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
}
|
||||
|
||||
// ---- Monitor ----
|
||||
export async function getDeployStatus(): Promise<DeployStatus> {
|
||||
return request<DeployStatus>('/api/deploy_status')
|
||||
|
||||
Reference in New Issue
Block a user