Skip to content

Commit

Permalink
added method for deleting poe account
Browse files Browse the repository at this point in the history
  • Loading branch information
sudouser777 committed May 1, 2023
1 parent 2ae26bf commit 4b86f50
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
23 changes: 12 additions & 11 deletions gpt4free/quora/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ def get(self):
cookies = open(Path(__file__).resolve().parent / 'cookies.txt', 'r').read().splitlines()
return choice(cookies)

@staticmethod
def delete_account(token: str, proxy: Optional[str] = None):
client = PoeClient(token, proxy=proxy)
client.delete_account()


class StreamingCompletion:
@staticmethod
Expand All @@ -293,11 +298,11 @@ def create(
custom_model: bool = None,
prompt: str = 'hello world',
token: str = '',
proxy: Optional[str] = None
proxy: Optional[str] = None,
) -> Generator[PoeResponse, None, None]:
_model = MODELS[model] if not custom_model else custom_model

proxies = { 'http': 'http:https://' + proxy, 'https': 'http:https://' + proxy } if proxy else False
proxies = {'http': 'http:https://' + proxy, 'https': 'http:https://' + proxy} if proxy else False
client = PoeClient(token)
client.proxy = proxies

Expand Down Expand Up @@ -333,7 +338,7 @@ def create(
custom_model: str = None,
prompt: str = 'hello world',
token: str = '',
proxy: Optional[str] = None
proxy: Optional[str] = None,
) -> PoeResponse:
_model = MODELS[model] if not custom_model else custom_model

Expand Down Expand Up @@ -454,14 +459,7 @@ def chat(self, message: str, model: Optional[str] = None) -> str:
response = chunk['text']
return response

def create_bot(
self,
name: str,
/,
prompt: str = '',
base_model: str = 'ChatGPT',
description: str = '',
) -> None:
def create_bot(self, name: str, /, prompt: str = '', base_model: str = 'ChatGPT', description: str = '') -> None:
if base_model not in MODELS:
raise RuntimeError('Sorry, the base_model you provided does not exist. Please check and try again.')

Expand All @@ -475,3 +473,6 @@ def create_bot(

def list_bots(self) -> list:
return list(self.client.bot_names.values())

def delete_account(self) -> None:
self.client.delete_account()
6 changes: 6 additions & 0 deletions gpt4free/quora/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,5 +541,11 @@ def edit_bot(
self.get_bots()
return data

def delete_account(self) -> None:
response = self.send_query('SettingsDeleteAccountButton_deleteAccountMutation_Mutation', {})
data = response['data']['deleteAccount']
if 'viewer' not in data:
raise RuntimeError(f'Error occurred while deleting the account, Please try again!')


load_queries()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mutation SettingsDeleteAccountButton_deleteAccountMutation_Mutation{ deleteAccount { viewer { uid id } }}

0 comments on commit 4b86f50

Please sign in to comment.