Spaces:
Sleeping
Sleeping
fredcaixeta commited on
Commit ·
7bbd250
1
Parent(s): c83dfac
chat
Browse files
app.py
CHANGED
|
@@ -5,11 +5,36 @@ from ocr_script import ocr_tesseract_only
|
|
| 5 |
# # chamar seu OCR aqui e retornar texto
|
| 6 |
# return "texto extraído"
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
with gr.Blocks() as demo:
|
| 9 |
-
gr.
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
# # chamar seu OCR aqui e retornar texto
|
| 6 |
# return "texto extraído"
|
| 7 |
|
| 8 |
+
def respond(message, history, user_id):
|
| 9 |
+
return "mock response"
|
| 10 |
+
# pydantic_history = convert_to_pydantic_history(history)
|
| 11 |
+
# tools_instance = SearchingTools()
|
| 12 |
+
# deps = SearchAgentDeps(tools=tools_instance)
|
| 13 |
+
# agent_config = start_convo(user_input=str(message), messages_history=pydantic_history)
|
| 14 |
+
# result = agent_config.run_sync(
|
| 15 |
+
# str(message),
|
| 16 |
+
# deps=deps,
|
| 17 |
+
# usage_limits=usage_limits,
|
| 18 |
+
# message_history=pydantic_history,
|
| 19 |
+
# )
|
| 20 |
+
return result.output
|
| 21 |
+
|
| 22 |
with gr.Blocks() as demo:
|
| 23 |
+
with gr.Tabs():
|
| 24 |
+
with gr.Tab("Text OCR Tesseract only"):
|
| 25 |
+
with gr.Row():
|
| 26 |
+
img_in = gr.Image(label="Imagem (png, jpg, jpeg)", type="pil") # ou "filepath"/"numpy"
|
| 27 |
+
txt_out = gr.Textbox(label="Texto OCR", lines=12)
|
| 28 |
+
img_in.change(fn=ocr_tesseract_only, inputs=img_in, outputs=txt_out)
|
| 29 |
+
|
| 30 |
|
| 31 |
+
with gr.Tab("Chat"):
|
| 32 |
+
user_id = gr.State(str(uuid.uuid4()))
|
| 33 |
+
chat = gr.ChatInterface(
|
| 34 |
+
fn=lambda m,h: respond(m,h,user_id.value),
|
| 35 |
+
type="messages",
|
| 36 |
+
title="Chat with AI Agent with Access to Extracted Data",
|
| 37 |
+
save_history=True,
|
| 38 |
+
)
|
| 39 |
+
chat.render()
|
| 40 |
+
#demo.launch()
|