fix: relax structured output test assertions to handle whitespace and case variations

The ollama/llama3.2:3b-instruct-fp16 model returns string values with trailing
whitespace in structured JSON output. Updated test assertions to use case-insensitive
substring matching instead of exact equality.

Use .lower() for case-insensitive comparison
Check if expected value is contained in actual value (handles whitespace)

Closes: #3996

Signed-off-by: Derek Higgins <derekh@redhat.com>
This commit is contained in:
Derek Higgins 2025-10-30 23:31:56 +00:00
parent 5e20938832
commit 09004b2645

View file

@ -721,6 +721,6 @@ def test_openai_chat_completion_structured_output(openai_client, text_model_id,
print(response.choices[0].message.content) print(response.choices[0].message.content)
answer = AnswerFormat.model_validate_json(response.choices[0].message.content) answer = AnswerFormat.model_validate_json(response.choices[0].message.content)
expected = tc["expected"] expected = tc["expected"]
assert answer.first_name == expected["first_name"] assert expected["first_name"].lower() in answer.first_name.lower()
assert answer.last_name == expected["last_name"] assert expected["last_name"].lower() in answer.last_name.lower()
assert answer.year_of_birth == expected["year_of_birth"] assert answer.year_of_birth == expected["year_of_birth"]