Skip to content

Commit

Permalink
fix api not valid if limit reached
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelrhmanNile committed Sep 5, 2022
1 parent 55fc746 commit 654d0cc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions freenlpc/freenlpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ def __check_keys(self):
try:
nlpcloud.Client(self.which_model("sentiment_pos_neg"),
self.__api_keys[i], lang="en").sentiment("i hate physics")
except requests.exceptions.HTTPError:
raise Exception(f"API Token at index {i} is not valid.")
except requests.exceptions.HTTPError as e:
if str(e).find("Unauthorized") != -1:
raise Exception(
f"API Token at index {i} is not valid.")

def which_model(self, task_name):
"""which model is being used for a specific task.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

VERSION = '0.1.6'
VERSION = '0.1.7'
DESCRIPTION = 'A wrapper for nlpcloud free-tier services with no requests per minute limits.'
LONG_DESCRIPTION = """# freenlpc
a wrapper for nlpcloud free-tier.
Expand Down

0 comments on commit 654d0cc

Please sign in to comment.