Skip to content

Commit 2a6f980

Browse files
authored
Merge pull request #64 from sudoleg/feat/chat
feat: introduce Q&A
2 parents 6ff01db + d02ecc7 commit 2a6f980

File tree

24 files changed

+1875
-237
lines changed

24 files changed

+1875
-237
lines changed

.assets/home.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# YTAI - Your personal YouTube AI
2+
3+
Get insights from YouTube videos with YTAI, an LLM-based app that allows you to summarize or even ask questions and receive answers about them! tailors YouTube video summaries to your needs, offering a custom prompt feature for summaries exactly how you want them.
4+
5+
Check out the project on [GitHub](https://github.com/sudoleg/ytai) for more information! Also, if you like the app, I would be very happy about a star :star:
6+
7+
## Summary
8+
9+
If you have a relatively short video (<30 minutes), you can use the `Summary` part of the application. It allows you to provide **a custom prompt** to tailor the summary to your needs. As the video is short anyways, you could, for example, provide your questions here. Moreover, you can save your responses (if you are running the app locally).
10+
11+
Or you could ask to list all the topics in the video and then ask specific questions about them using the other part of the application (see below) 😉
12+
13+
## Q&A - Chat
14+
15+
The `Chat` part of the application is best suited when you have a longer video you have specific questions about. It is more efficient and less cost consuming, as only the relevant parts of the video are provided to the language model. Moreover, once you process a video, you can Q&A it whenever you want (as long as you don't remove the volume accidentally 😅).
16+
17+
I've found that the chat function works especially well for videos with manual transcripts but it's also really good for videos with autogernerated ones. Personally, I use the chat feature for lengthy podcasts with timestamps, like podcasts from [Andrew Huberman](https://www.youtube.com/@hubermanlab), [Lex Fridman](https://www.youtube.com/@lexfridman) or [Chris Williamson](https://www.youtube.com/@ChrisWillx). You can just copy the title of the section/timestamp and get a good overview of the topics discussed.
18+
19+
## WIP: FAQ
20+
21+
Some day, an FAQ section will be here...

.assets/rag_quidelines.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Guidelines
2+
3+
You can either provide a question or just a topic from the video. If you ask a question, try to be as specific as possible. Your question should adress a specific topic or a passage from the video.
4+
5+
**Don't ask for a summary! This part of the application is not designed for that! Use the `Summary` part instead!**
6+
7+
## General tips
8+
9+
- be specific
10+
- be concise
11+
- Don't include instructions, like 'explain in detail' or 'answer from a perspective of X' etc.
12+
13+
## Important notice ❗
14+
15+
While this part of the application is designed to assist with your questions using advanced technology, it relies on a large language model (LLM) and therefore may produce inaccurate responses. LLMs may reflect biases present in its training data, leading to potentially inappropriate or unfair answers. The model might hallucinate, misinterpret questions, provide vague responses and does not possess true understanding. Responses might inadvertently include sensitive or inappropriate content. Please acknowledge these limitations and use the provided information with caution and critical judgment.

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ test/
77
.vscode/
88
video_meta/*
99
docs/
10-
.git/
10+
.git/
11+
data/*

.github/workflows/test.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ jobs:
1616
- uses: actions/checkout@v4
1717
- uses: actions/setup-python@v5
1818
with:
19-
python-version: "3.12.3"
19+
python-version: "3.12.4"
2020
- uses: streamlit/streamlit-app-action@v0.0.3
2121
with:
22-
app-path: main.py
22+
app-path: main.py
23+
skip-smoke: 'true'

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ video_meta/
55
design/
66
test/
77
certs/
8-
*.ipynb
98
transcripts*/
109
/data/chroma/*
1110
!/data/chroma/.gitkeep
1211
*.sqlite3
12+
scripts/test.ipynb
1313

1414
# Byte-compiled / optimized / DLL files
1515
__pycache__/

.streamlit/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
[client]
2+
showSidebarNavigation = false
3+
14
[browser]
25
gatherUsageStats = false
36

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# Base stage for shared environment setup
2-
FROM python:3.12.3-slim
1+
FROM python:3.12.4
32

43
# Set working directory
54
WORKDIR /app
@@ -8,7 +7,7 @@ WORKDIR /app
87
COPY requirements.txt .
98

109
# Install Python dependencies
11-
RUN pip3 install -r requirements.txt
10+
RUN pip3 install --upgrade pip && pip3 install -r requirements.txt
1211

1312
# Copy application's code
1413
COPY . /app/
@@ -17,6 +16,7 @@ COPY . /app/
1716
ENV PYTHONPATH="/app"
1817
ENV STREAMLIT_CLIENT_TOOLBAR_MODE="viewer"
1918
ENV STREAMLIT_SERVER_PORT=8501
19+
ENV ENVIRONMENT=production
2020

2121
# Expose port for the application
2222
EXPOSE 8501

README.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66

77
## Features :sparkles:
88

9-
YTAI summarizes YouTube videos and is not the first project to do that. However, it offers some features that other similar projects and AI summarizers on the internet don't:
9+
YTAI lets you **summarize and chat (Q&A)** with YouTube videos. Its features include:
1010

11-
- **provide a custom prompt** :writing_hand:
12-
- you can tailor the response to your needs by providing a custom prompt or just use the default summarization
11+
- **provide a custom prompt for summaries** :writing_hand:
12+
- you can tailor the summary to your needs by providing a custom prompt or just use the default summarization
1313
- **automatically save summaries** :open_file_folder:
1414
- the summaries can be automatically saved in the directory where you run the app. The summaries will be available under `<YT-channel-name>/<video-title>.md`
15+
- **create your own knowledge base** :floppy_disk:
16+
- once you process a video, you can chat with it at any time!
1517
- **choose from different OpenAI models** :robot:
1618
- currently available: gpt-3.5-turbo, gpt-4 (turbo), gpt-4o
1719
- by choosing a different model, you can summarize even longer videos and potentially get better responses
@@ -24,13 +26,23 @@ YTAI summarizes YouTube videos and is not the first project to do that. However,
2426

2527
No matter how you choose to run the app, you will first need to get an OpenAI API-Key. This is very straightforward and free. Have a look at [their instructions](https://platform.openai.com/docs/quickstart/account-setup) to get started.
2628

27-
### build & run with Docker
29+
### build & run with Docker (or docker-compose)
30+
31+
1. make sure to provide an OpenAI API key (l. 43 in [docker-compose.yml](docker-compose.yml))
32+
2. adjust the path to save the summaries (l. 39 in [docker-compose.yml](docker-compose.yml))
33+
3. execute the following command:
2834

2935
```bash
30-
# build locally
31-
docker build --tag=ytai:latest .
32-
# or pull from Docker Hub
36+
docker-compose up --build -d
37+
```
38+
39+
### if you are only interested in summaries
40+
41+
```bash
42+
# pull from Docker Hub
3343
docker pull sudoleg/ytai:latest
44+
# or build locally
45+
docker build --tag=ytai:latest .
3446
docker run -d -p 8501:8501 -v $(pwd):/app/responses -e OPENAI_API_KEY=<your-openai-api-key> --name yt-summarizer sudoleg/ytai:latest
3547
```
3648

@@ -64,6 +76,7 @@ The project is built using some amazing libraries:
6476
- The project uses [YouTube Transcript API](https://github.com/jdepoix/youtube-transcript-api) for fetching transcripts.
6577
- [LangChain](https://github.com/langchain-ai/langchain) is used to create a prompt, submit it to an LLM and process it's response.
6678
- The UI is built using [Streamlit](https://github.com/streamlit/streamlit).
79+
- [ChromaDB](https://docs.trychroma.com/) is used as a vector store for embeddings.
6780

6881
## License
6982

config.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
"model": "The OpenAI API is powered by a diverse set of models with different capabilities and price points. Read more at https://platform.openai.com/docs/models/overview",
1717
"temperature": "In short, the lower the temperature, the more deterministic the results in the sense that the highest probable next token is always picked. Increasing temperature could lead to more randomness, which encourages more diverse or creative outputs. Read more at https://platform.openai.com/docs/guides/text-generation/how-should-i-set-the-temperature-parameter.",
1818
"top_p": "If you use Top P it means that only the tokens comprising the top_p probability mass are considered for responses, so a low top_p value selects the most confident responses. This means that a high top_p value will enable the model to look at more possible words, including less likely ones, leading to more diverse outputs. Read more at https://www.promptingguide.ai/introduction/settings",
19-
"saving_responses": "Whether to save responses in the directory, where you run the app. The responses will be saved under '<YT-channel-name>/<video-title>.md'."
19+
"saving_responses": "Whether to save responses in the directory, where you run the app. The responses will be saved under '<YT-channel-name>/<video-title>.md'.",
20+
"chunk_size": "A larger chunk size increases the amount of context provided to the model to answer your question. However, it may be less relevant than with a small chunk size, as smaller chunks can encapsulate more semantic meaning. I would reccommend to use a smaller chunk size for shorter and a larger one for longer videos (> 1h).",
21+
"preprocess_checkbox": "By enabling this, the original transcript gets preprocessed. This can greatly improve the results, especially for videos with automatically generated transcripts. However, it results in higher costs, as the whole transcript get's processed by gpt3.5-turbo. Also, the preprocessing will take a substantial amount of time.",
22+
"selected_video": "Once you process a video, it gets saved in a database. You can chat with it at any time, without processing it again! Tip: you may also search for videos by typing (parts of) its title."
2023
}
2124
}

data/chroma/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)