diff --git a/backend/brand_style.py b/backend/brand_style.py index 0d819fd..6ef38d0 100644 --- a/backend/brand_style.py +++ b/backend/brand_style.py @@ -17,7 +17,7 @@ class BrandStyleManager: def _load_brand_voice(self) -> Dict[str, Any]: """Load brand voice guidelines from JSON.""" - file_path = "data/style_guidelines/brand_voice.json" + file_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "data", "style_guidelines", "brand_voice.json")) if os.path.exists(file_path): with open(file_path, 'r', encoding='utf-8') as f: return json.load(f) @@ -25,7 +25,8 @@ class BrandStyleManager: def _load_sample_campaigns(self) -> List[Dict[str, Any]]: """Load sample campaigns from JSON.""" - file_path = "data/past_campaigns/sample_campaigns.json" + + file_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "data", "past_campaigns", "sample_campaigns.json")) if os.path.exists(file_path): with open(file_path, 'r', encoding='utf-8') as f: data = json.load(f) diff --git a/backend/copywriter.py b/backend/copywriter.py index 6bf59fa..ab75b38 100644 --- a/backend/copywriter.py +++ b/backend/copywriter.py @@ -3,6 +3,8 @@ import requests import json from config import settings from brand_style import BrandStyleManager +from embeddings import CohereEmbeddings +from vector_store import VectorStore class MarketingCopywriter: def __init__(self, brand_style_manager: BrandStyleManager): @@ -52,10 +54,10 @@ class MarketingCopywriter: Generate the marketing copy: """ - def generate_copy(self, prompt: str, context: List[Dict], content_type: str, tone: str, - brand_voice: Dict[str, Any], sample_campaigns: List[Dict[str, Any]]) -> str: + def generate_copy(self, prompt: str, context: List[Dict], tone: str, + brand_voice: Dict[str, Any], sample_campaigns) -> str: """Generate marketing copy using DeepSeek.""" - full_prompt = self._build_prompt(prompt, context, content_type, tone, brand_voice, sample_campaigns) + full_prompt = self._build_prompt(prompt, context, tone, brand_voice, sample_campaigns) headers = { "Authorization": f"Bearer {self.api_key}", @@ -79,10 +81,13 @@ class MarketingCopywriter: def generate_marketing_copy(prompt: str) -> str: """Helper function to generate marketing copy.""" - brand_style_manager = BrandStyleManager() + embeddings = CohereEmbeddings() + vector_store = VectorStore() + brand_style_manager = BrandStyleManager(embeddings, vector_store) copywriter = MarketingCopywriter(brand_style_manager) context = brand_style_manager.get_relevant_context(prompt) tone = "professional and empathetic" brand_voice = brand_style_manager.get_brand_voice() sample_campaigns = brand_style_manager.get_sample_campaigns() + print(sample_campaigns) return copywriter.generate_copy(prompt, context, tone, brand_voice, sample_campaigns) \ No newline at end of file diff --git a/backend/main.py b/backend/main.py index e935bda..e208165 100644 --- a/backend/main.py +++ b/backend/main.py @@ -11,7 +11,6 @@ import datetime app = Flask(__name__) # Initialize brand style manager -brand_style_manager = BrandStyleManager() data_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "data")) campaign_prompt = [] @@ -35,7 +34,6 @@ def root(): global prompt if request.method == 'POST': prompt = request.form.get('prompt') - campaign_prompt.pop() campaign_prompt.append(prompt) marketing_copy = generate_marketing_copy(prompt) return render_template('index.html', generated_copy=marketing_copy) diff --git a/data/past_campaigns/campaigns.json b/data/past_campaigns/campaigns.json index 6003ecf..d8c4b4e 100644 --- a/data/past_campaigns/campaigns.json +++ b/data/past_campaigns/campaigns.json @@ -6,9 +6,9 @@ "timestamp": "2025-04-18T19:43:30.474972" }, { - "prompt": "chair company", - "content": "Subject: Elevate Your Workspace with Premium Comfort \r\n\r\nHi [Name], \r\n\r\nYour workspace should inspire productivity and comfort\u2014without compromise. Whether you're building your business from home or leading a team in the office, the right chair can transform.\r\n\r\nHere\u2019s what you deserve: \r\n- **Ergonomic support** to keep you focused and pain-free \r\n- **Timeless design** that complements your professional aesthetic \r\n- **Durable craftsmanship** for long-lasting performance \r\n- **Adjustable features** tailored to your unique needs \r\n\r\nDon\u2019t settle for discomfort. Upgrade to a chair that supports your ambition and reflects your standards. \r\n\r\nExplore your options now: [Link] \r\n\r\nWarmly, \r\n[Your Name] \r\n\r\nP.S. Limited stock available\u2014prioritize your comfort today.", - "timestamp": "2025-04-18T19:52:34.117453" + "prompt": "generate a marketing campaign for a TV company", + "content": "**Subject:** Elevate Your Entertainment Experience with Premium TV \r\n\r\n**Header:** Transform How You Watch TV \r\n\r\nDear Waqas.\r\n\r\nAre you tired of settling for mediocre entertainment? It\u2019s time to upgrade your TV experience with cutting-edge technology, unbeatable content, and seamless streaming\u2014all tailored to your lifestyle. \r\n\r\nHere\u2019s what you\u2019ll enjoy with our premium TV service: \r\n- **Unmatched clarity:** Crystal-clear 4K resolution for a theater-like experience at home \r\n- **Endless content:** Thousands of shows, movies, and live sports at your fingertips \r\n- **Personalized recommendations:** Discover new favorites curated just for you \r\n- **Flexible viewing:** Watch anytime, anywhere, on any device \r\n\r\nTake control of your entertainment and never miss a moment of what you love. \r\n\r\n**Ready to upgrade?** [Sign up now] and start your premium TV journey today. \r\n\r\nWarmly, \r\n[Your Name] \r\n[Company Name] \r\n\r\n--- \r\n\r\n**Follow-Up Email Subject:** Your Invitation to Unlimited Entertainment \r\n\r\n**Header:** Don\u2019t Just Watch TV\u2014Experience It \r\n\r\nHi [Name], \r\n\r\nImagine flipping through channels and finding exactly what you want, every time. No more scrolling fatigue, no more compromises. With our TV service, you get: \r\n- **Ad-free options:** Binge without interruptions \r\n- **Exclusive originals:** Access shows you won\u2019t find anywhere else \r\n- **Smart features:** Voice control and intuitive navigation for effortless viewing \r\n\r\nYour entertainment should work for you, not the other way around. \r\n\r\n**Join now:** [Link] and unlock a world of premium content. \r\n\r\nTo your entertainment success, \r\n[Your Name] \r\n[Company Name] \r\n\r\n--- \r\n\r\n**Final Reminder Subject:** Last Chance: Your Premium TV Awaits \r\n\r\n**Header:** Your Best TV Experience Starts Today \r\n\r\nHello [Name], \r\n\r\nThis is your final opportunity to elevate your TV setup with: \r\n- **Dedicated customer support:** We\u2019re here 24/7 to ensure flawless streaming \r\n- **No hidden fees:** Transparent pricing, no surprises \r\n- **30-day trial:** Experience the difference risk-free \r\n\r\nDon\u2019t wait\u2014great entertainment shouldn\u2019t be put on hold. \r\n\r\n**Act now:** [Link] and start watching smarter. \r\n\r\nBest regards, \r\n[Your Name] \r\n[Company Name]", + "timestamp": "2025-04-18T22:24:00.616677" } ] } \ No newline at end of file