@@ -255,6 +255,8 @@ def optimize_python_code_refinement(self, request: list[AIServiceRefinerRequest]
255255 "optimized_code_runtime" : opt .optimized_code_runtime ,
256256 "speedup" : opt .speedup ,
257257 "trace_id" : opt .trace_id ,
258+ "function_references" : opt .function_references ,
259+ "python_version" : platform .python_version (),
258260 }
259261 for opt in request
260262 ]
@@ -308,6 +310,7 @@ def get_new_explanation( # noqa: D417
308310 original_throughput : str | None = None ,
309311 optimized_throughput : str | None = None ,
310312 throughput_improvement : str | None = None ,
313+ function_references : str | None = None ,
311314 ) -> str :
312315 """Optimize the given python code for performance by making a request to the Django endpoint.
313316
@@ -327,6 +330,7 @@ def get_new_explanation( # noqa: D417
327330 - original_throughput: str | None - throughput for the baseline code (operations per second)
328331 - optimized_throughput: str | None - throughput for the optimized code (operations per second)
329332 - throughput_improvement: str | None - throughput improvement percentage
333+ - function_references: str | None - where the function is called in the codebase
330334
331335 Returns
332336 -------
@@ -349,6 +353,7 @@ def get_new_explanation( # noqa: D417
349353 "original_throughput" : original_throughput ,
350354 "optimized_throughput" : optimized_throughput ,
351355 "throughput_improvement" : throughput_improvement ,
356+ "function_references" : function_references ,
352357 }
353358 logger .info ("loading|Generating explanation" )
354359 console .rule ()
@@ -373,7 +378,12 @@ def get_new_explanation( # noqa: D417
373378 return ""
374379
375380 def generate_ranking ( # noqa: D417
376- self , trace_id : str , diffs : list [str ], optimization_ids : list [str ], speedups : list [float ]
381+ self ,
382+ trace_id : str ,
383+ diffs : list [str ],
384+ optimization_ids : list [str ],
385+ speedups : list [float ],
386+ function_references : str | None = None ,
377387 ) -> list [int ] | None :
378388 """Optimize the given python code for performance by making a request to the Django endpoint.
379389
@@ -382,6 +392,7 @@ def generate_ranking( # noqa: D417
382392 - trace_id : unique uuid of function
383393 - diffs : list of unified diff strings of opt candidates
384394 - speedups : list of speedups of opt candidates
395+ - function_references : where the function is called in the codebase
385396
386397 Returns
387398 -------
@@ -394,6 +405,7 @@ def generate_ranking( # noqa: D417
394405 "speedups" : speedups ,
395406 "optimization_ids" : optimization_ids ,
396407 "python_version" : platform .python_version (),
408+ "function_references" : function_references ,
397409 }
398410 logger .info ("loading|Generating ranking" )
399411 console .rule ()
@@ -594,6 +606,7 @@ def get_optimization_review(
594606 "optimized_runtime" : humanize_runtime (explanation .best_runtime_ns ),
595607 "original_runtime" : humanize_runtime (explanation .original_runtime_ns ),
596608 "calling_fn_details" : calling_fn_details ,
609+ "python_version" : platform .python_version (),
597610 }
598611 console .rule ()
599612 try :
0 commit comments