Skip to content

Chrome extension that enables users to leverage the OpenAI Chat Completions endpoint on any YouTube video.

Notifications You must be signed in to change notification settings

josephrmartinez/AskYouTube

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AskYouTube

A simple Chrome extension that enables users to leverage the OpenAI Chat Completions endpoint on any YouTube video.

This extension simply pulls down a transcript for the video you are currently viewing and sends this to the OpenAI API with your task request.

"Generate a vegetarian version of this recipe."

"Extract the materials list for this project."

"What was the book they recommended?"

This extension does not use a speech to text model to transcribe the video or an image recognition model to actually pass along information about what took place in the video. Automatically generated YouTube transcripts are not great quality, but they tend to be totally fine for the lightweight use cases when you just have a simple question on a video.

gpt-3.5-turbo-1106 with the 16k token context window is used by default for videos under about ten minutes. For longer videos, the gpt-4-1106-preview model with a 128k context window is automatically selected. You should be able to use this for videos of to about four hours in length, but this is highly dependent on the volume of dialogue.

Demo Video

AskYouTube demo

How to Run the Project

  1. Download the Repository
  • Clone or download the entire repository to your local machine.
  1. Install the Chrome Extension
  • Open your Chrome browser and go to "chrome://extensions."
  • Toggle the "developer mode" switch to ON.
  • Click "Load unpacked" on the upper left and select the "chrome-extension" folder from the local repository.
  • The AskYouTube extension should now appear in your list of 'All Extensions.' Copy the displayed ID (a string of random lower-case letters).
  1. Update the Chrome Extension ID
  • Open main.py in the fastapi-server folder.
  • Paste the extension ID into the allow_origins middleware:

allow_origins=["chrome-extension://PASTE_ID_HERE"], # Use correct extension ID

  • Save the main.py file.
  1. Navigate to folder, activate virtual environment:

Open a terminal or command prompt window.

Navigate to the fastapi-server folder within the downloaded repository. You can do this using the cd command. For example:

cd path/to/AskYouTube/fastapi-server

Once you're in the fastapi-server folder, activate the virtual environment. (This requires that you already have python3 installed on your machine). Create a virtual environment using the following command:

python3 -m venv venv

Then, activate the virtual environment:

On macOS and Linux:

source venv/bin/activate

On Windows:

venv\Scripts\activate

With the virtual environment activated, install the required dependencies by running:

pip install -r requirements.txt
  1. Set OPENAI_API_KEY in environmental variables:

Setting an environmental variable is a way to provide specific information to a program or script that it needs to function properly. In this case, the program requires an environmental variable called OPENAI_API_KEY to be set in order to access a service provided by OpenAI.

Here's how you can set the OPENAI_API_KEY environmental variable on different operating systems:

For Windows: Open the Start menu and search for "Environment Variables" and select "Edit the system environment variables." In the System Properties window, click on the "Environment Variables" button. In the Environment Variables window, under "System Variables," click "New." In the "Variable Name" field, enter OPENAI_API_KEY. In the "Variable Value" field, paste your OpenAI API key. Click "OK" to save the changes.

For macOS and Linux: Open a terminal window. Type the following command:

export OPENAI_API_KEY=your-api-key-here

Replace your-api-key-here with your actual OpenAI API key. Press Enter.

After setting the environmental variable, you may need to restart your computer or terminal session for the changes to take effect. Once done, the program will be able to access the OpenAI service using the provided API key.

  1. Run the FastAPI Server

After installing the dependencies, you're ready to start the FastAPI server. Make sure you have uvicorn installed on your machine, then run the following command:

uvicorn main:app

This command uses Uvicorn, an ASGI server, to run the FastAPI application defined in main.py.

Once the server is running, you should see output indicating that the server has started and is listening for incoming connections. You can now leave the terminal window open to keep the server running.

With the FastAPI server running, you can now use the Chrome extension locally. Ensure that the Chrome extension is installed and the server is running to enable communication between the extension and the API.

That's it! You've successfully started the FastAPI server and can now use the extension locally. If you need to stop the server at any time, you can do so by pressing Ctrl + C in the terminal window where the server is running.

About

Chrome extension that enables users to leverage the OpenAI Chat Completions endpoint on any YouTube video.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published