diff options
author | A.J. Shulman <Shulman.aj@gmail.com> | 2025-01-23 11:51:50 -0500 |
---|---|---|
committer | A.J. Shulman <Shulman.aj@gmail.com> | 2025-01-23 11:51:50 -0500 |
commit | 99e2a1728b9b97d30f5e0fffe6a10201bdee49c2 (patch) | |
tree | 33b0e487348883582dd2479e55739cf75bf79f19 /src/server/ApiManagers/AssistantManager.ts | |
parent | 971d107574031885c17c339d39c4fd813682cc02 (diff) |
added commenting
Diffstat (limited to 'src/server/ApiManagers/AssistantManager.ts')
-rw-r--r-- | src/server/ApiManagers/AssistantManager.ts | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/src/server/ApiManagers/AssistantManager.ts b/src/server/ApiManagers/AssistantManager.ts index fbda74194..c5ba4b830 100644 --- a/src/server/ApiManagers/AssistantManager.ts +++ b/src/server/ApiManagers/AssistantManager.ts @@ -124,6 +124,8 @@ export default class AssistantManager extends ApiManager { }, }); + // Register an API route to retrieve web search results using Google Custom Search + // This route filters results by checking their x-frame-options headers for security purposes register({ method: Method.POST, subscription: '/getWebSearchResults', @@ -205,6 +207,13 @@ export default class AssistantManager extends ApiManager { } }, }); + + /** + * Converts a video file to audio format using ffmpeg. + * @param videoPath The path to the input video file. + * @param outputAudioPath The path to the output audio file. + * @returns A promise that resolves when the conversion is complete. + */ function convertVideoToAudio(videoPath: string, outputAudioPath: string): Promise<void> { return new Promise((resolve, reject) => { const ffmpegProcess = spawn('ffmpeg', [ @@ -238,6 +247,8 @@ export default class AssistantManager extends ApiManager { }); } + // Register an API route to process a media file (audio or video) + // Extracts audio from video files, transcribes the audio using OpenAI Whisper, and provides a summary register({ method: Method.POST, subscription: '/processMediaFile', @@ -412,6 +423,8 @@ export default class AssistantManager extends ApiManager { } }; + // Register an API route to generate an image using OpenAI's DALL-E model + // Uploads the generated image to the server and provides a URL for access register({ method: Method.POST, subscription: '/generateImage', @@ -440,7 +453,8 @@ export default class AssistantManager extends ApiManager { }, }); - // Register a proxy fetch API route + // Register an API route to fetch data from a URL using a proxy with retry logic + // Useful for bypassing rate limits or scraping inaccessible data register({ method: Method.POST, subscription: '/proxyFetch', @@ -465,6 +479,7 @@ export default class AssistantManager extends ApiManager { }); // Register an API route to scrape website content using Puppeteer and JSDOM + // Extracts and returns readable content from a given URL register({ method: Method.POST, subscription: '/scrapeWebsite', @@ -505,6 +520,8 @@ export default class AssistantManager extends ApiManager { }, }); + // Register an API route to create a document and start a background job for processing + // Uses Python scripts to process files and generate document chunks for further use register({ method: Method.POST, subscription: '/createDocument', @@ -536,6 +553,7 @@ export default class AssistantManager extends ApiManager { }); // Register an API route to check the progress of a document creation job + // Returns the current step and progress percentage register({ method: Method.GET, subscription: '/getProgress/:jobId', @@ -553,7 +571,8 @@ export default class AssistantManager extends ApiManager { }, }); - // Register an API route to get the final result of a document creation job + // Register an API route to retrieve the final result of a document creation job + // Returns the processed data or an error status if the job is incomplete register({ method: Method.GET, subscription: '/getResult/:jobId', @@ -574,7 +593,8 @@ export default class AssistantManager extends ApiManager { }, }); - // Register an API route to format chunks (e.g., text or image chunks) for display + // Register an API route to format chunks of text or images for structured display + // Converts raw chunk data into a structured format for frontend consumption register({ method: Method.POST, subscription: '/formatChunks', @@ -630,6 +650,7 @@ export default class AssistantManager extends ApiManager { }); // Register an API route to create and save a CSV file on the server + // Writes the CSV content to a unique file and provides a URL for download register({ method: Method.POST, subscription: '/createCSV', @@ -669,6 +690,12 @@ export default class AssistantManager extends ApiManager { } } +/** + * Spawns a Python process to handle file processing tasks. + * @param jobId The job ID for tracking progress. + * @param file_name The name of the file to process. + * @param file_path The filepath of the file to process. + */ function spawnPythonProcess(jobId: string, file_name: string, file_path: string) { const venvPath = path.join(__dirname, '../chunker/venv'); const requirementsPath = path.join(__dirname, '../chunker/requirements.txt'); |