Felipe Silva commited on
Commit
9ec48a8
·
1 Parent(s): c71745c

add decorator

Browse files
Files changed (1) hide show
  1. app.py +24 -19
app.py CHANGED
@@ -42,22 +42,27 @@ def ask_question(texto_extraido, question):
42
  resposta = rag_chain.run(question)
43
  return resposta
44
 
45
- with gr.Blocks() as demo:
46
- gr.Markdown("## ⚙️ Pergunte qualquer coisa para seu arquivo.")
47
- gr.Markdown(
48
- "🐶 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. 😁"
49
- )
50
-
51
- with gr.Row():
52
- with gr.Column():
53
- file_input = gr.File(label="Upload da Imagem ou PDF", file_types=[".png", ".jpg", ".jpeg", ".pdf"])
54
- extracted_text = gr.Textbox(label="Texto extraído", lines=15)
55
- with gr.Column():
56
- question_input = gr.Textbox(label="Faça uma pergunta ao seu documento!")
57
- answer_output = gr.Textbox(label="Resposta")
58
-
59
- # Conecta funções
60
- file_input.change(fn=process_file, inputs=file_input, outputs=extracted_text)
61
- question_input.submit(fn=ask_question, inputs=[extracted_text, question_input], outputs=answer_output)
62
-
63
- demo.launch()
 
 
 
 
 
 
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()