Spaces:
Sleeping
Sleeping
Commit ·
65f9a61
1
Parent(s): 9000383
test: 任意でYouTube API KEYを入力できる
Browse files- .gitignore +2 -0
- app.py +10 -4
.gitignore
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.env
|
| 2 |
+
*.txt
|
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
# 必要なライブラリをインポート
|
|
|
|
| 2 |
import streamlit as st
|
| 3 |
from googleapiclient.discovery import build
|
| 4 |
from googleapiclient.errors import HttpError
|
|
@@ -10,6 +11,8 @@ from create_chatbot import chatbot
|
|
| 10 |
YOUTUBE_API_SERVICE_NAME = 'youtube'
|
| 11 |
YOUTUBE_API_VERSION = 'v3'
|
| 12 |
|
|
|
|
|
|
|
| 13 |
# Hugging Faceの設定
|
| 14 |
classifier = pipeline('sentiment-analysis')
|
| 15 |
|
|
@@ -19,17 +22,20 @@ def main():
|
|
| 19 |
|
| 20 |
# API Keyや質問の入力
|
| 21 |
openai_api_key = st.text_input('Enter your OpenAI API key')
|
| 22 |
-
yt_api_key = st.text_input('Enter your YouTube Data API key')
|
| 23 |
video_url = st.text_input('Enter a YouTube video URL')
|
| 24 |
question = st.text_input('Enter a question')
|
| 25 |
|
| 26 |
with st.expander('Options'):
|
| 27 |
# OpenAIのモデルの選択などの設定
|
| 28 |
-
model_name = st.selectbox('Select a model', ['gpt-3.5-turbo', 'gpt-4'])
|
|
|
|
| 29 |
|
| 30 |
-
if openai_api_key and
|
| 31 |
video_id = video_url.split('v=')[1]
|
| 32 |
-
youtube = build(
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
try:
|
| 35 |
get_comments(youtube, video_id)
|
|
|
|
| 1 |
# 必要なライブラリをインポート
|
| 2 |
+
import os
|
| 3 |
import streamlit as st
|
| 4 |
from googleapiclient.discovery import build
|
| 5 |
from googleapiclient.errors import HttpError
|
|
|
|
| 11 |
YOUTUBE_API_SERVICE_NAME = 'youtube'
|
| 12 |
YOUTUBE_API_VERSION = 'v3'
|
| 13 |
|
| 14 |
+
YOUTUBE_API_KEY = os.environ.get('YOUTUBE_API_KEY')
|
| 15 |
+
|
| 16 |
# Hugging Faceの設定
|
| 17 |
classifier = pipeline('sentiment-analysis')
|
| 18 |
|
|
|
|
| 22 |
|
| 23 |
# API Keyや質問の入力
|
| 24 |
openai_api_key = st.text_input('Enter your OpenAI API key')
|
|
|
|
| 25 |
video_url = st.text_input('Enter a YouTube video URL')
|
| 26 |
question = st.text_input('Enter a question')
|
| 27 |
|
| 28 |
with st.expander('Options'):
|
| 29 |
# OpenAIのモデルの選択などの設定
|
| 30 |
+
model_name = st.selectbox('Select a GPT model', ['gpt-3.5-turbo', 'gpt-4'])]
|
| 31 |
+
yt_api_key = st.text_input('Enter your YouTube Data API key')
|
| 32 |
|
| 33 |
+
if openai_api_key and video_url and question:
|
| 34 |
video_id = video_url.split('v=')[1]
|
| 35 |
+
youtube = build(
|
| 36 |
+
YOUTUBE_API_SERVICE_NAME,
|
| 37 |
+
YOUTUBE_API_VERSION,
|
| 38 |
+
developerKey=yt_api_key if yt_api_key else YOUTUBE_API_KEY)
|
| 39 |
|
| 40 |
try:
|
| 41 |
get_comments(youtube, video_id)
|