Skip to content

Commit

Permalink
Update unittests for refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
smathot committed Mar 9, 2024
1 parent 2d71256 commit 861582f
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 60 deletions.
29 changes: 20 additions & 9 deletions heymans/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,26 @@
# - The answermodel generates the actual answer. This should be a very capable
# model
model_config = {
'openai': {'search_model': 'gpt-3.5',
'condense_model': 'gpt-3.5',
'answer_model': 'gpt-4'},
'anthropic': {'search_model': 'claude-3-sonnet',
'condense_model': 'claude-3-sonnet',
'answer_model': 'claude-3-opus'},
'mistral': {'search_model': 'mistral-medium',
'condense_model': 'mistral-medium',
'answer_model': 'mistral-large'}
'openai': {
'search_model': 'gpt-3.5',
'condense_model': 'gpt-3.5',
'answer_model': 'gpt-4'
},
'anthropic': {
'search_model': 'claude-3-sonnet',
'condense_model': 'claude-3-sonnet',
'answer_model': 'claude-3-opus'
},
'mistral': {
'search_model': 'mistral-medium',
'condense_model': 'mistral-medium',
'answer_model': 'mistral-large'
},
'dummy': {
'search_model': 'dummy',
'condense_model': 'dummy',
'answer_model': 'dummy'
}
}

# TOOLS
Expand Down
4 changes: 1 addition & 3 deletions tests/cheap/test_api_attachments.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ class TestApiAttachments(BaseRoutesTestCase):

def setUp(self):
super().setUp()
config.answer_model = 'dummy'
config.search_model = 'dummy'
config.condense_model = 'dummy'
config.settings_default['model_config'] = 'dummy'
self.login()

def add_attachment(self):
Expand Down
15 changes: 6 additions & 9 deletions tests/cheap/test_api_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,18 @@ class TestApiChat(BaseRoutesTestCase):

def setUp(self):
super().setUp()
config.answer_model = 'dummy'
config.search_model = 'dummy'
config.condense_model = 'dummy'
config.settings_default['model_config'] = 'dummy'
# Check that before login we are not allowed to use the API
response = self.client.post('/api/chat/start', json={
'message': 'hello',
'search_first': False
'message': 'hello'
})
assert response.status_code == 401
self.login()

def test_chat_without_search(self):
self.client.post('/api/setting/set', json={'search_first': 'false'})
response = self.client.post('/api/chat/start', json={
'message': 'hello',
'search_first': False
'message': 'hello'
})
assert response.status_code == 200
response = self.client.get('/api/chat/stream')
Expand All @@ -36,9 +33,9 @@ def test_chat_without_search(self):
assert data['action'] == 'close'

def test_chat_with_search(self):
self.client.post('/api/setting/set', json={'search_first': 'true'})
response = self.client.post('/api/chat/start', json={
'message': 'hello',
'search_first': True
'message': 'hello'
})
assert response.status_code == 200
response = self.client.get('/api/chat/stream')
Expand Down
8 changes: 3 additions & 5 deletions tests/cheap/test_api_conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ class TestApiConversation(BaseRoutesTestCase):

def setUp(self):
super().setUp()
config.answer_model = 'dummy'
config.search_model = 'dummy'
config.condense_model = 'dummy'
config.settings_default['model_config'] = 'dummy'
self.login()

def test_new_conversation(self):
response = self.client.get('/api/conversation/list')
original_count = len(response.json)
response = self.client.get('/api/conversation/new/0',
response = self.client.get('/api/conversation/new',
follow_redirects=True)
self.assertEqual(response.status_code, 200)
response = self.client.get('/api/conversation/list')
Expand All @@ -28,7 +26,7 @@ def test_clear_conversation(self):
self.assertEqual(response.status_code, 200)

def test_delete_conversation(self):
self.client.get('/api/conversation/new/0', follow_redirects=True)
self.client.get('/api/conversation/new', follow_redirects=True)
list_resp = self.client.get('/api/conversation/list')
conversation_id = list(list_resp.json)[0]
original_count = len(list_resp.json)
Expand Down
4 changes: 1 addition & 3 deletions tests/cheap/test_api_setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ class TestApiSetting(BaseRoutesTestCase):

def setUp(self):
super().setUp()
config.answer_model = 'dummy'
config.search_model = 'dummy'
config.condense_model = 'dummy'
config.settings_default['model_config'] = 'dummy'
self.login()

def test_setting(self):
Expand Down
16 changes: 5 additions & 11 deletions tests/expensive/expensive_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,14 @@ def setUp(self):
def _test_tool(self):
pass

def test_gpt4(self):
config.search_model = 'gpt-3.5'
config.condense_model = 'gpt-3.5'
config.answer_model = 'gpt-4'
def test_openai(self):
config.settings_default['model_config'] = 'openai'
self._test_tool()

def test_claude3opus(self):
config.search_model = 'claude-3-sonnet'
config.condense_model = 'claude-3-sonnet'
config.answer_model = 'claude-3-opus'
def test_anthropic(self):
config.settings_default['model_config'] = 'anthropic'
self._test_tool()

def test_mistral(self):
config.search_model = 'mistral-medium'
config.condense_model = 'mistral-medium'
config.answer_model = 'mistral-large'
config.settings_default['model_config'] = 'mistral'
self._test_tool()
26 changes: 6 additions & 20 deletions tests/quality/test_opensesame_qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def init_testlog():
testlog_folder = Path(__file__).parent / 'testlog'
if not testlog_folder.exists():
testlog_folder.mkdir()
testlog = Path(testlog_folder) / f'testlog.{str(datetime.now())}.{config.answer_model}.log'
testlog = Path(testlog_folder) / f'testlog.{str(dtetime.now())}.{config.model_config}.log'


def read_testcases():
Expand Down Expand Up @@ -107,34 +107,20 @@ def score_testcases(select_cases=None):
fd.write(s + '\n')


def test_gpt4():
config.search_model = 'gpt-3.5'
config.condense_model = 'gpt-3.5'
config.answer_model = 'gpt-4'
def test_openai():
config.settings_default['model_config'] = 'openai'
init_testlog()
score_testcases()


def test_gpt4mistral():
config.search_model = 'mistral-medium'
config.condense_model = 'mistral-medium'
config.answer_model = 'gpt-4'
init_testlog()
score_testcases()


def test_mistral():
config.search_model = 'mistral-medium'
config.condense_model = 'mistral-medium'
config.answer_model = 'mistral-large'
config.settings_default['model_config'] = 'mistral'
init_testlog()
score_testcases()


def test_claude3opus():
config.search_model = 'mistral-medium'
config.condense_model = 'claude-3-sonnet'
config.answer_model = 'claude-3-opus'
def test_anthropic():
config.settings_default['model_config'] = 'anthropic'
init_testlog()
score_testcases()

Expand Down

0 comments on commit 861582f

Please sign in to comment.