@@ -105,6 +105,8 @@ def optimize_python_code( # noqa: D417
105105 trace_id : str ,
106106 num_candidates : int = 10 ,
107107 experiment_metadata : ExperimentMetadata | None = None ,
108+ * ,
109+ is_async : bool = False ,
108110 ) -> list [OptimizedCandidate ]:
109111 """Optimize the given python code for performance by making a request to the Django endpoint.
110112
@@ -136,6 +138,7 @@ def optimize_python_code( # noqa: D417
136138 "repo_owner" : git_repo_owner ,
137139 "repo_name" : git_repo_name ,
138140 "n_candidates" : N_CANDIDATES_EFFECTIVE ,
141+ "is_async" : is_async ,
139142 }
140143
141144 logger .info ("!lsp|Generating optimized candidates…" )
@@ -302,6 +305,9 @@ def get_new_explanation( # noqa: D417
302305 annotated_tests : str ,
303306 optimization_id : str ,
304307 original_explanation : str ,
308+ original_throughput : str | None = None ,
309+ optimized_throughput : str | None = None ,
310+ throughput_improvement : str | None = None ,
305311 ) -> str :
306312 """Optimize the given python code for performance by making a request to the Django endpoint.
307313
@@ -318,6 +324,9 @@ def get_new_explanation( # noqa: D417
318324 - annotated_tests: str - test functions annotated with runtime
319325 - optimization_id: str - unique id of opt candidate
320326 - original_explanation: str - original_explanation generated for the opt candidate
327+ - original_throughput: str | None - throughput for the baseline code (operations per second)
328+ - optimized_throughput: str | None - throughput for the optimized code (operations per second)
329+ - throughput_improvement: str | None - throughput improvement percentage
321330
322331 Returns
323332 -------
@@ -337,6 +346,9 @@ def get_new_explanation( # noqa: D417
337346 "optimization_id" : optimization_id ,
338347 "original_explanation" : original_explanation ,
339348 "dependency_code" : dependency_code ,
349+ "original_throughput" : original_throughput ,
350+ "optimized_throughput" : optimized_throughput ,
351+ "throughput_improvement" : throughput_improvement ,
340352 }
341353 logger .info ("loading|Generating explanation" )
342354 console .rule ()
@@ -491,6 +503,7 @@ def generate_regression_tests( # noqa: D417
491503 "test_index" : test_index ,
492504 "python_version" : platform .python_version (),
493505 "codeflash_version" : codeflash_version ,
506+ "is_async" : function_to_optimize .is_async ,
494507 }
495508 try :
496509 response = self .make_ai_service_request ("/testgen" , payload = payload , timeout = 600 )
0 commit comments