Dave67350 commited on
Commit
81a6310
·
verified ·
1 Parent(s): e612c9d

Update Gradio_UI.py

Browse files
Files changed (1) hide show
  1. Gradio_UI.py +20 -25
Gradio_UI.py CHANGED
@@ -82,30 +82,31 @@ def continue_conversation(user_input):
82
 
83
  if conversation_state["step"] < len(conversation_state["questions"]):
84
  next_question = conversation_state["questions"][conversation_state["step"]][1]
85
- messages.append({"role": "assistant", "content": f"🧐 {next_question}"})
86
  return messages, None
87
  else:
88
  pdf_path = export_pdf(conversation_state["title"], conversation_state["answers"], lang=conversation_state["lang"])
89
  messages.append({"role": "assistant", "content": "✅ Done! Your document is ready to download."})
90
  return messages, pdf_path
91
 
92
- # === Custom CSS for Cleanup ===
93
- def get_custom_css():
94
- return """
95
- <style>
96
- footer,
97
- a[href*='gradio.app'],
98
- a[href*='huggingface.co'],
99
- button[aria-label='Share'],
100
- button[data-testid='share-button'],
101
- button[title='Share'] {
102
- display: none !important;
103
- }
104
- </style>
105
- """
106
-
107
  # === Gradio Interface ===
108
- with gr.Blocks(title="Regulatory Compliance Generator") as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  gr.Markdown("""
110
  ### 🔒 GDPR Notice
111
  This assistant does not store any personal data.
@@ -113,8 +114,6 @@ with gr.Blocks(title="Regulatory Compliance Generator") as demo:
113
  You are responsible for the accuracy and legality of the information submitted.
114
  """)
115
 
116
- css_injector = gr.HTML(get_custom_css())
117
-
118
  with gr.Row():
119
  reg_dropdown = gr.Dropdown(
120
  choices=list(DOCUMENT_TO_MODULE.keys()),
@@ -139,15 +138,11 @@ with gr.Blocks(title="Regulatory Compliance Generator") as demo:
139
  reg_dropdown.change(update_doc_dropdown, inputs=reg_dropdown, outputs=doc_dropdown)
140
 
141
  start_btn = gr.Button("🚀 Start")
142
- chatbox = gr.Chatbot(label="🧑‍⚖️ Legalbot", value=[], type="messages")
143
  user_input = gr.Textbox(label="Your answer", placeholder="Type your answer and press Enter")
144
  pdf_output = gr.File(label="Download PDF", visible=True)
145
 
146
- def start_conversation_and_inject_css(reg, doc):
147
- css_injector.update(get_custom_css())
148
- return start_conversation(reg, doc)
149
-
150
- start_btn.click(start_conversation_and_inject_css, inputs=[reg_dropdown, doc_dropdown], outputs=chatbox)
151
  user_input.submit(continue_conversation, inputs=user_input, outputs=[chatbox, pdf_output])
152
  user_input.submit(lambda: "", None, user_input)
153
 
 
82
 
83
  if conversation_state["step"] < len(conversation_state["questions"]):
84
  next_question = conversation_state["questions"][conversation_state["step"]][1]
85
+ messages.append({"role": "assistant", "content": f"🧠 {next_question}"})
86
  return messages, None
87
  else:
88
  pdf_path = export_pdf(conversation_state["title"], conversation_state["answers"], lang=conversation_state["lang"])
89
  messages.append({"role": "assistant", "content": "✅ Done! Your document is ready to download."})
90
  return messages, pdf_path
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  # === Gradio Interface ===
93
+ with gr.Blocks(
94
+ title="Regulatory Compliance Generator",
95
+ css="""
96
+ footer,
97
+ a[href*="gradio.app"],
98
+ a[href*="huggingface.co"],
99
+ button[aria-label="Share"],
100
+ button[title="Share"],
101
+ button[data-testid="share-button"],
102
+ .svelte-drgfjz[data-testid="share-button"],
103
+ .svelte-drgfjz svg path[d^="M15 8a3"],
104
+ .chatbot button[data-testid="share-button"] {
105
+ display: none !important;
106
+ }
107
+ """
108
+ ) as demo:
109
+ # GDPR Notice
110
  gr.Markdown("""
111
  ### 🔒 GDPR Notice
112
  This assistant does not store any personal data.
 
114
  You are responsible for the accuracy and legality of the information submitted.
115
  """)
116
 
 
 
117
  with gr.Row():
118
  reg_dropdown = gr.Dropdown(
119
  choices=list(DOCUMENT_TO_MODULE.keys()),
 
138
  reg_dropdown.change(update_doc_dropdown, inputs=reg_dropdown, outputs=doc_dropdown)
139
 
140
  start_btn = gr.Button("🚀 Start")
141
+ chatbox = gr.Chatbot(label="🧑‍⚖️ Legalbot", value=[], type="messages", elem_classes=["chatbot"])
142
  user_input = gr.Textbox(label="Your answer", placeholder="Type your answer and press Enter")
143
  pdf_output = gr.File(label="Download PDF", visible=True)
144
 
145
+ start_btn.click(start_conversation, inputs=[reg_dropdown, doc_dropdown], outputs=chatbox)
 
 
 
 
146
  user_input.submit(continue_conversation, inputs=user_input, outputs=[chatbox, pdf_output])
147
  user_input.submit(lambda: "", None, user_input)
148