fix(projekt-matching): use response_format json_schema (vLLM 0.22 ignores guided_json)

This commit is contained in:
tlg
2026-07-09 10:55:23 +02:00
parent a7f94914d0
commit 9cbdd2e28c
2 changed files with 13 additions and 18 deletions

View File

@@ -25,18 +25,14 @@ def test_chat_json_strips_think_and_parses():
assert out == {"a": 1}
body = p.call_args.kwargs["json"]
assert "max_tokens" not in body
assert body["guided_json"] == {"type": "object"}
assert body["response_format"]["json_schema"]["schema"] == {"type": "object"}
def test_chat_json_fallback_to_response_format():
bad = mock.Mock(status_code=400,
text="Unknown parameter: 'guided_json'")
good = mock.Mock(status_code=200)
good.json.return_value = {"choices": [{"message": {"content": "{}"}}]}
with mock.patch("projektmatch.llm.requests.post",
mock.Mock(side_effect=[bad, good])) as p:
assert llm.chat_json("http://v/v1", "m", [], {"type": "object"}) == {}
assert "response_format" in p.call_args.kwargs["json"]
def test_chat_json_strips_markdown_fences():
content = "```json\n{\"a\": 2}\n```"
with mock.patch("projektmatch.llm.requests.post", fake_post([content])):
out = llm.chat_json("http://v/v1", "m", [], {"type": "object"})
assert out == {"a": 2}
def test_match_cv_retries_on_missing_nr_then_raises():