AndrewRqy commited on
Commit ·
26f70c8
1
Parent(s): dd4200b
Default --keep-warm and add --stop-on-exit + safer launch for Gradio 4/5/6
Browse files5150 unmodified lines51515152515351545155515651575158515951605161516251635150 unmodified linesreturn run_self_test()# Local entry point — uses the module-level ``demo`` so the local run# matches the HF Space behavior exactly.demo.launch(server_name="0.0.0.0",server_port=7860,ssr_mode=False,allowed_paths=[str(_HERE / "assets")],show_error=True,)return 05150 unmodified lines515151525153515451555156515751585159516051615162516351645165516651675168516951705150 unmodified linesreturn run_self_test()# Local entry point — uses the module-level ``demo`` so the local run# matches the HF Space behavior exactly.# ssr_mode is Gradio 5+ only. The local dev env may still be on# Gradio 4.44 (the version this app was originally built against),# which would TypeError on the unknown kwarg. Try-with-ssr first,# fall back to without on TypeError.launch_kwargs = dict(server_name="0.0.0.0",server_port=7860,allowed_paths=[str(_HERE / "assets")],show_error=True,)try:demo.launch(ssr_mode=False, **launch_kwargs)except TypeError:demo.launch(**launch_kwargs)return 0
8 unmodified lines91011121314151634 unmodified lines515253545556571 unmodified line596061626364658 unmodified lines# --base-model Request bare base Qwen (no LoRA) from whichever# backend is running. Equivalent to# ORACLES_LLM_MODEL=llm.# --keep-warm Do NOT stop the Modal LLM on exit# (KEEP_LLM_WARM=1). Ignored in --local-llama mode.# --local-llama Run llama-cpp-python locally on a GGUF copy of# the model — no Modal calls, no cloud. Requires# the .gguf file already on disk (see env var34 unmodified lines# -----------------------------------------------------------------------------# Parse our own flags (everything else gets passed through to app.py)# -----------------------------------------------------------------------------KEEP_WARM="${KEEP_LLM_WARM:-0}"USE_BASE_MODEL="0"USE_LOCAL_LLAMA="0"SAVE_TRACE_DIR=""1 unmodified linefor arg in "$@"; docase "$arg" in--base-model) USE_BASE_MODEL="1" ;;--keep-warm) KEEP_WARM="1" ;;--local-llama) USE_LOCAL_LLAMA="1" ;;--save-trace) SAVE_TRACE_DIR="./traces" ;;--save-trace=*) SAVE_TRACE_DIR="${arg#--save-trace=}" ;;8 unmodified lines9101112131415161718192034 unmodified lines555657585960616263641 unmodified line66676869707172738 unmodified lines# --base-model Request bare base Qwen (no LoRA) from whichever# backend is running. Equivalent to# ORACLES_LLM_MODEL=llm.# --keep-warm (default) Leave the Modal LLM running on exit# so the deployed HF Space can still reach it.# Ignored in --local-llama mode.# --stop-on-exit Inverse of --keep-warm: stop the Modal app when# this script exits. Useful only if you know no# other clients (HF Space, teammates) are using it.# --local-llama Run llama-cpp-python locally on a GGUF copy of# the model — no Modal calls, no cloud. Requires# the .gguf file already on disk (see env var34 unmodified lines# -----------------------------------------------------------------------------# Parse our own flags (everything else gets passed through to app.py)# -----------------------------------------------------------------------------# Default to keep-warm so the deployed HF Space (which shares the same# Modal endpoint) doesn't get an APIConnectionError every time a local# run exits. Pass --stop-on-exit to opt out and stop billing.KEEP_WARM="${KEEP_LLM_WARM:-1}"USE_BASE_MODEL="0"USE_LOCAL_LLAMA="0"SAVE_TRACE_DIR=""1 unmodified linefor arg in "$@"; docase "$arg" in--base-model) USE_BASE_MODEL="1" ;;--keep-warm) KEEP_WARM="1" ;; # back-compat noop--stop-on-exit) KEEP_WARM="0" ;;--local-llama) USE_LOCAL_LLAMA="1" ;;--save-trace) SAVE_TRACE_DIR="./traces" ;;--save-trace=*) SAVE_TRACE_DIR="${arg#--save-trace=}" ;;
app.py+9-2
run.sh+12-4