contentflow 0.2.0__tar.gz → 0.3.0__tar.gz
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-0.2.0 → contentflow-0.3.0}/PKG-INFO +1 -1
- {contentflow-0.2.0 → contentflow-0.3.0}/setup.py +1 -1
- {contentflow-0.2.0 → contentflow-0.3.0}/src/contentflow/__init__.py +1 -1
- contentflow-0.3.0/src/contentflow/generator.py +61 -0
- {contentflow-0.2.0 → contentflow-0.3.0}/src/contentflow.egg-info/PKG-INFO +1 -1
- contentflow-0.2.0/src/contentflow/generator.py +0 -41
- {contentflow-0.2.0 → contentflow-0.3.0}/README.md +0 -0
- {contentflow-0.2.0 → contentflow-0.3.0}/setup.cfg +0 -0
- {contentflow-0.2.0 → contentflow-0.3.0}/src/contentflow.egg-info/SOURCES.txt +0 -0
- {contentflow-0.2.0 → contentflow-0.3.0}/src/contentflow.egg-info/dependency_links.txt +0 -0
- {contentflow-0.2.0 → contentflow-0.3.0}/src/contentflow.egg-info/requires.txt +0 -0
- {contentflow-0.2.0 → contentflow-0.3.0}/src/contentflow.egg-info/top_level.txt +0 -0
|
@@ -6,7 +6,7 @@ long_description = (this_directory / "README.md").read_text()
|
|
|
6
6
|
|
|
7
7
|
setup(
|
|
8
8
|
name="contentflow",
|
|
9
|
-
version="0.
|
|
9
|
+
version="0.3.0",
|
|
10
10
|
description="AI Marketing Content Generator",
|
|
11
11
|
long_description=long_description,
|
|
12
12
|
long_description_content_type='text/markdown',
|
|
@@ -0,0 +1,61 @@
|
|
|
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, destination: str, vibe: str = "exciting", platform: str = "Instagram") -> str:
|
|
16
|
+
"""
|
|
17
|
+
Generate a short ad copy for a destination.
|
|
18
|
+
"""
|
|
19
|
+
if self.api_key:
|
|
20
|
+
return self._generate_ai(destination, vibe, platform)
|
|
21
|
+
return self._generate_template(destination, vibe, platform)
|
|
22
|
+
|
|
23
|
+
def _generate_template(self, destination: str, vibe: str, platform: str) -> str:
|
|
24
|
+
templates = [
|
|
25
|
+
f"{destination} is calling! Experience a {vibe} adventure filled with history and flavor. Book your dream trip today! ✈️ #{destination} #Travel",
|
|
26
|
+
f"Discover the {vibe} magic of {destination} for your next {platform} story! 🌟",
|
|
27
|
+
f"Escape to {destination}. It's simply {vibe}. Check our bio for deals! 🌴",
|
|
28
|
+
]
|
|
29
|
+
return random.choice(templates)
|
|
30
|
+
|
|
31
|
+
def _generate_ai(self, destination: str, vibe: str, platform: str) -> str:
|
|
32
|
+
prompt = f"Write a catchy {platform} marketing slogan for visiting {destination}. 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(destination, vibe, platform)
|
|
40
|
+
except:
|
|
41
|
+
return self._generate_template(destination, vibe, platform)
|
|
42
|
+
|
|
43
|
+
def get_travel_quote(self, category: str = "Adventure") -> str:
|
|
44
|
+
"""
|
|
45
|
+
Get a famous travel quote based on category.
|
|
46
|
+
"""
|
|
47
|
+
quotes = {
|
|
48
|
+
"Adventure": [
|
|
49
|
+
"\"Adventure is worthwhile in itself.\" - Amelia Earhart",
|
|
50
|
+
"\"Life is either a daring adventure or nothing at all.\" - Helen Keller"
|
|
51
|
+
],
|
|
52
|
+
"Luxury": [
|
|
53
|
+
"\"Luxury is the ease of a t-shirt in a very expensive dress.\" - Karl Lagerfeld",
|
|
54
|
+
"\"The best things in life are free. The second best are very expensive.\" - Coco Chanel"
|
|
55
|
+
],
|
|
56
|
+
"Family": [
|
|
57
|
+
"\"The greatest legacy we can leave our children is happy memories.\" - Og Mandino"
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
category_quotes = quotes.get(category, quotes["Adventure"])
|
|
61
|
+
return random.choice(category_quotes)
|
|
@@ -1,41 +0,0 @@
|
|
|
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)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|