Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes: Add Check on Reload to see if still logged in #10

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .env.example

This file was deleted.

3 changes: 2 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ dependencies:
- python-dotenv
- python-telegram-bot==20.0a6
- requests
- google-search-results
- nest_asyncio
- google-search-results
20 changes: 13 additions & 7 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,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__)

Expand Down Expand Up @@ -72,7 +72,7 @@ def send_message(message):
box.press("Enter")


class AtrributeError:
class AttributeError:
pass


Expand All @@ -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
Expand Down Expand Up @@ -132,17 +132,23 @@ 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:
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
Expand Down Expand Up @@ -183,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:
Expand Down