| 451 | } |
| 452 | |
| 453 | async uploadFilesToIndex(indexId: string, files: File[]): Promise<{ message: string; uploaded_files: any[] }> { |
| 454 | const fd = new FormData(); |
| 455 | files.forEach((f) => fd.append('files', f, f.name)); |
| 456 | const resp = await fetch(`${API_BASE_URL}/indexes/${indexId}/upload`, { method: 'POST', body: fd }); |
| 457 | if (!resp.ok) { |
| 458 | const err = await resp.json().catch(() => ({})); |
| 459 | throw new Error(`Upload to index error: ${err.error || resp.statusText}`); |
| 460 | } |
| 461 | return resp.json(); |
| 462 | } |
| 463 | |
| 464 | async buildIndex(indexId: string, opts: { |
| 465 | latechunk?: boolean; |