mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-13 10:24:44 +08:00
feat: 1. replace black with ruff for fomatting and sort import (#489)
2. use tavily from`langchain-tavily` rather than the older one from `langchain-community` Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
This commit is contained in:
@@ -5,10 +5,11 @@ import logging
|
||||
from typing import Annotated
|
||||
|
||||
from langchain_core.tools import tool
|
||||
from .decorators import log_io
|
||||
|
||||
from src.crawler import Crawler
|
||||
|
||||
from .decorators import log_io
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
import logging
|
||||
import functools
|
||||
import logging
|
||||
from typing import Any, Callable, Type, TypeVar
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -4,8 +4,10 @@
|
||||
import logging
|
||||
import os
|
||||
from typing import Annotated, Optional
|
||||
|
||||
from langchain_core.tools import tool
|
||||
from langchain_experimental.utilities import PythonREPL
|
||||
|
||||
from .decorators import log_io
|
||||
|
||||
|
||||
|
||||
@@ -3,15 +3,16 @@
|
||||
|
||||
import logging
|
||||
from typing import List, Optional, Type
|
||||
from langchain_core.tools import BaseTool
|
||||
|
||||
from langchain_core.callbacks import (
|
||||
AsyncCallbackManagerForToolRun,
|
||||
CallbackManagerForToolRun,
|
||||
)
|
||||
from langchain_core.tools import BaseTool
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from src.config.tools import SELECTED_RAG_PROVIDER
|
||||
from src.rag import Document, Retriever, Resource, build_retriever
|
||||
from src.rag import Document, Resource, Retriever, build_retriever
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -22,9 +23,7 @@ class RetrieverInput(BaseModel):
|
||||
|
||||
class RetrieverTool(BaseTool):
|
||||
name: str = "local_search_tool"
|
||||
description: str = (
|
||||
"Useful for retrieving information from the file with `rag://` uri prefix, it should be higher priority than the web search or writing code. Input should be a search keywords."
|
||||
)
|
||||
description: str = "Useful for retrieving information from the file with `rag://` uri prefix, it should be higher priority than the web search or writing code. Input should be a search keywords."
|
||||
args_schema: Type[BaseModel] = RetrieverInput
|
||||
|
||||
retriever: Retriever = Field(default_factory=Retriever)
|
||||
|
||||
@@ -17,18 +17,16 @@ from langchain_community.utilities import (
|
||||
WikipediaAPIWrapper,
|
||||
)
|
||||
|
||||
from src.config import SearchEngine, SELECTED_SEARCH_ENGINE
|
||||
from src.config import load_yaml_config
|
||||
from src.tools.tavily_search.tavily_search_results_with_images import (
|
||||
TavilySearchResultsWithImages,
|
||||
)
|
||||
|
||||
from src.config import SELECTED_SEARCH_ENGINE, SearchEngine, load_yaml_config
|
||||
from src.tools.decorators import create_logged_tool
|
||||
from src.tools.tavily_search.tavily_search_results_with_images import (
|
||||
TavilySearchWithImages,
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Create logged versions of the search tools
|
||||
LoggedTavilySearch = create_logged_tool(TavilySearchResultsWithImages)
|
||||
LoggedTavilySearch = create_logged_tool(TavilySearchWithImages)
|
||||
LoggedDuckDuckGoSearch = create_logged_tool(DuckDuckGoSearchResults)
|
||||
LoggedBraveSearch = create_logged_tool(BraveSearch)
|
||||
LoggedArxivSearch = create_logged_tool(ArxivQueryRun)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from .tavily_search_api_wrapper import EnhancedTavilySearchAPIWrapper
|
||||
from .tavily_search_results_with_images import TavilySearchResultsWithImages
|
||||
from .tavily_search_results_with_images import TavilySearchWithImages
|
||||
|
||||
__all__ = ["EnhancedTavilySearchAPIWrapper", "TavilySearchResultsWithImages"]
|
||||
__all__ = ["EnhancedTavilySearchAPIWrapper", "TavilySearchWithImages"]
|
||||
|
||||
@@ -7,8 +7,8 @@ from typing import Dict, List, Optional
|
||||
|
||||
import aiohttp
|
||||
import requests
|
||||
from langchain_community.utilities.tavily_search import TAVILY_API_URL
|
||||
from langchain_community.utilities.tavily_search import (
|
||||
from langchain_tavily._utilities import TAVILY_API_URL
|
||||
from langchain_tavily.tavily_search import (
|
||||
TavilySearchAPIWrapper as OriginalTavilySearchAPIWrapper,
|
||||
)
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
# Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
import logging
|
||||
import json
|
||||
import logging
|
||||
from typing import Dict, List, Optional, Tuple, Union
|
||||
|
||||
from langchain.callbacks.manager import (
|
||||
AsyncCallbackManagerForToolRun,
|
||||
CallbackManagerForToolRun,
|
||||
)
|
||||
from langchain_community.tools.tavily_search.tool import TavilySearchResults
|
||||
from langchain_tavily.tavily_search import TavilySearch
|
||||
from pydantic import Field
|
||||
|
||||
from src.tools.tavily_search.tavily_search_api_wrapper import (
|
||||
@@ -19,7 +19,7 @@ from src.tools.tavily_search.tavily_search_api_wrapper import (
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TavilySearchResultsWithImages(TavilySearchResults): # type: ignore[override, override]
|
||||
class TavilySearchWithImages(TavilySearch): # type: ignore[override, override]
|
||||
"""Tool that queries the Tavily Search API and gets back json.
|
||||
|
||||
Setup:
|
||||
@@ -34,9 +34,9 @@ class TavilySearchResultsWithImages(TavilySearchResults): # type: ignore[overri
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from langchain_community.tools import TavilySearchResults
|
||||
from langchain_tavily.tavily_search import TavilySearch
|
||||
|
||||
tool = TavilySearchResults(
|
||||
tool = TavilySearch(
|
||||
max_results=5,
|
||||
include_answer=True,
|
||||
include_raw_content=True,
|
||||
@@ -102,7 +102,9 @@ class TavilySearchResultsWithImages(TavilySearchResults): # type: ignore[overri
|
||||
Default is False.
|
||||
"""
|
||||
|
||||
api_wrapper: EnhancedTavilySearchAPIWrapper = Field(default_factory=EnhancedTavilySearchAPIWrapper) # type: ignore[arg-type]
|
||||
api_wrapper: EnhancedTavilySearchAPIWrapper = Field(
|
||||
default_factory=EnhancedTavilySearchAPIWrapper
|
||||
) # type: ignore[arg-type]
|
||||
|
||||
def _run(
|
||||
self,
|
||||
|
||||
@@ -6,10 +6,11 @@ Text-to-Speech module using volcengine TTS API.
|
||||
"""
|
||||
|
||||
import json
|
||||
import uuid
|
||||
import logging
|
||||
import uuid
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
import requests
|
||||
from typing import Optional, Dict, Any
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user