This commit is contained in:
18
backend/app/tools/web_search.py
Normal file
18
backend/app/tools/web_search.py
Normal file
@@ -0,0 +1,18 @@
|
||||
"""
|
||||
联网搜索工具
|
||||
"""
|
||||
|
||||
from langchain_core.tools import tool
|
||||
from backend.app.logger import info
|
||||
|
||||
|
||||
@tool
|
||||
def web_search(query: str) -> str:
|
||||
"""联网搜索获取最新信息"""
|
||||
info(f"[Tool] web_search: {query[:30]}...")
|
||||
try:
|
||||
from backend.app.core.web_search import web_search as search_fn
|
||||
return search_fn(query, max_results=5)
|
||||
except Exception as e:
|
||||
info(f"[Tool] web_search 失败: {e}")
|
||||
return f"联网搜索失败: {str(e)}"
|
||||
Reference in New Issue
Block a user