Spaces:
Sleeping
Sleeping
Add echo/useless mode to improve testing efficiency without loading models
Browse files- __pycache__/app.cpython-313.pyc +0 -0
- app.py +12 -0
__pycache__/app.cpython-313.pyc
CHANGED
|
Binary files a/__pycache__/app.cpython-313.pyc and b/__pycache__/app.cpython-313.pyc differ
|
|
|
app.py
CHANGED
|
@@ -20,6 +20,7 @@ HEALTH_PORT = int(os.getenv("HEALTH_PORT", "8080"))
|
|
| 20 |
GRADIO_HOST = os.getenv("GRADIO_HOST", "0.0.0.0")
|
| 21 |
GRADIO_PORT = int(os.getenv("GRADIO_PORT", "7860"))
|
| 22 |
DEFAULT_MAX_NEW_TOKENS = int(os.getenv("DEFAULT_MAX_NEW_TOKENS", "128"))
|
|
|
|
| 23 |
|
| 24 |
|
| 25 |
# ---------------- Logging ----------------
|
|
@@ -131,6 +132,17 @@ def predict(instruction: str,
|
|
| 131 |
if not instruction or not instruction.strip():
|
| 132 |
return "⚠️ مهرباني وکړئ یوه لارښوونه ولیکئ." # please provide an instruction
|
| 133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
# Build a simple prompt: instruction (+ input if provided)
|
| 135 |
prompt = instruction.strip()
|
| 136 |
if input_text and input_text.strip():
|
|
|
|
| 20 |
GRADIO_HOST = os.getenv("GRADIO_HOST", "0.0.0.0")
|
| 21 |
GRADIO_PORT = int(os.getenv("GRADIO_PORT", "7860"))
|
| 22 |
DEFAULT_MAX_NEW_TOKENS = int(os.getenv("DEFAULT_MAX_NEW_TOKENS", "128"))
|
| 23 |
+
ECHO_MODE = os.getenv("ECHO_MODE", "off").lower() # 'off'|'echo'|'useless'
|
| 24 |
|
| 25 |
|
| 26 |
# ---------------- Logging ----------------
|
|
|
|
| 132 |
if not instruction or not instruction.strip():
|
| 133 |
return "⚠️ مهرباني وکړئ یوه لارښوونه ولیکئ." # please provide an instruction
|
| 134 |
|
| 135 |
+
# Fast path: echo/useless mode avoids loading large models during testing.
|
| 136 |
+
if ECHO_MODE in ("echo", "useless"):
|
| 137 |
+
# If echo mode, return exactly the combined prompt
|
| 138 |
+
prompt = instruction.strip()
|
| 139 |
+
if input_text and input_text.strip():
|
| 140 |
+
prompt += "\n" + input_text.strip()
|
| 141 |
+
if ECHO_MODE == "echo":
|
| 142 |
+
return prompt
|
| 143 |
+
# If useless mode, return a simple placeholder text
|
| 144 |
+
return "This is a useless placeholder response."
|
| 145 |
+
|
| 146 |
# Build a simple prompt: instruction (+ input if provided)
|
| 147 |
prompt = instruction.strip()
|
| 148 |
if input_text and input_text.strip():
|