Katya Beresneva commited on
Commit ·
6b2a8a9
1
Parent(s): d23d069
fix
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ import gradio as gr
|
|
| 4 |
import requests
|
| 5 |
import pandas as pd
|
| 6 |
from agent import MultiModalAgent
|
|
|
|
| 7 |
|
| 8 |
# (Keep Constants as is)
|
| 9 |
# --- Constants ---
|
|
@@ -183,12 +184,24 @@ with gr.Blocks() as demo:
|
|
| 183 |
"""
|
| 184 |
)
|
| 185 |
|
| 186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
|
| 188 |
run_button = gr.Button("Run Evaluation & Submit All Answers")
|
| 189 |
|
| 190 |
status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
| 191 |
-
# Removed max_rows=10 from DataFrame constructor
|
| 192 |
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|
| 193 |
|
| 194 |
run_button.click(
|
|
@@ -198,24 +211,25 @@ with gr.Blocks() as demo:
|
|
| 198 |
|
| 199 |
if __name__ == "__main__":
|
| 200 |
print("\n" + "-"*30 + " App Starting " + "-"*30)
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
|
|
|
| 215 |
else:
|
| 216 |
-
print("ℹ️
|
| 217 |
|
| 218 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
| 219 |
-
|
| 220 |
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
|
|
|
| 221 |
demo.launch(debug=True, share=False)
|
|
|
|
| 4 |
import requests
|
| 5 |
import pandas as pd
|
| 6 |
from agent import MultiModalAgent
|
| 7 |
+
from config import is_running_in_space
|
| 8 |
|
| 9 |
# (Keep Constants as is)
|
| 10 |
# --- Constants ---
|
|
|
|
| 184 |
"""
|
| 185 |
)
|
| 186 |
|
| 187 |
+
if is_running_in_space():
|
| 188 |
+
gr.LoginButton()
|
| 189 |
+
else:
|
| 190 |
+
gr.Markdown(
|
| 191 |
+
"""
|
| 192 |
+
⚠️ **Local Development Mode**
|
| 193 |
+
|
| 194 |
+
When running locally:
|
| 195 |
+
1. OAuth is not required
|
| 196 |
+
2. Set up your .env file with required API keys
|
| 197 |
+
3. Test your agent implementation
|
| 198 |
+
4. Deploy to HuggingFace Spaces for full OAuth functionality
|
| 199 |
+
"""
|
| 200 |
+
)
|
| 201 |
|
| 202 |
run_button = gr.Button("Run Evaluation & Submit All Answers")
|
| 203 |
|
| 204 |
status_output = gr.Textbox(label="Run Status / Submission Result", lines=5, interactive=False)
|
|
|
|
| 205 |
results_table = gr.DataFrame(label="Questions and Agent Answers", wrap=True)
|
| 206 |
|
| 207 |
run_button.click(
|
|
|
|
| 211 |
|
| 212 |
if __name__ == "__main__":
|
| 213 |
print("\n" + "-"*30 + " App Starting " + "-"*30)
|
| 214 |
+
|
| 215 |
+
if is_running_in_space():
|
| 216 |
+
space_host = os.getenv("SPACE_HOST")
|
| 217 |
+
space_id = os.getenv("SPACE_ID")
|
| 218 |
+
|
| 219 |
+
if space_host:
|
| 220 |
+
print(f"✅ SPACE_HOST found: {space_host}")
|
| 221 |
+
print(f" Runtime URL should be: https://{space_host}.hf.space")
|
| 222 |
+
|
| 223 |
+
if space_id:
|
| 224 |
+
print(f"✅ SPACE_ID found: {space_id}")
|
| 225 |
+
print(f" Repo URL: https://huggingface.co/spaces/{space_id}")
|
| 226 |
+
print(f" Repo Tree URL: https://huggingface.co/spaces/{space_id}/tree/main")
|
| 227 |
+
|
| 228 |
+
print("\n⚠️ Running in Space mode - OAuth required")
|
| 229 |
else:
|
| 230 |
+
print("\nℹ️ Running in local development mode - OAuth not required")
|
| 231 |
|
| 232 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
|
|
|
| 233 |
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
| 234 |
+
|
| 235 |
demo.launch(debug=True, share=False)
|