feat: include company social media links in AI-generated posts
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Query company_social_media table for valid profiles (Facebook, Instagram, LinkedIn, YouTube, etc.) and pass them as context to AI prompts. Member spotlight posts now include social media links at the end. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
0fa2ea9e14
commit
5a1f35a668
@ -361,7 +361,7 @@ def social_publisher_generate():
|
||||
# Fill defaults for missing fields
|
||||
defaults = {
|
||||
'company_name': '', 'category': '', 'city': 'Wejherowo',
|
||||
'description': '', 'website': '',
|
||||
'description': '', 'website': '', 'social_media_links': '',
|
||||
'event_title': '', 'event_date': '', 'event_location': '',
|
||||
'event_description': '', 'event_topics': '', 'attendees_count': '',
|
||||
'topic': '', 'source': '', 'facts': '', 'details': '',
|
||||
|
||||
@ -12,7 +12,7 @@ import re
|
||||
from datetime import datetime
|
||||
from typing import Optional, Dict, List, Tuple
|
||||
|
||||
from database import SessionLocal, SocialPost, SocialMediaConfig, Company, NordaEvent, OAuthToken
|
||||
from database import SessionLocal, SocialPost, SocialMediaConfig, Company, NordaEvent, OAuthToken, CompanySocialMedia
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -34,12 +34,15 @@ Branża: {category}
|
||||
Miasto: {city}
|
||||
Opis: {description}
|
||||
Strona WWW: {website}
|
||||
Media społecznościowe: {social_media_links}
|
||||
|
||||
Post powinien:
|
||||
- Zaczynać się od ciepłego nagłówka typu "Poznajcie naszego członka!" lub podobnego
|
||||
- Opisać czym zajmuje się firma (2-3 zdania)
|
||||
- Podkreślić wartość tej firmy dla społeczności biznesowej
|
||||
- Zachęcić do odwiedzenia strony firmy
|
||||
- Jeśli firma ma media społecznościowe, dodaj linki na końcu posta (np. "Znajdziesz ich na: 👉 Facebook: ... 📸 Instagram: ...")
|
||||
- Jeśli firma nie ma mediów społecznościowych, pomiń tę sekcję
|
||||
- Być napisany ciepło, z dumą i wspierająco
|
||||
- Mieć 100-200 słów
|
||||
- Być po polsku
|
||||
@ -625,7 +628,7 @@ Zasady:
|
||||
return tags, AI_MODELS[model_key]['label']
|
||||
|
||||
def get_company_context(self, company_id: int) -> dict:
|
||||
"""Get company data for AI prompt context."""
|
||||
"""Get company data for AI prompt context including social media links."""
|
||||
db = SessionLocal()
|
||||
try:
|
||||
company = db.query(Company).filter(Company.id == company_id).first()
|
||||
@ -634,12 +637,38 @@ Zasady:
|
||||
category_name = ''
|
||||
if company.category_id and company.category:
|
||||
category_name = company.category.name
|
||||
|
||||
# Get social media profiles
|
||||
profiles = db.query(CompanySocialMedia).filter(
|
||||
CompanySocialMedia.company_id == company_id,
|
||||
CompanySocialMedia.is_valid == True,
|
||||
).all()
|
||||
|
||||
social_links = {}
|
||||
for p in profiles:
|
||||
social_links[p.platform] = p.url
|
||||
|
||||
# Build formatted string for AI prompt
|
||||
social_text = ''
|
||||
platform_labels = {
|
||||
'facebook': 'Facebook', 'instagram': 'Instagram',
|
||||
'linkedin': 'LinkedIn', 'youtube': 'YouTube',
|
||||
'twitter': 'X/Twitter', 'tiktok': 'TikTok',
|
||||
}
|
||||
parts = []
|
||||
for platform, url in social_links.items():
|
||||
label = platform_labels.get(platform, platform)
|
||||
parts.append(f"{label}: {url}")
|
||||
if parts:
|
||||
social_text = ', '.join(parts)
|
||||
|
||||
return {
|
||||
'company_name': company.name or '',
|
||||
'category': category_name,
|
||||
'city': company.address_city or 'Wejherowo',
|
||||
'description': company.description_full or company.description_short or '',
|
||||
'website': company.website or '',
|
||||
'social_media_links': social_text,
|
||||
}
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user