Update app.py
Browse files
app.py
CHANGED
@@ -23,9 +23,13 @@ def get_transcript(urls):
|
|
23 |
return contents
|
24 |
|
25 |
# Function to summarize text using OpenAI's API
|
26 |
-
def summarize_text(contents):
|
|
|
27 |
response = openai.ChatCompletion.create(
|
28 |
model="gpt-4-turbo-preview", # Corrected engine identifier
|
|
|
|
|
|
|
29 |
messages=[
|
30 |
{"role": "system", "content": "You are a helpful assistant."},
|
31 |
{"role": "user", "content": f"Summarize this: {contents}"}
|
@@ -49,9 +53,15 @@ def summarize_youtube_videos(keyword):
|
|
49 |
|
50 |
# Define Gradio interface
|
51 |
iface = gr.Interface(
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
title="Summarize YouTube Videos",
|
56 |
description="Enter a keyword to summarize related YouTube videos.",
|
57 |
)
|
|
|
23 |
return contents
|
24 |
|
25 |
# Function to summarize text using OpenAI's API
|
26 |
+
def summarize_text(contents, OPENAI_API_KEY):
|
27 |
+
|
28 |
response = openai.ChatCompletion.create(
|
29 |
model="gpt-4-turbo-preview", # Corrected engine identifier
|
30 |
+
headers = {
|
31 |
+
"Content-Type": "application/json",
|
32 |
+
"Authorization": f"Bearer {OPENAI_API_KEY}"}
|
33 |
messages=[
|
34 |
{"role": "system", "content": "You are a helpful assistant."},
|
35 |
{"role": "user", "content": f"Summarize this: {contents}"}
|
|
|
53 |
|
54 |
# Define Gradio interface
|
55 |
iface = gr.Interface(
|
56 |
+
input = gr.Textbox(label="keyword", placeholder='ํค์๋๋ฅผ ์
๋ ฅํ์ธ์. (์.๋นํธ์ฝ์ธ)'),
|
57 |
+
OPENAI_API_KEY = gr.Textbox(label="OpenAI API ํค", placeholder="์ฌ๊ธฐ์ OpenAI API ํค๋ฅผ ์
๋ ฅํ์ธ์"),
|
58 |
+
output =gr.JSON(label='์ ํ๋ธ 5๊ฐ ์์ฝ ๊ฒฐ๊ณผ',
|
59 |
+
result = gr.Button('submit'),
|
60 |
+
result.click(
|
61 |
+
fn = summarize_youtube_videos,
|
62 |
+
inputs = [input, OPEN_API_KEY],
|
63 |
+
outputs = [output]
|
64 |
+
)
|
65 |
title="Summarize YouTube Videos",
|
66 |
description="Enter a keyword to summarize related YouTube videos.",
|
67 |
)
|