Skip to content

Commit 020b000

Browse files
committed
Update beta.py
1 parent 6a4b02d commit 020b000

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

codeflash/lsp/beta.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,21 @@ def third_step_in_optimize_function(server: CodeflashLanguageServer, params: Opt
8989
}
9090

9191

92+
@server.feature("fourth_step_in_optimize_function")
93+
def fourth_step_in_optimize_function(server: CodeflashLanguageServer, params: OptimizeFunctionParams) -> dict[str, str]:
94+
current_function_optimizer = server.optimizer.current_function_optimizer
95+
96+
if not current_function_optimizer:
97+
return {"functionName": params.functionName, "status": "error", "message": "No function optimizer found"}
98+
99+
optimized_code = current_function_optimizer.optimize_function()
100+
101+
if not optimized_code:
102+
return {"functionName": params.functionName, "status": "error", "message": "Optimization failed"}
103+
104+
return {"functionName": params.functionName, "status": "success", "optimized_code": optimized_code}
105+
106+
92107
if __name__ == "__main__":
93108
from codeflash.cli_cmds.console import console
94109

0 commit comments

Comments
 (0)