mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2025-06-07 06:06:20 -04:00
Make web search attachments clickable
This commit is contained in:
parent
0aedb89921
commit
6c3590ba9a
2 changed files with 10 additions and 3 deletions
|
@ -370,10 +370,16 @@ def format_message_attachments(history, role, index):
|
|||
|
||||
attachments_html = '<div class="message-attachments">'
|
||||
for attachment in attachments:
|
||||
name = html.escape(attachment["name"])
|
||||
|
||||
# Make clickable if URL exists
|
||||
if "url" in attachment:
|
||||
name = f'<a href="{html.escape(attachment["url"])}" target="_blank" rel="noopener noreferrer">{name}</a>'
|
||||
|
||||
attachments_html += (
|
||||
f'<div class="attachment-box">'
|
||||
f'<div class="attachment-icon">{attachment_svg}</div>'
|
||||
f'<div class="attachment-name">{html.escape(attachment["name"])}</div>'
|
||||
f'<div class="attachment-name">{name}</div>'
|
||||
f'</div>'
|
||||
)
|
||||
attachments_html += '</div>'
|
||||
|
|
|
@ -113,9 +113,10 @@ def add_web_search_attachments(history, row_idx, user_message, state):
|
|||
|
||||
for result in search_results:
|
||||
attachment = {
|
||||
"name": f"{result['title']}",
|
||||
"name": result['title'],
|
||||
"type": "text/html",
|
||||
"content": f"URL: {result['url']}\n\n{result['content']}"
|
||||
"url": result['url'],
|
||||
"content": result['content']
|
||||
}
|
||||
history['metadata'][key]["attachments"].append(attachment)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue