Spaces:
Sleeping
Sleeping
import os | |
import gradio as gr | |
import pandas as pd | |
from src.brain import generate_answers | |
processing = False | |
data = pd.read_csv('anomalies.csv') | |
def response(query, history): | |
global processing | |
processing = True | |
prompt = f"Analyze the following data to answer the question: {data.head().to_string(index=False)}\nQuestion: {query}\nAnswer:" | |
output = generate_answers(prompt) | |
history.append((query, output)) | |
processing = False | |
return "", history | |
def loading(): | |
return "Carregando ..." | |
with gr.Blocks() as app: | |
with gr.Column(elem_id="column_container"): | |
chatbot = gr.Chatbot([], elem_id="chatbot") | |
with gr.Column(): | |
send = gr.Label(value="Escreva sua QUESTÃO abaixo e pressione ENTER") | |
query = gr.Textbox( | |
label="Escreva sua questão aqui:", | |
placeholder="Sobre o que você quer saber?", | |
) | |
clear = gr.ClearButton([query, chatbot]) | |
query.submit(response, [query, chatbot], [query, chatbot], queue=True) | |
app.launch() | |