Link - https://youtu.be/cMCn2cljlls
This is an unofficial API for ChatGPT using Selenium. it is not recommended to use this API for production. This API is only for testing purposes.
This API is for projects that just need to use the ChatGPT API for testing purposes. And don't want to pay for the official API just for testing.
Note: This API is extremely slow than the official API. So, it is not recommended to use this API for production. This API is only for testing purposes.
- chrome_d_download.py # use to download chrome driver.
- unzipper.py # use to unzip chrome driver.
- chrome_handler.py # use to handle chrome browser.
- api_backend.py # use to handle ChatGPT with selenium.
- helper_funcs.py # use to handle core functions of selenium.
python3 -m venv venv
source venv/bin/activate
python -m venv venv
venv\Scripts\activate
pip install -r req.txt
python chrome_d_download.py
python chrome_handler.py s
Now you can see a chrome browser window opened. You can use this browser to login to chatgpt. And accept the promepts which are asking for your permission on chatapt page.
https://chat.openai.com/chat paste this link to the remote chrome browser and login to chatgpt.
python chrome_handler.py k
python api_backend.py
This will open in a terminal where you can type your message and get the response from chatgpt.
To exit the program, in terminal type i quit!
(sorry for being weird) and press enter.
import api_backend
To Start start remote chrome browser and go to chatgpt site. (Only once)
api_backend.start_chat_gpt()
To get response from chatgpt and store it in a variable. (You can use this function as many times as you want)
variable = api_backend.make_gpt_request("what is gpt model?")
To close the remote chrome browser. (Only once)
api_backend.stop_chat_gpt()
gmail_xpath
instart_chat_gpt
function inapi_backend.py
file is the xpath of which search by email holder's name this can be changed to the users name. this will enable auto login to chatgpt if the user is already logged in togoogle
in the remote chrome browser.
make_gpt_request()
should fuction should be improved to handle errors.make_gpt_request()
should return good formatted response in json format.- Instead of using
time.sleep()
we should useimplicit wait
andexplicit wait
in selenium. - We can use
threading
if we want to use the API in multiple projects at the same time. - The speef of the API should be improved. We can use requests module to improve the speed of the API. Or we can use
asyncio
to improve the speed of the API.
This project is licensed under the MIT License - see the LICENSE file for details.
You can contribute to this project by making a pull request. If you want to contribute to this project, you can fork this project and make a pull request.
Any type of contribution is welcome. You can contribute to this project by improving the code, adding new features, fixing bugs, etc.
Thank you.