Spaces:
Running
on
Zero
Running
on
Zero
Felipe Silva
commited on
Commit
·
9ec48a8
1
Parent(s):
c71745c
add decorator
Browse files
app.py
CHANGED
|
@@ -42,22 +42,27 @@ def ask_question(texto_extraido, question):
|
|
| 42 |
resposta = rag_chain.run(question)
|
| 43 |
return resposta
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
gr.
|
| 48 |
-
"
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
resposta = rag_chain.run(question)
|
| 43 |
return resposta
|
| 44 |
|
| 45 |
+
@spaces.GPU
|
| 46 |
+
def launch_app():
|
| 47 |
+
with gr.Blocks() as demo:
|
| 48 |
+
gr.Markdown("## ⚙️ Pergunte qualquer coisa para seu arquivo.")
|
| 49 |
+
gr.Markdown(
|
| 50 |
+
"🐶 Faça o upload do seu arquivo e pergunte qualquer coisa a ele! Este código é open source e disponível [aqui](https://github.com/FelipeErmeson) no GitHub. 😁"
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
with gr.Row():
|
| 54 |
+
with gr.Column():
|
| 55 |
+
file_input = gr.File(label="Upload da Imagem ou PDF", file_types=[".png", ".jpg", ".jpeg", ".pdf"])
|
| 56 |
+
extracted_text = gr.Textbox(label="Texto extraído", lines=15)
|
| 57 |
+
with gr.Column():
|
| 58 |
+
question_input = gr.Textbox(label="Faça uma pergunta ao seu documento!")
|
| 59 |
+
answer_output = gr.Textbox(label="Resposta")
|
| 60 |
+
|
| 61 |
+
# Conecta funções
|
| 62 |
+
file_input.change(fn=process_file, inputs=file_input, outputs=extracted_text)
|
| 63 |
+
question_input.submit(fn=ask_question, inputs=[extracted_text, question_input], outputs=answer_output)
|
| 64 |
+
|
| 65 |
+
demo.launch()
|
| 66 |
+
|
| 67 |
+
if __name__ == "__main__":
|
| 68 |
+
launch_app()
|