Spaces:
Sleeping
Sleeping
Update app/main.py
Browse files- app/main.py +20 -2
app/main.py
CHANGED
|
@@ -74,15 +74,33 @@ MODEL_INFO: Dict[str, Dict[str, Any]] = {
|
|
| 74 |
}
|
| 75 |
|
| 76 |
def _probe_model_latency(model_id: str, timeout_sec: float = 8.0) -> Dict[str, Any]:
|
| 77 |
-
"""
|
|
|
|
|
|
|
|
|
|
| 78 |
q = "ping"
|
| 79 |
ctx = "quick latency probe"
|
| 80 |
start = time.perf_counter()
|
| 81 |
ok, err = True, None
|
|
|
|
| 82 |
try:
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
except Exception as e:
|
| 85 |
ok, err = False, str(e)[:200]
|
|
|
|
| 86 |
latency_ms = int((time.perf_counter() - start) * 1000)
|
| 87 |
return {"ok": ok, "latency_ms": latency_ms, "error": err}
|
| 88 |
|
|
|
|
| 74 |
}
|
| 75 |
|
| 76 |
def _probe_model_latency(model_id: str, timeout_sec: float = 8.0) -> Dict[str, Any]:
|
| 77 |
+
"""
|
| 78 |
+
诪讜讚讚 latency 诪砖讜注专 讘注讝专转 驻讬谞讙 拽爪专爪专.
|
| 79 |
+
诪谞住讛 讻诪讛 讞转讬诪讜转 讗驻砖专讬讜转 砖诇 ask_question 讻讚讬 诇讛转讗讬诐 诇住讘讬讘转讱.
|
| 80 |
+
"""
|
| 81 |
q = "ping"
|
| 82 |
ctx = "quick latency probe"
|
| 83 |
start = time.perf_counter()
|
| 84 |
ok, err = True, None
|
| 85 |
+
|
| 86 |
try:
|
| 87 |
+
# 谞住讬讜谉 1: model_key=...
|
| 88 |
+
try:
|
| 89 |
+
_ = ask_question(context=ctx, question=q, model_key=model_id, mode="short")
|
| 90 |
+
except TypeError:
|
| 91 |
+
# 谞住讬讜谉 2: model_name=...
|
| 92 |
+
try:
|
| 93 |
+
_ = ask_question(context=ctx, question=q, model_name=model_id, mode="short")
|
| 94 |
+
except TypeError:
|
| 95 |
+
# 谞住讬讜谉 3: model=...
|
| 96 |
+
try:
|
| 97 |
+
_ = ask_question(context=ctx, question=q, model=model_id, mode="short")
|
| 98 |
+
except TypeError:
|
| 99 |
+
# 谞住讬讜谉 4: 讘诇讬 爪讬讜谉 诪讜讚诇 讻诇诇
|
| 100 |
+
_ = ask_question(context=ctx, question=q)
|
| 101 |
except Exception as e:
|
| 102 |
ok, err = False, str(e)[:200]
|
| 103 |
+
|
| 104 |
latency_ms = int((time.perf_counter() - start) * 1000)
|
| 105 |
return {"ok": ok, "latency_ms": latency_ms, "error": err}
|
| 106 |
|