Update ui/ui_core.py
Browse files- ui/ui_core.py +4 -5
ui/ui_core.py
CHANGED
|
@@ -6,15 +6,14 @@ def create_ui(agent):
|
|
| 6 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 7 |
gr.Markdown("<h1 style='text-align: center;'>💊 TxAgent: Therapeutic Reasoning</h1>")
|
| 8 |
chatbot = gr.Chatbot(label="TxAgent", height=600, type="messages")
|
| 9 |
-
|
| 10 |
file_upload = gr.File(label="Upload Medical File", file_types=[".pdf", ".txt", ".docx", ".jpg", ".png"])
|
| 11 |
message_input = gr.Textbox(placeholder="Ask a biomedical question...", show_label=False)
|
| 12 |
send_button = gr.Button("Send", variant="primary")
|
| 13 |
conversation_state = gr.State([])
|
| 14 |
file_state = gr.State(None)
|
| 15 |
|
| 16 |
-
def handle_chat(message, history, conversation,
|
| 17 |
-
# Use the file with the message
|
| 18 |
generator = agent.run_gradio_chat(
|
| 19 |
message=message,
|
| 20 |
history=history,
|
|
@@ -23,7 +22,7 @@ def create_ui(agent):
|
|
| 23 |
max_token=8192,
|
| 24 |
call_agent=False,
|
| 25 |
conversation=conversation,
|
| 26 |
-
|
| 27 |
max_round=30
|
| 28 |
)
|
| 29 |
for update in generator:
|
|
@@ -40,4 +39,4 @@ def create_ui(agent):
|
|
| 40 |
inputs=message_input,
|
| 41 |
)
|
| 42 |
|
| 43 |
-
return demo
|
|
|
|
| 6 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 7 |
gr.Markdown("<h1 style='text-align: center;'>💊 TxAgent: Therapeutic Reasoning</h1>")
|
| 8 |
chatbot = gr.Chatbot(label="TxAgent", height=600, type="messages")
|
| 9 |
+
|
| 10 |
file_upload = gr.File(label="Upload Medical File", file_types=[".pdf", ".txt", ".docx", ".jpg", ".png"])
|
| 11 |
message_input = gr.Textbox(placeholder="Ask a biomedical question...", show_label=False)
|
| 12 |
send_button = gr.Button("Send", variant="primary")
|
| 13 |
conversation_state = gr.State([])
|
| 14 |
file_state = gr.State(None)
|
| 15 |
|
| 16 |
+
def handle_chat(message, history, conversation, uploaded_files):
|
|
|
|
| 17 |
generator = agent.run_gradio_chat(
|
| 18 |
message=message,
|
| 19 |
history=history,
|
|
|
|
| 22 |
max_token=8192,
|
| 23 |
call_agent=False,
|
| 24 |
conversation=conversation,
|
| 25 |
+
uploaded_files=[uploaded_files] if uploaded_files else [],
|
| 26 |
max_round=30
|
| 27 |
)
|
| 28 |
for update in generator:
|
|
|
|
| 39 |
inputs=message_input,
|
| 40 |
)
|
| 41 |
|
| 42 |
+
return demo
|