contentflow 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
contentflow/__init__.py
ADDED
contentflow/generator.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import requests
|
|
3
|
+
import random
|
|
4
|
+
from typing import Optional
|
|
5
|
+
|
|
6
|
+
class ContentGenerator:
|
|
7
|
+
"""
|
|
8
|
+
Generates marketing copy using AI or templates.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
def __init__(self, api_key: Optional[str] = None):
|
|
12
|
+
self.api_key = api_key or os.environ.get("HF_API_TOKEN")
|
|
13
|
+
self.api_url = "https://api-inference.huggingface.co/models/google/flan-t5-large"
|
|
14
|
+
|
|
15
|
+
def generate_ad_copy(self, city: str, vibe: str = "exciting") -> str:
|
|
16
|
+
"""
|
|
17
|
+
Generate a short ad copy for a city.
|
|
18
|
+
"""
|
|
19
|
+
if self.api_key:
|
|
20
|
+
return self._generate_ai(city, vibe)
|
|
21
|
+
return self._generate_template(city, vibe)
|
|
22
|
+
|
|
23
|
+
def _generate_template(self, city: str, vibe: str) -> str:
|
|
24
|
+
templates = [
|
|
25
|
+
f"Discover the {vibe} magic of {city}! Book your trip today.",
|
|
26
|
+
f"{city} is calling! Experience a {vibe} adventure.",
|
|
27
|
+
f"Escape to {city}. It's simply {vibe}.",
|
|
28
|
+
]
|
|
29
|
+
return random.choice(templates)
|
|
30
|
+
|
|
31
|
+
def _generate_ai(self, city: str, vibe: str) -> str:
|
|
32
|
+
prompt = f"Write a catchy marketing slogan for visiting {city}. The vibe should be {vibe}."
|
|
33
|
+
headers = {"Authorization": f"Bearer {self.api_key}"}
|
|
34
|
+
try:
|
|
35
|
+
response = requests.post(self.api_url, headers=headers, json={"inputs": prompt})
|
|
36
|
+
result = response.json()
|
|
37
|
+
if isinstance(result, list) and 'generated_text' in result[0]:
|
|
38
|
+
return result[0]['generated_text']
|
|
39
|
+
return self._generate_template(city, vibe)
|
|
40
|
+
except:
|
|
41
|
+
return self._generate_template(city, vibe)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
contentflow/__init__.py,sha256=rLICcjy7hpVxqwZd0m7dbSF8cjBXQGpPYw5svM5zXuY,117
|
|
2
|
+
contentflow/generator.py,sha256=GpKAUEzjTJojPK4zfmeKGVbPeUKqr-xYpY8sgChwQWc,1615
|
|
3
|
+
contentflow-0.1.0.dist-info/METADATA,sha256=RmAB7ZWCtGWXvqO_s-HYA0FzgHvgzKyZGITK5Km9EMk,207
|
|
4
|
+
contentflow-0.1.0.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
|
|
5
|
+
contentflow-0.1.0.dist-info/top_level.txt,sha256=9XX3utx2U9LYgn6WlpcAWNR3rp9KHrQ9xEe0FO3MJkA,12
|
|
6
|
+
contentflow-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
contentflow
|