Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -35,7 +35,6 @@ class ContentGenerator:
|
|
| 35 |
self.llm = OpenAI(api_key=openai_api_key, temperature=0.7)
|
| 36 |
self.openai_client = OpenAIClient(api_key=openai_api_key)
|
| 37 |
self.replicate_client = replicate.Client(api_token=replicate_api_key)
|
| 38 |
-
# Initialize search tool
|
| 39 |
self.search_tool = SearchTool()
|
| 40 |
|
| 41 |
def generate_quote(self):
|
|
@@ -58,6 +57,12 @@ class ContentGenerator:
|
|
| 58 |
4. Ensure it's authentic and verifiable
|
| 59 |
5. Keep the quote concise and impactful
|
| 60 |
Return in JSON format with keys: quote, author, tradition""",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
agent=quote_curator
|
| 62 |
)
|
| 63 |
|
|
@@ -75,7 +80,6 @@ class ContentGenerator:
|
|
| 75 |
logger.error(f"Quote generation failed: {str(e)}")
|
| 76 |
raise
|
| 77 |
|
| 78 |
-
|
| 79 |
def _parse_quote_result(self, result):
|
| 80 |
"""Parse the generated quote result"""
|
| 81 |
try:
|
|
@@ -117,10 +121,10 @@ class ContentGenerator:
|
|
| 117 |
"""Generate background music using MusicGen"""
|
| 118 |
try:
|
| 119 |
prompts = {
|
| 120 |
-
"Hinduism": "Indian meditation music with soft flute and gentle tabla",
|
| 121 |
-
"Buddhism": "Tibetan singing bowls with gentle bells and deep resonance",
|
| 122 |
-
"Taoism": "Chinese zen music with flowing water sounds and bamboo flute",
|
| 123 |
-
"default": "Peaceful ambient meditation music with soft drones"
|
| 124 |
}
|
| 125 |
|
| 126 |
prompt = prompts.get(tradition, prompts["default"])
|
|
@@ -139,6 +143,7 @@ class ContentGenerator:
|
|
| 139 |
logger.error(f"Audio generation failed: {str(e)}")
|
| 140 |
raise
|
| 141 |
|
|
|
|
| 142 |
def generate_hashtags(tradition):
|
| 143 |
"""Generate relevant hashtags"""
|
| 144 |
base_tags = ["#spirituality", "#mindfulness", "#wisdom", "#inspiration", "#meditation"]
|
|
|
|
| 35 |
self.llm = OpenAI(api_key=openai_api_key, temperature=0.7)
|
| 36 |
self.openai_client = OpenAIClient(api_key=openai_api_key)
|
| 37 |
self.replicate_client = replicate.Client(api_token=replicate_api_key)
|
|
|
|
| 38 |
self.search_tool = SearchTool()
|
| 39 |
|
| 40 |
def generate_quote(self):
|
|
|
|
| 57 |
4. Ensure it's authentic and verifiable
|
| 58 |
5. Keep the quote concise and impactful
|
| 59 |
Return in JSON format with keys: quote, author, tradition""",
|
| 60 |
+
expected_output="""A JSON object containing:
|
| 61 |
+
{
|
| 62 |
+
"quote": "The spiritual quote text",
|
| 63 |
+
"author": "Name of the author or source",
|
| 64 |
+
"tradition": "The spiritual tradition (e.g., Buddhism, Hinduism, Taoism)"
|
| 65 |
+
}""",
|
| 66 |
agent=quote_curator
|
| 67 |
)
|
| 68 |
|
|
|
|
| 80 |
logger.error(f"Quote generation failed: {str(e)}")
|
| 81 |
raise
|
| 82 |
|
|
|
|
| 83 |
def _parse_quote_result(self, result):
|
| 84 |
"""Parse the generated quote result"""
|
| 85 |
try:
|
|
|
|
| 121 |
"""Generate background music using MusicGen"""
|
| 122 |
try:
|
| 123 |
prompts = {
|
| 124 |
+
"Hinduism": "Indian meditation music with soft flute and gentle tabla, peaceful and calming",
|
| 125 |
+
"Buddhism": "Tibetan singing bowls with gentle bells and deep resonance, meditative atmosphere",
|
| 126 |
+
"Taoism": "Chinese zen music with flowing water sounds and bamboo flute, tranquil and balanced",
|
| 127 |
+
"default": "Peaceful ambient meditation music with soft drones and gentle bells"
|
| 128 |
}
|
| 129 |
|
| 130 |
prompt = prompts.get(tradition, prompts["default"])
|
|
|
|
| 143 |
logger.error(f"Audio generation failed: {str(e)}")
|
| 144 |
raise
|
| 145 |
|
| 146 |
+
# [Rest of the code remains the same...]
|
| 147 |
def generate_hashtags(tradition):
|
| 148 |
"""Generate relevant hashtags"""
|
| 149 |
base_tags = ["#spirituality", "#mindfulness", "#wisdom", "#inspiration", "#meditation"]
|