fredcaixeta commited on
Commit
b83e38c
·
1 Parent(s): a5edea0

back to tabs

Browse files
Files changed (1) hide show
  1. app.py +18 -15
app.py CHANGED
@@ -23,22 +23,25 @@ def respond(message, history, user_id):
23
  with gr.Blocks() as demo:
24
  with gr.Tabs():
25
  with gr.Tab("Text OCR Tesseract only"):
26
- # Coluna esquerda: OCR
27
- with gr.Column(scale=1, min_width=360):
28
  img_in = gr.Image(label="Imagem (png, jpg, jpeg)", type="pil")
29
  txt_out = gr.Textbox(label="Texto OCR", lines=12)
30
- img_in.change(fn=ocr_tesseract_only, inputs=img_in, outputs=txt_out)
31
 
32
- # Coluna direita: Chat
33
- with gr.Column(scale=1, min_width=360):
34
- user_id = gr.State(str(uuid.uuid4()))
35
- gr.ChatInterface(
36
- fn=respond,
37
- additional_inputs=[user_id],
38
- type="messages",
39
- title="Chat with AI Agent with Access to Extracted Data",
40
- description="Envie perguntas sobre os dados extraídos.",
41
- save_history=True,
42
- fill_height=True, # ajuda a ocupar a altura disponível
43
- )
 
 
 
 
44
  demo.launch()
 
23
  with gr.Blocks() as demo:
24
  with gr.Tabs():
25
  with gr.Tab("Text OCR Tesseract only"):
26
+ with gr.Row():
 
27
  img_in = gr.Image(label="Imagem (png, jpg, jpeg)", type="pil")
28
  txt_out = gr.Textbox(label="Texto OCR", lines=12)
29
+ img_in.change(fn=ocr_tesseract_only, inputs=img_in, outputs=txt_out)
30
 
31
+ with gr.Tab("Chat"):
32
+ user_id = gr.State(str(uuid.uuid4()))
33
+ gr.ChatInterface(
34
+ fn=respond,
35
+ additional_inputs=[user_id],
36
+ type="messages",
37
+ title="Chat with AI Agent with Access to Extracted Data",
38
+ description="Envie perguntas sobre os dados extraídos.",
39
+ save_history=True,
40
+ examples=[
41
+ "What is the name of the invoice document available?",
42
+ "Which document has the ID aZwfUT2Zs?",
43
+ "How much is the Auto Previously Billed Premium?",
44
+ ],
45
+ cache_examples=True,
46
+ )
47
  demo.launch()