iamseyedalipro / ChatGPTAutomation

automate chatgpt using selenium without api
MIT License
30 stars 1 forks source link

ChatGPTAutomation πŸ€–πŸ’»πŸ§ 

Description

ChatGPTAutomation is a Python package that automates interactions with ChatGPT using Selenium, streamlining the process for developers and testers. πŸš€

Features

Installation

Install with:

pip install ChatGPTAutomation

Usage

Chrome WebDriver Download

Setup

Automatic setup (without paths):

from chatgpt_automation.chatgpt_automation import ChatGPTAutomation

chat_bot = ChatGPTAutomation(
    username="<your username here>", # Optional
    password="<your password here>"  # Optional
)

Manual setup (with paths):

from chatgpt_automation.chatgpt_automation import ChatGPTAutomation

chat_bot = ChatGPTAutomation(
    chrome_path="path/to/chrome.exe", 
    chrome_driver_path="path/to/chromedriver.exe",
    username="<your username here>", # Optional
    password="<your password here>"  # Optional
)

# Send prompt
chat_bot.send_prompt_to_chatgpt("Hello, ChatGPT!")

# Save conversation
chat_bot.save_conversation("conversation.txt")

File upload

chat_bot.upload_file_for_prompt("test_file.txt")
chat_bot.send_prompt_to_chatgpt("Explain this file?")

Check response status

if chat_bot.check_response_status():
    print("Response ready.")
else:
    print("Response issue.")

Get last response

chat_bot.send_prompt_to_chatgpt("Hello, ChatGPT!")
response = chat_bot.return_last_response()

Switch models

chat_bot.switch_model(4)

Login check

if chat_bot.check_login_page():
    chat_bot.login()

Login with Gmail

The gmail_login_setup function in ChatGPTAutomation allows you to automate the process of logging into ChatGPT using a Gmail account.

Automatic Gmail Login

To automatically log in using Gmail credentials, you can use the gmail_login_setup method. This method requires the email and password to be set either as parameters or within the class instance.

# Automatic login using stored credentials
chat_bot.gmail_login_setup()

# Alternatively, specify the credentials directly
chat_bot.gmail_login_setup(email="your.email@gmail.com", password="yourpassword")

Login with google

if you logged in to the google account but logged out from openai account can use this function for login with that gmail

chat_bot.login_using_gamil("iamseyedalipro@gmail.com") #this is optional you can set the email first of setup on username field

Delay Configurations

The ChatGPTAutomation class includes configurable delays for various operations, defined in the DelayTimes class:

These delays are crucial for the stability and reliability of automated interactions with ChatGPT.

Customizing Delay Times

The ChatGPTAutomation class comes with default delay settings for various operations, suitable for most use cases. However, you might find the need to adjust these delay times based on your network speed, system performance, or specific use case requirements. Here’s how you can customize these delay times.

Accessing Delay Times

The delay settings are part of the DelayTimes inner class in ChatGPTAutomation. They are defined as class variables and can be accessed directly using the class name.

Changing Delay Times

To change the delay times, access the respective variable in the DelayTimes class and set it to your desired value (in seconds). Here’s an example of how to do this:

from chatgpt_automation.chatgpt_automation import ChatGPTAutomation

# Access and modify delay times
ChatGPTAutomation.DelayTimes.CONSTRUCTOR_DELAY = 10  # Set constructor delay to 10 seconds
ChatGPTAutomation.DelayTimes.SEND_PROMPT_DELAY = 25  # Set send prompt delay to 25 seconds
# ... similarly for other delay times

# Initialize ChatGPTAutomation with customized delay times
chat_bot = ChatGPTAutomation(
    username="<your username here>",
    password="<your password here>"
)

# The rest of your code...

Recommended Practices

By following these steps and recommendations, you can fine-tune the behavior of the ChatGPTAutomation class to best fit your automation needs.


Requirements

To-Do List

Sign up:

Conversation Management:

Advanced Features:

User Account Handling:

Browser:

License

MIT License - see LICENCE.md.

Contact

Seyed Ali Hosseini πŸ§‘β€πŸ’» - iamseyedalipro@gmail.com πŸ“§.

Acknowledgements