Skip to main content

A Python package for automating interactions with ChatGPT using Selenium.

Project description

ChatGPTAutomation

Description

ChatGPTAutomation is a Python package designed to automate interactions with ChatGPT using Selenium. It simplifies the process of sending prompts, managing responses, and handling files in the ChatGPT interface, making it an ideal tool for developers and testers who require automated ChatGPT interactions.

Features

  • Automated sending of messages to ChatGPT.
  • Support for file uploads to ChatGPT.
  • Retrieval and storage of ChatGPT conversations.
  • Customizable WebDriver settings for browser management.

Installation

To install ChatGPTAutomation, simply run:

pip install ChatGPTAutomation

Usage

Before using the ChatGPTAutomation package, it is essential to download the Chrome WebDriver. The version of the WebDriver must match the version of your Google Chrome browser.

For downloading the Chrome WebDriver:

  • Latest Version of Chrome WebDriver: If you are using the latest version of Google Chrome, download the corresponding latest version of Chrome WebDriver from: Chrome WebDriver - Latest Version

  • Older Versions of Chrome WebDriver: If you are using an older version of Google Chrome, find and download the compatible version of Chrome WebDriver from: Chrome WebDriver - Older Versions

Ensure that the version of Chrome WebDriver you download matches the version of your Google Chrome browser to avoid compatibility issues.

Import the package and use it in your Python scripts as follows:

from chatgpt_automation.chatgpt_automation import ChatGPTAutomation

# Initialize with path to Chrome and ChromeDriver
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
)

# Example: Sending a prompt
chat_bot.send_prompt_to_chatgpt("Hello, ChatGPT!")

# Retrieve and save conversation
chat_bot.save_conversation("conversation.txt")

Send file with prompt:

chat_bot.upload_file_for_prompt("test_file.txt")
chat_bot.send_prompt_to_chatgpt("Please explain to me what is in this file?")

check_response_status function:

if chat_bot.check_response_status():
    print("Response is ready and complete.")
    # You can now proceed to retrieve or process the response.
else:
    print("There was an issue in generating the response.")

get the last response using return_last_response function:

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

switch between the chatgpt models: (In this example, we switched to version 4 you can use 3.5)

chat_bot.switch_model(4)

check login page:

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

Requirements

  • Python 3.8 or higher
  • Selenium==4.9.0
  • Other dependencies can be found in requirements.txt

License

This project is licensed under the MIT License - see the LICENCE.md file for details.

Contact

For questions or feedback, please contact Seyed Ali Hosseini at iamseyedalipro@gmail.com.

Acknowledgements

  • OpenAI for ChatGPT
  • Selenium contributors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ChatGPTAutomation-0.1.4.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ChatGPTAutomation-0.1.4-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file ChatGPTAutomation-0.1.4.tar.gz.

File metadata

  • Download URL: ChatGPTAutomation-0.1.4.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for ChatGPTAutomation-0.1.4.tar.gz
Algorithm Hash digest
SHA256 2f83fef03b8e8118f850b1c32e16131c8580574166fbe1537415c587ce1b3642
MD5 d0a85e86b15deecdaf4f620c96da5829
BLAKE2b-256 0e0776acb3defd6d01f8ccf03aca76738c67cc8456ac4aedfdc300ad3644b221

See more details on using hashes here.

File details

Details for the file ChatGPTAutomation-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for ChatGPTAutomation-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1c1da49126cb04ec8d60337b35103e50a2dccab16e6698afbb5a7742e42c67e5
MD5 c1d402f8f12c1a665874aa6559fd2b2c
BLAKE2b-256 20cb5e8e7a2c059157451490f038b07abe6524a372ca87516ff149f40f755904

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page