Spaces:
Sleeping
Sleeping
Update Gradio_UI.py
Browse files- Gradio_UI.py +15 -0
Gradio_UI.py
CHANGED
|
@@ -98,12 +98,27 @@ def step_by_step_agent(user_input, state):
|
|
| 98 |
Generated by AI Act Assistant.
|
| 99 |
"""
|
| 100 |
|
|
|
|
|
|
|
|
|
|
| 101 |
try:
|
| 102 |
detected_lang = detect(filled_template)
|
| 103 |
except:
|
| 104 |
detected_lang = "en"
|
| 105 |
|
| 106 |
flag = "🇬🇧" if detected_lang == "en" else "🇫🇷"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
pdf_path = export_text_to_pdf(filled_template, language=detected_lang)
|
| 108 |
return f"{flag} Language detected: {detected_lang.upper()}
|
| 109 |
✅ All answers received. Download your AI Act compliance PDF below.", {"done": True, "pdf": pdf_path}
|
|
|
|
| 98 |
Generated by AI Act Assistant.
|
| 99 |
"""
|
| 100 |
|
| 101 |
+
import csv
|
| 102 |
+
import datetime
|
| 103 |
+
|
| 104 |
try:
|
| 105 |
detected_lang = detect(filled_template)
|
| 106 |
except:
|
| 107 |
detected_lang = "en"
|
| 108 |
|
| 109 |
flag = "🇬🇧" if detected_lang == "en" else "🇫🇷"
|
| 110 |
+
# Save to CSV
|
| 111 |
+
csv_file = "ai_act_registers.csv"
|
| 112 |
+
fieldnames = [key for key, _ in QUESTIONS] + ["timestamp"]
|
| 113 |
+
row_data = {**answers, "timestamp": datetime.datetime.now().isoformat()}
|
| 114 |
+
|
| 115 |
+
file_exists = os.path.isfile(csv_file)
|
| 116 |
+
with open(csv_file, mode="a", newline="", encoding="utf-8") as csvfile:
|
| 117 |
+
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
|
| 118 |
+
if not file_exists:
|
| 119 |
+
writer.writeheader()
|
| 120 |
+
writer.writerow(row_data)
|
| 121 |
+
|
| 122 |
pdf_path = export_text_to_pdf(filled_template, language=detected_lang)
|
| 123 |
return f"{flag} Language detected: {detected_lang.upper()}
|
| 124 |
✅ All answers received. Download your AI Act compliance PDF below.", {"done": True, "pdf": pdf_path}
|