Skip to content

Commit

Permalink
Address code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
XiChenn committed Apr 26, 2023
1 parent 4c1fc67 commit 17a99c7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pybossa/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ def large_language_model(model_name):
model_endpoint = endpoints.get(model_name.lower())

if not model_endpoint:
return abort(403, f'Model with name {model_name} does not exist.')
return abort(400, f'{model_name} LLM is unsupported on this platform.')

proxies = current_app.config.get('PROXIES')
cert = current_app.config.get('CA_CERT', False)
Expand All @@ -899,7 +899,7 @@ def large_language_model(model_name):
if isinstance(prompts, list):
prompts = prompts[0] # Batch request temporarily NOT supported
if not isinstance(prompts, str):
return abort(400, f'prompts should be a string a list of strings')
return abort(400, f'prompts should be a string or a list of strings')
data = {
"instances": [
{
Expand Down
4 changes: 2 additions & 2 deletions test/test_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ def test_invalid_model_name(self, mock_post):
"prompts": "Identify the company name: Microsoft will release Windows 20 next year."
}):
response = large_language_model('invalid-model')
self.assertEqual(response.status_code, 403)
self.assertIn('Model with name', response.json.get('exception_msg'))
self.assertEqual(response.status_code, 400)
self.assertIn('LLM is unsupported', response.json.get('exception_msg'))

@patch('requests.post')
def test_invalid_json(self, mock_post):
Expand Down

0 comments on commit 17a99c7

Please sign in to comment.