youtube-summarizer/backend/services/template_defaults.py

603 lines
22 KiB
Python

"""Default analysis templates for different perspectives and complexity levels."""
from typing import Dict, List
from ..models.analysis_templates import (
AnalysisTemplate,
TemplateSet,
TemplateType,
ComplexityLevel,
TemplateRegistry
)
def create_educational_templates() -> TemplateSet:
"""Create default educational template set with beginner/expert/scholarly perspectives."""
# Beginner's Lens Template
beginner_template = AnalysisTemplate(
id="educational_beginner",
name="Beginner's Lens",
description="Simplified analysis suitable for newcomers to the topic",
template_type=TemplateType.EDUCATIONAL,
complexity_level=ComplexityLevel.BEGINNER,
target_audience="beginners, students, general public",
tone="friendly, encouraging, accessible",
depth="surface",
system_prompt="""You are an educational guide helping beginners understand complex topics.
Your analysis should:
- Use simple, clear language that anyone can understand
- Explain technical terms when they must be used
- Focus on the most important, foundational concepts
- Provide relatable examples and analogies
- Break down complex ideas into digestible steps
- Encourage further learning with "next steps" suggestions
Content Context: {content_type} about {topic}
Target Audience: Complete beginners with no prior knowledge
Format your response as a friendly, encouraging explanation that builds confidence.""",
analysis_focus=[
"Core concepts and fundamentals",
"Simple explanations of key ideas",
"Practical applications beginners can understand",
"Common misconceptions to avoid",
"Next steps for continued learning"
],
output_format="""
## What This Is About (In Simple Terms)
[Clear, jargon-free explanation]
## Key Points You Should Know
- [3-5 fundamental concepts with simple explanations]
## Why This Matters
[Relevance to everyday life or future learning]
## Getting Started
[Actionable first steps for beginners]
## Keep Learning
[Gentle suggestions for next steps]
""",
variables={
"content_type": "video content",
"topic": "the subject matter",
"examples_count": 2,
"use_analogies": True
},
min_insights=3,
max_insights=5,
include_examples=True,
include_recommendations=True,
tags=["educational", "beginner-friendly", "accessible", "foundational"]
)
# Expert's Lens Template
expert_template = AnalysisTemplate(
id="educational_expert",
name="Expert's Lens",
description="In-depth analysis for experienced practitioners",
template_type=TemplateType.EDUCATIONAL,
complexity_level=ComplexityLevel.EXPERT,
target_audience="professionals, experienced practitioners, industry experts",
tone="professional, technical, precise",
depth="deep",
system_prompt="""You are a seasoned expert providing advanced analysis for fellow professionals.
Your analysis should:
- Use precise technical language and industry terminology
- Identify subtle nuances and advanced implications
- Connect concepts to broader industry trends and patterns
- Highlight strategic considerations and trade-offs
- Provide actionable insights for professional application
- Reference best practices and proven methodologies
Content Context: {content_type} about {topic}
Target Audience: Experienced professionals seeking advanced insights
Format your response as a comprehensive professional analysis with strategic depth.""",
analysis_focus=[
"Advanced technical concepts and methodologies",
"Strategic implications and business impact",
"Industry trends and competitive landscape",
"Implementation challenges and solutions",
"Performance optimization and best practices",
"Risk assessment and mitigation strategies"
],
output_format="""
## Executive Summary
[Concise overview of key strategic points]
## Technical Analysis
[Detailed technical breakdown with precision]
## Strategic Implications
- [5-7 actionable professional insights]
## Implementation Considerations
[Practical guidance for professional application]
## Industry Context
[Broader trends, competitive positioning, future outlook]
## Recommendations
[Specific next steps for experienced practitioners]
""",
variables={
"content_type": "video content",
"topic": "the subject matter",
"industry_context": True,
"technical_depth": "advanced"
},
min_insights=5,
max_insights=8,
include_examples=True,
include_recommendations=True,
tags=["professional", "advanced", "strategic", "technical-depth"]
)
# Scholarly Lens Template
scholarly_template = AnalysisTemplate(
id="educational_scholarly",
name="Scholarly Lens",
description="Academic analysis with theoretical frameworks and research connections",
template_type=TemplateType.EDUCATIONAL,
complexity_level=ComplexityLevel.SCHOLARLY,
target_audience="researchers, academics, graduate students",
tone="academic, analytical, rigorous",
depth="comprehensive",
system_prompt="""You are an academic researcher providing scholarly analysis with theoretical rigor.
Your analysis should:
- Apply relevant theoretical frameworks and models
- Connect content to established research and literature
- Identify gaps in knowledge or areas for further investigation
- Use precise academic language and methodology
- Provide critical evaluation of claims and evidence
- Suggest research questions and hypotheses for further study
Content Context: {content_type} about {topic}
Target Audience: Academic researchers and advanced scholars
Format your response as a rigorous academic analysis with proper theoretical grounding.""",
analysis_focus=[
"Theoretical frameworks and models",
"Research methodology and evidence quality",
"Literature connections and scholarly context",
"Critical analysis of claims and assumptions",
"Epistemological considerations",
"Research gaps and future investigation opportunities"
],
output_format="""
## Abstract
[Concise academic summary of key findings]
## Theoretical Framework
[Relevant theories, models, and academic context]
## Critical Analysis
[Rigorous examination of content, methodology, claims]
## Literature Connections
[Links to existing research and scholarly work]
## Research Implications
- [3-5 scholarly insights and research questions]
## Future Research Directions
[Specific areas for academic investigation]
## Conclusion
[Academic synthesis and scholarly significance]
""",
variables={
"content_type": "video content",
"topic": "the subject matter",
"theoretical_frameworks": True,
"literature_connections": True,
"research_methodology": "qualitative analysis"
},
min_insights=4,
max_insights=6,
include_examples=True,
include_recommendations=True,
tags=["academic", "theoretical", "research-oriented", "scholarly"]
)
# Synthesis Template for Educational Progression
synthesis_template = AnalysisTemplate(
id="educational_synthesis",
name="Educational Synthesis",
description="Synthesizes beginner/expert/scholarly perspectives into progressive learning path",
template_type=TemplateType.EDUCATIONAL,
target_audience="learners at all levels",
tone="educational, scaffolding, progressive",
depth="comprehensive",
system_prompt="""You are an educational designer creating a comprehensive learning progression.
Your synthesis should:
- Create a logical learning pathway from beginner to expert to scholarly levels
- Identify connections and progressions between different complexity levels
- Highlight how understanding deepens across perspectives
- Provide guidance for learners at different stages
- Show the intellectual journey from basic to advanced understanding
Previous Analysis Results:
- Beginner Perspective: {beginner_analysis}
- Expert Perspective: {expert_analysis}
- Scholarly Perspective: {scholarly_analysis}
Create a unified educational experience that honors all levels of understanding.""",
analysis_focus=[
"Learning progression and scaffolding",
"Conceptual connections across complexity levels",
"Educational pathways and milestones",
"Skill and knowledge development trajectory",
"Intellectual maturation process"
],
output_format="""
## Learning Journey Overview
[How understanding evolves from beginner to scholarly level]
## Progressive Understanding
### Foundation Level (Beginner)
[Key concepts and starting points]
### Practitioner Level (Expert)
[Advanced application and professional insights]
### Research Level (Scholarly)
[Theoretical understanding and research implications]
## Connections and Progressions
[How concepts build upon each other]
## Personalized Learning Paths
[Recommendations based on current knowledge level]
## The Complete Picture
[Unified synthesis showing the full spectrum of understanding]
""",
variables={
"beginner_analysis": "",
"expert_analysis": "",
"scholarly_analysis": ""
},
min_insights=4,
max_insights=6,
include_examples=True,
include_recommendations=True,
tags=["synthesis", "progressive-learning", "educational-design", "scaffolding"]
)
# Create the educational template set
educational_set = TemplateSet(
id="educational_perspectives",
name="Educational Perspectives",
description="Three-tier educational analysis: Beginner's Lens, Expert's Lens, and Scholarly Lens",
template_type=TemplateType.EDUCATIONAL,
templates={
"educational_beginner": beginner_template,
"educational_expert": expert_template,
"educational_scholarly": scholarly_template
},
synthesis_template=synthesis_template,
execution_order=["educational_beginner", "educational_expert", "educational_scholarly"],
parallel_execution=True
)
return educational_set
def create_domain_templates() -> TemplateSet:
"""Create default domain-specific template set (Technical/Business/UX)."""
# Technical Domain Template
technical_template = AnalysisTemplate(
id="domain_technical",
name="Technical Analysis",
description="Technical implementation and engineering perspective",
template_type=TemplateType.DOMAIN,
target_audience="developers, engineers, technical professionals",
tone="technical, precise, implementation-focused",
depth="deep",
system_prompt="""You are a senior technical architect analyzing content from an engineering perspective.
Focus on:
- Technical implementation details and architecture
- Code quality, performance, and scalability considerations
- Technology stack choices and technical trade-offs
- Security, maintainability, and technical debt
- Development processes and engineering best practices
Content Context: {content_type} about {topic}
Provide actionable technical insights for engineering teams.""",
analysis_focus=[
"Technical architecture and design patterns",
"Implementation details and code quality",
"Performance and scalability considerations",
"Security and reliability aspects",
"Development workflow and tooling",
"Technical debt and maintenance implications"
],
output_format="""
## Technical Overview
[Architecture and implementation summary]
## Key Technical Insights
- [Technical findings and observations]
## Implementation Considerations
[Practical guidance for development teams]
## Performance & Scalability
[Optimization recommendations]
## Technical Recommendations
[Specific next steps for engineers]
""",
variables={
"content_type": "video content",
"topic": "the technical subject"
},
tags=["technical", "engineering", "implementation", "architecture"]
)
# Business Domain Template
business_template = AnalysisTemplate(
id="domain_business",
name="Business Analysis",
description="Business value and strategic perspective",
template_type=TemplateType.DOMAIN,
target_audience="business leaders, product managers, stakeholders",
tone="business-focused, strategic, ROI-oriented",
depth="strategic",
system_prompt="""You are a business strategist analyzing content for its business implications and value.
Focus on:
- Business value proposition and ROI potential
- Market opportunities and competitive advantages
- Risk assessment and business impact
- Strategic alignment with business objectives
- Cost-benefit analysis and resource requirements
Content Context: {content_type} about {topic}
Provide actionable business insights for decision makers.""",
analysis_focus=[
"Business value and ROI potential",
"Market opportunities and competitive landscape",
"Strategic alignment and business impact",
"Risk assessment and mitigation",
"Resource requirements and cost analysis",
"Stakeholder considerations and change management"
],
output_format="""
## Business Summary
[Strategic overview and value proposition]
## Key Business Insights
- [Business findings and opportunities]
## Strategic Implications
[Impact on business strategy and goals]
## Risk & ROI Assessment
[Business case and risk evaluation]
## Business Recommendations
[Strategic next steps for leadership]
""",
variables={
"content_type": "video content",
"topic": "the business subject"
},
tags=["business", "strategic", "ROI", "market-analysis"]
)
# UX Domain Template
ux_template = AnalysisTemplate(
id="domain_ux",
name="User Experience Analysis",
description="User experience and usability perspective",
template_type=TemplateType.DOMAIN,
target_audience="UX designers, product managers, user researchers",
tone="user-centered, empathetic, design-focused",
depth="user-focused",
system_prompt="""You are a UX researcher analyzing content from a user experience perspective.
Focus on:
- User needs, pain points, and journey considerations
- Usability principles and accessibility requirements
- User interface design and interaction patterns
- User research insights and behavioral implications
- Design system and user experience consistency
Content Context: {content_type} about {topic}
Provide actionable UX insights for design and product teams.""",
analysis_focus=[
"User needs and pain point analysis",
"Usability and accessibility considerations",
"User interface and interaction design",
"User journey and experience flow",
"User research and behavioral insights",
"Design system and consistency principles"
],
output_format="""
## User Experience Summary
[Overview of user-centered findings]
## Key UX Insights
- [User experience observations and opportunities]
## Usability Considerations
[Accessibility and usability recommendations]
## User Journey Impact
[Effects on user experience and satisfaction]
## UX Recommendations
[Design and user experience next steps]
""",
variables={
"content_type": "video content",
"topic": "the user experience subject"
},
tags=["UX", "user-experience", "design", "usability", "accessibility"]
)
# Domain Synthesis Template
domain_synthesis_template = AnalysisTemplate(
id="domain_synthesis",
name="Domain Perspective Synthesis",
description="Synthesizes technical, business, and UX perspectives into unified recommendations",
template_type=TemplateType.DOMAIN,
target_audience="cross-functional teams, decision makers",
tone="strategic, balanced, actionable",
depth="comprehensive",
system_prompt="""You are a strategic synthesis expert combining technical, business, and user experience perspectives.
Your synthesis should:
- Identify synergies and conflicts between technical, business, and UX considerations
- Provide balanced recommendations that consider all three domains
- Highlight critical decision points requiring cross-functional collaboration
- Offer implementation roadmaps that balance technical feasibility, business value, and user impact
Previous Analysis Results:
- Technical Perspective: {domain_technical_analysis}
- Business Perspective: {domain_business_analysis}
- UX Perspective: {domain_ux_analysis}
Create a unified strategic perspective that enables informed decision-making.""",
analysis_focus=[
"Cross-domain synergies and trade-offs",
"Strategic decision points and priorities",
"Implementation feasibility and timelines",
"Risk assessment across all domains",
"Resource allocation and optimization"
],
output_format="""
## Strategic Overview
[Unified perspective integrating all domain insights]
## Cross-Domain Analysis
### Technical-Business Alignment
[How technical capabilities align with business goals]
### Business-UX Synergies
[How business objectives support user experience]
### Technical-UX Considerations
[How technical implementation affects user experience]
## Strategic Recommendations
[Prioritized recommendations balancing all perspectives]
## Implementation Roadmap
[Sequenced approach considering technical, business, and UX factors]
## Decision Framework
[Framework for future cross-functional decisions]
""",
variables={
"domain_technical_analysis": "",
"domain_business_analysis": "",
"domain_ux_analysis": ""
},
min_insights=4,
max_insights=8,
include_examples=True,
include_recommendations=True,
tags=["synthesis", "strategic", "cross-functional", "domain-integration"]
)
# Create domain template set
domain_set = TemplateSet(
id="domain_perspectives",
name="Domain Perspectives",
description="Domain-specific analysis: Technical, Business, and User Experience with strategic synthesis",
template_type=TemplateType.DOMAIN,
templates={
"domain_technical": technical_template,
"domain_business": business_template,
"domain_ux": ux_template
},
synthesis_template=domain_synthesis_template,
execution_order=["domain_technical", "domain_business", "domain_ux"],
parallel_execution=True
)
return domain_set
def create_default_registry() -> TemplateRegistry:
"""Create a template registry with all default templates."""
registry = TemplateRegistry()
# Add educational template set
educational_set = create_educational_templates()
registry.register_template_set(educational_set)
# Register individual educational templates
for template in educational_set.templates.values():
registry.register_template(template)
if educational_set.synthesis_template:
registry.register_template(educational_set.synthesis_template)
# Add domain template set
domain_set = create_domain_templates()
registry.register_template_set(domain_set)
# Register individual domain templates
for template in domain_set.templates.values():
registry.register_template(template)
if domain_set.synthesis_template:
registry.register_template(domain_set.synthesis_template)
return registry
# Export default templates for easy access
DEFAULT_EDUCATIONAL_TEMPLATES = create_educational_templates()
DEFAULT_DOMAIN_TEMPLATES = create_domain_templates()
DEFAULT_REGISTRY = create_default_registry()