bstraehle commited on
Commit
9ed9edc
1 Parent(s): 5af0e35

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -8
app.py CHANGED
@@ -8,10 +8,11 @@ from langchain.document_loaders.blob_loaders.youtube_audio import YoutubeAudioLo
8
  from dotenv import load_dotenv, find_dotenv
9
  _ = load_dotenv(find_dotenv())
10
 
11
- openai.api_key = os.environ["OPENAI_API_KEY"]
12
 
13
- def invoke(url):
14
- url = url
 
15
  save_dir = "docs/youtube/"
16
  loader = GenericLoader(
17
  YoutubeAudioLoader([url], save_dir),
@@ -19,14 +20,20 @@ def invoke(url):
19
  )
20
  docs = loader.load()
21
  shutil.rmtree(save_dir)
22
- return docs[0].page_content
 
 
23
 
24
- description = """<a href='https://www.gradio.app/'>Gradio</a> UI using <a href='https://platform.openai.com/'>OpenAI</a> API with Whisper 1 foundation model."""
 
 
 
 
25
 
26
  gr.close_all()
27
  demo = gr.Interface(fn=invoke,
28
- inputs = [gr.Textbox(label = "YouTube URL", lines = 1)],
29
- outputs = [gr.Textbox(label = "Automatic Speech Recognition", lines = 1)],
30
- title = "Generative AI - Speech to Text",
31
  description = description)
32
  demo.launch()
 
8
  from dotenv import load_dotenv, find_dotenv
9
  _ = load_dotenv(find_dotenv())
10
 
11
+ #openai.api_key = os.environ["OPENAI_API_KEY"]
12
 
13
+ def invoke(openai_api_key, youtube_url, prompt):
14
+ openai.api_key = openai_api_key
15
+ url = youtube_url
16
  save_dir = "docs/youtube/"
17
  loader = GenericLoader(
18
  YoutubeAudioLoader([url], save_dir),
 
20
  )
21
  docs = loader.load()
22
  shutil.rmtree(save_dir)
23
+ retrieval = docs[0].page_content
24
+ ###
25
+ return retrieval
26
 
27
+ description = """The app demonstrates how to use a Large Language Model (LLM) with Retrieval Augmented Generation (RAG) on external data.\n\n
28
+ <a href='https://www.gradio.app/'>Gradio</a> UI using <a href='https://platform.openai.com/'>OpenAI</a> API
29
+ with <a href='https://openai.com/research/whisper'>Whisper</a> foundation model (for speech to text generation)
30
+ and <a href='https://openai.com/research/gpt-4'>GPT-4</a> foundation model (for LLM use cases like search, summarization, translation, etc.)
31
+ via AI-first toolkit <a href='https://www.langchain.com/'>LangChain</a>."""
32
 
33
  gr.close_all()
34
  demo = gr.Interface(fn=invoke,
35
+ inputs = [gr.Textbox(label = "OpenAI API Key", lines = 1), gr.Textbox(label = "YouTube URL", lines = 1), gr.Textbox(label = "Prompt", lines = 1)],
36
+ outputs = [gr.Textbox(label = "Completion", lines = 1)],
37
+ title = "Generative AI - RAG",
38
  description = description)
39
  demo.launch()