mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-05-21 23:46:50 +00:00
feat: lite deep researcher implementation
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user