test(medgemma): add tests for Gemma chat template formatting
Browse filesCo-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
trialpath/tests/test_medgemma.py
CHANGED
|
@@ -90,6 +90,27 @@ class TestMedGemmaExtraction:
|
|
| 90 |
assert "65" in prompt
|
| 91 |
assert "male" in prompt
|
| 92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
class TestMedGemmaHFEndpoint:
|
| 95 |
"""Test HF Inference Endpoint integration."""
|
|
|
|
| 90 |
assert "65" in prompt
|
| 91 |
assert "male" in prompt
|
| 92 |
|
| 93 |
+
def test_format_gemma_prompt_basic(self):
|
| 94 |
+
"""_format_gemma_prompt should produce valid Gemma chat template."""
|
| 95 |
+
extractor = MedGemmaExtractor.__new__(MedGemmaExtractor)
|
| 96 |
+
messages = [
|
| 97 |
+
{"role": "system", "content": "You are an oncology expert."},
|
| 98 |
+
{"role": "user", "content": "Extract the diagnosis."},
|
| 99 |
+
]
|
| 100 |
+
result = extractor._format_gemma_prompt(messages)
|
| 101 |
+
assert "<start_of_turn>user" in result
|
| 102 |
+
assert "You are an oncology expert." in result
|
| 103 |
+
assert "Extract the diagnosis." in result
|
| 104 |
+
assert result.endswith("<start_of_turn>model\n")
|
| 105 |
+
|
| 106 |
+
def test_format_gemma_prompt_no_system(self):
|
| 107 |
+
"""_format_gemma_prompt should work without system message."""
|
| 108 |
+
extractor = MedGemmaExtractor.__new__(MedGemmaExtractor)
|
| 109 |
+
messages = [{"role": "user", "content": "Hello"}]
|
| 110 |
+
result = extractor._format_gemma_prompt(messages)
|
| 111 |
+
assert "<start_of_turn>user\nHello<end_of_turn>" in result
|
| 112 |
+
assert "<start_of_turn>model\n" in result
|
| 113 |
+
|
| 114 |
|
| 115 |
class TestMedGemmaHFEndpoint:
|
| 116 |
"""Test HF Inference Endpoint integration."""
|