Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,7 @@ from utils import extract_text_from_pdf, chunk_text, embed_chunks, build_faiss_i
|
|
| 6 |
from sentence_transformers import SentenceTransformer
|
| 7 |
from groq import Groq
|
| 8 |
|
| 9 |
-
# ✅ Load Groq API Key securely
|
| 10 |
groq_api_key = os.getenv("GROQ_API_KEY")
|
| 11 |
client = Groq(api_key=groq_api_key)
|
| 12 |
|
|
@@ -82,4 +82,19 @@ with gr.Blocks() as demo:
|
|
| 82 |
process_button.click(
|
| 83 |
fn=handle_pdf,
|
| 84 |
inputs=[file_input],
|
| 85 |
-
outputs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
from sentence_transformers import SentenceTransformer
|
| 7 |
from groq import Groq
|
| 8 |
|
| 9 |
+
# ✅ Load Groq API Key securely from Hugging Face secrets
|
| 10 |
groq_api_key = os.getenv("GROQ_API_KEY")
|
| 11 |
client = Groq(api_key=groq_api_key)
|
| 12 |
|
|
|
|
| 82 |
process_button.click(
|
| 83 |
fn=handle_pdf,
|
| 84 |
inputs=[file_input],
|
| 85 |
+
outputs=[chunk_output, token_output, vector_output]
|
| 86 |
+
)
|
| 87 |
+
|
| 88 |
+
gr.Markdown("## 💬 Ask Questions About the Document")
|
| 89 |
+
|
| 90 |
+
question_input = gr.Textbox(label="Your Question")
|
| 91 |
+
ask_button = gr.Button("🤖 Ask")
|
| 92 |
+
answer_output = gr.Textbox(label="Answer", lines=5)
|
| 93 |
+
|
| 94 |
+
ask_button.click(
|
| 95 |
+
fn=answer_query,
|
| 96 |
+
inputs=[question_input],
|
| 97 |
+
outputs=[answer_output]
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
+
demo.launch()
|