INNER CODE UNIT · Python

handle_story_request

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

    async def handle_story_request(self, message: StoryRequest, ctx: MessageContext) -> None:
        try:
            print(f">>> StoryGeneratorAgent: {message.prompt}")
            response = self.client.models.generate_content(
                model="gemini-2.0-flash-exp",
                contents=f"Create a children's story book based on this prompt: {message.prompt}",
                config=types.GenerateContentConfig(
                    system_instruction="""You are a creative children's book writer.
                                Create engaging, age-appropriate stories structured as a book with clear sections.
                                Each section needs a descriptive image that matches the story content. The book MUST HAVE:
                    1. Exactly 2 chapter sections
                    2. Each section must have an engaging title, a level (e.g., "title", "h1", "h2"), appropriate content, and a vivid image description.""",
                    response_mime_type="application/json",
                    response_schema={
                        "required": ["sections"],
                        "properties": {
                            "sections": {
                                "type": "array",

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…