Spaces:
Sleeping
Sleeping
Update tools/ai_act_generator.py
Browse files- tools/ai_act_generator.py +8 -34
tools/ai_act_generator.py
CHANGED
|
@@ -165,42 +165,16 @@ Generated by AI Act Assistant.
|
|
| 165 |
✅ All answers received. Your PDF is ready below:
|
| 166 |
👉 Click the download button to save your AI Act compliance register.""", {"done": True, "pdf": pdf_path}, pdf_path
|
| 167 |
|
|
|
|
| 168 |
def launch_step_by_step_ui():
|
| 169 |
-
with gr.Blocks(
|
| 170 |
-
fill_height=True,
|
| 171 |
-
css=".prose > div.flex.justify-between.items-center { display: none !important; }"
|
| 172 |
-
) as demo:
|
| 173 |
initial_question = QUESTIONS[0][1]
|
| 174 |
-
initial_message = gr.ChatMessage(role="assistant", content=
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
chatbot = gr.Chatbot(type="messages", value=stored_messages)
|
| 178 |
-
msg = gr.Textbox(label="Your answer")
|
| 179 |
-
state = gr.State()
|
| 180 |
-
file_output = gr.File(label="Download PDF", visible=True)
|
| 181 |
-
restart_button = gr.Button("🔁 Restart")
|
| 182 |
-
|
| 183 |
-
def chat_logic(user_msg, state):
|
| 184 |
-
reply, updated_state, file_path = step_by_step_agent(user_msg, state)
|
| 185 |
-
messages = [gr.ChatMessage(role="user", content=user_msg)]
|
| 186 |
-
|
| 187 |
-
if isinstance(reply, str):
|
| 188 |
-
messages.append(gr.ChatMessage(role="assistant", content=reply))
|
| 189 |
-
|
| 190 |
-
if not file_path or not os.path.isfile(file_path):
|
| 191 |
-
file_path = None
|
| 192 |
-
return messages, updated_state, file_path
|
| 193 |
-
|
| 194 |
-
def restart_conversation():
|
| 195 |
-
return [initial_message], {"step": 0, "answers": {}}, None
|
| 196 |
-
|
| 197 |
-
msg.submit(chat_logic, [msg, state], [chatbot, state, file_output])
|
| 198 |
-
restart_button.click(restart_conversation, outputs=[chatbot, state, file_output])
|
| 199 |
-
|
| 200 |
-
demo.launch(show_api=False)
|
| 201 |
-
|
| 202 |
-
...
|
| 203 |
|
|
|
|
|
|
|
| 204 |
stored_messages = [initial_message]
|
| 205 |
chatbot = gr.Chatbot(type="messages", value=stored_messages)
|
| 206 |
msg = gr.Textbox(label="Your answer")
|
|
@@ -231,4 +205,4 @@ def get_questions():
|
|
| 231 |
return QUESTIONS
|
| 232 |
|
| 233 |
def run_tool():
|
| 234 |
-
return launch_step_by_step_ui()
|
|
|
|
| 165 |
✅ All answers received. Your PDF is ready below:
|
| 166 |
👉 Click the download button to save your AI Act compliance register.""", {"done": True, "pdf": pdf_path}, pdf_path
|
| 167 |
|
| 168 |
+
# === UI for Step-by-Step Form ===
|
| 169 |
def launch_step_by_step_ui():
|
| 170 |
+
with gr.Blocks(fill_height=True) as demo:
|
|
|
|
|
|
|
|
|
|
| 171 |
initial_question = QUESTIONS[0][1]
|
| 172 |
+
initial_message = gr.ChatMessage(role="assistant", content="""
|
| 173 |
+
👋 Welcome! I will guide you through the AI Act compliance form.
|
| 174 |
+
Let's begin with a few questions to generate your compliance register.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
|
| 176 |
+
What is the name of your organization?
|
| 177 |
+
""")
|
| 178 |
stored_messages = [initial_message]
|
| 179 |
chatbot = gr.Chatbot(type="messages", value=stored_messages)
|
| 180 |
msg = gr.Textbox(label="Your answer")
|
|
|
|
| 205 |
return QUESTIONS
|
| 206 |
|
| 207 |
def run_tool():
|
| 208 |
+
return launch_step_by_step_ui()
|