84 lines
3.2 KiB
Python
Executable file
84 lines
3.2 KiB
Python
Executable file
from app.agents.base_agent import BaseAgent
|
|
from app.models.schemas import SubReview
|
|
from app.services.gemini_service import GeminiService
|
|
from app.services.reference_docs import ReferenceDocsService
|
|
|
|
|
|
class ChannelAgent(BaseAgent):
|
|
"""Channel Agent - analyzes proofs for digital channel suitability using Gemini."""
|
|
|
|
name = "Channel Agent"
|
|
|
|
def __init__(self, gemini_service: GeminiService, reference_docs: ReferenceDocsService):
|
|
"""
|
|
Initialize the Channel Agent.
|
|
|
|
Args:
|
|
gemini_service: Service for making Gemini API calls
|
|
reference_docs: Service for loading reference documents
|
|
"""
|
|
self.gemini = gemini_service
|
|
self.channel_context = reference_docs.get_channel_context()
|
|
|
|
async def analyze(self, file_data: bytes, file_type: str) -> SubReview:
|
|
"""
|
|
Analyze the proof for channel suitability.
|
|
|
|
Args:
|
|
file_data: Raw bytes of the file to analyze
|
|
file_type: MIME type of the file
|
|
|
|
Returns:
|
|
SubReview with channel suitability assessment
|
|
"""
|
|
prompt = f"""You are a digital channel specialist for Barclays Bank. Your role is to analyze marketing proofs for technical suitability across digital and social media channels.
|
|
|
|
Here are the channel guidelines to use for your analysis:
|
|
|
|
{self.channel_context}
|
|
|
|
---
|
|
|
|
Analyze the uploaded proof for technical suitability for its intended digital channel, checking:
|
|
|
|
1. **Social Media Compliance** (if applicable):
|
|
- Logo placement (should be top-right corner, 40px from edges on social)
|
|
- Portal sizing for different platforms (8px thin, 16px thin, or standard as appropriate)
|
|
- Format specifications (proper dimensions for the target platform)
|
|
|
|
2. **Digital Grid System**:
|
|
- Desktop: 12-column grid
|
|
- Tablet: 12-column grid
|
|
- Mobile: 6-column grid
|
|
- 8px baseline grid adherence
|
|
|
|
3. **Typography Scale**:
|
|
- Check if text sizing follows the 8-level scale (Supersize 80px down to X Small 12px)
|
|
- Responsive type considerations for different breakpoints (640px mobile threshold)
|
|
|
|
4. **Accessibility**:
|
|
- Color contrast meets accessibility requirements
|
|
- Only documented color pairings are used
|
|
- Text is readable at the intended display size
|
|
|
|
5. **Platform-Specific Requirements**:
|
|
- Hashtag usage guidelines (if social media)
|
|
- Emoji usage (appropriate vs. inappropriate as per guidelines)
|
|
- Character limits (Headlines: 65 chars, Body: 300 chars, Quotations: 250 chars)
|
|
|
|
6. **Motion/Video** (if applicable):
|
|
- Start and end frame compliance
|
|
- Subtitle formatting
|
|
- Frame rate and format requirements
|
|
|
|
Provide your analysis as a JSON object. Be specific about any technical issues and reference the relevant platform or guideline.
|
|
|
|
RAG Status Guidelines:
|
|
- **Green**: Fully suitable for the intended channel, all specs met
|
|
- **Amber**: Minor technical adjustments needed for optimal display
|
|
- **Red**: Significant technical issues that will impact display or accessibility
|
|
|
|
If the proof is nonsensical, not a marketing material, or cannot be analyzed, set analysisStatus to 'low_confidence'.
|
|
"""
|
|
|
|
return await self.gemini.analyze_with_image(prompt, file_data, file_type)
|