INNER CODE UNIT · Python

generate_image

victordibia/designing-multiagent-systems · course/samples/book_generator/autogen_core/app.py:85

    async def generate_image(self, prompt: str) -> str:
        try:
            images = generate_images(prompt, output_dir=OUTPUT_DIR)
            return images[0] if images else ""
        except Exception as e:
            print(f"Error generating image: {str(e)}")
            return ""

    @message_handler
    async def handle_book_sections(self, message: BookSections, ctx: MessageContext) -> None:
        try:
            print(">>> ImageGeneratorAgent: Generating images for book sections")
            sections_with_images = []
            for section in message.sections:
                image_path = await self.generate_image(section.image) if section.image else None
                sections_with_images.append(Section(
                    title=section.title,
                    level=section.level,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…