MCPcopy Index your code
hub / github.com/showlab/Code2Video / render_section

Method render_section

src/agent.py:527–580  ·  view source on GitHub ↗
(self, section: Section)

Source from the content-addressed store, hash-verified

525 return self.section_codes
526
527 def render_section(self, section: Section) -> bool:
528 section_id = section.id
529
530 try:
531 success = False
532 for regenerate_attempt in range(self.max_regenerate_tries):
533 # print(f"🎯 Processing {section_id} (regenerate attempt {regenerate_attempt + 1}/{self.max_regenerate_tries})")
534 try:
535 if regenerate_attempt > 0:
536 self.generate_section_code(section, attempt=regenerate_attempt + 1)
537 success = self.debug_and_fix_code(section_id, max_fix_attempts=self.max_fix_bug_tries)
538 if success:
539 break
540 else:
541 pass
542 except Exception as e:
543 print(f"⚠️ {section_id} attempt {regenerate_attempt + 1} raised exception: {str(e)}")
544 continue
545 if not success:
546 print(f"❌{self.learning_topic} {section_id} all failed, skipping section")
547 return False
548
549 # MLLM feedback
550 if self.use_feedback:
551 try:
552 for round in range(self.feedback_rounds):
553 current_video = self.section_videos.get(section_id)
554 if not current_video:
555 print(f"❌ {self.learning_topic} {section_id} no video available for MLLM feedback")
556 return success
557 try:
558 feedback = self.get_mllm_feedback(section, current_video, round_number=round + 1)
559
560 optimization_success = self.optimize_with_feedback(section, feedback)
561 if optimization_success:
562 pass
563 else:
564 print(
565 f"⚠️ {self.learning_topic} {section_id} round {round+1} MLLM feedback optimization failed, using current version"
566 )
567 except Exception as e:
568 print(
569 f"⚠️ {self.learning_topic} {section_id} round {round+1} MLLM feedback processing exception: {str(e)}"
570 )
571 continue
572
573 except Exception as e:
574 print(f"⚠️ {self.learning_topic} {section_id} MLLM feedback processing exception: {str(e)}")
575
576 return success
577
578 except Exception as e:
579 print(f"❌ {self.learning_topic} {section_id} render process exception: {str(e)}")
580 return False
581
582 def render_section_worker(self, section_data) -> Tuple[str, bool, Optional[str]]:
583 section_id = "unknown"

Callers 1

render_section_workerMethod · 0.80

Calls 4

generate_section_codeMethod · 0.95
debug_and_fix_codeMethod · 0.95
get_mllm_feedbackMethod · 0.95

Tested by

no test coverage detected