Skip to content

Commit

Permalink
Add test for converting model output without code block markers
Browse files Browse the repository at this point in the history
  • Loading branch information
roribio committed Nov 23, 2024
1 parent caab7aa commit 9dfb1af
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tests/utilities/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ def test_convert_to_model_with_multiple_special_characters():
)


def test_convert_to_model_remove_code_block_markers():
result = '```json {"name": "Charlie", "age": 35}```'
output = convert_to_model(result, SimpleModel, None, None)
assert isinstance(output, SimpleModel)
assert output.age == 35
assert output.name == "Charlie"


# Tests for validate_model
def test_validate_model_pydantic_output():
result = '{"name": "Alice", "age": 25}'
Expand All @@ -142,13 +150,6 @@ def test_validate_model_json_output():
assert output == {"name": "Bob", "age": 40}


def test_validate_model_remove_code_block_markers():
result = '```json {"name": "Charlie", "age": 35}```'
output = validate_model(result, SimpleModel, True, None)
assert isinstance(output, dict)
assert output == {"name": "Charlie", "age": 35}


# Tests for handle_partial_json
def test_handle_partial_json_with_valid_partial():
result = 'Some text {"name": "Charlie", "age": 35} more text'
Expand Down

0 comments on commit 9dfb1af

Please sign in to comment.