Serhan Yılmaz commited on
Commit
98f4961
·
1 Parent(s): fe4ee2d

syntax fix

Browse files
Files changed (1) hide show
  1. pas2.py +11 -6
pas2.py CHANGED
@@ -1121,7 +1121,12 @@ def create_interface():
1121
  conflicting_facts_text += str(fact)
1122
  conflicting_facts_text += "\n"
1123
 
1124
- # Create HTML display
 
 
 
 
 
1125
  html_output = f"""
1126
  <div class="container">
1127
  <h2 class="title">Hallucination Detection Results</h2>
@@ -1157,13 +1162,13 @@ def create_interface():
1157
 
1158
  <div class="section-title">Original Response</div>
1159
  <div class="response-box">
1160
- {original_response.replace('\n', '<br>')}
1161
  </div>
1162
 
1163
  <div class="section-title">Paraphrased Queries and Responses</div>
1164
  """
1165
 
1166
- for i, (q, r) in enumerate(zip(paraphrased_queries, paraphrased_responses), 1):
1167
  html_output += f"""
1168
  <div class="section-title">Paraphrased Query {i}</div>
1169
  <div class="response-box">
@@ -1172,7 +1177,7 @@ def create_interface():
1172
 
1173
  <div class="section-title">Response {i}</div>
1174
  <div class="response-box">
1175
- {r.replace('\n', '<br>')}
1176
  </div>
1177
  """
1178
 
@@ -1180,10 +1185,10 @@ def create_interface():
1180
  <div class="section-title">Detailed Analysis</div>
1181
  <div class="info-box">
1182
  <p><strong>Reasoning:</strong></p>
1183
- <p>{reasoning.replace('\n', '<br>')}</p>
1184
 
1185
  <p><strong>Conflicting Facts:</strong></p>
1186
- <p>{conflicting_facts_text.replace('\n', '<br>') if conflicting_facts_text else "None identified"}</p>
1187
  </div>
1188
  </div>
1189
  """
 
1121
  conflicting_facts_text += str(fact)
1122
  conflicting_facts_text += "\n"
1123
 
1124
+ # Format responses to escape any backslashes
1125
+ original_response_safe = original_response.replace('\\', '\\\\').replace('\n', '<br>')
1126
+ paraphrased_responses_safe = [r.replace('\\', '\\\\').replace('\n', '<br>') for r in paraphrased_responses]
1127
+ reasoning_safe = reasoning.replace('\\', '\\\\').replace('\n', '<br>')
1128
+ conflicting_facts_text_safe = conflicting_facts_text.replace('\\', '\\\\').replace('\n', '<br>') if conflicting_facts_text else "None identified"
1129
+
1130
  html_output = f"""
1131
  <div class="container">
1132
  <h2 class="title">Hallucination Detection Results</h2>
 
1162
 
1163
  <div class="section-title">Original Response</div>
1164
  <div class="response-box">
1165
+ {original_response_safe}
1166
  </div>
1167
 
1168
  <div class="section-title">Paraphrased Queries and Responses</div>
1169
  """
1170
 
1171
+ for i, (q, r) in enumerate(zip(paraphrased_queries, paraphrased_responses_safe), 1):
1172
  html_output += f"""
1173
  <div class="section-title">Paraphrased Query {i}</div>
1174
  <div class="response-box">
 
1177
 
1178
  <div class="section-title">Response {i}</div>
1179
  <div class="response-box">
1180
+ {r}
1181
  </div>
1182
  """
1183
 
 
1185
  <div class="section-title">Detailed Analysis</div>
1186
  <div class="info-box">
1187
  <p><strong>Reasoning:</strong></p>
1188
+ <p>{reasoning_safe}</p>
1189
 
1190
  <p><strong>Conflicting Facts:</strong></p>
1191
+ <p>{conflicting_facts_text_safe}</p>
1192
  </div>
1193
  </div>
1194
  """