Spaces:
Sleeping
Sleeping
fix: bind to 0.0.0.0 on HF Spaces; move CSS to launch()
Browse files
app.py
CHANGED
|
@@ -13,6 +13,7 @@ Usage:
|
|
| 13 |
from __future__ import annotations
|
| 14 |
|
| 15 |
import argparse
|
|
|
|
| 16 |
import sys
|
| 17 |
from dataclasses import asdict
|
| 18 |
from pathlib import Path
|
|
@@ -103,8 +104,7 @@ def _retrieved_html(retrieved: list[dict]) -> str:
|
|
| 103 |
|
| 104 |
|
| 105 |
def _build_app(bot: Chatbot) -> gr.Blocks:
|
| 106 |
-
with gr.Blocks(title="Multilingual Chatbot — AR/EN/FR/CS"
|
| 107 |
-
css=CUSTOM_CSS) as demo:
|
| 108 |
gr.Markdown(
|
| 109 |
"# Multilingual Chatbot\n"
|
| 110 |
"**AR / EN / FR / CS** · Detects language → classifies intent → extracts entities "
|
|
@@ -191,15 +191,18 @@ def main() -> int:
|
|
| 191 |
help="Create a public Gradio share link.")
|
| 192 |
parser.add_argument("--port", type=int, default=7860,
|
| 193 |
help="Local server port (default 7860).")
|
| 194 |
-
parser.add_argument("--host", type=str,
|
| 195 |
-
|
|
|
|
|
|
|
| 196 |
args = parser.parse_args()
|
| 197 |
|
| 198 |
print("Loading models ...")
|
| 199 |
bot = Chatbot()
|
| 200 |
demo = _build_app(bot)
|
| 201 |
demo.launch(server_name=args.host, server_port=args.port, share=args.share,
|
| 202 |
-
theme=gr.themes.Soft(primary_hue="indigo", secondary_hue="slate")
|
|
|
|
| 203 |
return 0
|
| 204 |
|
| 205 |
|
|
|
|
| 13 |
from __future__ import annotations
|
| 14 |
|
| 15 |
import argparse
|
| 16 |
+
import os
|
| 17 |
import sys
|
| 18 |
from dataclasses import asdict
|
| 19 |
from pathlib import Path
|
|
|
|
| 104 |
|
| 105 |
|
| 106 |
def _build_app(bot: Chatbot) -> gr.Blocks:
|
| 107 |
+
with gr.Blocks(title="Multilingual Chatbot — AR/EN/FR/CS") as demo:
|
|
|
|
| 108 |
gr.Markdown(
|
| 109 |
"# Multilingual Chatbot\n"
|
| 110 |
"**AR / EN / FR / CS** · Detects language → classifies intent → extracts entities "
|
|
|
|
| 191 |
help="Create a public Gradio share link.")
|
| 192 |
parser.add_argument("--port", type=int, default=7860,
|
| 193 |
help="Local server port (default 7860).")
|
| 194 |
+
parser.add_argument("--host", type=str,
|
| 195 |
+
default=os.environ.get("GRADIO_SERVER_NAME", "127.0.0.1"),
|
| 196 |
+
help="Server host (default 127.0.0.1 locally; HF Spaces sets "
|
| 197 |
+
"GRADIO_SERVER_NAME=0.0.0.0 which is then used).")
|
| 198 |
args = parser.parse_args()
|
| 199 |
|
| 200 |
print("Loading models ...")
|
| 201 |
bot = Chatbot()
|
| 202 |
demo = _build_app(bot)
|
| 203 |
demo.launch(server_name=args.host, server_port=args.port, share=args.share,
|
| 204 |
+
theme=gr.themes.Soft(primary_hue="indigo", secondary_hue="slate"),
|
| 205 |
+
css=CUSTOM_CSS)
|
| 206 |
return 0
|
| 207 |
|
| 208 |
|