A JavaScript program to use Playwright and GPT-3 to answer questions on Quora. The program uses Playwright to open a Chrome browser and navigate to Quora. The program then extracts the first question listed on Quora and passes it to GPT-3 for a response. The response from GPT-3 is then posted on Quora. This program uses the OpenAI API to access GPT-3.
- JavaScript
- child_process
- fs
- openai
- selenium-webdriver
- sendkeys
- util
- webdriver_manager
- answer_quora_question(answer): This function is used to post an answer received from GPT-3 on Quora and selecting a personalized answer credential.
- extract_question(): This function is used to extract the first question listed on www.quora.com/answers and return it as a string.
- 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.
- launch_test_case(): This function is used to open Quora in a Chrome instance.
- open_file(filepath): This function is used to open a file and read the contents.
- quit_application(): This function is used to close the Chrome browser.
- setup(): This function is used to maximize Chrome window and have the driver wait for 10 seconds.
- main(): This function is the main method in JavaScript.
- loop(): This function is used to call the main method in a loop.
- Install the required libraries: openai, selenium-webdriver, and chrome.
- Copy your API key from the OpenAI website.
- Define Chrome options.
- Instansiate Google Chrome with the above options.
- Create a method to post answer received from GPT-3 on Quora and selecting a personalized answer credential.
- Create a method to extract the first question listed on www.quora.com/answers and return it as a string.
- Create a method to ask GPT-3 the question extracted from Quora and return the respone text as a string.
- Create a method to open Quora in a Chrome instance.
- Create a method to open a file and read the contents.
- Create a method to close the Chrome browser.
- Create a setup method to maximize the Chrome window and have the driver wait for 10 seconds.
- Create a main method to call the above methods.
- Call the main method in a loop.
- OpenAI
- YouTube
- Playwright Documentation