mirror of
https://github.com/JefferyHcool/BiliNote.git
synced 2026-06-20 23:14:26 +08:00
Merge pull request #299 from JefferyHcool/feature/note-qa-chat-optimize
Feature/note qa chat optimize
This commit is contained in:
44
BillNote_frontend/src/services/chat.ts
Normal file
44
BillNote_frontend/src/services/chat.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export interface ChatMessage {
|
||||
role: 'user' | 'assistant'
|
||||
content: string
|
||||
}
|
||||
|
||||
export interface ChatSource {
|
||||
text: string
|
||||
source_type: 'markdown' | 'transcript'
|
||||
section_title?: string
|
||||
start_time?: number
|
||||
end_time?: number
|
||||
}
|
||||
|
||||
export interface AskResponse {
|
||||
answer: string
|
||||
sources: ChatSource[]
|
||||
}
|
||||
|
||||
export type IndexStatus = 'idle' | 'indexing' | 'indexed' | 'failed'
|
||||
|
||||
export interface ChatStatusResponse {
|
||||
indexed: boolean
|
||||
status: IndexStatus
|
||||
}
|
||||
|
||||
export const indexTask = async (taskId: string): Promise<void> => {
|
||||
return await request.post('/chat/index', { task_id: taskId })
|
||||
}
|
||||
|
||||
export const askQuestion = async (data: {
|
||||
task_id: string
|
||||
question: string
|
||||
history: ChatMessage[]
|
||||
provider_id: string
|
||||
model_name: string
|
||||
}): Promise<AskResponse> => {
|
||||
return await request.post('/chat/ask', data, { timeout: 60000 })
|
||||
}
|
||||
|
||||
export const getChatStatus = async (taskId: string): Promise<ChatStatusResponse> => {
|
||||
return await request.get(`/chat/status?task_id=${taskId}`)
|
||||
}
|
||||
Reference in New Issue
Block a user