Spaces:
Running
Running
sample model testing
Browse files- __pycache__/main.cpython-312.pyc +0 -0
- main.py +38 -0
__pycache__/main.cpython-312.pyc
CHANGED
|
Binary files a/__pycache__/main.cpython-312.pyc and b/__pycache__/main.cpython-312.pyc differ
|
|
|
main.py
CHANGED
|
@@ -416,6 +416,44 @@ def batch_match_cv(payload: BatchMatchCVRequest):
|
|
| 416 |
)
|
| 417 |
|
| 418 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 419 |
# ---------------------------------------------------------------------------
|
| 420 |
# POST /v2/process-cv — LLM-powered extraction (pymupdf4llm + local GGUF)
|
| 421 |
# ---------------------------------------------------------------------------
|
|
|
|
| 416 |
)
|
| 417 |
|
| 418 |
|
| 419 |
+
# ---------------------------------------------------------------------------
|
| 420 |
+
# GET /v2/ping-llm — quick diagnostic endpoint to test LLM & latency
|
| 421 |
+
# ---------------------------------------------------------------------------
|
| 422 |
+
|
| 423 |
+
|
| 424 |
+
@app.get("/v2/ping-llm", response_model=APIResponse)
|
| 425 |
+
def ping_llm(prompt: str = "Say hello in one short sentence."):
|
| 426 |
+
"""Diagnostic endpoint to ping the local LLM and measure cold start / response time."""
|
| 427 |
+
t_start = datetime.now(timezone.utc)
|
| 428 |
+
try:
|
| 429 |
+
resp = cv_processor_v2.extractor.llm.create_chat_completion(
|
| 430 |
+
messages=[{"role": "user", "content": prompt}],
|
| 431 |
+
max_tokens=64,
|
| 432 |
+
temperature=0.1,
|
| 433 |
+
)
|
| 434 |
+
reply = resp["choices"][0]["message"]["content"].strip()
|
| 435 |
+
t_end = datetime.now(timezone.utc)
|
| 436 |
+
duration_ms = int((t_end - t_start).total_seconds() * 1000)
|
| 437 |
+
|
| 438 |
+
active_cfg = cv_processor_v2.extractor._active_cfg or {}
|
| 439 |
+
return APIResponse(
|
| 440 |
+
message="LLM ping successful",
|
| 441 |
+
statusCode=200,
|
| 442 |
+
payload={
|
| 443 |
+
"model": active_cfg.get("label", "unknown"),
|
| 444 |
+
"prompt": prompt,
|
| 445 |
+
"reply": reply,
|
| 446 |
+
"duration_ms": duration_ms,
|
| 447 |
+
"duration_seconds": round(duration_ms / 1000, 2),
|
| 448 |
+
},
|
| 449 |
+
)
|
| 450 |
+
except Exception as exc:
|
| 451 |
+
return APIResponse(
|
| 452 |
+
message=f"LLM ping error: {exc}",
|
| 453 |
+
statusCode=500,
|
| 454 |
+
)
|
| 455 |
+
|
| 456 |
+
|
| 457 |
# ---------------------------------------------------------------------------
|
| 458 |
# POST /v2/process-cv — LLM-powered extraction (pymupdf4llm + local GGUF)
|
| 459 |
# ---------------------------------------------------------------------------
|