Skip to content

Commit

Permalink
Auto-fetch OAuth value instead of accepting as parameter
Browse files Browse the repository at this point in the history
 - Chat History
 - Rename conversation
 - Share conversation
 - Delete conversation
 - Retrieve shared conversations
 - Stop sharing conversation
 - Archive conversation
 - Conversation index starts from 1, 0 reserved for new creations
  • Loading branch information
Simatwa committed Dec 20, 2023
1 parent 363ef34 commit 187080d
Show file tree
Hide file tree
Showing 8 changed files with 404 additions and 67 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,6 @@ cython_debug/
*.vscode
*.env
*test.py
README.md
README.md
resp.json
*recons
2 changes: 1 addition & 1 deletion WebChatGPT/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__all__ = ["ChatGPT"]

__version__ = "0.0.2"
__version__ = "0.1.0"
__author__ = "Smartwa"
__repo__ = "https://github.com/Simatwa/WebChatGPT"
__info__ = "Reverse Engineered ChatGPT Web-version."
34 changes: 10 additions & 24 deletions WebChatGPT/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ class InteractiveChatGPT(cmd.Cmd):
f"┌─[{getpass.getuser().capitalize()}@WebChatGPT]({__version__})\r\n└──╼ ❯❯❯"
)

def __init__(self, auth, cookie_path, model, index, timeout, *args, **kwargs):
def __init__(self, cookie_path, model, index, timeout, *args, **kwargs):
super().__init__(*args, **kwargs)
self.bot = ChatGPT(auth, cookie_path, model, index, timeout=timeout)
self.bot = ChatGPT(
cookie_path, model=model, conversation_index=index, timeout=timeout
)

def do_help(self, text):
"""Echoes useful help info
Expand Down Expand Up @@ -167,13 +169,6 @@ def chat():


@chat.command()
@click.option(
"-A",
"--auth",
help="OpenAI's authorization value",
envvar="openai_authorization",
prompt="Enter authorization value for `chat.openai.com`",
)
@click.option(
"-C",
"--cookie-path",
Expand All @@ -190,7 +185,7 @@ def chat():
default="text-davinci-002-render-sha",
)
@click.option(
"-I", "--index", help="Conversation index to resume from", type=click.INT, default=0
"-I", "--index", help="Conversation index to resume from", type=click.INT, default=1
)
@click.option(
"-T",
Expand All @@ -213,27 +208,18 @@ def chat():
envvar="busy_bar_index",
)
@click.option("--prettify/--raw", default=True, help="Prettify the markdowned response")
def interactive(
auth, cookie_path, model, index, timeout, prompt, busy_bar_index, prettify
):
def interactive(cookie_path, model, index, timeout, prompt, busy_bar_index, prettify):
"""Chat with ChatGPT interactively"""
assert isinstance(busy_bar_index, int), "Index must be an integer only"
busy_bar.spin_index = busy_bar_index
bot = InteractiveChatGPT(auth, cookie_path, model, index, timeout)
bot = InteractiveChatGPT(cookie_path, model, index, timeout)
bot.prettify = prettify
if prompt:
bot.default(prompt)
bot.cmdloop()


@chat.command()
@click.option(
"-A",
"--auth",
help="OpenAI's authorization value",
envvar="openai_authorization",
prompt="Enter authorization value for `chat.openai.com`",
)
@click.option(
"-C",
"--cookie-path",
Expand All @@ -250,7 +236,7 @@ def interactive(
default="text-davinci-002-render-sha",
)
@click.option(
"-I", "--index", help="Conversation index to resume from", type=click.INT, default=0
"-I", "--index", help="Conversation index to resume from", type=click.INT, default=1
)
@click.option(
"-T",
Expand All @@ -266,10 +252,10 @@ def interactive(
prompt="Enter message",
)
@click.option("--prettify/--raw", default=True, help="Prettify the markdowned response")
def generate(auth, cookie_path, model, index, timeout, prompt, prettify):
def generate(cookie_path, model, index, timeout, prompt, prettify):
"""Generate a quick response with ChatGPT"""

content = ChatGPT(auth, cookie_path, model, index, timeout=timeout).chat(prompt)
content = ChatGPT(cookie_path, model, index, timeout=timeout).chat(prompt)

if prettify:
rich.print(Markdown(content))
Expand Down
Loading

0 comments on commit 187080d

Please sign in to comment.