Dave67350 commited on
Commit
2729068
·
verified ·
1 Parent(s): 2914f64

Update Gradio_UI.py

Browse files
Files changed (1) hide show
  1. Gradio_UI.py +12 -14
Gradio_UI.py CHANGED
@@ -19,7 +19,7 @@ DOCUMENT_TO_MODULE = {
19
  "GDPR": {
20
  "Data Processing Record": "tools.gdpr_data_record",
21
  "DPIA (Data Protection Impact Assessment)": "tools.gdpr_dpia",
22
- "Data Breach Notification Log": "tools.gdpr_breach_log",
23
  "Subject Access Request Record": "tools.gdpr_sar_log",
24
  "Consent Management Log": "tools.gdpr_consent_log",
25
  "Data Processor Agreements": "tools.gdpr_dpa_log"
@@ -38,7 +38,7 @@ def export_pdf(title, answers, lang="en"):
38
  pdf.cell(0, 10, title, ln=True, align='C')
39
  pdf.ln(8)
40
 
41
- # Metadata section
42
  company = answers.get("What is the name of your organization?", "N/A")
43
  name = answers.get("What is your name?", "N/A")
44
  role = answers.get("What is your role?", "N/A")
@@ -51,7 +51,7 @@ def export_pdf(title, answers, lang="en"):
51
  pdf.cell(0, 8, f"Timestamp: {timestamp}", ln=True, align='C')
52
  pdf.ln(10)
53
 
54
- # Main content
55
  pdf.set_font("Arial", '', 12)
56
  pdf.set_text_color(0, 0, 0)
57
  for label, value in answers.items():
@@ -95,17 +95,16 @@ def continue_conversation(user_input):
95
  step = conversation_state["step"]
96
 
97
  if step < len(conversation_state["questions"]):
98
- key, question = conversation_state["questions"][step]
99
- conversation_state["answers"][question] = user_input
100
- conversation_state["step"] += 1
101
-
102
- try:
103
- if user_input and len(user_input.strip()) > 3:
104
- conversation_state["lang"] = detect(user_input)
105
- except:
106
- conversation_state["lang"] = "en"
107
-
108
 
 
 
 
 
 
 
109
 
110
  if conversation_state["step"] < len(conversation_state["questions"]):
111
  next_question = conversation_state["questions"][conversation_state["step"]][1]
@@ -135,7 +134,6 @@ with gr.Blocks(
135
  }
136
  """
137
  ) as demo:
138
- # GDPR Notice
139
  gr.Markdown("""
140
  ### 🔒 GDPR Notice
141
  This assistant does not store any personal data.
 
19
  "GDPR": {
20
  "Data Processing Record": "tools.gdpr_data_record",
21
  "DPIA (Data Protection Impact Assessment)": "tools.gdpr_dpia",
22
+ "Data Breach Notification Log": "tools.gdpr_breach_log",
23
  "Subject Access Request Record": "tools.gdpr_sar_log",
24
  "Consent Management Log": "tools.gdpr_consent_log",
25
  "Data Processor Agreements": "tools.gdpr_dpa_log"
 
38
  pdf.cell(0, 10, title, ln=True, align='C')
39
  pdf.ln(8)
40
 
41
+ # Metadata
42
  company = answers.get("What is the name of your organization?", "N/A")
43
  name = answers.get("What is your name?", "N/A")
44
  role = answers.get("What is your role?", "N/A")
 
51
  pdf.cell(0, 8, f"Timestamp: {timestamp}", ln=True, align='C')
52
  pdf.ln(10)
53
 
54
+ # Answers
55
  pdf.set_font("Arial", '', 12)
56
  pdf.set_text_color(0, 0, 0)
57
  for label, value in answers.items():
 
95
  step = conversation_state["step"]
96
 
97
  if step < len(conversation_state["questions"]):
98
+ key, question = conversation_state["questions"][step]
99
+ conversation_state["answers"][question] = user_input
100
+ conversation_state["step"] += 1
 
 
 
 
 
 
 
101
 
102
+ # Language detection (safe fallback)
103
+ try:
104
+ if user_input and len(user_input.strip()) > 3:
105
+ conversation_state["lang"] = detect(user_input)
106
+ except:
107
+ conversation_state["lang"] = "en"
108
 
109
  if conversation_state["step"] < len(conversation_state["questions"]):
110
  next_question = conversation_state["questions"][conversation_state["step"]][1]
 
134
  }
135
  """
136
  ) as demo:
 
137
  gr.Markdown("""
138
  ### 🔒 GDPR Notice
139
  This assistant does not store any personal data.