Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -598,7 +598,7 @@ def render_tool_call(fn_name: str, args: dict, browser: SimpleBrowser = None) ->
|
|
| 598 |
</div>
|
| 599 |
</div>'''
|
| 600 |
|
| 601 |
-
def render_tool_result(result: str, fn_name: str) -> str:
|
| 602 |
"""Render tool result in an expanded card with direct HTML rendering."""
|
| 603 |
import uuid
|
| 604 |
tool_label = {
|
|
@@ -744,7 +744,20 @@ def render_tool_result(result: str, fn_name: str) -> str:
|
|
| 744 |
ref_num = parts_match.group(1)
|
| 745 |
title = parts_match.group(2)
|
| 746 |
domain = parts_match.group(3)
|
|
|
|
| 747 |
url = f"https://{domain}" if not domain.startswith('http') else domain
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 748 |
return f'<a href="{html.escape(url)}" target="_blank" style="background: #e0f7fa; padding: 2px 6px; border-radius: 4px; font-size: 0.85em; color: #006064; font-weight: 500; text-decoration: none; display: inline-block;" title="{html.escape(title)}">【{ref_num}†{html.escape(domain)}】</a>'
|
| 749 |
else:
|
| 750 |
simple_match = re.match(r'【(\d+)†([^】]+)】', full_text)
|
|
@@ -957,7 +970,7 @@ async def run_agent_streaming(
|
|
| 957 |
except Exception as e:
|
| 958 |
result = f"Tool error: {str(e)}\n{traceback.format_exc()}"
|
| 959 |
|
| 960 |
-
html_parts.append(render_tool_result(result, fn_name))
|
| 961 |
yield ''.join(html_parts)
|
| 962 |
|
| 963 |
messages.append({
|
|
@@ -2566,4 +2579,4 @@ if __name__ == "__main__":
|
|
| 2566 |
print("OpenResearcher DeepSearch Agent - ZeroGPU Space")
|
| 2567 |
print("="*60)
|
| 2568 |
demo = create_interface()
|
| 2569 |
-
demo.queue(default_concurrency_limit=20).launch()
|
|
|
|
| 598 |
</div>
|
| 599 |
</div>'''
|
| 600 |
|
| 601 |
+
def render_tool_result(result: str, fn_name: str, browser: SimpleBrowser = None) -> str:
|
| 602 |
"""Render tool result in an expanded card with direct HTML rendering."""
|
| 603 |
import uuid
|
| 604 |
tool_label = {
|
|
|
|
| 744 |
ref_num = parts_match.group(1)
|
| 745 |
title = parts_match.group(2)
|
| 746 |
domain = parts_match.group(3)
|
| 747 |
+
# Default URL construction (fallback)
|
| 748 |
url = f"https://{domain}" if not domain.startswith('http') else domain
|
| 749 |
+
|
| 750 |
+
# If browser instance is available, try to get the full URL from link_map
|
| 751 |
+
if browser and hasattr(browser, 'link_map'):
|
| 752 |
+
try:
|
| 753 |
+
idx = int(ref_num)
|
| 754 |
+
if idx in browser.link_map:
|
| 755 |
+
full_url = browser.link_map[idx].get('url')
|
| 756 |
+
if full_url:
|
| 757 |
+
url = full_url
|
| 758 |
+
except:
|
| 759 |
+
pass
|
| 760 |
+
|
| 761 |
return f'<a href="{html.escape(url)}" target="_blank" style="background: #e0f7fa; padding: 2px 6px; border-radius: 4px; font-size: 0.85em; color: #006064; font-weight: 500; text-decoration: none; display: inline-block;" title="{html.escape(title)}">【{ref_num}†{html.escape(domain)}】</a>'
|
| 762 |
else:
|
| 763 |
simple_match = re.match(r'【(\d+)†([^】]+)】', full_text)
|
|
|
|
| 970 |
except Exception as e:
|
| 971 |
result = f"Tool error: {str(e)}\n{traceback.format_exc()}"
|
| 972 |
|
| 973 |
+
html_parts.append(render_tool_result(result, fn_name, browser))
|
| 974 |
yield ''.join(html_parts)
|
| 975 |
|
| 976 |
messages.append({
|
|
|
|
| 2579 |
print("OpenResearcher DeepSearch Agent - ZeroGPU Space")
|
| 2580 |
print("="*60)
|
| 2581 |
demo = create_interface()
|
| 2582 |
+
demo.queue(default_concurrency_limit=20).launch(server_name="127.0.0.1", server_port=8888, share=True)
|