Spaces:
Sleeping
Sleeping
João Lima commited on
Commit ·
ba96169
1
Parent(s): c42660f
creating tests
Browse files
app.py
CHANGED
|
@@ -1,41 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from ingestion.pdf import process_pdf
|
| 3 |
-
from rag.pipeline import run_rag
|
| 4 |
|
| 5 |
-
|
|
|
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
if file is None:
|
| 10 |
-
return "Please select a PDF file."
|
| 11 |
-
vectorstore = process_pdf(file.name)
|
| 12 |
-
return "Document processed successfully."
|
| 13 |
-
|
| 14 |
-
def ask(question):
|
| 15 |
-
if vectorstore is None:
|
| 16 |
-
return "Upload a document first", "", ""
|
| 17 |
-
if not question.strip():
|
| 18 |
-
return "Please enter a question", "", ""
|
| 19 |
-
return run_rag(question, vectorstore)
|
| 20 |
-
|
| 21 |
-
with gr.Blocks() as demo:
|
| 22 |
-
gr.Markdown("# Tech Explainer — RAG with Automatic Evaluation")
|
| 23 |
-
|
| 24 |
-
file = gr.File(label="Upload PDF", file_types=[".pdf"])
|
| 25 |
-
load_btn = gr.Button("Process PDF")
|
| 26 |
-
status = gr.Textbox(label="Status")
|
| 27 |
-
|
| 28 |
-
gr.Markdown("---")
|
| 29 |
-
|
| 30 |
-
question = gr.Textbox(label="Question")
|
| 31 |
-
ask_btn = gr.Button("Ask")
|
| 32 |
-
|
| 33 |
-
answer = gr.Textbox(label="Answer")
|
| 34 |
-
sources = gr.Textbox(label="Sources")
|
| 35 |
-
evaluation = gr.Textbox(label="Evaluation")
|
| 36 |
-
|
| 37 |
-
load_btn.click(load_document, inputs=file, outputs=status)
|
| 38 |
-
ask_btn.click(ask, inputs=question, outputs=[answer, sources, evaluation])
|
| 39 |
-
|
| 40 |
-
if __name__ == "__main__":
|
| 41 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
def echo(text):
|
| 4 |
+
return text
|
| 5 |
|
| 6 |
+
demo = gr.Interface(fn=echo, inputs="text", outputs="text")
|
| 7 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|