Spaces:
Runtime error
Runtime error
Commit ·
bbd2e28
1
Parent(s): dc1b08f
feat(frontend): Add documentAPI and UploadResponse to api.ts
Browse files- rag-quest-hub/src/lib/api.ts +19 -0
rag-quest-hub/src/lib/api.ts
CHANGED
|
@@ -35,4 +35,23 @@ export const queryAPI = {
|
|
| 35 |
},
|
| 36 |
};
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
export default api;
|
|
|
|
| 35 |
},
|
| 36 |
};
|
| 37 |
|
| 38 |
+
export interface UploadResponse {
|
| 39 |
+
filename: string;
|
| 40 |
+
message: string;
|
| 41 |
+
num_chunks_stored: number;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
export const documentAPI = {
|
| 45 |
+
upload: async (file: File) => {
|
| 46 |
+
const formData = new FormData();
|
| 47 |
+
formData.append('file', file);
|
| 48 |
+
const response = await api.post<UploadResponse>('/upload', formData, {
|
| 49 |
+
headers: {
|
| 50 |
+
'Content-Type': 'multipart/form-data',
|
| 51 |
+
},
|
| 52 |
+
});
|
| 53 |
+
return response.data;
|
| 54 |
+
},
|
| 55 |
+
};
|
| 56 |
+
|
| 57 |
export default api;
|