Spaces:
Sleeping
Sleeping
Update Gradio_UI.py
Browse files- Gradio_UI.py +7 -4
Gradio_UI.py
CHANGED
|
@@ -8,7 +8,7 @@ import importlib
|
|
| 8 |
# === Map document choices to modules ===
|
| 9 |
DOCUMENT_TO_MODULE = {
|
| 10 |
"AI Act": {
|
| 11 |
-
"Compliance Register": "tools.
|
| 12 |
"High-Risk System Record": "tools.ai_high_risk_system"
|
| 13 |
},
|
| 14 |
"GDPR": {
|
|
@@ -45,7 +45,8 @@ conversation_state = {
|
|
| 45 |
"questions": [],
|
| 46 |
"answers": {},
|
| 47 |
"title": "",
|
| 48 |
-
"lang": "en"
|
|
|
|
| 49 |
}
|
| 50 |
|
| 51 |
# === Load Tool Dynamically ===
|
|
@@ -57,6 +58,7 @@ def start_conversation(reg, doc):
|
|
| 57 |
module_path = DOCUMENT_TO_MODULE[reg][doc]
|
| 58 |
module = importlib.import_module(module_path)
|
| 59 |
conversation_state["questions"] = module.get_questions()
|
|
|
|
| 60 |
|
| 61 |
return f"📋 {conversation_state['questions'][0][1]}"
|
| 62 |
|
|
@@ -73,6 +75,7 @@ def continue_conversation(user_input):
|
|
| 73 |
next_question = conversation_state["questions"][conversation_state["step"]][1]
|
| 74 |
return f"🧠 {next_question}", None
|
| 75 |
else:
|
|
|
|
| 76 |
pdf_path = export_pdf(conversation_state["title"], conversation_state["answers"], lang=conversation_state["lang"])
|
| 77 |
return "✅ Done! Your document is ready to download.", pdf_path
|
| 78 |
|
|
@@ -88,11 +91,11 @@ with gr.Blocks(title="Regulatory Compliance Generator") as demo:
|
|
| 88 |
|
| 89 |
start_btn = gr.Button("🚀 Start")
|
| 90 |
chatbox = gr.Chatbot(label="🧑⚖️ Legalbot")
|
| 91 |
-
user_input = gr.Textbox(label="Your answer")
|
| 92 |
pdf_output = gr.File(label="Download PDF", visible=True)
|
| 93 |
|
| 94 |
start_btn.click(start_conversation, inputs=[reg_dropdown, doc_dropdown], outputs=chatbox)
|
| 95 |
user_input.submit(continue_conversation, inputs=user_input, outputs=[chatbox, pdf_output])
|
| 96 |
-
user_input.submit(lambda: "", None, user_input)
|
| 97 |
|
| 98 |
demo.launch()
|
|
|
|
| 8 |
# === Map document choices to modules ===
|
| 9 |
DOCUMENT_TO_MODULE = {
|
| 10 |
"AI Act": {
|
| 11 |
+
"Compliance Register": "tools.ai_act_generator",
|
| 12 |
"High-Risk System Record": "tools.ai_high_risk_system"
|
| 13 |
},
|
| 14 |
"GDPR": {
|
|
|
|
| 45 |
"questions": [],
|
| 46 |
"answers": {},
|
| 47 |
"title": "",
|
| 48 |
+
"lang": "en",
|
| 49 |
+
"tool": None
|
| 50 |
}
|
| 51 |
|
| 52 |
# === Load Tool Dynamically ===
|
|
|
|
| 58 |
module_path = DOCUMENT_TO_MODULE[reg][doc]
|
| 59 |
module = importlib.import_module(module_path)
|
| 60 |
conversation_state["questions"] = module.get_questions()
|
| 61 |
+
conversation_state["tool"] = module
|
| 62 |
|
| 63 |
return f"📋 {conversation_state['questions'][0][1]}"
|
| 64 |
|
|
|
|
| 75 |
next_question = conversation_state["questions"][conversation_state["step"]][1]
|
| 76 |
return f"🧠 {next_question}", None
|
| 77 |
else:
|
| 78 |
+
# Optionally: use conversation_state["tool"].run_tool() here if needed
|
| 79 |
pdf_path = export_pdf(conversation_state["title"], conversation_state["answers"], lang=conversation_state["lang"])
|
| 80 |
return "✅ Done! Your document is ready to download.", pdf_path
|
| 81 |
|
|
|
|
| 91 |
|
| 92 |
start_btn = gr.Button("🚀 Start")
|
| 93 |
chatbox = gr.Chatbot(label="🧑⚖️ Legalbot")
|
| 94 |
+
user_input = gr.Textbox(label="Your answer", placeholder="Type your answer and press Enter")
|
| 95 |
pdf_output = gr.File(label="Download PDF", visible=True)
|
| 96 |
|
| 97 |
start_btn.click(start_conversation, inputs=[reg_dropdown, doc_dropdown], outputs=chatbox)
|
| 98 |
user_input.submit(continue_conversation, inputs=user_input, outputs=[chatbox, pdf_output])
|
| 99 |
+
user_input.submit(lambda: "", None, user_input) # clears input
|
| 100 |
|
| 101 |
demo.launch()
|