import type { BaseAgentResponse, BatchPreview, BatchStatus, BatchUploadResponse, DocumentList, TextEntryRequest, TextEntryResponse, } from '../../types/documentation'; import BaseAgentService from '../BaseAgentService'; import { DOCUMENTATION_BATCH_STATUS, DOCUMENTATION_DELETE, DOCUMENTATION_LIST, DOCUMENTATION_TEXT_ENTRY, DOCUMENTATION_UPLOAD_BATCH, } from './documentation.routes'; export const uploadBatch = async ( formData: FormData, clientId: string, token?: string | null ): Promise> => { return await BaseAgentService.raw>( DOCUMENTATION_UPLOAD_BATCH, clientId, token, { method: 'POST', responseType: 'json', data: formData, } ); }; export const getBatchStatus = async ( jobId: string, clientId: string, token?: string | null ): Promise> => { return await BaseAgentService.getWithClientId>( `${DOCUMENTATION_BATCH_STATUS}/${jobId}/status`, clientId, token ); }; export const getBatchPreview = async ( batchId: string, clientId: string, token?: string | null ): Promise> => { return await BaseAgentService.getWithClientId< BaseAgentResponse >(`${DOCUMENTATION_BATCH_STATUS}/${batchId}/preview`, clientId, token); }; export const pushToRag = async ( batchId: string, clientId: string, token?: string | null ): Promise< BaseAgentResponse<{ job_id: string; batch_id: string; status: string }> > => { return await BaseAgentService.postWithClientId< BaseAgentResponse<{ job_id: string; batch_id: string; status: string }> >( `${DOCUMENTATION_BATCH_STATUS}/${batchId}/push-to-rag`, {}, clientId, token ); }; export const listDocuments = async ( clientId: string, token?: string | null ): Promise> => { return await BaseAgentService.getWithClientId< BaseAgentResponse >(DOCUMENTATION_LIST, clientId, token); }; export const deleteDocument = async ( fileName: string, clientId: string, token?: string | null ): Promise> => { return await BaseAgentService.postWithClientId< BaseAgentResponse<{ file_name: string; deleted: boolean }> >( `${DOCUMENTATION_DELETE}/delete/${encodeURIComponent(fileName)}`, {}, clientId, token ); }; export const createTextEntry = async ( payload: TextEntryRequest, clientId: string, token?: string | null ): Promise> => { return await BaseAgentService.postWithClientId< BaseAgentResponse >(DOCUMENTATION_TEXT_ENTRY, payload, clientId, token); };