@@ -88,7 +88,7 @@ def gemini_qna(
8888 readme_file :pathlib .Path ,
8989 api_key :str ,
9090 explanation_in :str = 'Korean' ,
91- ) -> str :
91+ ) -> Tuple [ int , str ] :
9292 '''
9393 Queries the Gemini API to provide explanations for failed pytest test cases.
9494
@@ -105,7 +105,7 @@ def gemini_qna(
105105 logging .info (f"Student files: { student_files } " )
106106 logging .info (f"Readme file: { readme_file } " )
107107
108- consolidated_question = get_prompt (
108+ n_failed , consolidated_question = get_prompt (
109109 report_paths ,
110110 student_files ,
111111 readme_file ,
@@ -114,17 +114,20 @@ def gemini_qna(
114114
115115 answers = ask_gemini (consolidated_question , api_key )
116116
117- return answers
117+ return n_failed , answers
118118
119119
120120def get_prompt (
121121 report_paths :Tuple [pathlib .Path ],
122122 student_files :Tuple [pathlib .Path ],
123123 readme_file :pathlib .Path ,
124124 explanation_in :str ,
125- ) -> str :
125+ ) -> Tuple [ int , str ] :
126126 pytest_longrepr_list = collect_longrepr_from_multiple_reports (report_paths , explanation_in )
127127
128+ n_failed_tests = len (pytest_longrepr_list )
129+
130+
128131 def get_initial_instruction (questions :List [str ],language :str ) -> str :
129132 # Add the main directive or instruction based on whether there are failed tests
130133 if questions :
@@ -153,7 +156,7 @@ def get_initial_instruction(questions:List[str],language:str) -> str:
153156 # Join all questions into a single string
154157 prompt_str = "\n \n " .join (prompt_list )
155158
156- return prompt_str
159+ return n_failed_tests , prompt_str
157160
158161
159162def collect_longrepr_from_multiple_reports (pytest_json_report_paths :Tuple [pathlib .Path ], explanation_in :str ) -> List [str ]:
0 commit comments