feat: lite deep researcher implementation

This commit is contained in:
He Tao
2025-04-07 16:25:55 +08:00
commit 03798ded08
58 changed files with 4242 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
import logging
from typing import Annotated
from langchain_core.tools import tool
from .decorators import log_io
from src.crawler import Crawler
logger = logging.getLogger(__name__)
@tool
@log_io
def crawl_tool(
url: Annotated[str, "The url to crawl."],
) -> str:
"""Use this to crawl a url and get a readable content in markdown format."""
try:
crawler = Crawler()
article = crawler.crawl(url)
return {"url": url, "crawled_content": article.to_markdown()[:1000]}
except BaseException as e:
error_msg = f"Failed to crawl. Error: {repr(e)}"
logger.error(error_msg)
return error_msg