jasonlawAI79 commited on
Commit
9e86500
Β·
verified Β·
1 Parent(s): a69988b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -18,19 +18,16 @@ try:
18
  modal_token = os.environ.get("MODAL_TOKEN")
19
  if modal_token:
20
  try:
21
- # Set up Modal client with token
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.lookup(
28
  "content-creation-agent",
29
  "generate_content_with_llm"
30
  )
31
 
32
  # Test connection with health check
33
- health_check_func = modal.Function.lookup(
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.lookup(
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__":