lekkalar commited on
Commit
5f4364a
1 Parent(s): 65e2d88

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -31,7 +31,7 @@ def load_pdf_and_generate_embeddings(pdf_doc, open_ai_key):
31
  {context}
32
 
33
  Question: {question}
34
- Return the key fields from the question followed by the answer :"""
35
  PROMPT = PromptTemplate(template=prompt_template, input_variables=["context", "question"])
36
  chain_type_kwargs = {"prompt": PROMPT}
37
  pdf_qa = RetrievalQA.from_chain_type(llm=ChatOpenAI(temperature=0, model_name="gpt-4"),chain_type="stuff", retriever=vectordb.as_retriever(), chain_type_kwargs=chain_type_kwargs, return_source_documents=False)
@@ -45,7 +45,7 @@ def load_pdf_and_generate_embeddings(pdf_doc, open_ai_key):
45
 
46
  def answer_query(query):
47
  question = query
48
- response = "Field Name: field; Question sent to gpt-4: ", question, "Response from gpt-4:",pdf_qa.run(question)
49
  return response
50
 
51
  css="""
@@ -78,7 +78,7 @@ with gr.Blocks(css=css,theme=gr.themes.Monochrome()) as demo:
78
  with gr.Row():
79
  input = gr.Textbox(label="Type in your question")
80
  output = gr.Textbox(label="Answer")
81
- submit_query = gr.Button("Submit")
82
 
83
 
84
  load_pdf.click(load_pdf_and_generate_embeddings, inputs=[pdf_doc, openai_key], outputs=status)
 
31
  {context}
32
 
33
  Question: {question}
34
+ Return the key fields from the question followed by : and the answer :"""
35
  PROMPT = PromptTemplate(template=prompt_template, input_variables=["context", "question"])
36
  chain_type_kwargs = {"prompt": PROMPT}
37
  pdf_qa = RetrievalQA.from_chain_type(llm=ChatOpenAI(temperature=0, model_name="gpt-4"),chain_type="stuff", retriever=vectordb.as_retriever(), chain_type_kwargs=chain_type_kwargs, return_source_documents=False)
 
45
 
46
  def answer_query(query):
47
  question = query
48
+ response = "Field Name: Location; Question sent to gpt-4: ", question, "Response from gpt-4:",pdf_qa.run(question)
49
  return response
50
 
51
  css="""
 
78
  with gr.Row():
79
  input = gr.Textbox(label="Type in your question")
80
  output = gr.Textbox(label="Answer")
81
+ submit_query = gr.Button("Submit")
82
 
83
 
84
  load_pdf.click(load_pdf_and_generate_embeddings, inputs=[pdf_doc, openai_key], outputs=status)