19 lines
483 B
Python
19 lines
483 B
Python
"""
|
|
联网搜索工具
|
|
"""
|
|
|
|
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)}"
|