Skip to content

Commit

Permalink
WIP Python GPT4All tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmic-snow committed Aug 6, 2023
1 parent 420a5b8 commit c46545b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions gpt4all-bindings/python/gpt4all/tests/test_gpt4all.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Iterable

from gpt4all import GPT4All, Embed4All, pyllmodel
from gpt4all.gpt4all import empty_chat_session, append_bin_suffix_if_missing
from . import get_model_folder
import time
import pytest
Expand Down Expand Up @@ -441,3 +442,24 @@ def test_generate_streaming_with_session(self, model):
print(response2)
assert ''.join(response1) == expected1
assert ''.join(response2) == expected2



@pytest.mark.parametrize('system_prompt', ['', 'System: Hi.', '### System: Be helpful, damnit.'])
def test_empty_chat_session(system_prompt):
chat_session = empty_chat_session(system_prompt)
assert isinstance(chat_session, list)
len(chat_session) == 1
assert all(k in ('role', 'content') for k in chat_session[0].keys())
assert all(isinstance(v, str) for v in chat_session[0].values())
assert chat_session[0]['content'] == system_prompt


@pytest.mark.parametrize('model_name', [None, '', 'mock-model.bin', 'orca-mini-3b.ggmlv3.q4_0'])
def test_append_bin_suffix(model_name):
if not hasattr(model_name, 'endswith'): # duck typing test
with pytest.raises(Exception):
append_bin_suffix_if_missing(model_name)
else:
new_model_name = append_bin_suffix_if_missing(model_name)
assert new_model_name[-4:] == '.bin'

0 comments on commit c46545b

Please sign in to comment.