@@ -190,6 +190,8 @@ export class GPTController {
190190 *
191191 * Adds a message to the ChatGPT thread and runs it.
192192 * This collects all of the paper metadata
193+ *
194+ * Parameters are given in a named object form
193195 *
194196 * @param assistantId the id of the chatgpt assistant to use
195197 * @param fileId the id of the file to search (file must have been already uploaded)
@@ -221,6 +223,8 @@ export class GPTController {
221223 *
222224 * Gets the initia part data and returns it as a list of Partial<ai_part> objects.
223225 * These contain info like the part name, type and manufacturer
226+ *
227+ * Parameters are given in a named object form
224228 *
225229 * @param assistantId the id of the chatgpt assistant to use
226230 * @param fileId the id of the file to search (file must have been already uploaded)
@@ -254,10 +258,12 @@ export class GPTController {
254258
255259 /**
256260 *
257- * @param assistantId
258- * @param fileId
259- * @param threadId
260- * @param parts
261+ * Parameters are given in a named object form
262+ *
263+ * @param assistantId the id of the chatgpt assistant to use
264+ * @param fileId the id of the file to search (file must have been already uploaded)
265+ * @param threadId the id of the thread to run (must already exist)
266+ * @param parts the list of Partial<ai_part> objects to run the tests against
261267 * @returns
262268 */
263269 async getPartTests ( {
@@ -300,6 +306,20 @@ export class GPTController {
300306 return partTests ;
301307 }
302308
309+ /**
310+ *
311+ * Get the test results related to specific tests
312+ * i.e. SEE, TID, or DD
313+ *
314+ *
315+ * Parameters are given in a named object form
316+ *
317+ * @param assistantId the id of the chatgpt assistant to use
318+ * @param fileId the id of the file to search (file must have been already uploaded)
319+ * @param threadId the id of the thread to run (must already exist)
320+ * @param parts the list of ai_part objects to run the tests against
321+ * @returns a list of completed ai_parts
322+ */
303323 async getSpecificTest ( {
304324 assistantId,
305325 fileId,
@@ -348,6 +368,17 @@ export class GPTController {
348368 return parts ;
349369 }
350370
371+ /**
372+ * Gets any tables and figures from the paper.
373+ * This can be good to try and stimulate answers related to the figures
374+ *
375+ * Parameters are given in a named object form
376+ *
377+ * @param assistantId the id of the chatgpt assistant to use
378+ * @param fileId the id of the file to search (file must have been already uploaded)
379+ * @param threadId the id of the thread to run (must already exist)
380+ * @returns
381+ */
351382 async getTablesAndFigures ( {
352383 assistantId,
353384 fileId,
@@ -390,10 +421,7 @@ export class GPTController {
390421 const threadId = await this . createThread ( ) ;
391422 if ( ! threadId ) return ;
392423 const ids = { assistantId, fileId, threadId } ;
393-
394- console . log ( "Getting Paper Data\n" ) ;
395424 const papersData = await this . getPaperData ( { ...ids } ) ;
396- console . log ( "Getting Part Data\n" ) ;
397425 const partData = await this . getSpecificTest ( {
398426 ...ids ,
399427 parts : await this . getPartTests ( {
@@ -409,9 +437,7 @@ export class GPTController {
409437 JSON . stringify ( { paper : papersData , parts : partData } , null , 2 ) ,
410438 ) ;
411439
412- console . log ( "🚀 Running thread to process all queries..." ) ;
413-
414- // ✅ Correctly write structured JSON data
440+ console . log ( "Running thread to process all queries..." ) ;
415441 const outputFile = pdfPath . replace ( ".pdf" , "_extracted.json" ) ;
416442 fs . writeFileSync (
417443 outputFile ,
@@ -427,18 +453,20 @@ export class GPTController {
427453 *
428454 * @param assistantId the id of the chatgpt assistant to use (must exist)
429455 * @param fileId the id of the file to search (file must have been already uploaded)
430- * @returns
456+ * @returns an instance of ai_FullDataType containing a fully extracted paper
431457 */
432458 async processPaper (
433459 fileId : string ,
434460 assistantId : string ,
435461 ) : Promise < ai_FullDataType > {
436462 const threadId = await this . createThread ( ) ;
463+
437464 const ids = { assistantId, fileId, threadId } ;
438465
439- //console.log(" Getting Paper Data\n");
466+ // Getting paper data
440467 const papersData = await this . getPaperData ( { ...ids } ) ;
441- //console.log("Getting Part Data\n");
468+
469+ // Getting the Part, Prelim and Specific data and passing them as arguments
442470 const partData = await this . getSpecificTest ( {
443471 ...ids ,
444472 parts : await this . getPartTests ( {
@@ -447,6 +475,8 @@ export class GPTController {
447475 } ) ,
448476 } ) ;
449477
478+ // Attempt to delete the thread, sometimes it doesn't work?
479+ // It will say the thread doesn't exist, idfk lol
450480 try {
451481 await this . deleteThread ( threadId ) ;
452482 } catch {
@@ -460,6 +490,16 @@ export class GPTController {
460490 return final ;
461491 }
462492
493+ /**
494+ *
495+ * Processes a list of pdfs using their local paths. Will upload the pdfs
496+ * to the OpenAI api and then run each paper through the processPaper()
497+ * function 3 times. The results are then packaged and returned
498+ *
499+ * @param pdfPaths a list of pdf paths to run through GPT
500+ * @param assistant_id OPTIONALLY pass an id for an existing assistant
501+ * @returns A list of ai_GPTResponse objects populated with the extracted data
502+ */
463503 async processRadiationPapers ( pdfPaths : string [ ] , assistant_id ?: string ) {
464504 // Create a new assistant if one is not given
465505 let assistantId = assistant_id ?? ( await this . createAssistant ( ) ) ;
0 commit comments