Spaces:
No application file
No application file
File size: 1,421 Bytes
f2393fe |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# content.py
def get_response_format(query_type):
"""
Defines AI response formatting using HTML for better visual appeal.
"""
response_templates = {
"default": "<p>{response}</p>", # Standard paragraph format
"paragraph": "<div style='font-size: 16px; line-height: 1.6;'><strong>π Detailed Explanation:</strong><br><br>{response}</div>",
"bullet_points": (
"<div style='font-size: 16px; line-height: 1.6;'>"
"<strong>πΉ Key Points:</strong><br><ul>"
+ "".join([f"<li>{point.strip()}</li>" for point in "{response}".split("\n") if point.strip()])
+ "</ul></div>"
).replace("{response}", "{response}"), # Fix incorrect replacement
"points_with_paragraph": (
"<div style='font-size: 16px; line-height: 1.6;'>"
"<strong>π Overview:</strong><br><br>{paragraph}<br><br>"
"<strong>πΉ Key Takeaways:</strong><br><ul>"
+ "".join([f"<li>{point.strip()}</li>" for point in "{points}".split("\n") if point.strip()])
+ "</ul></div>"
).replace("{paragraph}", "{response}").replace("{points}", "{response}"),
"bold": "<strong>{response}</strong>",
"italic": "<em>{response}</em>",
"underline": "<u>{response}</u>",
}
return response_templates.get(query_type, response_templates["default"]) |