Spaces:
Running
Running
File size: 2,034 Bytes
f871fed |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
import apiClient from './client'
export interface EmbedContentRequest {
item_id: string
item_type: 'source' | 'note'
async_processing?: boolean
}
export interface EmbedContentResponse {
success: boolean
message: string
chunks_created?: number
command_id?: string
}
export interface RebuildEmbeddingsRequest {
mode: 'existing' | 'all'
include_sources?: boolean
include_notes?: boolean
include_insights?: boolean
}
export interface RebuildEmbeddingsResponse {
command_id: string
message: string
estimated_items: number
}
export interface RebuildProgress {
total_items?: number
processed_items?: number
failed_items?: number
total?: number
processed?: number
percentage?: number
}
export interface RebuildStats {
sources_processed?: number
notes_processed?: number
insights_processed?: number
sources?: number
notes?: number
insights?: number
failed?: number
failed_items?: number
processing_time?: number
}
export interface RebuildStatusResponse {
command_id: string
status: 'queued' | 'running' | 'completed' | 'failed'
progress?: RebuildProgress
stats?: RebuildStats
started_at?: string
completed_at?: string
error_message?: string
}
export const embeddingApi = {
embedContent: async (itemId: string, itemType: 'source' | 'note', asyncProcessing = false): Promise<EmbedContentResponse> => {
const response = await apiClient.post<EmbedContentResponse>('/embed', {
item_id: itemId,
item_type: itemType,
async_processing: asyncProcessing
})
return response.data
},
rebuildEmbeddings: async (request: RebuildEmbeddingsRequest): Promise<RebuildEmbeddingsResponse> => {
const response = await apiClient.post<RebuildEmbeddingsResponse>('/embeddings/rebuild', request)
return response.data
},
getRebuildStatus: async (commandId: string): Promise<RebuildStatusResponse> => {
const response = await apiClient.get<RebuildStatusResponse>(`/embeddings/rebuild/${commandId}/status`)
return response.data
}
}
|