RAG-GEMINI / app.py
DHEIVER's picture
Create app.py
8a359ec verified
raw
history blame
1.25 kB
import gradio as gr
from metrology_rag import MetrologyRAGPipeline # Assuming your code is in a file named metrology_rag.py
# Initialize the pipeline
rag_pipeline = MetrologyRAGPipeline()
# Function to handle user queries
def process_query(query, pdf_files):
# If PDF files are uploaded, load them into the pipeline
if pdf_files:
pdf_paths = [file.name for file in pdf_files] # Gradio uploads files to temporary paths
rag_pipeline.load_pdfs(pdf_paths=pdf_paths)
# Process the query and return the response
response = rag_pipeline.query(query)
return response
# Define the Gradio interface
interface = gr.Interface(
fn=process_query,
inputs=[
gr.Textbox(label="Digite sua pergunta sobre metrologia", placeholder="Ex: Avaliação do certificado de calibração..."),
gr.File(label="Carregar arquivos PDF (opcional)", file_count="multiple", type="file")
],
outputs=gr.Textbox(label="Resposta do Agente de Metrologia"),
title="Agente de Metrologia Avançado",
description="Faça perguntas técnicas sobre metrologia e carregue PDFs para análise (ex.: certificados, normas).",
theme="default"
)
# Launch the app
if __name__ == "__main__":
interface.launch()