Update app.py
Browse files
app.py
CHANGED
|
@@ -32,7 +32,7 @@ from gradio_client import Client
|
|
| 32 |
# ============================================================
|
| 33 |
|
| 34 |
APP_NAME = "X-RUDRA"
|
| 35 |
-
VERSION = "3.8.
|
| 36 |
|
| 37 |
M1_REPO = os.getenv("M1_REPO", "Shrijanagain/M1")
|
| 38 |
M2_REPO = os.getenv("M2_REPO", "Shrijanagain/M2")
|
|
@@ -93,13 +93,13 @@ Do NOT add any extra text, punctuation, or explanation.
|
|
| 93 |
def classify_intent(question: str) -> str:
|
| 94 |
prompt = f"{CLASSIFIER_SYSTEM_PROMPT}\n\nUser message: \"{question}\"\n\nClassification:"
|
| 95 |
|
| 96 |
-
# Try M1
|
| 97 |
m1_client = get_m1_client()
|
| 98 |
if m1_client is not None:
|
| 99 |
try:
|
| 100 |
result = m1_client.predict(
|
| 101 |
prompt=prompt,
|
| 102 |
-
max_tokens=
|
| 103 |
temperature=0.0,
|
| 104 |
api_name="/generate"
|
| 105 |
)
|
|
@@ -116,13 +116,13 @@ def classify_intent(question: str) -> str:
|
|
| 116 |
except Exception as e:
|
| 117 |
print(f"[Classifier] M1 call failed: {e}")
|
| 118 |
|
| 119 |
-
# Try M2
|
| 120 |
m2_client = get_m2_client()
|
| 121 |
if m2_client is not None:
|
| 122 |
try:
|
| 123 |
result = m2_client.predict(
|
| 124 |
prompt=prompt,
|
| 125 |
-
max_tokens=
|
| 126 |
temperature=0.0,
|
| 127 |
api_name="/generate"
|
| 128 |
)
|
|
@@ -139,7 +139,7 @@ def classify_intent(question: str) -> str:
|
|
| 139 |
except Exception as e:
|
| 140 |
print(f"[Classifier] M2 call failed: {e}")
|
| 141 |
|
| 142 |
-
#
|
| 143 |
print("[Classifier] Defaulting to ACTION")
|
| 144 |
return "ACTION"
|
| 145 |
|
|
@@ -688,4 +688,5 @@ if __name__ == "__main__":
|
|
| 688 |
print("HF_TOKEN set – rate limits reduced.")
|
| 689 |
else:
|
| 690 |
print("HF_TOKEN not set – you may experience rate limits. Set it as a Secret in your Space.")
|
| 691 |
-
demo.launch(server_name="0.0.0.0", server_port=PORT, css=CSS, show_error=True)
|
|
|
|
|
|
| 32 |
# ============================================================
|
| 33 |
|
| 34 |
APP_NAME = "X-RUDRA"
|
| 35 |
+
VERSION = "3.8.2" # bumped
|
| 36 |
|
| 37 |
M1_REPO = os.getenv("M1_REPO", "Shrijanagain/M1")
|
| 38 |
M2_REPO = os.getenv("M2_REPO", "Shrijanagain/M2")
|
|
|
|
| 93 |
def classify_intent(question: str) -> str:
|
| 94 |
prompt = f"{CLASSIFIER_SYSTEM_PROMPT}\n\nUser message: \"{question}\"\n\nClassification:"
|
| 95 |
|
| 96 |
+
# Try M1
|
| 97 |
m1_client = get_m1_client()
|
| 98 |
if m1_client is not None:
|
| 99 |
try:
|
| 100 |
result = m1_client.predict(
|
| 101 |
prompt=prompt,
|
| 102 |
+
max_tokens=64, # FIXED: was 10 → now 64 (minimum)
|
| 103 |
temperature=0.0,
|
| 104 |
api_name="/generate"
|
| 105 |
)
|
|
|
|
| 116 |
except Exception as e:
|
| 117 |
print(f"[Classifier] M1 call failed: {e}")
|
| 118 |
|
| 119 |
+
# Try M2
|
| 120 |
m2_client = get_m2_client()
|
| 121 |
if m2_client is not None:
|
| 122 |
try:
|
| 123 |
result = m2_client.predict(
|
| 124 |
prompt=prompt,
|
| 125 |
+
max_tokens=64, # FIXED
|
| 126 |
temperature=0.0,
|
| 127 |
api_name="/generate"
|
| 128 |
)
|
|
|
|
| 139 |
except Exception as e:
|
| 140 |
print(f"[Classifier] M2 call failed: {e}")
|
| 141 |
|
| 142 |
+
# Fallback: default to ACTION (research) if both fail
|
| 143 |
print("[Classifier] Defaulting to ACTION")
|
| 144 |
return "ACTION"
|
| 145 |
|
|
|
|
| 688 |
print("HF_TOKEN set – rate limits reduced.")
|
| 689 |
else:
|
| 690 |
print("HF_TOKEN not set – you may experience rate limits. Set it as a Secret in your Space.")
|
| 691 |
+
demo.launch(server_name="0.0.0.0", server_port=PORT, css=CSS, show_error=True)
|
| 692 |
+
|