https://github.com/harmindersinghnijjar/quora-qa-automation
This repository hosts a tool that automates answering questions on Quora using OpenAI's GPT-3. It identifies unanswered questions in specified topics, formulates answers with GPT-3, and posts them on Quora.
https://github.com/harmindersinghnijjar/quora-qa-automation
automation bot chatbot chatgpt chromedriver gpt-3 gpt3 llm openai python quora-bot selenium
Last synced: about 1 month ago
JSON representation
This repository hosts a tool that automates answering questions on Quora using OpenAI's GPT-3. It identifies unanswered questions in specified topics, formulates answers with GPT-3, and posts them on Quora.
- Host: GitHub
- URL: https://github.com/harmindersinghnijjar/quora-qa-automation
- Owner: harmindersinghnijjar
- Created: 2022-11-06T22:53:17.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-22T02:43:54.000Z (almost 2 years ago)
- Last Synced: 2025-04-04T00:03:36.560Z (about 1 month ago)
- Topics: automation, bot, chatbot, chatgpt, chromedriver, gpt-3, gpt3, llm, openai, python, quora-bot, selenium
- Language: Python
- Homepage:
- Size: 1.02 MB
- Stars: 20
- Watchers: 3
- Forks: 16
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Quora QA Automation
Welcome to the Quora QA Automation project, an open-source program that utilizes Selenium and GPT-3 for answering questions on Quora.### Overview
This open-source program uses a combination of Selenium and GPT-3 to answer questions on the Quora platform. The program utilizes Selenium to automate the opening of a Chrome browser, navigates to the Quora website, extracts the first question listed on the page, and passes it to GPT-3 for a response. The response generated by GPT-3 is then posted on Quora.The program employs the OpenAI API for accessing GPT-3, which provides the necessary interface for making requests to the GPT-3 model. This integration allows the program to leverage GPT-3's state-of-the-art natural language processing capabilities, which are capable of generating human-like responses to a wide variety of questions.
One key advantage of this program is its flexibility in allowing users to specify a custom data directory for the Chrome browser. This feature provides users with the option to store their browsing data, such as cookies and cache, in a location of their choosing.
This program is ideal for anyone looking to automate their Quora activities, particularly those who frequently respond to questions on the platform. By leveraging GPT-3's advanced natural language processing capabilities, the program can generate high-quality responses to questions, saving users significant time and effort.
### Customization
This program can be customized to your personal/organizational needs. For more information, please contact me via [LinkedIn](https://www.linkedin.com/in/harmindersinghnijjar/) or email at [email protected]### Frameworks:
[Selenium](https://www.selenium.dev/) - a popular automation testing framework that provides a suite of tools for web browser automation. It allows for programmatically controlling a web browser and automating user actions, such as clicking buttons, filling forms, and extracting data from web pages.
[OpenAI API](https://openai.com/api/) - a powerful artificial intelligence API that provides access to GPT-3, a language model capable of generating human-like text. It can be used for a variety of natural language processing tasks, such as language translation, summarization, and conversation generation.
### Language:
- [Python](https://www.python.org/)
### Flow diagrams:
### Requirements:
- [API key](https://beta.openai.com/account/api-keys)
### Modules:
- child_process
- fs
- [openai](https://www.npmjs.com/package/openai)
- os
- [selenium-webdriver](https://www.npmjs.com/package/selenium-webdriver)
- sendkeys
- util
- [webdriver_manager](https://www.npmjs.com/package/webdriver-manager)### API:
- [openai-api](https://openai.com/api/)
### Classes:
### Functions:
1. answer_quora_question(answer): This function is used to post an answer received from GPT-3 on Quora and selecting a personalized answer credential.
2. extract_question(): This function is used to extract the first question listed on www.quora.com/answers and return it as a string.
3. gpt3_completion(prompt, engine='text-davinci-002', temp=0.7, top_p=1.0, tokens=400, freq_pen=0.0, pres_pen=0.0, stop=['JAX:', 'USER:']): This function is used to ask GPT-3 the question extracted from Quora and return the respone text as a string.
4. launch_test_case(): This function is used to open Quora in a Chrome instance.
5. open_file(filepath): This function is used to open a file and read the contents.
6. quit_application(): This function is used to close the Chrome browser.
7. setup(): This function is used to maximize Chrome window and have the driver wait for 10 seconds.
8. main(): This function is the main method in JavaScript.
9. loop(): This function is used to call the main method in a loop.### Procedure:
1. Install the required libraries: openai, selenium-webdriver, and chrome.
2. Copy your API key from the OpenAI website.
3. Define Chrome options.
4. Instansiate Google Chrome with the above options.
5. Create a method to post answer received from GPT-3 on Quora and selecting a personalized answer credential.
6. Create a method to extract the first question listed on www.quora.com/answers and return it as a string.
7. Create a method to ask GPT-3 the question extracted from Quora and return the respone text as a string.
8. Create a method to open Quora in a Chrome instance.
9. Create a method to open a file and read the contents.
10. Create a method to close the Chrome browser.
11. Create a setup method to maximize the Chrome window and have the driver wait for 10 seconds.
12. Create a main method to call the above methods.
13. Call the main method in a loop.### Resources:
1. OpenAI
- [Best Practices for API Key Safety](https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety)
2. YouTube
- [Build a Desktop App with Electron... But Should You?](https://www.youtube.com/watch?v=3yqDxhR2XxE)
3. Playwright Documentation
- [launch](https://playwright.dev/docs/api/class-browsertype#browser-type-launch)
### Additional notes:
### Potential errors:
If you encounter the error message "timeout: Timed out receiving message from renderer" while attempting to paste an answer into a text box, it is possible that the page load timeout has been set too low. In such instances, it is advisable to increase the page load timeout using the set_page_load_timeout() method.
For example, if you are using the Selenium library in Python, you can increase the page load timeout by executing the following code:
```
from selenium import webdriverdriver = webdriver.Chrome()
driver.set_page_load_timeout(X) # Increase the timeout to X seconds
```In the code above, the set_page_load_timeout() method is responsible for specifying the maximum time the browser should wait for a page to load before throwing an error. By increasing this timeout value, you may be able to circumvent the "timeout: Timed out receiving message from renderer" error.
It is important to remember to adjust the timeout value based on your specific needs and internet speed. A lengthier timeout may result in slower test execution, so finding the appropriate balance is crucial.