|
import re |
|
import os |
|
|
|
|
|
|
|
|
|
def format_response(response_text): |
|
|
|
response_text = re.sub(r'\\n', '\n', response_text) |
|
|
|
|
|
response_text = re.sub(r'^\s*-\s+(.*)$', r'* \1', response_text, flags=re.MULTILINE) |
|
|
|
|
|
response_text = re.sub(r'^\s*\d+\.\s+(.*)$', r'1. \1', response_text, flags=re.MULTILINE) |
|
|
|
|
|
response_text = re.sub(r'^\s*(#+)\s+(.*)$', r'\1 \2', response_text, flags=re.MULTILINE) |
|
|
|
return response_text |
|
|
|
|
|
def unlink_images(folder_path): |
|
|
|
image_files = os.listdir(folder_path) |
|
|
|
|
|
for image_file in image_files: |
|
try: |
|
os.unlink(os.path.join(folder_path, image_file)) |
|
print(f"Deleted: {image_file}") |
|
except Exception as e: |
|
print(f"Error deleting {image_file}: {e}") |