File tree Expand file tree Collapse file tree 1 file changed +29
-1
lines changed
Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,31 @@ class OpenEvolve:
3535 LLM ensemble, evaluator, and program database.
3636 """
3737
38+ # Mapping of language identifiers to their conventional file extensions
39+ LANGUAGE_TO_EXTENSION = {
40+ "python" : "py" ,
41+ "javascript" : "js" ,
42+ "typescript" : "ts" ,
43+ "java" : "java" ,
44+ "c" : "c" ,
45+ "cpp" : "cpp" ,
46+ "csharp" : "cs" ,
47+ "go" : "go" ,
48+ "rust" : "rs" ,
49+ "php" : "php" ,
50+ "ruby" : "rb" ,
51+ "swift" : "swift" ,
52+ "kotlin" : "kt" ,
53+ "scala" : "scala" ,
54+ "r" : "r" ,
55+ "shell" : "sh" ,
56+ "sql" : "sql" ,
57+ "html" : "html" ,
58+ "css" : "css" ,
59+ "yaml" : "yaml" ,
60+ "json" : "json" ,
61+ }
62+
3863 def __init__ (
3964 self ,
4065 initial_program_path : str ,
@@ -322,8 +347,11 @@ def _save_best_program(self, program: Program) -> None:
322347 best_dir = os .path .join (self .output_dir , "best" )
323348 os .makedirs (best_dir , exist_ok = True )
324349
350+ # Convert language name to proper file extension
351+ extension = self .LANGUAGE_TO_EXTENSION .get (program .language .lower (), program .language )
352+
325353 # Save the program code
326- code_path = os .path .join (best_dir , f"best_program.{ self . language } " )
354+ code_path = os .path .join (best_dir , f"best_program.{ extension } " )
327355 with open (code_path , "w" ) as f :
328356 f .write (program .code )
329357
You can’t perform that action at this time.
0 commit comments