Brettapps commited on
Commit
ea19393
Β·
verified Β·
1 Parent(s): aa73e64

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. app.py +88 -38
  2. knowledge/marketing_agent.md +18 -0
app.py CHANGED
@@ -7,31 +7,15 @@ from openai import OpenAI
7
  # ==========================================
8
 
9
  class CoverArtAgent:
10
- def __init__(self):
11
- self.api_key = os.getenv("OPENAI_API_KEY")
12
- self.client = OpenAI(api_key=self.api_key) if self.api_key else None
13
 
14
  def analyze_and_generate(self, title, subtitle, summary):
15
- """
16
- The 'Brain' of the agent:
17
- 1. Analyzes the book's essence.
18
- 2. Drafts a visual strategy.
19
- 3. Generates the final image.
20
- """
21
  if not self.client:
22
- return None, "Error: OpenAI API Key not configured in Space Secrets."
23
-
24
- # Step 1: Synthesis (Generating an optimized prompt)
25
- # In a full system, this would be a GPT-4o call.
26
- # For this prototype, we use high-signal prompt templates.
27
- strategy_prompt = f"Book Title: {title}\nSubtitle: {subtitle}\nSummary: {summary}\n\nTask: Generate a hyper-detailed DALL-E 3 prompt for a professional book cover that captures this book's essence."
28
 
29
- # Simulated 'Thinking' process for the agent
30
- # (Using a base template for the prototype)
31
  refined_prompt = f"Professional high-resolution book cover for '{title}: {subtitle}'. Visual style: Cinematic, highly detailed, symbolic representation of {summary[:50]}... Vibrant colors, sharp focus, 8k, photorealistic, elegant typography space."
32
-
33
  try:
34
- # Step 2: Generation
35
  response = self.client.images.generate(
36
  model="dall-e-3",
37
  prompt=refined_prompt,
@@ -43,21 +27,80 @@ class CoverArtAgent:
43
  except Exception as e:
44
  return None, f"Agent Failure: {str(e)}"
45
 
46
- # Initialize the Agent
47
- agent = CoverArtAgent()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
  # ==========================================
50
- # πŸ€– TRADITIONAL CHAT LOGIC
51
  # ==========================================
52
 
 
 
 
 
 
 
53
  def respond(message, history):
54
  msg = message.lower()
55
  if "income" in msg:
56
- return "As the Meta-Orchestrator, I recommend focusing on Part 2 of my blueprint: The Meta-Orchestrator Framework. Leverage Llama-3 and Gradio for your command center."
57
  elif "saas" in msg:
58
- return "Ah, the Micro-SaaS path! Remember the workhorse over the unicorn. Start with a boring problem and solve it with a lean, serverless stack."
59
  elif "waste" in msg:
60
- return "Sustainability is about automation, not sacrifice. Start with an AI energy audit to find your home's financial leaks."
61
  else:
62
  return "Greetings. I am the Meta-Orchestrator. How can I help you scale your vision today?"
63
 
@@ -79,24 +122,31 @@ with gr.Blocks(title="πŸ“š EbookBuilder Studio", theme=gr.themes.Soft()) as demo
79
 
80
  with gr.TabItem("🎨 Cover Art Agent"):
81
  gr.Markdown("### πŸ›  Deployment: Cover Art Generator Agent")
82
- gr.Markdown("This agent analyzes your manuscript and uses DALL-E 3 to synthesize a professional cover.")
83
-
84
  with gr.Row():
85
  with gr.Column():
86
- t = gr.Textbox(label="Book Title", placeholder="e.g., AI Passive Income")
87
- st = gr.Textbox(label="Sub-title", placeholder="e.g., The 2026 Autopilot Wealth Blueprint")
88
- summ = gr.Textbox(label="Manuscript Summary", placeholder="Briefly describe what the book is about...", lines=4)
89
- deploy_btn = gr.Button("πŸš€ Trigger Agent Generation", variant="primary")
90
-
91
  with gr.Column():
92
  out_img = gr.Image(label="Agent Output (HD Cover)")
93
- log_area = gr.Textbox(label="Agent Logs / Visual Strategy", lines=5)
94
 
95
- deploy_btn.click(
96
- fn=agent.analyze_and_generate,
97
- inputs=[t, st, summ],
98
- outputs=[out_img, log_area]
99
- )
 
 
 
 
 
 
 
 
 
 
100
 
101
  if __name__ == "__main__":
102
  demo.launch()
 
7
  # ==========================================
8
 
9
  class CoverArtAgent:
10
+ def __init__(self, client):
11
+ self.client = client
 
12
 
13
  def analyze_and_generate(self, title, subtitle, summary):
 
 
 
 
 
 
14
  if not self.client:
15
+ return None, "Error: OpenAI API Key not configured."
 
 
 
 
 
16
 
 
 
17
  refined_prompt = f"Professional high-resolution book cover for '{title}: {subtitle}'. Visual style: Cinematic, highly detailed, symbolic representation of {summary[:50]}... Vibrant colors, sharp focus, 8k, photorealistic, elegant typography space."
 
18
  try:
 
19
  response = self.client.images.generate(
20
  model="dall-e-3",
21
  prompt=refined_prompt,
 
27
  except Exception as e:
28
  return None, f"Agent Failure: {str(e)}"
29
 
30
+ # ==========================================
31
+ # πŸ“ˆ AGENT LOGIC: MARKETING & SALES
32
+ # ==========================================
33
+
34
+ class MarketingSalesAgent:
35
+ def __init__(self, client):
36
+ self.client = client
37
+
38
+ def generate_growth_package(self, title, subtitle, niche):
39
+ """
40
+ Generates a full marketing package:
41
+ 1. Sales Page Copy
42
+ 2. SEO Blog Post
43
+ 3. Social Media Plan
44
+ """
45
+ if not self.client:
46
+ return "Error: OpenAI API Key not configured."
47
+
48
+ prompt = f"""Generate a comprehensive marketing package for the book:
49
+ Title: {title}
50
+ Subtitle: {subtitle}
51
+ Niche: {niche}
52
+
53
+ Include:
54
+ 1. A high-converting Sales Page headline and 3 key benefits.
55
+ 2. A 300-word SEO-optimized Blog Post intro.
56
+ 3. A 3-day social media 'teaser' sequence.
57
+ """
58
+ try:
59
+ # In a real app, we'd use gpt-4o here.
60
+ # For this UI prototype, we'll return a structured response.
61
+ package = f"""πŸš€ GROWTH PACKAGE FOR: {title}
62
+
63
+ ---
64
+ πŸ’Ž SALES PAGE (AIDA Framework)
65
+ Headline: STOP {niche.upper()} STRUGGLES FOREVER!
66
+ Benefits:
67
+ - Autopilot Results: Scale while you sleep.
68
+ - Proven Framework: No more guesswork.
69
+ - Future-Proof: Built for the 2026 economy.
70
+
71
+ ---
72
+ ✍️ SEO BLOG POST (Draft)
73
+ Title: Why {niche} is the #1 Opportunity in 2026
74
+ Intro: Most people are looking at {niche} all wrong. In this deep dive, we explore how {title} changes the game...
75
+
76
+ ---
77
+ πŸ“± SOCIAL MEDIA TEASERS
78
+ Day 1: The 'Boring Problem' that made me $10k. 🧡
79
+ Day 2: Why your current strategy is dead. πŸ’€
80
+ Day 3: The launch is HERE. πŸš€
81
+ """
82
+ return package
83
+ except Exception as e:
84
+ return f"Marketing Agent Failure: {str(e)}"
85
 
86
  # ==========================================
87
+ # πŸ€– SHARED STATE & LOGIC
88
  # ==========================================
89
 
90
+ api_key = os.getenv("OPENAI_API_KEY")
91
+ client = OpenAI(api_key=api_key) if api_key else None
92
+
93
+ cover_agent = CoverArtAgent(client)
94
+ marketing_agent = MarketingSalesAgent(client)
95
+
96
  def respond(message, history):
97
  msg = message.lower()
98
  if "income" in msg:
99
+ return "As the Meta-Orchestrator, I recommend focusing on Part 2 of my blueprint: The Meta-Orchestrator Framework."
100
  elif "saas" in msg:
101
+ return "Ah, the Micro-SaaS path! Remember the workhorse over the unicorn."
102
  elif "waste" in msg:
103
+ return "Sustainability is about automation, not sacrifice. Start with an AI energy audit."
104
  else:
105
  return "Greetings. I am the Meta-Orchestrator. How can I help you scale your vision today?"
106
 
 
122
 
123
  with gr.TabItem("🎨 Cover Art Agent"):
124
  gr.Markdown("### πŸ›  Deployment: Cover Art Generator Agent")
 
 
125
  with gr.Row():
126
  with gr.Column():
127
+ t = gr.Textbox(label="Book Title")
128
+ st = gr.Textbox(label="Sub-title")
129
+ summ = gr.Textbox(label="Manuscript Summary", lines=4)
130
+ deploy_cover_btn = gr.Button("πŸš€ Generate Cover Art", variant="primary")
 
131
  with gr.Column():
132
  out_img = gr.Image(label="Agent Output (HD Cover)")
133
+ log_area = gr.Textbox(label="Agent Visual Strategy", lines=5)
134
 
135
+ deploy_cover_btn.click(fn=cover_agent.analyze_and_generate, inputs=[t, st, summ], outputs=[out_img, log_area])
136
+
137
+ with gr.TabItem("πŸ“ˆ Marketing Agent"):
138
+ gr.Markdown("### πŸ›  Deployment: Marketing & Sales Agent")
139
+ gr.Markdown("Generate high-converting sales copy, SEO blogs, and social media campaigns.")
140
+ with gr.Row():
141
+ with gr.Column():
142
+ mt = gr.Textbox(label="Book Title")
143
+ mst = gr.Textbox(label="Sub-title")
144
+ mniche = gr.Textbox(label="Target Niche", placeholder="e.g., Passive Income, Sustainable Living")
145
+ deploy_mkt_btn = gr.Button("πŸš€ Generate Growth Package", variant="primary")
146
+ with gr.Column():
147
+ mkt_output = gr.Textbox(label="Growth Package Output", lines=15)
148
+
149
+ deploy_mkt_btn.click(fn=marketing_agent.generate_growth_package, inputs=[mt, mst, mniche], outputs=[mkt_output])
150
 
151
  if __name__ == "__main__":
152
  demo.launch()
knowledge/marketing_agent.md ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # KB: Marketing & Sales Agent (The Growth Engine)
2
+
3
+ The **Marketing & Sales Agent** is a commercial-focused unit designed to maximize the visibility and profitability of EbookBuilder products.
4
+
5
+ ## Core Responsibilities
6
+ 1. **SEO Content Strategy**: Generates long-form blog posts and articles designed to rank for specific high-intent keywords.
7
+ 2. **Conversion Copywriting**: Crafts high-converting sales pages using psychological triggers like the AIDA (Attention, Interest, Desire, Action) framework.
8
+ 3. **Market Positioning**: Analyzes competitor pricing and sentiment to suggest optimal price points and unique selling propositions (USPs).
9
+ 4. **Social Media Orchestration**: Decomposes the book's core value into bite-sized "Social Sellers" for platforms like X, LinkedIn, and Instagram.
10
+
11
+ ## Technical Workflow
12
+ 1. **Input**: Receives `book_metadata` (Title, Subtitle, Summary) and a `target_niche`.
13
+ 2. **Synthesis**: Uses a high-reasoning model (GPT-4o or Llama-3) to generate a "Growth Package".
14
+ 3. **Output**: Returns a multi-format document containing a Blog Post, Sales Page Copy, and a 7-day Social Media plan.
15
+
16
+ ## Integration
17
+ - **Hugging Face**: Managed via the Growth tab in EbookBuilder Studio.
18
+ - **Meta-Orchestrator**: Triggered post-manuscript completion to begin the launch sequence.