Mayank2027 commited on
Commit
b89a90d
·
verified ·
1 Parent(s): b6ee73c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -2
app.py CHANGED
@@ -1,8 +1,18 @@
1
- """Swarm CLI - Gradio Web Interface for Hugging Face Spaces"""
 
 
2
  import os
3
  import sys
4
  import json
5
  import gradio as gr
 
 
 
 
 
 
 
 
6
  from config import Config
7
  from agents.orchestrator import AgentOrchestrator
8
  from utils import UI
@@ -128,4 +138,9 @@ with gr.Blocks(css=CSS, title="Swarm CLI") as demo:
128
  # Launch
129
  if __name__ == "__main__":
130
  demo.launch(server_name="0.0.0.0", server_port=7860)
131
-
 
 
 
 
 
 
1
+
2
+ # Fix app.py to handle Hugging Face secrets properly
3
+ app_py = '''"""Swarm CLI - Gradio Web Interface for Hugging Face Spaces"""
4
  import os
5
  import sys
6
  import json
7
  import gradio as gr
8
+
9
+ # Handle Hugging Face secrets
10
+ if os.path.exists("/run/secrets/"):
11
+ # Hugging Face secrets are mounted here
12
+ for secret_file in os.listdir("/run/secrets/"):
13
+ with open(f"/run/secrets/{secret_file}", "r") as f:
14
+ os.environ[secret_file] = f.read().strip()
15
+
16
  from config import Config
17
  from agents.orchestrator import AgentOrchestrator
18
  from utils import UI
 
138
  # Launch
139
  if __name__ == "__main__":
140
  demo.launch(server_name="0.0.0.0", server_port=7860)
141
+ '''
142
+
143
+ with open(f"{base_dir}/app.py", "w") as f:
144
+ f.write(app_py)
145
+
146
+ print("app.py updated with HF secrets support")