aakash0563 commited on
Commit
61477db
·
1 Parent(s): d832d3e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -33
app.py CHANGED
@@ -54,47 +54,32 @@ def get_Answer(query):
54
  answer = model.generate_content(prompt).text
55
  return answer
56
 
57
- # Define the Gradio interface
58
- iface1 = gr.Interface(
59
- fn=get_Answer,
60
- inputs=gr.Textbox(lines=5, placeholder="Ask a question"), # Textbox for query
61
- outputs="textbox", # Display the generated answer in a textbox
62
- title="Answer Questions with Gemini-Pro",
63
- description="Ask a question and get an answer based on context from a ChromaDB collection.",
64
- )
 
 
 
 
 
 
65
 
66
 
67
 
68
  # Define the Gradio interface
69
  iface2 = gr.Interface(
70
- fn=upload_pdf,
71
- inputs=["file"], # Specify a file input component
72
  outputs="textbox", # Display the output text in a textbox
73
- title="Upload PDF to ChromaDB",
74
- description="Upload a PDF file and store its text chunks in ChromaDB.",
75
  )
76
 
77
-
78
-
79
- # def check_boxes(checkbox_values):
80
- # if checkbox_values == "iface1":
81
- # return iface1.launch(debug=True, share=True)
82
- # else:
83
- # return iface1.launch(debug=True, share=True)
84
-
85
- # checkboxes = [
86
- # gr.Checkbox(label="iface1"),
87
- # gr.Checkbox(label="iface2"),
88
- # ]
89
-
90
- # iface = gr.Interface(
91
- # check_boxes,
92
- # inputs=checkboxes,
93
- # outputs="text",
94
- # title="Checkbox Demo",
95
- # description="Select one or both checkboxes.",
96
- # )
97
-
98
  iface2.launch(debug=True)
99
 
100
 
 
54
  answer = model.generate_content(prompt).text
55
  return answer
56
 
57
+ def Show_Interface(file_path,query):
58
+ if file_path:
59
+ return upload_pdf(file_path)
60
+ else:
61
+ return get_Answer(query)
62
+
63
+ # # Define the Gradio interface
64
+ # iface1 = gr.Interface(
65
+ # fn=get_Answer,
66
+ # inputs=gr.Textbox(lines=5, placeholder="Ask a question"), # Textbox for query
67
+ # outputs="textbox", # Display the generated answer in a textbox
68
+ # title="Answer Questions with Gemini-Pro",
69
+ # description="Ask a question and get an answer based on context from a ChromaDB collection.",
70
+ # )
71
 
72
 
73
 
74
  # Define the Gradio interface
75
  iface2 = gr.Interface(
76
+ fn=Show_Interface,
77
+ inputs=["file","text"], # Specify a file input component
78
  outputs="textbox", # Display the output text in a textbox
79
+ title="Choose only one method at a time(Upload pdf /or Query from uploaded PDF)",
80
+ description="Choose only one method at a time(Upload pdf /or Query from uploaded PDF)",
81
  )
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  iface2.launch(debug=True)
84
 
85