Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,33 +1,25 @@
|
|
1 |
import gradio as gr
|
2 |
-
from metrology_rag import MetrologyRAGPipeline
|
3 |
|
4 |
-
# Initialize the pipeline
|
5 |
rag_pipeline = MetrologyRAGPipeline()
|
6 |
|
7 |
-
# Function to handle user queries
|
8 |
def process_query(query, pdf_files):
|
9 |
-
# If PDF files are uploaded, load them into the pipeline
|
10 |
if pdf_files:
|
11 |
-
pdf_paths = [file.name for file in pdf_files] #
|
12 |
rag_pipeline.load_pdfs(pdf_paths=pdf_paths)
|
13 |
-
|
14 |
-
# Process the query and return the response
|
15 |
response = rag_pipeline.query(query)
|
16 |
return response
|
17 |
|
18 |
-
# Define the Gradio interface
|
19 |
interface = gr.Interface(
|
20 |
fn=process_query,
|
21 |
inputs=[
|
22 |
-
gr.Textbox(label="Digite sua pergunta sobre metrologia"
|
23 |
-
gr.File(label="Carregar arquivos PDF (opcional)", file_count="multiple", type="
|
24 |
],
|
25 |
outputs=gr.Textbox(label="Resposta do Agente de Metrologia"),
|
26 |
title="Agente de Metrologia Avançado",
|
27 |
-
description="Faça perguntas técnicas sobre metrologia e carregue PDFs para análise
|
28 |
-
theme="default"
|
29 |
)
|
30 |
|
31 |
-
# Launch the app
|
32 |
if __name__ == "__main__":
|
33 |
interface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from metrology_rag import MetrologyRAGPipeline
|
3 |
|
|
|
4 |
rag_pipeline = MetrologyRAGPipeline()
|
5 |
|
|
|
6 |
def process_query(query, pdf_files):
|
|
|
7 |
if pdf_files:
|
8 |
+
pdf_paths = [file.name for file in pdf_files] # Works with type="filepath"
|
9 |
rag_pipeline.load_pdfs(pdf_paths=pdf_paths)
|
|
|
|
|
10 |
response = rag_pipeline.query(query)
|
11 |
return response
|
12 |
|
|
|
13 |
interface = gr.Interface(
|
14 |
fn=process_query,
|
15 |
inputs=[
|
16 |
+
gr.Textbox(label="Digite sua pergunta sobre metrologia"),
|
17 |
+
gr.File(label="Carregar arquivos PDF (opcional)", file_count="multiple", type="filepath")
|
18 |
],
|
19 |
outputs=gr.Textbox(label="Resposta do Agente de Metrologia"),
|
20 |
title="Agente de Metrologia Avançado",
|
21 |
+
description="Faça perguntas técnicas sobre metrologia e carregue PDFs para análise."
|
|
|
22 |
)
|
23 |
|
|
|
24 |
if __name__ == "__main__":
|
25 |
interface.launch()
|