Spaces:
Runtime error
Runtime error
# Helper formatting functions | |
def format_local_map(result): | |
html = ( | |
f"<div><strong>Local Map:</strong><br>" | |
f"<a href='{result.get('link','')}' target='_blank'>View on Google Maps</a><br>" | |
f"<img src='{result.get('image','')}' style='width:100%;'/></div>" | |
) | |
return html | |
def format_knowledge(result): | |
html = ( | |
f"<div><strong>{result.get('title','Unknown')}</strong><br>" | |
f"Type: {result.get('type','')}<br>" | |
f"Born: {result.get('born','')}<br>" | |
f"Died: {result.get('died','')}</div>" | |
) | |
return html | |
def format_images(result): | |
# Extract 'original' URL from each image dict. | |
urls = [item.get("original", "") for item in result] | |
return urls | |
def format_videos(result): | |
html = "<div>" | |
for vid in result: | |
html += ( | |
f"<div style='margin-bottom:10px;'>" | |
f"<video controls style='width:100%;' src='{vid.get('link','')}'></video><br>" | |
f"{vid.get('title','')}" | |
f"</div>" | |
) | |
html += "</div>" | |
return html | |
def format_links(result): | |
html = "<div><ul>" | |
for url in result: | |
# Use the final part of the URL as the title. | |
title = url.rstrip('/').split('/')[-1] | |
html += f"<li><a href='{url}' target='_blank'>{title}</a></li>" | |
html += "</ul></div>" | |
return html |