Update app.py
Browse files
app.py
CHANGED
|
@@ -18,19 +18,16 @@ try:
|
|
| 18 |
modal_token = os.environ.get("MODAL_TOKEN")
|
| 19 |
if modal_token:
|
| 20 |
try:
|
| 21 |
-
#
|
| 22 |
-
os.environ["MODAL_TOKEN"] = modal_token
|
| 23 |
-
|
| 24 |
-
# Try to connect to your deployed Modal functions
|
| 25 |
logger.info("π Attempting to connect to Modal functions...")
|
| 26 |
|
| 27 |
-
generate_content_with_llm = modal.Function.
|
| 28 |
"content-creation-agent",
|
| 29 |
"generate_content_with_llm"
|
| 30 |
)
|
| 31 |
|
| 32 |
# Test connection with health check
|
| 33 |
-
health_check_func = modal.Function.
|
| 34 |
"content-creation-agent",
|
| 35 |
"health_check"
|
| 36 |
)
|
|
@@ -46,7 +43,7 @@ try:
|
|
| 46 |
logger.warning(f"β οΈ Modal main function connection failed: {e}")
|
| 47 |
# Try fallback function instead
|
| 48 |
try:
|
| 49 |
-
generate_content_with_llm = modal.Function.
|
| 50 |
"content-creation-agent",
|
| 51 |
"generate_fallback_content"
|
| 52 |
)
|
|
@@ -57,6 +54,7 @@ try:
|
|
| 57 |
MODAL_AVAILABLE = False
|
| 58 |
else:
|
| 59 |
logger.warning("β οΈ MODAL_TOKEN not found in environment variables")
|
|
|
|
| 60 |
|
| 61 |
except ImportError:
|
| 62 |
logger.warning("β οΈ Modal package not available")
|
|
@@ -326,6 +324,8 @@ with gr.Blocks(theme=gr.themes.Soft(), title="π΅ Music Content Creator") as de
|
|
| 326 |
- π€ Support for both named artists and anonymous releases
|
| 327 |
|
| 328 |
**π§ Backend Status:** {"π’ Modal Available" if MODAL_AVAILABLE else "π‘ Local Mode Only"}
|
|
|
|
|
|
|
| 329 |
""")
|
| 330 |
|
| 331 |
with gr.Row():
|
|
@@ -412,6 +412,8 @@ with gr.Blocks(theme=gr.themes.Soft(), title="π΅ Music Content Creator") as de
|
|
| 412 |
- **Best Results:** Include rich, descriptive lyrics for better theme detection
|
| 413 |
|
| 414 |
**π§ Status:** {"β
Modal Working" if MODAL_AVAILABLE else "π‘ Local Mode Only"}
|
|
|
|
|
|
|
| 415 |
""")
|
| 416 |
|
| 417 |
if __name__ == "__main__":
|
|
|
|
| 18 |
modal_token = os.environ.get("MODAL_TOKEN")
|
| 19 |
if modal_token:
|
| 20 |
try:
|
| 21 |
+
# Try to connect to your deployed Modal functions using the new API
|
|
|
|
|
|
|
|
|
|
| 22 |
logger.info("π Attempting to connect to Modal functions...")
|
| 23 |
|
| 24 |
+
generate_content_with_llm = modal.Function.from_name(
|
| 25 |
"content-creation-agent",
|
| 26 |
"generate_content_with_llm"
|
| 27 |
)
|
| 28 |
|
| 29 |
# Test connection with health check
|
| 30 |
+
health_check_func = modal.Function.from_name(
|
| 31 |
"content-creation-agent",
|
| 32 |
"health_check"
|
| 33 |
)
|
|
|
|
| 43 |
logger.warning(f"β οΈ Modal main function connection failed: {e}")
|
| 44 |
# Try fallback function instead
|
| 45 |
try:
|
| 46 |
+
generate_content_with_llm = modal.Function.from_name(
|
| 47 |
"content-creation-agent",
|
| 48 |
"generate_fallback_content"
|
| 49 |
)
|
|
|
|
| 54 |
MODAL_AVAILABLE = False
|
| 55 |
else:
|
| 56 |
logger.warning("β οΈ MODAL_TOKEN not found in environment variables")
|
| 57 |
+
logger.info("π‘ To fix this, add MODAL_TOKEN to your HuggingFace Space environment variables")
|
| 58 |
|
| 59 |
except ImportError:
|
| 60 |
logger.warning("β οΈ Modal package not available")
|
|
|
|
| 324 |
- π€ Support for both named artists and anonymous releases
|
| 325 |
|
| 326 |
**π§ Backend Status:** {"π’ Modal Available" if MODAL_AVAILABLE else "π‘ Local Mode Only"}
|
| 327 |
+
|
| 328 |
+
{"" if MODAL_AVAILABLE else "π‘ **To enable AI generation:** Add your Modal token to the HuggingFace Space environment variables"}
|
| 329 |
""")
|
| 330 |
|
| 331 |
with gr.Row():
|
|
|
|
| 412 |
- **Best Results:** Include rich, descriptive lyrics for better theme detection
|
| 413 |
|
| 414 |
**π§ Status:** {"β
Modal Working" if MODAL_AVAILABLE else "π‘ Local Mode Only"}
|
| 415 |
+
|
| 416 |
+
{"" if MODAL_AVAILABLE else "**To enable Modal AI:** Add MODAL_TOKEN to your HuggingFace Space environment variables"}
|
| 417 |
""")
|
| 418 |
|
| 419 |
if __name__ == "__main__":
|