Files
ailine/backend/app/tools/web_search.py
root b30f7b00a7
All checks were successful
构建并部署 AI Agent 服务 / deploy (push) Successful in 5m33s
优化查询代码,优化工具代码
2026-05-08 22:30:26 +08:00

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)}"