Skip to content
4 changes: 4 additions & 0 deletions codeflash/api/aiservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ def get_new_explanation( # noqa: D417
original_throughput: str | None = None,
optimized_throughput: str | None = None,
throughput_improvement: str | None = None,
codeflash_version: str = codeflash_version,
) -> str:
"""Optimize the given python code for performance by making a request to the Django endpoint.

Expand All @@ -327,6 +328,7 @@ def get_new_explanation( # noqa: D417
- original_throughput: str | None - throughput for the baseline code (operations per second)
- optimized_throughput: str | None - throughput for the optimized code (operations per second)
- throughput_improvement: str | None - throughput improvement percentage
- current codeflash version

Returns
-------
Expand All @@ -349,6 +351,7 @@ def get_new_explanation( # noqa: D417
"original_throughput": original_throughput,
"optimized_throughput": optimized_throughput,
"throughput_improvement": throughput_improvement,
"codeflash_version": codeflash_version,
}
logger.info("loading|Generating explanation")
console.rule()
Expand Down Expand Up @@ -593,6 +596,7 @@ def get_optimization_review(
"benchmark_details": explanation.benchmark_details if explanation.benchmark_details else None,
"optimized_runtime": humanize_runtime(explanation.best_runtime_ns),
"original_runtime": humanize_runtime(explanation.original_runtime_ns),
"codeflash_version": codeflash_version,
"calling_fn_details": calling_fn_details,
}
console.rule()
Expand Down
10 changes: 6 additions & 4 deletions codeflash/optimization/function_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1379,11 +1379,13 @@ def process_review(
generated_tests, original_runtime_by_test, optimized_runtime_by_test
)

generated_tests_str = "\n#------------------------------------------------\n".join(
[test.generated_original_test_source for test in generated_tests.generated_tests]
)
generated_tests_str = ""
for test in generated_tests.generated_tests:
generated_tests_str += f"```python\n{test.generated_original_test_source}\n```"
generated_tests_str += "\n\n"

if concolic_test_str:
generated_tests_str += "\n#------------------------------------------------\n" + concolic_test_str
generated_tests_str += f"```python\n{concolic_test_str}\n```\n\n"

existing_tests, replay_tests, concolic_tests = existing_tests_source_for(
self.function_to_optimize.qualified_name_with_modules_from_root(self.project_root),
Expand Down
Loading