Skip to content
This repository has been archived by the owner on Aug 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #43 from terry3041/main
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Cheong authored Dec 5, 2022
2 parents 817e17a + 7bbd37e commit e3eea41
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/revChatGPT/revChatGPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def get_chat_text(self, data):
response = response[6:]
except:
print(response.text)
return ValueError("Response is not in the correct format")
raise ValueError("Response is not in the correct format")
response = json.loads(response)
self.parent_id = response["message"]["id"]
self.conversation_id = response["conversation_id"]
Expand All @@ -84,11 +84,11 @@ def get_chat_response(self, prompt, output="text"):
elif output == "stream":
return self.get_chat_stream(data)
else:
return ValueError("Output must be either 'text' or 'response'")
raise ValueError("Output must be either 'text' or 'response'")

def refresh_session(self):
if 'session_token' not in self.config and ('email' not in self.config or 'password' not in self.config):
return ValueError("No tokens provided")
raise ValueError("No tokens provided")
elif 'session_token' in self.config:
s = requests.Session()
# Set cookies
Expand All @@ -109,7 +109,7 @@ def refresh_session(self):
print("Error refreshing session: " + e)
return e
else:
return ValueError("No tokens provided")
raise ValueError("No tokens provided")

def login(self, email, password):
print("Logging in...")
Expand All @@ -120,7 +120,7 @@ def login(self, email, password):
# if ValueError with e as "Captcha detected" fail
if e == "Captcha detected":
print("Captcha not supported. Use session tokens instead.")
return ValueError("Captcha detected")
raise ValueError("Captcha detected")
self.config['Authorization'] = auth.access_token
self.refresh_headers()

Expand Down Expand Up @@ -271,7 +271,7 @@ def part_five(self, state: str):
soup = BeautifulSoup(response.text, 'lxml')
if soup.find('img', alt='captcha'):
print("Captcha detected")
return ValueError("Captcha detected")
raise ValueError("Captcha detected")
else:
self.part_six(state=state, captcha=None)
else:
Expand Down

0 comments on commit e3eea41

Please sign in to comment.