Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/outlines/models/mlxlm.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def format_output_type(
The logits processor argument to be passed to the model.

"""
if not output_type:
if output_type is None:
return None
return [output_type]

Expand Down
23 changes: 23 additions & 0 deletions tests/models/test_mlxlm_type_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,29 @@ def test_mlxlm_type_adapter_format_input(adapter, image):
]))


def test_mlxlm_type_adapter_format_output_type_falsy_processor():
tokenizer = MagicMock()
adapter = MLXLMTypeAdapter(tokenizer=tokenizer)

class FalsyProcessor:
def __bool__(self):
return False

processor = FalsyProcessor()
result = adapter.format_output_type(processor)

assert result == [processor]


def test_mlxlm_type_adapter_format_output_type_none():
tokenizer = MagicMock()
adapter = MLXLMTypeAdapter(tokenizer=tokenizer)

result = adapter.format_output_type(None)

assert result is None


@pytest.mark.skipif(not HAS_MLX, reason="MLX tests require Apple Silicon")
def test_mlxlm_type_adapter_format_output_type(adapter, logits_processor):
formatted = adapter.format_output_type(logits_processor)
Expand Down