| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- import { API_BASE_URL } from '../utils/constants';
- export interface ImportTask {
- id: string;
- sourcePath: string;
- targetGroupId?: string;
- targetGroupName?: string;
- scheduledAt?: string;
- status: 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'FAILED';
- logs?: string;
- embeddingModelId?: string;
- chunkSize?: number;
- chunkOverlap?: number;
- mode?: string;
- createdAt: string;
- }
- export const importService = {
- create: async (token: string, data: {
- sourcePath: string;
- targetGroupId?: string;
- targetGroupName?: string;
- embeddingModelId: string;
- scheduledAt?: string;
- chunkSize?: number;
- chunkOverlap?: number;
- mode?: string;
- }): Promise<ImportTask> => {
- const response = await fetch(`${API_BASE_URL}/import-tasks`, {
- method: 'POST',
- headers: {
- 'Authorization': `Bearer ${token}`,
- 'Content-Type': 'application/json'
- },
- body: JSON.stringify(data)
- });
- if (!response.ok) throw new Error('Failed to create import task');
- return response.json();
- },
- getAll: async (token: string): Promise<ImportTask[]> => {
- const response = await fetch(`${API_BASE_URL}/import-tasks`, {
- headers: {
- 'Authorization': `Bearer ${token}`
- }
- });
- if (!response.ok) throw new Error('Failed to fetch import tasks');
- return response.json();
- }
- };
|