Commit
·
f482e4d
1
Parent(s):
aaa77dc
Fix: Add proper launch configuration with HF Space detection and queue support
Browse files
app.py
CHANGED
|
@@ -5,6 +5,7 @@ Gradio приложение для мультиагентной системы
|
|
| 5 |
|
| 6 |
import gradio as gr
|
| 7 |
import json
|
|
|
|
| 8 |
from typing import Tuple, Dict, Any
|
| 9 |
|
| 10 |
from agents import LogParserAgent, AnomalyDetectionAgent, RootCauseAgent
|
|
@@ -209,5 +210,20 @@ def create_interface():
|
|
| 209 |
return app
|
| 210 |
|
| 211 |
|
| 212 |
-
# Создание приложения
|
| 213 |
app = create_interface()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
import gradio as gr
|
| 7 |
import json
|
| 8 |
+
import os
|
| 9 |
from typing import Tuple, Dict, Any
|
| 10 |
|
| 11 |
from agents import LogParserAgent, AnomalyDetectionAgent, RootCauseAgent
|
|
|
|
| 210 |
return app
|
| 211 |
|
| 212 |
|
| 213 |
+
# Создание приложения
|
| 214 |
app = create_interface()
|
| 215 |
+
|
| 216 |
+
# Запуск приложения
|
| 217 |
+
if __name__ == "__main__":
|
| 218 |
+
# Проверка, запущено ли в Hugging Face Space
|
| 219 |
+
in_hf_space = bool(os.getenv("SPACE_ID") or os.getenv("HF_SPACE"))
|
| 220 |
+
share_flag = False if in_hf_space else False
|
| 221 |
+
host = os.getenv("GRADIO_HOST") or os.getenv("GRADIO_SERVER_NAME") or "0.0.0.0"
|
| 222 |
+
port = int(os.getenv("PORT") or os.getenv("GRADIO_SERVER_PORT") or 7860)
|
| 223 |
+
|
| 224 |
+
app.queue(api_open=False).launch(
|
| 225 |
+
server_name=host,
|
| 226 |
+
server_port=port,
|
| 227 |
+
share=share_flag,
|
| 228 |
+
show_api=False,
|
| 229 |
+
)
|