Spaces:
Runtime error
Runtime error
Commit ·
29aeeac
1
Parent(s): 33db722
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,4 @@
|
|
| 1 |
-
import
|
| 2 |
-
import importlib
|
| 3 |
-
|
| 4 |
import re
|
| 5 |
import gradio as gr
|
| 6 |
import os
|
|
@@ -33,14 +31,14 @@ def get_Answer(query):
|
|
| 33 |
answer = model.generate_content(prompt).text
|
| 34 |
return answer
|
| 35 |
|
| 36 |
-
# Define the Gradio interface
|
| 37 |
-
iface = gr.Interface(
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
)
|
| 44 |
|
| 45 |
|
| 46 |
|
|
@@ -69,18 +67,39 @@ def upload_pdf(file_path):
|
|
| 69 |
)
|
| 70 |
return f"PDF Uploaded Successfully. {collection.count()} chunks stored in ChromaDB"
|
| 71 |
|
| 72 |
-
# Define the Gradio interface
|
| 73 |
-
iface = gr.Interface(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
fn=upload_pdf,
|
| 75 |
-
inputs=["file"],
|
| 76 |
-
outputs="textbox",
|
| 77 |
title="Upload PDF to ChromaDB",
|
| 78 |
description="Upload a PDF file and store its text chunks in ChromaDB.",
|
| 79 |
)
|
| 80 |
|
| 81 |
|
| 82 |
-
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
|
| 86 |
|
|
|
|
| 1 |
+
import threading
|
|
|
|
|
|
|
| 2 |
import re
|
| 3 |
import gradio as gr
|
| 4 |
import os
|
|
|
|
| 31 |
answer = model.generate_content(prompt).text
|
| 32 |
return answer
|
| 33 |
|
| 34 |
+
# # Define the Gradio interface
|
| 35 |
+
# iface = gr.Interface(
|
| 36 |
+
# fn=get_Answer,
|
| 37 |
+
# inputs=gr.Textbox(lines=5, placeholder="Ask a question"), # Textbox for query
|
| 38 |
+
# outputs="textbox", # Display the generated answer in a textbox
|
| 39 |
+
# title="Answer Questions with Gemini-Pro",
|
| 40 |
+
# description="Ask a question and get an answer based on context from a ChromaDB collection.",
|
| 41 |
+
# )
|
| 42 |
|
| 43 |
|
| 44 |
|
|
|
|
| 67 |
)
|
| 68 |
return f"PDF Uploaded Successfully. {collection.count()} chunks stored in ChromaDB"
|
| 69 |
|
| 70 |
+
# # Define the Gradio interface
|
| 71 |
+
# iface = gr.Interface(
|
| 72 |
+
# fn=upload_pdf,
|
| 73 |
+
# inputs=["file"], # Specify a file input component
|
| 74 |
+
# outputs="textbox", # Display the output text in a textbox
|
| 75 |
+
# title="Upload PDF to ChromaDB",
|
| 76 |
+
# description="Upload a PDF file and store its text chunks in ChromaDB.",
|
| 77 |
+
# )
|
| 78 |
+
|
| 79 |
+
# Gradio interfaces
|
| 80 |
+
iface1 = gr.Interface(
|
| 81 |
+
fn=get_Answer,
|
| 82 |
+
inputs=gr.Textbox(lines=5, placeholder="Ask a question"),
|
| 83 |
+
outputs="textbox",
|
| 84 |
+
title="Answer Questions with Gemini-Pro",
|
| 85 |
+
description="Ask a question and get an answer based on context from a ChromaDB collection.",
|
| 86 |
+
)
|
| 87 |
+
iface2 = gr.Interface(
|
| 88 |
fn=upload_pdf,
|
| 89 |
+
inputs=["file"],
|
| 90 |
+
outputs="textbox",
|
| 91 |
title="Upload PDF to ChromaDB",
|
| 92 |
description="Upload a PDF file and store its text chunks in ChromaDB.",
|
| 93 |
)
|
| 94 |
|
| 95 |
|
| 96 |
+
|
| 97 |
+
# Launch the apps in separate threads
|
| 98 |
+
thread1 = threading.Thread(target=iface1.launch, args=(debug=True, share=True))
|
| 99 |
+
thread2 = threading.Thread(target=iface2.launch, args=(debug=True, share=True))
|
| 100 |
+
|
| 101 |
+
thread1.start()
|
| 102 |
+
thread2.start()
|
| 103 |
|
| 104 |
|
| 105 |
|