Expose llama.cpp worker errors
Browse filesCo-authored-by: Codex <chatgpt-codex-connector[bot]@users.noreply.github.com>
- src/extraction/llamacpp_gpu.py +25 -10
src/extraction/llamacpp_gpu.py
CHANGED
|
@@ -126,7 +126,14 @@ def _run_llamacpp_generation(
|
|
| 126 |
chat_handler: str,
|
| 127 |
max_tokens: int,
|
| 128 |
) -> str:
|
| 129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
try:
|
| 131 |
llm = _load(model_path, mmproj_path, chat_handler)
|
| 132 |
except Exception as exc:
|
|
@@ -134,13 +141,21 @@ def _run_llamacpp_generation(
|
|
| 134 |
"The llama.cpp backend could not load the MiniCPM-V GGUF/mmproj pair. "
|
| 135 |
"This usually means the downloaded model build is incompatible with the installed "
|
| 136 |
"llama-cpp-python wheel, the chat handler name does not match the wheel, or one of "
|
| 137 |
-
"the model files is incomplete."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
) from exc
|
| 139 |
-
response = llm.create_chat_completion(
|
| 140 |
-
messages=[{"role": "user", "content": [{"type": "text", "text": EXTRACTION_PROMPT}, *parts]}],
|
| 141 |
-
response_format={"type": "json_object"},
|
| 142 |
-
temperature=0.0,
|
| 143 |
-
reasoning_budget=0,
|
| 144 |
-
max_tokens=max_tokens,
|
| 145 |
-
)
|
| 146 |
-
return response["choices"][0]["message"].get("content") or "{}"
|
|
|
|
| 126 |
chat_handler: str,
|
| 127 |
max_tokens: int,
|
| 128 |
) -> str:
|
| 129 |
+
try:
|
| 130 |
+
model_path, mmproj_path = _download(repo, model_file, mmproj_file)
|
| 131 |
+
except Exception as exc:
|
| 132 |
+
raise RuntimeError(
|
| 133 |
+
"llama.cpp download failed while preparing the GGUF/mmproj pair: "
|
| 134 |
+
f"{type(exc).__name__}: {exc}"
|
| 135 |
+
) from exc
|
| 136 |
+
|
| 137 |
try:
|
| 138 |
llm = _load(model_path, mmproj_path, chat_handler)
|
| 139 |
except Exception as exc:
|
|
|
|
| 141 |
"The llama.cpp backend could not load the MiniCPM-V GGUF/mmproj pair. "
|
| 142 |
"This usually means the downloaded model build is incompatible with the installed "
|
| 143 |
"llama-cpp-python wheel, the chat handler name does not match the wheel, or one of "
|
| 144 |
+
"the model files is incomplete. "
|
| 145 |
+
f"Inner error: {type(exc).__name__}: {exc}"
|
| 146 |
+
) from exc
|
| 147 |
+
|
| 148 |
+
try:
|
| 149 |
+
response = llm.create_chat_completion(
|
| 150 |
+
messages=[{"role": "user", "content": [{"type": "text", "text": EXTRACTION_PROMPT}, *parts]}],
|
| 151 |
+
response_format={"type": "json_object"},
|
| 152 |
+
temperature=0.0,
|
| 153 |
+
reasoning_budget=0,
|
| 154 |
+
max_tokens=max_tokens,
|
| 155 |
+
)
|
| 156 |
+
return response["choices"][0]["message"].get("content") or "{}"
|
| 157 |
+
except Exception as exc:
|
| 158 |
+
raise RuntimeError(
|
| 159 |
+
"llama.cpp generation failed while extracting the document. "
|
| 160 |
+
f"Inner error: {type(exc).__name__}: {exc}"
|
| 161 |
) from exc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|