Dựa vào prompt này hãy thiết kế một Pydantic model cho lecture draft phù hợp: content_creation_prompt = """Role: Content Creation Agent
Objective: Create engaging and structured presentation slides based on the structure and topic analysis, keyword extraction, and the processed text from previous steps.
Additionally, include a final slide containing all extracted keywords for learners to reference terminology.
Instructions:
Input:
structure_and_topic: The output from the Content Structuring & Topic Agent, detailing the logical structure, main topics, subtopics, and related concepts.
keyword: The output from the Keyword Extraction Agent, including important keywords and their simplified technical terms.
processed_text: The cleaned and structured text output from Step 1, maintaining a conversational tone and preserving all source citations.
Responsibilities: As a Content Creation Agent, your tasks are as follows:
1. Simplify & Design Content
Convert Technical Terms:
Utilize the keyword list to transform specialized terminology into familiar and relatable scenarios.
Example: "momentum burst" ➔ "sprint"
Example: "volatility" ➔ "roller coaster ride"
Develop Stories and Examples:
Craft engaging narratives and illustrative examples to explain complex concepts, leveraging the simplified terms.
Create Characters/Personas:
Introduce characters or personas that can embody and demonstrate strategic ideas related to the main topics.
Build Metaphors and Analogies:
Use easy-to-understand metaphors and analogies to simplify abstract concepts, based on the related concepts from structure_and_topic.
Design Highlight Information Boxes:
Create boxes containing 2-3 concise sentences that summarize key points for each slide.
2. Create Engaging Slides
For each identified topic and subtopic from the structure_and_topic, create a slide that includes the following elements:
Title:
Assistant
Craft an engaging and clear headline that grabs attention and accurately reflects the slide’s content.
Content:
Main Text: Write in a conversational, natural, and friendly tone, incorporating simplified technical terms from the keyword list.
Real-life Examples/Cases: Incorporate practical examples or stories that illustrate the concept, using relatable scenarios.
Metaphors and Visual Analogies: Use visual and relatable comparisons to explain ideas, enhancing understanding.
Highlight Information Box: Include a box that succinctly summarizes the main points of the slide.
Resource Links:
Include Resource Links if Available: Add links to credible sources referenced in the original text. Ensure that resource links are always included if they are present in the processed_text.
Format: Present resource links in a clear and accessible manner, such as a bulleted list or within the content where relevant.
Image: (Optional)
Provide a description of an illustrative image or infographic that complements the slide content and aids visual learning.
Name:
Assign a unique identifier or name to each slide for easy reference and organization.
3. Create Keywords Glossary Slide(s)
After creating all content slides, create one or more final slides dedicated to listing all extracted keywords and their simplified explanations to aid learners in understanding and referencing terminology.
Title:
Use a clear and descriptive title such as "Glossary of Terms" or "Key Terminology."
Content:
Keyword List: Present a list of all extracted keywords.
Definitions/Simplifications: For each keyword, provide its simplified term or a brief explanation.
Example:
Momentum Burst: Sprint
Volatility: Roller Coaster Ride
Design:
Organize the keywords in a readable format, such as a table or bullet points.
Ensure that the glossary is easy to navigate and reference.
Image: (Optional)
Include relevant icons or visuals that represent the glossary concept.
Name:
Assign a unique identifier or name to the glossary slide(s), such as "Glossary Slide 1."
4. Ensure Each Slide Meets the Following Criteria:
Conversational Tone:
Use natural language that fosters a personal connection with the audience, making the content approachable and engaging.
Memorable Content:
Include real-life examples, metaphors, and stories that make the content memorable and easier to recall.
Compelling Headlines:
Develop headlines that are both attractive and clearly convey the slide’s purpose, enticing the audience to engage with the content.
Visual Elements:
Suggest appropriate images or infographics that enhance understanding and retention of the information presented.
Highlight Information:
Ensure the summary boxes effectively capture and convey the key points, providing quick takeaways for the audience.
Credibility:
Integrate and reference credible sources from the processed_text to maintain trustworthiness and authority of the information presented.
Resource Links:
Ensure that every slide includes resource links if they are available in the processed_text. Resource links should be relevant, properly formatted, and enhance the credibility of the slide content.
Output:
Provide a comprehensive list of slides, each containing the following components:
Title
Content
Main Text
Real-life Examples/Cases
Metaphors and Visual Analogies
Highlight Information Box
Resource Links (if available)
Image Description (if applicable)
Slide Name
Ensure that the final slide(s) include a complete glossary of all extracted keywords with their simplified terms or definitions.
Input:
Structure and Topic Analysis:
{structure_and_topic}
Keyword Extraction:
{keyword}
Processed Text:
{processed_text}
Note:
Ensure that all slides are cohesive, follow a logical flow based on the structure_and_topic, and collectively convey the intended message effectively.
Utilize the simplified terms from the keyword list to make the content more accessible and engaging.
Maintain the integrity and credibility of the original content by accurately representing information and properly citing sources.
The final glossary slide(s) should be clearly distinguished from the main content slides and serve as a reliable reference for learners to look up terminology.
Resource Links Inclusion: Each slide should always include resource links if they are available in the processed_text. Ensure that these links are relevant and directly support the slide's content.
"""
Certainly! Below is a comprehensive Pydantic model designed to represent the Lecture Draft as described in your content_creation_prompt. This model captures all necessary components, including content slides and glossary slides, ensuring a structured and organized representation of the lecture material.
Overview of the Pydantic Models
LectureDraft: The root model containing a list of slides.
SlideBase: An abstract base class for different types of slides, utilizing a discriminant field type to differentiate between slide types.
ContentSlide: Represents standard content slides with various content sections.
GlossarySlide: Represents glossary slides dedicated to terminology.
SlideContent: Encapsulates the different content sections within a content slide.
GlossaryEntry: Represents individual keyword-definition pairs in the glossary.
Pydantic Models
python
from typing import List, Optional, Union, Literal
from pydantic import BaseModel, Field
class GlossaryEntry(BaseModel):
"""
Represents a single glossary entry with a keyword and its simplified definition.
"""
keyword: str = Field(..., description="The technical term extracted from the content.")
definition: str = Field(..., description="The simplified term or explanation of the keyword.")
class SlideContent(BaseModel):
"""
Encapsulates the various content sections within a standard content slide.
"""
main_text: str = Field(..., description="The primary explanatory text of the slide.")
real_life_examples: Optional[str] = Field(None, description="Practical examples or cases illustrating the concept.")
metaphors: Optional[str] = Field(None, description="Metaphors or visual analogies to simplify abstract ideas.")
highlight_info_box: Optional[str] = Field(None, description="A concise summary of key points for quick reference.")
resource_links: Optional[List[str]] = Field(
None,
description="A list of credible resource URLs referenced in the slide."
)
class SlideBase(BaseModel):
"""
Abstract base class for different types of slides.
Utilizes a discriminant field 'type' to differentiate between slide types.
"""
type: Literal["content", "glossary"] = Field(..., description="The type of the slide, either 'content' or 'glossary'.")
title: str = Field(..., description="The headline of the slide.")
image_description: Optional[str] = Field(
None,
description="A description of an illustrative image or infographic for the slide."
)
slide_name: str = Field(..., description="A unique identifier or name for the slide.")
class ContentSlide(SlideBase):
"""
Represents a standard content slide with various sections.
"""
type: Literal["content"] = "content"
content: SlideContent = Field(..., description="The detailed content of the slide.")
class GlossarySlide(SlideBase):
"""
Represents a glossary slide containing a list of terms and their definitions.
"""
type: Literal["glossary"] = "glossary"
glossary: List[GlossaryEntry] = Field(..., description="A list of glossary entries with keywords and definitions.")
class LectureDraft(BaseModel):
"""
The root model representing the entire lecture draft containing multiple slides.
"""
slides: List[Union[ContentSlide, GlossarySlide]] = Field(
...,
description="A list of slides composing the lecture, including both content and glossary slides."
)
class Config:
schema_extra = {
"example": {
"slides": [
{
"type": "content",
"title": "Introduction to Momentum Burst",
"content": {
"main_text": "Momentum Burst refers to a rapid acceleration in performance...",
"real_life_examples": "Consider a sprinter in the 100m dash...",
"metaphors": "Think of Momentum Burst as the initial push of a roller coaster.",
"highlight_info_box": "Key Point: Momentum Burst can significantly impact overall performance.",
"resource_links": [
"https://example.com/momentum-burst-study",
"https://example.com/sprint-techniques"
]
},
"image_description": "An image of a sprinter exploding off the starting blocks.",
"slide_name": "Slide 1"
},
{
"type": "glossary",
"title": "Glossary of Terms",
"glossary": [
{
"keyword": "Momentum Burst",
"definition": "Sprint"
},
{
"keyword": "Volatility",
"definition": "Roller Coaster Ride"
}
],
"image_description": "Icons representing different glossary terms.",
"slide_name": "Glossary Slide 1"
}
]
}
}
Explanation of the Models
GlossaryEntry:
keyword: The technical term extracted from the lecture content.
definition: The simplified explanation or relatable term corresponding to the keyword.
SlideContent:
main_text: The central explanatory text of a content slide, written in a conversational tone.
real_life_examples: (Optional) Practical examples or case studies that illustrate the concept discussed.
metaphors: (Optional) Metaphors or analogies that simplify complex ideas.
highlight_info_box: (Optional) A concise summary box that captures key points for quick reference.
resource_links: (Optional) A list of URLs linking to credible resources or references relevant to the slide's content.
SlideBase:
type: Discriminant field to differentiate between content and glossary slides.
title: The headline of the slide designed to grab attention.
image_description: (Optional) A description of an image or infographic that complements the slide content.
slide_name: A unique identifier for the slide, facilitating easy reference and organization.
ContentSlide:
Inherits from SlideBase.
type: Fixed as "content" to identify the slide type.
content: An instance of SlideContent containing detailed sections of the slide.
GlossarySlide:
Inherits from SlideBase.
type: Fixed as "glossary" to identify the slide type.
glossary: A list of GlossaryEntry items, each representing a keyword and its definition.
LectureDraft:
slides: A list containing instances of either ContentSlide or GlossarySlide. This allows the lecture to comprise a mix of standard content slides and specialized glossary slides.
Usage Example
Here's how you might create an instance of LectureDraft using the provided models:
python
from pydantic import ValidationError
# Example data matching the LectureDraft model
example_data = {
"slides": [
{
"type": "content",
"title": "Introduction to Momentum Burst",
"content": {
"main_text": "Momentum Burst refers to a rapid acceleration in performance...",
"real_life_examples": "Consider a sprinter in the 100m dash...",
"metaphors": "Think of Momentum Burst as the initial push of a roller coaster.",
"highlight_info_box": "Key Point: Momentum Burst can significantly impact overall performance.",
"resource_links": [
"https://example.com/momentum-burst-study",
"https://example.com/sprint-techniques"
]
},
"image_description": "An image of a sprinter exploding off the starting blocks.",
"slide_name": "Slide 1"
},
{
"type": "glossary",
"title": "Glossary of Terms",
"glossary": [
{
"keyword": "Momentum Burst",
"definition": "Sprint"
},
{
"keyword": "Volatility",
"definition": "Roller Coaster Ride"
}
],
"image_description": "Icons representing different glossary terms.",
"slide_name": "Glossary Slide 1"
}
]
}
try:
lecture = LectureDraft(**example_data)
print(lecture.json(indent=4))
except ValidationError as e:
print(e.json())
Validation and Error Handling
The models include field validations and descriptive metadata. For instance:
The type field in SlideBase ensures that only "content" or "glossary" are acceptable, preventing invalid slide types.
Required fields (marked with ...) must be provided; otherwise, Pydantic will raise a ValidationError.
Optional fields are gracefully handled, allowing flexibility in slide content.
Benefits of This Model
Clarity and Organization: Separating content slides from glossary slides ensures a well-structured lecture.
Flexibility: Easily extendable to include more slide types in the future by adding new subclasses of SlideBase.
Validation: Ensures that all necessary fields are present and correctly formatted, reducing potential errors during content creation.
Documentation: Descriptive Field metadata aids in understanding the purpose of each attribute, which is beneficial for developers and content creators alike.
This Pydantic model should serve as a robust foundation for managing lecture drafts, facilitating seamless integration with content creation pipelines, and ensuring consistency across your presentation slides.