@@ -102,6 +102,8 @@ def optimize_python_code( # noqa: D417
102102 trace_id : str ,
103103 num_candidates : int = 10 ,
104104 experiment_metadata : ExperimentMetadata | None = None ,
105+ * ,
106+ is_async : bool = False ,
105107 ) -> list [OptimizedCandidate ]:
106108 """Optimize the given python code for performance by making a request to the Django endpoint.
107109
@@ -133,6 +135,7 @@ def optimize_python_code( # noqa: D417
133135 "repo_owner" : git_repo_owner ,
134136 "repo_name" : git_repo_name ,
135137 "n_candidates" : N_CANDIDATES_EFFECTIVE ,
138+ "is_async" : is_async ,
136139 }
137140
138141 logger .info ("!lsp|Generating optimized candidates…" )
@@ -299,6 +302,9 @@ def get_new_explanation( # noqa: D417
299302 annotated_tests : str ,
300303 optimization_id : str ,
301304 original_explanation : str ,
305+ original_throughput : str | None = None ,
306+ optimized_throughput : str | None = None ,
307+ throughput_improvement : str | None = None ,
302308 ) -> str :
303309 """Optimize the given python code for performance by making a request to the Django endpoint.
304310
@@ -315,6 +321,9 @@ def get_new_explanation( # noqa: D417
315321 - annotated_tests: str - test functions annotated with runtime
316322 - optimization_id: str - unique id of opt candidate
317323 - original_explanation: str - original_explanation generated for the opt candidate
324+ - original_throughput: str | None - throughput for the baseline code (operations per second)
325+ - optimized_throughput: str | None - throughput for the optimized code (operations per second)
326+ - throughput_improvement: str | None - throughput improvement percentage
318327
319328 Returns
320329 -------
@@ -334,6 +343,9 @@ def get_new_explanation( # noqa: D417
334343 "optimization_id" : optimization_id ,
335344 "original_explanation" : original_explanation ,
336345 "dependency_code" : dependency_code ,
346+ "original_throughput" : original_throughput ,
347+ "optimized_throughput" : optimized_throughput ,
348+ "throughput_improvement" : throughput_improvement ,
337349 }
338350 logger .info ("loading|Generating explanation" )
339351 console .rule ()
@@ -488,6 +500,7 @@ def generate_regression_tests( # noqa: D417
488500 "test_index" : test_index ,
489501 "python_version" : platform .python_version (),
490502 "codeflash_version" : codeflash_version ,
503+ "is_async" : function_to_optimize .is_async ,
491504 }
492505 try :
493506 response = self .make_ai_service_request ("/testgen" , payload = payload , timeout = 600 )
0 commit comments