ALwrity Prompts - AI Integration Plan

This commit is contained in:
ajaysi
2025-09-03 23:16:39 +05:30
parent 5efee4235d
commit c19fc3f225
104 changed files with 9392 additions and 17462 deletions

View File

@@ -0,0 +1,24 @@
"""
Content Generator Prompts Package
This package contains all the prompt templates and generation logic used by the ContentGenerator class
for generating various types of LinkedIn content.
"""
from .post_prompts import PostPromptBuilder
from .article_prompts import ArticlePromptBuilder
from .carousel_prompts import CarouselPromptBuilder
from .video_script_prompts import VideoScriptPromptBuilder
from .comment_response_prompts import CommentResponsePromptBuilder
from .carousel_generator import CarouselGenerator
from .video_script_generator import VideoScriptGenerator
__all__ = [
'PostPromptBuilder',
'ArticlePromptBuilder',
'CarouselPromptBuilder',
'VideoScriptPromptBuilder',
'CommentResponsePromptBuilder',
'CarouselGenerator',
'VideoScriptGenerator'
]

View File

@@ -0,0 +1,65 @@
"""
LinkedIn Article Generation Prompts
This module contains prompt templates and builders for generating LinkedIn articles.
"""
from typing import Any
class ArticlePromptBuilder:
"""Builder class for LinkedIn article generation prompts."""
@staticmethod
def build_article_prompt(request: Any) -> str:
"""
Build prompt for article generation.
Args:
request: LinkedInArticleRequest object containing generation parameters
Returns:
Formatted prompt string for article generation
"""
prompt = f"""
You are a senior content strategist and industry expert specializing in {request.industry}. Create a comprehensive, thought-provoking LinkedIn article that establishes authority, drives engagement, and provides genuine value to professionals in this field.
TOPIC: {request.topic}
INDUSTRY: {request.industry}
TONE: {request.tone}
TARGET AUDIENCE: {request.target_audience or 'Industry professionals, executives, and thought leaders'}
WORD COUNT: {request.word_count} words
CONTENT STRUCTURE:
- Compelling headline that promises specific value
- Engaging introduction with a hook and clear value proposition
- 3-5 main sections with actionable insights and examples
- Data-driven insights with proper citations
- Practical takeaways and next steps
- Strong conclusion with a call-to-action
CONTENT QUALITY REQUIREMENTS:
- Include current industry statistics and trends (2024-2025)
- Provide real-world examples and case studies
- Address common challenges and pain points
- Offer actionable strategies and frameworks
- Use industry-specific terminology appropriately
- Include expert quotes or insights when relevant
SEO & ENGAGEMENT OPTIMIZATION:
- Use relevant keywords naturally throughout the content
- Include engaging subheadings for scannability
- Add bullet points and numbered lists for key insights
- Include relevant hashtags for discoverability
- End with thought-provoking questions to encourage comments
VISUAL ELEMENTS:
- Suggest 2-3 relevant images or graphics
- Recommend data visualization opportunities
- Include pull quotes for key insights
KEY SECTIONS TO COVER: {', '.join(request.key_sections) if request.key_sections else 'Industry overview, current challenges, emerging trends, practical solutions, future outlook'}
REMEMBER: This article should position the author as a thought leader while providing actionable insights that readers can immediately apply in their professional lives.
"""
return prompt.strip()

View File

@@ -0,0 +1,112 @@
"""
LinkedIn Carousel Generation Module
This module handles the generation of LinkedIn carousels with all processing steps.
"""
from typing import Dict, Any, List
from datetime import datetime
from loguru import logger
from services.linkedin.quality_handler import QualityHandler
class CarouselGenerator:
"""Handles LinkedIn carousel generation with all processing steps."""
def __init__(self, citation_manager=None, quality_analyzer=None):
self.citation_manager = citation_manager
self.quality_analyzer = quality_analyzer
async def generate_carousel(
self,
request,
research_sources: List,
research_time: float,
content_result: Dict[str, Any],
grounding_enabled: bool
):
"""Generate LinkedIn carousel with all processing steps."""
try:
start_time = datetime.now()
# Step 3: Add citations if requested
citations = []
source_list = None
if request.include_citations and research_sources:
# Extract citations from all slides
all_content = " ".join([slide['content'] for slide in content_result['slides']])
citations = self.citation_manager.extract_citations(all_content) if self.citation_manager else []
source_list = self.citation_manager.generate_source_list(research_sources) if self.citation_manager else None
# Step 4: Analyze content quality
quality_metrics = None
if grounding_enabled and self.quality_analyzer:
try:
all_content = " ".join([slide['content'] for slide in content_result['slides']])
quality_handler = QualityHandler(self.quality_analyzer)
quality_metrics = quality_handler.create_quality_metrics(
content=all_content,
sources=research_sources,
industry=request.industry,
grounding_enabled=grounding_enabled
)
except Exception as e:
logger.warning(f"Quality analysis failed: {e}")
# Step 5: Build response
slides = []
for i, slide_data in enumerate(content_result['slides']):
slide_citations = []
if request.include_citations and research_sources and self.citation_manager:
slide_citations = self.citation_manager.extract_citations(slide_data['content'])
slides.append({
'slide_number': i + 1,
'title': slide_data['title'],
'content': slide_data['content'],
'visual_elements': slide_data.get('visual_elements', []),
'design_notes': slide_data.get('design_notes'),
'citations': slide_citations
})
carousel_content = {
'title': content_result['title'],
'slides': slides,
'cover_slide': content_result.get('cover_slide'),
'cta_slide': content_result.get('cta_slide'),
'design_guidelines': content_result.get('design_guidelines', {}),
'citations': citations,
'source_list': source_list,
'quality_metrics': quality_metrics,
'grounding_enabled': grounding_enabled
}
generation_time = (datetime.now() - start_time).total_seconds()
# Build grounding status
grounding_status = {
'status': 'success' if grounding_enabled else 'disabled',
'sources_used': len(research_sources),
'citation_coverage': len(citations) / max(len(research_sources), 1) if research_sources else 0,
'quality_score': quality_metrics.overall_score if quality_metrics else 0.0
} if grounding_enabled else None
return {
'success': True,
'data': carousel_content,
'research_sources': research_sources,
'generation_metadata': {
'model_used': 'gemini-2.0-flash-001',
'generation_time': generation_time,
'research_time': research_time,
'grounding_enabled': grounding_enabled
},
'grounding_status': grounding_status
}
except Exception as e:
logger.error(f"Error generating LinkedIn carousel: {str(e)}")
return {
'success': False,
'error': f"Failed to generate LinkedIn carousel: {str(e)}"
}

View File

@@ -0,0 +1,63 @@
"""
LinkedIn Carousel Generation Prompts
This module contains prompt templates and builders for generating LinkedIn carousels.
"""
from typing import Any
class CarouselPromptBuilder:
"""Builder class for LinkedIn carousel generation prompts."""
@staticmethod
def build_carousel_prompt(request: Any) -> str:
"""
Build prompt for carousel generation.
Args:
request: LinkedInCarouselRequest object containing generation parameters
Returns:
Formatted prompt string for carousel generation
"""
prompt = f"""
You are a visual content strategist and {request.industry} industry expert. Create a compelling LinkedIn carousel that tells a cohesive story and drives engagement through visual storytelling and valuable insights.
TOPIC: {request.topic}
INDUSTRY: {request.industry}
TONE: {request.tone}
TARGET AUDIENCE: {request.target_audience or 'Industry professionals and decision-makers'}
NUMBER OF SLIDES: {request.number_of_slides}
INCLUDE COVER SLIDE: {request.include_cover_slide}
INCLUDE CTA SLIDE: {request.include_cta_slide}
CAROUSEL STRUCTURE & DESIGN:
- Cover Slide: Compelling headline with visual hook and clear value proposition
- Content Slides: Each slide should focus on ONE key insight with supporting data
- Visual Flow: Create a logical progression that builds understanding
- CTA Slide: Clear next steps and engagement prompts
CONTENT REQUIREMENTS PER SLIDE:
- Maximum 3-4 bullet points per slide for readability
- Include relevant statistics, percentages, or data points
- Use action-oriented language and specific examples
- Each slide should be self-contained but contribute to the overall narrative
VISUAL DESIGN GUIDELINES:
- Suggest color schemes that match the industry (professional yet engaging)
- Recommend icon styles and visual elements for each slide
- Include layout suggestions (text placement, image positioning)
- Suggest data visualization opportunities (charts, graphs, infographics)
ENGAGEMENT STRATEGY:
- Include thought-provoking questions on key slides
- Suggest interactive elements (polls, surveys, comment prompts)
- Use storytelling elements to create emotional connection
- End with clear call-to-action and hashtag suggestions
KEY INSIGHTS TO COVER: {', '.join(request.key_points) if request.key_points else 'Industry trends, challenges, solutions, and opportunities'}
REMEMBER: Each slide should be visually appealing, informative, and encourage the viewer to continue reading. The carousel should provide immediate value while building anticipation for the next slide.
"""
return prompt.strip()

View File

@@ -0,0 +1,64 @@
"""
LinkedIn Comment Response Generation Prompts
This module contains prompt templates and builders for generating LinkedIn comment responses.
"""
from typing import Any
class CommentResponsePromptBuilder:
"""Builder class for LinkedIn comment response generation prompts."""
@staticmethod
def build_comment_response_prompt(request: Any) -> str:
"""
Build prompt for comment response generation.
Args:
request: LinkedInCommentResponseRequest object containing generation parameters
Returns:
Formatted prompt string for comment response generation
"""
prompt = f"""
You are a {request.industry} industry expert and LinkedIn engagement specialist. Create a thoughtful, professional comment response that adds genuine value to the conversation and encourages further engagement.
ORIGINAL COMMENT: "{request.original_comment}"
POST CONTEXT: {request.post_context}
INDUSTRY: {request.industry}
TONE: {request.tone}
RESPONSE LENGTH: {request.response_length}
INCLUDE QUESTIONS: {request.include_questions}
RESPONSE STRATEGY:
- Acknowledge the commenter's perspective or question
- Provide specific, actionable insights or examples
- Share relevant industry knowledge or experience
- Encourage further discussion and engagement
- Maintain professional yet conversational tone
CONTENT REQUIREMENTS:
- Start with appreciation or acknowledgment of the comment
- Include 1-2 specific insights that add value
- Use industry-specific examples when relevant
- End with a thought-provoking question or invitation to continue
- Keep the tone consistent with the original post
ENGAGEMENT TECHNIQUES:
- Ask follow-up questions that encourage response
- Share relevant statistics or data points
- Include personal experiences or case studies
- Suggest additional resources or next steps
- Use inclusive language that welcomes others to join
PROFESSIONAL GUIDELINES:
- Always be respectful and constructive
- Avoid controversial or polarizing statements
- Focus on building relationships, not just responding
- Demonstrate expertise without being condescending
- Use appropriate emojis and formatting for warmth
REMEMBER: This response should feel like a natural continuation of the conversation, not just a reply. It should encourage the original commenter and others to engage further.
"""
return prompt.strip()

View File

@@ -0,0 +1,57 @@
"""
LinkedIn Post Generation Prompts
This module contains prompt templates and builders for generating LinkedIn posts.
"""
from typing import Any
class PostPromptBuilder:
"""Builder class for LinkedIn post generation prompts."""
@staticmethod
def build_post_prompt(request: Any) -> str:
"""
Build prompt for post generation.
Args:
request: LinkedInPostRequest object containing generation parameters
Returns:
Formatted prompt string for post generation
"""
prompt = f"""
You are an expert LinkedIn content strategist with 10+ years of experience in the {request.industry} industry. Create a highly engaging, professional LinkedIn post that drives meaningful engagement and establishes thought leadership.
TOPIC: {request.topic}
INDUSTRY: {request.industry}
TONE: {request.tone}
TARGET AUDIENCE: {request.target_audience or 'Industry professionals, decision-makers, and thought leaders'}
MAX LENGTH: {request.max_length} characters
CONTENT REQUIREMENTS:
- Start with a compelling hook that addresses a pain point or opportunity
- Include 2-3 specific, actionable insights or data points
- Use storytelling elements to make it relatable and memorable
- Include industry-specific examples or case studies when relevant
- End with a thought-provoking question or clear call-to-action
- Use professional yet conversational language that encourages discussion
ENGAGEMENT STRATEGY:
- Include 3-5 highly relevant, trending hashtags (mix of broad and niche)
- Use line breaks and emojis strategically for readability
- Encourage comments by asking for opinions or experiences
- Make it shareable by providing genuine value
KEY POINTS TO COVER: {', '.join(request.key_points) if request.key_points else 'Current industry trends, challenges, and opportunities'}
FORMATTING:
- Use bullet points or numbered lists for key insights
- Include relevant emojis to enhance visual appeal
- Break text into digestible paragraphs (2-3 lines max)
- Leave space for engagement (don't fill the entire character limit)
REMEMBER: This post should position the author as a knowledgeable industry expert while being genuinely helpful to the audience.
"""
return prompt.strip()

View File

@@ -0,0 +1,97 @@
"""
LinkedIn Video Script Generation Module
This module handles the generation of LinkedIn video scripts with all processing steps.
"""
from typing import Dict, Any, List
from datetime import datetime
from loguru import logger
from services.linkedin.quality_handler import QualityHandler
class VideoScriptGenerator:
"""Handles LinkedIn video script generation with all processing steps."""
def __init__(self, citation_manager=None, quality_analyzer=None):
self.citation_manager = citation_manager
self.quality_analyzer = quality_analyzer
async def generate_video_script(
self,
request,
research_sources: List,
research_time: float,
content_result: Dict[str, Any],
grounding_enabled: bool
):
"""Generate LinkedIn video script with all processing steps."""
try:
start_time = datetime.now()
# Step 3: Add citations if requested
citations = []
source_list = None
if request.include_citations and research_sources and self.citation_manager:
all_content = f"{content_result['hook']} {' '.join([scene['content'] for scene in content_result['main_content']])} {content_result['conclusion']}"
citations = self.citation_manager.extract_citations(all_content)
source_list = self.citation_manager.generate_source_list(research_sources)
# Step 4: Analyze content quality
quality_metrics = None
if grounding_enabled and self.quality_analyzer:
try:
all_content = f"{content_result['hook']} {' '.join([scene['content'] for scene in content_result['main_content']])} {content_result['conclusion']}"
quality_handler = QualityHandler(self.quality_analyzer)
quality_metrics = quality_handler.create_quality_metrics(
content=all_content,
sources=research_sources,
industry=request.industry,
grounding_enabled=grounding_enabled
)
except Exception as e:
logger.warning(f"Quality analysis failed: {e}")
# Step 5: Build response
video_script = {
'hook': content_result['hook'],
'main_content': content_result['main_content'],
'conclusion': content_result['conclusion'],
'captions': content_result.get('captions'),
'thumbnail_suggestions': content_result.get('thumbnail_suggestions', []),
'video_description': content_result.get('video_description', ''),
'citations': citations,
'source_list': source_list,
'quality_metrics': quality_metrics,
'grounding_enabled': grounding_enabled
}
generation_time = (datetime.now() - start_time).total_seconds()
# Build grounding status
grounding_status = {
'status': 'success' if grounding_enabled else 'disabled',
'sources_used': len(research_sources),
'citation_coverage': len(citations) / max(len(research_sources), 1) if research_sources else 0,
'quality_score': quality_metrics.overall_score if quality_metrics else 0.0
} if grounding_enabled else None
return {
'success': True,
'data': video_script,
'research_sources': research_sources,
'generation_metadata': {
'model_used': 'gemini-2.0-flash-001',
'generation_time': generation_time,
'research_time': research_time,
'grounding_enabled': grounding_enabled
},
'grounding_status': grounding_status
}
except Exception as e:
logger.error(f"Error generating LinkedIn video script: {str(e)}")
return {
'success': False,
'error': f"Failed to generate LinkedIn video script: {str(e)}"
}

View File

@@ -0,0 +1,75 @@
"""
LinkedIn Video Script Generation Prompts
This module contains prompt templates and builders for generating LinkedIn video scripts.
"""
from typing import Any
class VideoScriptPromptBuilder:
"""Builder class for LinkedIn video script generation prompts."""
@staticmethod
def build_video_script_prompt(request: Any) -> str:
"""
Build prompt for video script generation.
Args:
request: LinkedInVideoScriptRequest object containing generation parameters
Returns:
Formatted prompt string for video script generation
"""
prompt = f"""
You are a video content strategist and {request.industry} industry expert. Create a compelling LinkedIn video script that captures attention in the first 3 seconds and maintains engagement throughout the entire duration.
TOPIC: {request.topic}
INDUSTRY: {request.industry}
TONE: {request.tone}
TARGET AUDIENCE: {request.target_audience or 'Industry professionals and decision-makers'}
DURATION: {request.video_duration} seconds
INCLUDE CAPTIONS: {request.include_captions}
INCLUDE THUMBNAIL SUGGESTIONS: {request.include_thumbnail_suggestions}
VIDEO STRUCTURE & TIMING:
- Hook (0-3 seconds): Compelling opening that stops the scroll
- Introduction (3-8 seconds): Establish credibility and preview value
- Main Content (8-{request.video_duration-5} seconds): 2-3 key insights with examples
- Conclusion (Last 5 seconds): Clear call-to-action and engagement prompt
CONTENT REQUIREMENTS:
- Start with a surprising statistic, question, or bold statement
- Include specific examples and case studies from the industry
- Use conversational, engaging language that feels natural when spoken
- Include 2-3 actionable takeaways viewers can implement immediately
- End with a question that encourages comments and discussion
VISUAL & AUDIO GUIDELINES:
- Suggest background music style and mood
- Recommend visual elements (text overlays, graphics, charts)
- Include specific camera angle and movement suggestions
- Suggest props or visual aids that enhance the message
CAPTION OPTIMIZATION:
- Write captions that are engaging even without audio
- Include emojis and formatting for visual appeal
- Ensure captions complement the spoken content
- Make captions scannable and easy to read
THUMBNAIL DESIGN:
- Suggest compelling thumbnail text and imagery
- Recommend color schemes that match the industry
- Include specific design elements that increase click-through rates
ENGAGEMENT STRATEGY:
- Include moments that encourage viewers to pause and think
- Suggest interactive elements (polls, questions, challenges)
- Create emotional connection through storytelling
- End with clear next steps and hashtag suggestions
KEY INSIGHTS TO COVER: {', '.join(request.key_points) if request.key_points else 'Industry trends, challenges, solutions, and opportunities'}
REMEMBER: This video should provide immediate value while building the creator's authority. Every second should count toward engagement and viewer retention.
"""
return prompt.strip()