fix(projekt-matching): retry chat_json on empty/unparseable vLLM completion
This commit is contained in:
@@ -35,6 +35,20 @@ def test_chat_json_strips_markdown_fences():
|
||||
assert out == {"a": 2}
|
||||
|
||||
|
||||
def test_chat_json_retries_on_empty_content():
|
||||
good = json.dumps({"a": 1})
|
||||
with mock.patch("projektmatch.llm.time.sleep", lambda s: None), \
|
||||
mock.patch("projektmatch.llm.requests.post", fake_post(["", good])):
|
||||
assert llm.chat_json("http://v/v1", "m", [], {"type": "object"}) == {"a": 1}
|
||||
|
||||
|
||||
def test_chat_json_raises_after_exhausted_retries():
|
||||
with mock.patch("projektmatch.llm.time.sleep", lambda s: None), \
|
||||
mock.patch("projektmatch.llm.requests.post", fake_post(["", "", ""])):
|
||||
with pytest.raises(llm.LlmError, match="kein JSON"):
|
||||
llm.chat_json("http://v/v1", "m", [], {"type": "object"})
|
||||
|
||||
|
||||
def test_match_cv_retries_on_missing_nr_then_raises():
|
||||
reqs = [{"nr": 1, "text": "Python"}, {"nr": 2, "text": "K8s"}]
|
||||
partial = json.dumps({"ratings": [
|
||||
|
||||
Reference in New Issue
Block a user