Kai Izumoto commited on
Commit
bdda78d
·
verified ·
1 Parent(s): df639fa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -417,9 +417,16 @@ class CodeGenController:
417
  self.current_files = scaffold["files"]
418
  self.current_code = "\n\n".join(f"# {n}\n{c}" for n, c in self.current_files.items())
419
  self.best_files = dict(self.current_files)
 
 
 
420
  return True
421
- self.current_files = {"main.py": "# New project"}
422
- self.current_code = "# New project"
 
 
 
 
423
  self.best_files = dict(self.current_files)
424
  return False
425
 
@@ -546,10 +553,10 @@ Return the perfected code in META format."""
546
  def format_output(self, log_msg: str, iteration: int, max_iters: int, state: Optional[Dict] = None):
547
  progress = f"Iteration {iteration}/{max_iters if max_iters < 999999 else 'INF'}" if iteration <= max_iters else "Complete"
548
 
549
- main = self.best_files.get("main.py", "")
550
- test = next((v for k, v in self.best_files.items() if 'test' in k and k.endswith('.py')), "")
551
- req = self.best_files.get("requirements.txt", "")
552
- readme = self.best_files.get("README.md", "")
553
  other = {k: v for k, v in self.best_files.items() if k not in [
554
  "main.py", next((k for k in self.best_files if 'test' in k and k.endswith('.py')), None),
555
  "requirements.txt", "README.md"
 
417
  self.current_files = scaffold["files"]
418
  self.current_code = "\n\n".join(f"# {n}\n{c}" for n, c in self.current_files.items())
419
  self.best_files = dict(self.current_files)
420
+ # Ensure we have at least requirements.txt
421
+ if "requirements.txt" not in self.best_files:
422
+ self.best_files["requirements.txt"] = "# Add your requirements here"
423
  return True
424
+ # Better defaults if scaffolding fails
425
+ self.current_files = {
426
+ "main.py": "# New project\n\ndef main():\n print('Hello, World!')\n\nif __name__ == '__main__':\n main()",
427
+ "requirements.txt": "# Add your requirements here"
428
+ }
429
+ self.current_code = "\n\n".join(f"# {n}\n{c}" for n, c in self.current_files.items())
430
  self.best_files = dict(self.current_files)
431
  return False
432
 
 
553
  def format_output(self, log_msg: str, iteration: int, max_iters: int, state: Optional[Dict] = None):
554
  progress = f"Iteration {iteration}/{max_iters if max_iters < 999999 else 'INF'}" if iteration <= max_iters else "Complete"
555
 
556
+ main = self.best_files.get("main.py", "# Generating code...")
557
+ test = next((v for k, v in self.best_files.items() if 'test' in k and k.endswith('.py')), "# No tests yet...")
558
+ req = self.best_files.get("requirements.txt", "# No requirements yet...")
559
+ readme = self.best_files.get("README.md", "# Generating README...")
560
  other = {k: v for k, v in self.best_files.items() if k not in [
561
  "main.py", next((k for k in self.best_files if 'test' in k and k.endswith('.py')), None),
562
  "requirements.txt", "README.md"