mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-28 00:04:47 +08:00
feat: fallback to error reporting
This commit is contained in:
@@ -21,6 +21,7 @@ def web_search_tool(query: str) -> str:
|
|||||||
Args:
|
Args:
|
||||||
query: The query to search for.
|
query: The query to search for.
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
config = get_app_config().get_tool_config("web_search")
|
config = get_app_config().get_tool_config("web_search")
|
||||||
max_results = 5
|
max_results = 5
|
||||||
if config is not None:
|
if config is not None:
|
||||||
@@ -41,6 +42,8 @@ def web_search_tool(query: str) -> str:
|
|||||||
]
|
]
|
||||||
json_results = json.dumps(normalized_results, indent=2, ensure_ascii=False)
|
json_results = json.dumps(normalized_results, indent=2, ensure_ascii=False)
|
||||||
return json_results
|
return json_results
|
||||||
|
except Exception as e:
|
||||||
|
return f"Error: {str(e)}"
|
||||||
|
|
||||||
|
|
||||||
@tool("web_fetch", parse_docstring=True)
|
@tool("web_fetch", parse_docstring=True)
|
||||||
@@ -54,6 +57,7 @@ def web_fetch_tool(url: str) -> str:
|
|||||||
Args:
|
Args:
|
||||||
url: The URL to fetch the contents of.
|
url: The URL to fetch the contents of.
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
client = _get_firecrawl_client()
|
client = _get_firecrawl_client()
|
||||||
result = client.scrape(url, formats=["markdown"])
|
result = client.scrape(url, formats=["markdown"])
|
||||||
|
|
||||||
@@ -63,5 +67,7 @@ def web_fetch_tool(url: str) -> str:
|
|||||||
|
|
||||||
if not markdown_content:
|
if not markdown_content:
|
||||||
return "Error: No content found"
|
return "Error: No content found"
|
||||||
|
except Exception as e:
|
||||||
|
return f"Error: {str(e)}"
|
||||||
|
|
||||||
return f"# {title}\n\n{markdown_content}"
|
return f"# {title}\n\n{markdown_content}"
|
||||||
|
|||||||
Reference in New Issue
Block a user