springwater commited on
Commit
637c10a
ยท
verified ยท
1 Parent(s): a37c688

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
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
- fn=summarize_youtube_videos,
53
- inputs="text", # Changed input to "text" (user input)
54
- outputs="text",
 
 
 
 
 
 
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
  )