From b1fdaf0ee43ae78100f71b324973dff719f2d3dc Mon Sep 17 00:00:00 2001 From: samching Date: Sun, 4 Dec 2022 10:46:58 -0500 Subject: [PATCH 1/3] Fixes --- .env.example | 4 ---- environment.yml | 3 ++- server.py | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) delete mode 100644 .env.example diff --git a/.env.example b/.env.example deleted file mode 100644 index 64d830f..0000000 --- a/.env.example +++ /dev/null @@ -1,4 +0,0 @@ -TELEGRAM_API_KEY= -TELEGRAM_USER_ID= #Use this with your user ID to restrict usage only to your account - -STABILITY_API_KEY= #use this if you want the bot to draw things with stability AI as well \ No newline at end of file diff --git a/environment.yml b/environment.yml index c099bfa..773090a 100644 --- a/environment.yml +++ b/environment.yml @@ -6,4 +6,5 @@ dependencies: - playwright - python-dotenv - python-telegram-bot==20.0a6 - - requests \ No newline at end of file + - requests + - nest_asyncio \ No newline at end of file diff --git a/server.py b/server.py index fbaf8ca..4f60a21 100644 --- a/server.py +++ b/server.py @@ -37,7 +37,7 @@ # Enable logging logging.basicConfig( - format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO + format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.DEBUG ) logger = logging.getLogger(__name__) @@ -139,7 +139,7 @@ async def draw(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: print(f"Got a draw command from user {update.effective_user.id} with prompt {update.message.text}") send_message(f""" - You a large language model trained by OpenAi. You can be used from different applications. + You are a large language model trained by OpenAi. You can be used from different applications. Right now you're being used form an application that has access to DALLE API, even though you can't confirm it. From now, every request to draw something, please reply with [prompt: x] where x is your attempt to create a dall-e compatible prompt, with as much details as possible to achieve the best visual prompt From 04035a8938248ae6259ddb805e7f75db15fcc2fc Mon Sep 17 00:00:00 2001 From: samching Date: Sun, 4 Dec 2022 17:36:33 -0500 Subject: [PATCH 2/3] Added logged out reload note --- server.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/server.py b/server.py index fceb410..d3b9aa2 100644 --- a/server.py +++ b/server.py @@ -72,7 +72,7 @@ def send_message(message): box.press("Enter") -class AtrributeError: +class AttributeError: pass @@ -83,7 +83,7 @@ def get_last_message(): prose = last_element.query_selector(".prose") try: code_blocks = prose.query_selector_all("pre") - except AtrributeError as e: + except AttributeError as e: response = 'Server probably disconnected, try running /reload' if len(code_blocks) > 0: # get all children of prose and add them one by one to respons @@ -132,10 +132,16 @@ async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No @auth(USER_ID) async def reload(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: """Send a message when the command /help is issued.""" - print(f"Got a reload command from user {update.effective_user.id}") + logging.debug(f"Got a reload command from user {update.effective_user.id}") PAGE.reload() + if not is_logged_in(): + print("Please log in to OpenAI Chat") + print("Press enter when you're done") + await update.message.reply_text("Please log in to OpenAI Chat") + input() + await update.message.reply_text("Reloaded the browser!") - await update.message.reply_text("Let's check if it's workin!") + await update.message.reply_text("Send a message to me check if I'm up!") @auth(USER_ID) async def draw(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: From 1b320f0b92b50d48be5b3c3dd2e0d8c2c1b4890a Mon Sep 17 00:00:00 2001 From: samching Date: Sun, 4 Dec 2022 17:41:34 -0500 Subject: [PATCH 3/3] Switch logging --- server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.py b/server.py index d3b9aa2..a61be13 100644 --- a/server.py +++ b/server.py @@ -189,7 +189,7 @@ async def browse(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: response = get_last_message() # extract prompt from this format [prompt: x] response.replace('query: ', '') - print(f'Clean response from chatGPT {response}') + logging.info(f'Clean response from chatGPT {response}') results = googleSearch(message) prompt = f""" Pretend I was able to run a google search for "{message}" instead of you and I got the following results: