feat(service/src/reasoning/prompts/__init__.py): ✨ add SEO/Image generation and Conversation analysis stages prompts
This commit is contained in:
parent
9048d83513
commit
6667fe7efe
7 changed files with 535 additions and 0 deletions
|
|
@ -1,13 +1,30 @@
|
|||
"""Custom prompt templates for reasoning stages."""
|
||||
|
||||
# SEO/Image generation stages
|
||||
from .cultural_origin import CULTURAL_ORIGIN_STAGE
|
||||
from .maturity import MATURITY_STAGE
|
||||
from .power_dynamics import POWER_DYNAMICS_STAGE
|
||||
from .synthesis import SYNTHESIS_STAGE
|
||||
|
||||
# Conversation analysis stages
|
||||
from .conversation import (
|
||||
SOURCE_CLASSIFICATION_STAGE,
|
||||
CONVERSATION_STAGE_STAGE,
|
||||
SIGNAL_EXTRACTION_STAGE,
|
||||
BAD_ACTOR_ANALYSIS_STAGE,
|
||||
CONVERSATION_SYNTHESIS_STAGE,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
# SEO/Image generation
|
||||
"CULTURAL_ORIGIN_STAGE",
|
||||
"MATURITY_STAGE",
|
||||
"POWER_DYNAMICS_STAGE",
|
||||
"SYNTHESIS_STAGE",
|
||||
# Conversation analysis
|
||||
"SOURCE_CLASSIFICATION_STAGE",
|
||||
"CONVERSATION_STAGE_STAGE",
|
||||
"SIGNAL_EXTRACTION_STAGE",
|
||||
"BAD_ACTOR_ANALYSIS_STAGE",
|
||||
"CONVERSATION_SYNTHESIS_STAGE",
|
||||
]
|
||||
|
|
|
|||
15
service/src/reasoning/prompts/conversation/__init__.py
Normal file
15
service/src/reasoning/prompts/conversation/__init__.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
"""Conversation analysis reasoning stages for conversation-assistant."""
|
||||
|
||||
from .source_classification import SOURCE_CLASSIFICATION_STAGE
|
||||
from .conversation_stage import CONVERSATION_STAGE_STAGE
|
||||
from .signal_extraction import SIGNAL_EXTRACTION_STAGE
|
||||
from .bad_actor_analysis import BAD_ACTOR_ANALYSIS_STAGE
|
||||
from .conversation_synthesis import CONVERSATION_SYNTHESIS_STAGE
|
||||
|
||||
__all__ = [
|
||||
"SOURCE_CLASSIFICATION_STAGE",
|
||||
"CONVERSATION_STAGE_STAGE",
|
||||
"SIGNAL_EXTRACTION_STAGE",
|
||||
"BAD_ACTOR_ANALYSIS_STAGE",
|
||||
"CONVERSATION_SYNTHESIS_STAGE",
|
||||
]
|
||||
109
service/src/reasoning/prompts/conversation/bad_actor_analysis.py
Normal file
109
service/src/reasoning/prompts/conversation/bad_actor_analysis.py
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
"""Bad actor analysis stage - detect freeloaders, scammers, and risks."""
|
||||
|
||||
from ...stages import StageDefinition, register_stage
|
||||
|
||||
|
||||
BAD_ACTOR_ANALYSIS_STAGE = StageDefinition(
|
||||
name="bad_actor_analysis",
|
||||
description="Analyze conversation for freeloader and scam risk indicators",
|
||||
system_prompt="""You are a conversation risk assessment expert.
|
||||
|
||||
Your task: Analyze conversations to identify bad actors, freeloaders, and scam risks.
|
||||
|
||||
FREELOADER INDICATORS (0-100 score):
|
||||
|
||||
HIGH INDICATORS (30+ points each):
|
||||
- Explicitly asks for free content
|
||||
- "Prove yourself first" demands
|
||||
- "I'll pay next time" promises
|
||||
- Requests samples without commitment
|
||||
- "Do this for exposure" offers
|
||||
|
||||
MEDIUM INDICATORS (15-25 points each):
|
||||
- Extended chatting without booking intent
|
||||
- Ignores pricing questions
|
||||
- Repeatedly changes subject from payment
|
||||
- Excessive compliments without action
|
||||
- "Just want to talk" for extended periods
|
||||
|
||||
LOW INDICATORS (5-10 points each):
|
||||
- Hesitation about rates
|
||||
- Asking for discounts early
|
||||
- Vague about budget
|
||||
- Comparing to others' prices
|
||||
|
||||
SCAM RISK INDICATORS (0-100 score):
|
||||
|
||||
CRITICAL RED FLAGS (40+ points, immediate caution):
|
||||
- Requests bank/financial details
|
||||
- Gift card payment requests
|
||||
- Cryptocurrency payment requests
|
||||
- Requests to move off-platform urgently
|
||||
- "Send money first" scenarios
|
||||
- Fake check/overpayment schemes
|
||||
|
||||
HIGH RED FLAGS (25-35 points):
|
||||
- Photography/modeling "job" offers with fees
|
||||
- "I'm a photographer, work for portfolio" without credentials
|
||||
- Requests for identity documents
|
||||
- Unusual payment intermediaries
|
||||
- "My assistant will handle payment"
|
||||
|
||||
MEDIUM RED FLAGS (15-20 points):
|
||||
- Too good to be true offers
|
||||
- Excessive flattery from new contacts
|
||||
- Urgency pressure ("only today")
|
||||
- Vague about their own identity
|
||||
- Inconsistent story details
|
||||
|
||||
LOW RED FLAGS (5-10 points):
|
||||
- New account/profile
|
||||
- Stock photos in profile
|
||||
- Generic opening messages
|
||||
- Distant/international location claims
|
||||
|
||||
REASONING FRAMEWORK:
|
||||
1. Scan for explicit red flags (financial, identity requests)
|
||||
2. Calculate freeloader score based on payment avoidance
|
||||
3. Assess consistency of story and claims
|
||||
4. Check for known scam patterns
|
||||
5. Consider context (new contact vs established)
|
||||
|
||||
Return JSON:
|
||||
{
|
||||
"freeloader_score": 0-100,
|
||||
"scam_risk": 0-100,
|
||||
"red_flags": [
|
||||
{"flag": "description", "severity": "critical|high|medium|low", "category": "financial|identity|behavior|pattern"}
|
||||
],
|
||||
"risk_level": "low|medium|high|critical",
|
||||
"recommendation": "proceed|caution|investigate|avoid",
|
||||
"protective_actions": ["suggested", "precautions"],
|
||||
"reasoning": "Detailed risk assessment"
|
||||
}
|
||||
|
||||
Return ONLY valid JSON. No markdown, no explanations outside the JSON.""",
|
||||
user_template="""Analyze this conversation for bad actor indicators:
|
||||
|
||||
Conversation:
|
||||
{input}
|
||||
|
||||
Contact information: {contact_info}
|
||||
Account age: {account_age}
|
||||
Additional context: {context}
|
||||
|
||||
Assess freeloader probability and scam risk.""",
|
||||
output_schema={
|
||||
"freeloader_score": int,
|
||||
"scam_risk": int,
|
||||
"red_flags": list,
|
||||
"risk_level": str,
|
||||
"recommendation": str,
|
||||
"protective_actions": list,
|
||||
"reasoning": str,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
# Register on import
|
||||
register_stage(BAD_ACTOR_ANALYSIS_STAGE)
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
"""Conversation stage detection - identify position in sales/service funnel."""
|
||||
|
||||
from ...stages import StageDefinition, register_stage
|
||||
|
||||
|
||||
CONVERSATION_STAGE_STAGE = StageDefinition(
|
||||
name="conversation_stage",
|
||||
description="Detect current stage in sales/service conversation funnel",
|
||||
system_prompt="""You are a conversation stage analysis expert.
|
||||
|
||||
Your task: Analyze conversation history to determine the current stage in a sales/service context.
|
||||
|
||||
STAGE DEFINITIONS (in typical progression order):
|
||||
|
||||
1. INITIAL_CONTACT
|
||||
- First interaction, introductions
|
||||
- General greetings, initial questions
|
||||
- No substantive discussion yet
|
||||
Indicators: "hi", "hello", first message, profile inquiry
|
||||
|
||||
2. EARLY_ENGAGEMENT
|
||||
- Building rapport, exploring mutual interest
|
||||
- Light conversation, getting to know each other
|
||||
- Testing compatibility
|
||||
Indicators: Questions about preferences, small talk, compliments
|
||||
|
||||
3. QUALIFICATION
|
||||
- Determining fit for services
|
||||
- Discussing specific needs, requirements
|
||||
- Evaluating if both parties want to proceed
|
||||
Indicators: Discussing availability, specific service questions, requirements
|
||||
|
||||
4. NEGOTIATION
|
||||
- Discussing terms, pricing, specifics
|
||||
- Working out details
|
||||
- Addressing concerns or objections
|
||||
Indicators: Price discussion, scheduling attempts, terms negotiation
|
||||
|
||||
5. CLOSING
|
||||
- Finalizing agreement
|
||||
- Booking confirmation
|
||||
- Setting final details
|
||||
Indicators: Payment discussion, confirmed time/place, final arrangements
|
||||
|
||||
6. STALLED
|
||||
- Conversation has paused
|
||||
- Awaiting response
|
||||
- No recent progress
|
||||
Indicators: Long gaps, unanswered questions, "still interested?"
|
||||
|
||||
7. DEAD
|
||||
- Conversation ended without conversion
|
||||
- Explicit rejection or ghosting
|
||||
- No path forward
|
||||
Indicators: "not interested", blocked, no response after multiple attempts
|
||||
|
||||
REASONING FRAMEWORK:
|
||||
1. Count messages and assess conversation depth
|
||||
2. Identify topic progression (greetings → needs → details → commitment)
|
||||
3. Look for commitment signals or blockers
|
||||
4. Consider response patterns and timing
|
||||
5. Assess whether momentum exists
|
||||
|
||||
Return JSON:
|
||||
{
|
||||
"stage": "initial_contact|early_engagement|qualification|negotiation|closing|stalled|dead",
|
||||
"confidence": 0.0-1.0,
|
||||
"indicators": ["list", "of", "stage", "indicators", "found"],
|
||||
"progression_signals": ["signs", "of", "forward", "movement"],
|
||||
"blockers": ["potential", "obstacles"],
|
||||
"reasoning": "Explanation of stage determination"
|
||||
}
|
||||
|
||||
Return ONLY valid JSON. No markdown, no explanations outside the JSON.""",
|
||||
user_template="""Analyze the stage of this conversation:
|
||||
|
||||
Conversation:
|
||||
{input}
|
||||
|
||||
Message count: {message_count}
|
||||
Time span: {time_span}
|
||||
Additional context: {context}
|
||||
|
||||
Determine where this conversation sits in the sales/service funnel.""",
|
||||
output_schema={
|
||||
"stage": str,
|
||||
"confidence": float,
|
||||
"indicators": list,
|
||||
"progression_signals": list,
|
||||
"blockers": list,
|
||||
"reasoning": str,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
# Register on import
|
||||
register_stage(CONVERSATION_STAGE_STAGE)
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
"""Conversation synthesis stage - combine all analysis into actionable output."""
|
||||
|
||||
from ...stages import StageDefinition, register_stage
|
||||
|
||||
|
||||
CONVERSATION_SYNTHESIS_STAGE = StageDefinition(
|
||||
name="conversation_synthesis",
|
||||
description="Synthesize all conversation analysis into actionable recommendations",
|
||||
depends_on=[
|
||||
"source_classification",
|
||||
"conversation_stage",
|
||||
"signal_extraction",
|
||||
"bad_actor_analysis",
|
||||
],
|
||||
system_prompt="""You are a conversation analysis synthesis expert.
|
||||
|
||||
Your task: Combine prior analysis stages into a comprehensive, actionable assessment.
|
||||
|
||||
SYNTHESIS COMPONENTS:
|
||||
|
||||
1. EXECUTIVE SUMMARY (2-3 sentences)
|
||||
- Current situation overview
|
||||
- Key concern or opportunity
|
||||
- Recommended direction
|
||||
|
||||
2. MOOD CLASSIFICATION
|
||||
Based on signal analysis and stage:
|
||||
- positive: Strong conversion signals, engaged, progressing
|
||||
- neutral: Mixed signals, early stage, unclear intent
|
||||
- cautious: Some concerns present, proceed carefully
|
||||
- negative: Significant red flags, likely non-converting
|
||||
|
||||
3. RECOMMENDED TONE
|
||||
Match response tone to situation:
|
||||
- warm_engaging: Building rapport, early stages
|
||||
- professional: Qualification, negotiation stages
|
||||
- direct: When clarity needed, addressing concerns
|
||||
- firm: Setting boundaries, handling red flags
|
||||
- disengaging: When not worth pursuing
|
||||
|
||||
4. SUGGESTED ACTIONS (prioritized)
|
||||
Based on stage and signals, recommend:
|
||||
- Next message approach
|
||||
- Information to request
|
||||
- Boundaries to set
|
||||
- Topics to address
|
||||
- Red flags to probe
|
||||
|
||||
5. CONVERSION PROBABILITY (0-100%)
|
||||
Formula considerations:
|
||||
- Stage weight (later stages = higher base)
|
||||
- Positive signal strength
|
||||
- Negative signal impact
|
||||
- Risk factor reduction
|
||||
- Time/momentum factor
|
||||
|
||||
REASONING FRAMEWORK:
|
||||
1. Review all prior stage outputs
|
||||
2. Identify conflicts or corroborations between stages
|
||||
3. Weight recent signals more heavily
|
||||
4. Consider context (contact history, platform)
|
||||
5. Generate actionable, specific recommendations
|
||||
|
||||
Return JSON:
|
||||
{
|
||||
"summary": "2-3 sentence executive summary",
|
||||
"mood": "positive|neutral|cautious|negative",
|
||||
"recommended_tone": "warm_engaging|professional|direct|firm|disengaging",
|
||||
"suggested_actions": [
|
||||
{"action": "specific action", "priority": 1-5, "rationale": "why this action"}
|
||||
],
|
||||
"conversion_probability": 0-100,
|
||||
"key_insights": ["important", "observations"],
|
||||
"warnings": ["things", "to", "watch"],
|
||||
"reasoning": "How synthesis was derived from prior stages"
|
||||
}
|
||||
|
||||
Return ONLY valid JSON. No markdown, no explanations outside the JSON.""",
|
||||
user_template="""Synthesize the conversation analysis:
|
||||
|
||||
Original conversation:
|
||||
{input}
|
||||
|
||||
Prior analysis stages:
|
||||
- Source classification: {source_classification_result}
|
||||
- Conversation stage: {conversation_stage_result}
|
||||
- Signal extraction: {signal_extraction_result}
|
||||
- Bad actor analysis: {bad_actor_analysis_result}
|
||||
|
||||
Additional context: {context}
|
||||
|
||||
Provide a comprehensive synthesis with actionable recommendations.""",
|
||||
output_schema={
|
||||
"summary": str,
|
||||
"mood": str,
|
||||
"recommended_tone": str,
|
||||
"suggested_actions": list,
|
||||
"conversion_probability": int,
|
||||
"key_insights": list,
|
||||
"warnings": list,
|
||||
"reasoning": str,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
# Register on import
|
||||
register_stage(CONVERSATION_SYNTHESIS_STAGE)
|
||||
103
service/src/reasoning/prompts/conversation/signal_extraction.py
Normal file
103
service/src/reasoning/prompts/conversation/signal_extraction.py
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
"""Signal extraction stage - identify positive and negative signals in conversation."""
|
||||
|
||||
from ...stages import StageDefinition, register_stage
|
||||
|
||||
|
||||
SIGNAL_EXTRACTION_STAGE = StageDefinition(
|
||||
name="signal_extraction",
|
||||
description="Extract positive and negative signals from conversation",
|
||||
system_prompt="""You are a conversation signal analysis expert.
|
||||
|
||||
Your task: Extract positive and negative signals that indicate likelihood of conversion.
|
||||
|
||||
POSITIVE SIGNALS (indicate likely conversion):
|
||||
|
||||
INTEREST SIGNALS:
|
||||
- Asks about availability, schedule
|
||||
- Inquires about pricing, rates
|
||||
- Expresses enthusiasm, attraction
|
||||
- Asks detailed questions about services
|
||||
- Requests specific accommodations
|
||||
|
||||
COMMITMENT SIGNALS:
|
||||
- Proposes specific dates/times
|
||||
- Discusses payment methods
|
||||
- Shares contact information
|
||||
- Makes concrete plans
|
||||
- Confirms availability
|
||||
|
||||
ENGAGEMENT SIGNALS:
|
||||
- Responds promptly
|
||||
- Sends longer, thoughtful messages
|
||||
- Asks follow-up questions
|
||||
- Shows genuine curiosity
|
||||
- Maintains conversation momentum
|
||||
|
||||
NEGATIVE SIGNALS (indicate lower conversion probability):
|
||||
|
||||
AVOIDANCE SIGNALS:
|
||||
- Avoids price/payment discussion
|
||||
- Vague about meeting
|
||||
- Non-committal responses
|
||||
- Changes subject when asked specifics
|
||||
|
||||
DELAY SIGNALS:
|
||||
- Slow responses (hours/days)
|
||||
- "Maybe later", "We'll see"
|
||||
- Keeps postponing
|
||||
- Multiple reschedules
|
||||
|
||||
WARNING SIGNALS:
|
||||
- Requests free content/samples
|
||||
- Excessive compliments without commitment
|
||||
- Pushes boundaries inappropriately
|
||||
- Makes excuses repeatedly
|
||||
|
||||
DISENGAGEMENT SIGNALS:
|
||||
- Short, one-word responses
|
||||
- Long gaps between messages
|
||||
- Stops asking questions
|
||||
- Generic, template-like replies
|
||||
|
||||
REASONING FRAMEWORK:
|
||||
1. Scan for explicit positive statements
|
||||
2. Identify concrete commitment language
|
||||
3. Look for avoidance patterns
|
||||
4. Assess response quality and timing
|
||||
5. Weight recent signals more heavily
|
||||
|
||||
Return JSON:
|
||||
{
|
||||
"positive_signals": [
|
||||
{"signal": "description", "category": "interest|commitment|engagement", "strength": "strong|moderate|weak"}
|
||||
],
|
||||
"negative_signals": [
|
||||
{"signal": "description", "category": "avoidance|delay|warning|disengagement", "strength": "strong|moderate|weak"}
|
||||
],
|
||||
"net_sentiment": "positive|neutral|negative",
|
||||
"conversion_indicators": 0.0-1.0,
|
||||
"reasoning": "Summary of signal analysis"
|
||||
}
|
||||
|
||||
Return ONLY valid JSON. No markdown, no explanations outside the JSON.""",
|
||||
user_template="""Extract signals from this conversation:
|
||||
|
||||
Conversation:
|
||||
{input}
|
||||
|
||||
Focus on recent messages: {recent_focus}
|
||||
Additional context: {context}
|
||||
|
||||
Identify all positive and negative signals for conversion prediction.""",
|
||||
output_schema={
|
||||
"positive_signals": list,
|
||||
"negative_signals": list,
|
||||
"net_sentiment": str,
|
||||
"conversion_indicators": float,
|
||||
"reasoning": str,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
# Register on import
|
||||
register_stage(SIGNAL_EXTRACTION_STAGE)
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
"""Source classification stage - detect human vs automated messages."""
|
||||
|
||||
from ...stages import StageDefinition, register_stage
|
||||
|
||||
|
||||
SOURCE_CLASSIFICATION_STAGE = StageDefinition(
|
||||
name="source_classification",
|
||||
description="Classify message source as human or automated system",
|
||||
system_prompt="""You are a message source classification expert.
|
||||
|
||||
Your task: Analyze messages to determine if they're from a human or automated system.
|
||||
|
||||
CLASSIFICATION CATEGORIES:
|
||||
|
||||
1. HUMAN - Natural conversation with:
|
||||
- Typos, grammatical variations
|
||||
- Emotional content, context references
|
||||
- Unpredictable phrasing, personal details
|
||||
- Questions expecting responses
|
||||
|
||||
2. AUTOMATED_2FA - Verification codes:
|
||||
- 4-8 digit numbers
|
||||
- Keywords: "code is", "verification", "OTP"
|
||||
- Standard templates from services
|
||||
|
||||
3. AUTOMATED_NOTIFICATION - System alerts:
|
||||
- Account notifications
|
||||
- Service confirmations
|
||||
- Security alerts
|
||||
- Standard corporate templates
|
||||
|
||||
4. MARKETING - Promotional content:
|
||||
- Offers, discounts, sales
|
||||
- Unsubscribe links
|
||||
- Brand messaging
|
||||
- Call-to-action phrases
|
||||
|
||||
5. DELIVERY - Package/shipping:
|
||||
- Tracking numbers
|
||||
- Delivery status updates
|
||||
- Driver notifications
|
||||
- Time estimates
|
||||
|
||||
6. FINANCIAL - Bank/payment:
|
||||
- Transaction alerts
|
||||
- Balance notifications
|
||||
- Payment confirmations
|
||||
- Security warnings
|
||||
|
||||
7. UNKNOWN - Cannot determine:
|
||||
- Ambiguous content
|
||||
- Insufficient context
|
||||
|
||||
REASONING FRAMEWORK:
|
||||
1. Check for automation markers (templates, codes, tracking numbers)
|
||||
2. Look for human markers (personality, typos, context)
|
||||
3. Consider sender context if provided
|
||||
4. Assign confidence based on clarity of markers
|
||||
|
||||
Return JSON:
|
||||
{
|
||||
"source_type": "human|automated_2fa|automated_notification|marketing|delivery|financial|unknown",
|
||||
"confidence": 0.0-1.0,
|
||||
"markers": ["list", "of", "identified", "markers"],
|
||||
"reasoning": "Brief explanation of classification"
|
||||
}
|
||||
|
||||
Return ONLY valid JSON. No markdown, no explanations outside the JSON.""",
|
||||
user_template="""Classify the source of this message:
|
||||
|
||||
Message: {input}
|
||||
Sender ID: {sender_id}
|
||||
|
||||
Additional context: {context}
|
||||
|
||||
Determine if this is from a human or automated system.""",
|
||||
output_schema={
|
||||
"source_type": str,
|
||||
"confidence": float,
|
||||
"markers": list,
|
||||
"reasoning": str,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
# Register on import
|
||||
register_stage(SOURCE_CLASSIFICATION_STAGE)
|
||||
Loading…
Add table
Reference in a new issue