Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -47,9 +47,10 @@ class ContentGenerator:
|
|
| 47 |
traditions = SpiritualThemes.TRADITIONS[tradition_category]
|
| 48 |
themes = random.sample(SpiritualThemes.THEMES, 2)
|
| 49 |
style = random.choice(SpiritualThemes.QUOTE_STYLES)
|
| 50 |
-
return f"""
|
| 51 |
-
|
| 52 |
-
|
|
|
|
| 53 |
|
| 54 |
def _get_fallback_quote(self):
|
| 55 |
fallback_quotes = [
|
|
@@ -76,24 +77,32 @@ class ContentGenerator:
|
|
| 76 |
model="gpt-4",
|
| 77 |
messages=[{
|
| 78 |
"role": "system",
|
| 79 |
-
"content": "Generate spiritual
|
| 80 |
}, {
|
| 81 |
"role": "user",
|
| 82 |
-
"content": self._generate_prompt_variation()
|
| 83 |
-
"\nProvide quote in this format only:\nQUOTE:\nAUTHOR:\nTRADITION:\nTHEME:"
|
| 84 |
}],
|
| 85 |
temperature=0.7
|
| 86 |
)
|
| 87 |
|
| 88 |
text = response.choices[0].message.content
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
"generated_at": datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 96 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
except Exception as e:
|
| 98 |
log_message(f"❌ Quote generation failed: {str(e)}")
|
| 99 |
return self._get_fallback_quote()
|
|
|
|
| 47 |
traditions = SpiritualThemes.TRADITIONS[tradition_category]
|
| 48 |
themes = random.sample(SpiritualThemes.THEMES, 2)
|
| 49 |
style = random.choice(SpiritualThemes.QUOTE_STYLES)
|
| 50 |
+
return f"""Generate a spiritual quote from {tradition_category} wisdom tradition.
|
| 51 |
+
Focus on themes of {themes[0]} and {themes[1]}.
|
| 52 |
+
Make it profound yet accessible.
|
| 53 |
+
Format: Return only the quote text on first line, then author name on second line."""
|
| 54 |
|
| 55 |
def _get_fallback_quote(self):
|
| 56 |
fallback_quotes = [
|
|
|
|
| 77 |
model="gpt-4",
|
| 78 |
messages=[{
|
| 79 |
"role": "system",
|
| 80 |
+
"content": "Generate a spiritual quote with attribution."
|
| 81 |
}, {
|
| 82 |
"role": "user",
|
| 83 |
+
"content": self._generate_prompt_variation()
|
|
|
|
| 84 |
}],
|
| 85 |
temperature=0.7
|
| 86 |
)
|
| 87 |
|
| 88 |
text = response.choices[0].message.content
|
| 89 |
+
lines = text.split('\n')
|
| 90 |
+
quote_text = lines[0] if lines else ""
|
| 91 |
+
author = lines[1].replace('-', '').strip() if len(lines) > 1 else "Unknown"
|
| 92 |
+
tradition = random.choice(list(SpiritualThemes.TRADITIONS.keys()))
|
| 93 |
+
theme = random.choice(SpiritualThemes.THEMES)
|
| 94 |
+
|
| 95 |
+
result = {
|
| 96 |
+
"text": quote_text,
|
| 97 |
+
"author": author,
|
| 98 |
+
"tradition": tradition,
|
| 99 |
+
"theme": theme,
|
| 100 |
"generated_at": datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
| 101 |
}
|
| 102 |
+
|
| 103 |
+
log_message(f"✨ Generated quote: {quote_text}")
|
| 104 |
+
return result
|
| 105 |
+
|
| 106 |
except Exception as e:
|
| 107 |
log_message(f"❌ Quote generation failed: {str(e)}")
|
| 108 |
return self._get_fallback_quote()
|