Spaces:
Sleeping
Sleeping
Update Gradio_UI.py
Browse files- Gradio_UI.py +18 -19
Gradio_UI.py
CHANGED
|
@@ -67,7 +67,7 @@ def start_conversation(reg, doc):
|
|
| 67 |
def continue_conversation(user_input):
|
| 68 |
messages = [{"role": "user", "content": user_input}]
|
| 69 |
step = conversation_state["step"]
|
| 70 |
-
|
| 71 |
if step < len(conversation_state["questions"]):
|
| 72 |
key, question = conversation_state["questions"][step]
|
| 73 |
conversation_state["answers"][question] = user_input
|
|
@@ -87,22 +87,21 @@ def continue_conversation(user_input):
|
|
| 87 |
with gr.Blocks(title="Regulatory Compliance Generator") as demo:
|
| 88 |
gr.Markdown("## 📑 Regulation Document Generator")
|
| 89 |
|
| 90 |
-
with gr.Row():
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
|
| 107 |
def update_doc_dropdown(selected_reg):
|
| 108 |
if selected_reg in DOCUMENT_TO_MODULE:
|
|
@@ -112,12 +111,12 @@ with gr.Row():
|
|
| 112 |
reg_dropdown.change(update_doc_dropdown, inputs=reg_dropdown, outputs=doc_dropdown)
|
| 113 |
|
| 114 |
start_btn = gr.Button("🚀 Start")
|
| 115 |
-
chatbox = gr.Chatbot(label="🧑⚖️ Legalbot", value=[], type="messages")
|
| 116 |
user_input = gr.Textbox(label="Your answer", placeholder="Type your answer and press Enter")
|
| 117 |
pdf_output = gr.File(label="Download PDF", visible=True)
|
| 118 |
|
| 119 |
start_btn.click(start_conversation, inputs=[reg_dropdown, doc_dropdown], outputs=chatbox)
|
| 120 |
user_input.submit(continue_conversation, inputs=user_input, outputs=[chatbox, pdf_output])
|
| 121 |
-
user_input.submit(lambda: "", None, user_input)
|
| 122 |
|
| 123 |
demo.launch()
|
|
|
|
| 67 |
def continue_conversation(user_input):
|
| 68 |
messages = [{"role": "user", "content": user_input}]
|
| 69 |
step = conversation_state["step"]
|
| 70 |
+
|
| 71 |
if step < len(conversation_state["questions"]):
|
| 72 |
key, question = conversation_state["questions"][step]
|
| 73 |
conversation_state["answers"][question] = user_input
|
|
|
|
| 87 |
with gr.Blocks(title="Regulatory Compliance Generator") as demo:
|
| 88 |
gr.Markdown("## 📑 Regulation Document Generator")
|
| 89 |
|
| 90 |
+
with gr.Row():
|
| 91 |
+
reg_dropdown = gr.Dropdown(
|
| 92 |
+
choices=list(DOCUMENT_TO_MODULE.keys()),
|
| 93 |
+
label="Select Regulation",
|
| 94 |
+
value=None,
|
| 95 |
+
interactive=True,
|
| 96 |
+
info="-- Please choose a regulation --"
|
| 97 |
+
)
|
| 98 |
+
doc_dropdown = gr.Dropdown(
|
| 99 |
+
label="Select Document Type",
|
| 100 |
+
choices=[],
|
| 101 |
+
value=None,
|
| 102 |
+
interactive=True,
|
| 103 |
+
info="-- Select a document after choosing a regulation --"
|
| 104 |
+
)
|
|
|
|
| 105 |
|
| 106 |
def update_doc_dropdown(selected_reg):
|
| 107 |
if selected_reg in DOCUMENT_TO_MODULE:
|
|
|
|
| 111 |
reg_dropdown.change(update_doc_dropdown, inputs=reg_dropdown, outputs=doc_dropdown)
|
| 112 |
|
| 113 |
start_btn = gr.Button("🚀 Start")
|
| 114 |
+
chatbox = gr.Chatbot(label="🧑⚖️ Legalbot", value=[], type="messages")
|
| 115 |
user_input = gr.Textbox(label="Your answer", placeholder="Type your answer and press Enter")
|
| 116 |
pdf_output = gr.File(label="Download PDF", visible=True)
|
| 117 |
|
| 118 |
start_btn.click(start_conversation, inputs=[reg_dropdown, doc_dropdown], outputs=chatbox)
|
| 119 |
user_input.submit(continue_conversation, inputs=user_input, outputs=[chatbox, pdf_output])
|
| 120 |
+
user_input.submit(lambda: "", None, user_input)
|
| 121 |
|
| 122 |
demo.launch()
|