bstraehle commited on
Commit
4b2b43c
·
1 Parent(s): 96ff3f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -39,7 +39,7 @@ def invoke(openai_api_key, youtube_url, process_video, prompt):
39
  splits = text_splitter.split_documents(docs)
40
  vectordb = Chroma.from_documents(documents = splits, embedding = OpenAIEmbeddings(), persist_directory = CHROMA_DIR)
41
  llm = ChatOpenAI(model_name = MODEL_NAME, temperature = 0)
42
- QA_CHAIN = RetrievalQA.from_chain_type(llm, retriever = vectordb.as_retriever(), return_source_documents = True, chain_type_kwargs = {"prompt": QA_CHAIN_PROMPT})
43
  else:
44
  print(222)
45
  result = QA_CHAIN({"query": prompt})
@@ -56,7 +56,7 @@ description = """The app demonstrates how to use a <strong>Large Language Model<
56
 
57
  gr.close_all()
58
  demo = gr.Interface(fn=invoke,
59
- inputs = [gr.Textbox(label = "OpenAI API Key", value = "sk-", lines = 1), gr.Textbox(label = "YouTube URL", value = "https://www.youtube.com/watch?v=--khbXchTeE", lines = 1), gr.Radio([True, False], label="Process Video", value = True), gr.Textbox(label = "Prompt", value = "GPT-4 human level performance", lines = 1)],
60
  outputs = [gr.Textbox(label = "Completion", lines = 1)],
61
  title = "Generative AI - LLM & RAG",
62
  description = description)
 
39
  splits = text_splitter.split_documents(docs)
40
  vectordb = Chroma.from_documents(documents = splits, embedding = OpenAIEmbeddings(), persist_directory = CHROMA_DIR)
41
  llm = ChatOpenAI(model_name = MODEL_NAME, temperature = 0)
42
+ global QA_CHAIN = RetrievalQA.from_chain_type(llm, retriever = vectordb.as_retriever(), return_source_documents = True, chain_type_kwargs = {"prompt": QA_CHAIN_PROMPT})
43
  else:
44
  print(222)
45
  result = QA_CHAIN({"query": prompt})
 
56
 
57
  gr.close_all()
58
  demo = gr.Interface(fn=invoke,
59
+ inputs = [gr.Textbox(label = "OpenAI API Key", value = "sk-", lines = 1), gr.Textbox(label = "YouTube URL", value = "https://www.youtube.com/watch?v=--khbXchTeE", lines = 1), gr.Radio([True, False], label="Process Video", value = True), gr.Textbox(label = "Prompt", value = "What is GPT-4", lines = 1)],
60
  outputs = [gr.Textbox(label = "Completion", lines = 1)],
61
  title = "Generative AI - LLM & RAG",
62
  description = description)