Skip to content

Commit 388890c

Browse files
committed
Add original explanation
1 parent 108fc60 commit 388890c

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

codeflash/api/aiservice.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ def get_new_explanation( # noqa: D417
291291
speedup: str,
292292
annotated_tests: str,
293293
optimization_id: str,
294+
original_explanation: str,
294295
) -> str:
295296
"""Optimize the given python code for performance by making a request to the Django endpoint.
296297
@@ -306,6 +307,7 @@ def get_new_explanation( # noqa: D417
306307
- speedup: str - speedup of the optimized code
307308
- annotated_tests: str - test functions annotated with runtime
308309
- optimization_id: str - unique id of opt candidate
310+
- original_explanation: str - original_explanation generated for the opt candidate
309311
310312
Returns
311313
-------
@@ -323,6 +325,7 @@ def get_new_explanation( # noqa: D417
323325
"speedup": speedup,
324326
"annotated_tests": annotated_tests,
325327
"optimization_id": optimization_id,
328+
"original_explanation": original_explanation,
326329
"dependency_code": dependency_code,
327330
}
328331
logger.info("Generating explanation")

codeflash/optimization/function_optimizer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,7 @@ def find_and_process_best_optimization(
11361136
speedup=f"{int(performance_gain(original_runtime_ns=original_code_baseline.runtime, optimized_runtime_ns=best_optimization.runtime) * 100)}%",
11371137
annotated_tests=generated_tests_str,
11381138
optimization_id=best_optimization.candidate.optimization_id,
1139+
original_explanation=best_optimization.candidate.explanation,
11391140
)
11401141
new_explanation = Explanation(
11411142
raw_explanation_message=new_explanation_raw_str or explanation.raw_explanation_message,

0 commit comments

Comments
 (0)