mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-03 06:12:14 +08:00
Upgrade langchain version to 1.x (#720)
* fix: revert the part of patch of issue-710 to extract the content from the plan * Upgrade the ddgs for the new compatible version * Upgraded langchain to 1.1.0 updated langchain related package to the new compatable version * Update pyproject.toml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import pytest
|
||||
from langchain.schema import HumanMessage, SystemMessage
|
||||
from langchain_core.messages import HumanMessage, SystemMessage
|
||||
|
||||
from src.config.report_style import ReportStyle
|
||||
from src.prompt_enhancer.graph.enhancer_node import prompt_enhancer_node
|
||||
|
||||
@@ -19,7 +19,7 @@ class TestCrawlTool:
|
||||
url = "https://example.com"
|
||||
|
||||
# Act
|
||||
result = crawl_tool(url)
|
||||
result = crawl_tool.invoke({"url": url})
|
||||
|
||||
# Assert
|
||||
assert isinstance(result, str)
|
||||
@@ -44,7 +44,7 @@ class TestCrawlTool:
|
||||
url = "https://example.com"
|
||||
|
||||
# Act
|
||||
result = crawl_tool(url)
|
||||
result = crawl_tool.invoke({"url": url})
|
||||
|
||||
# Assert
|
||||
result_dict = json.loads(result)
|
||||
@@ -61,7 +61,7 @@ class TestCrawlTool:
|
||||
url = "https://example.com"
|
||||
|
||||
# Act
|
||||
result = crawl_tool(url)
|
||||
result = crawl_tool.invoke({"url": url})
|
||||
|
||||
# Assert
|
||||
assert isinstance(result, str)
|
||||
@@ -80,7 +80,7 @@ class TestCrawlTool:
|
||||
url = "https://example.com"
|
||||
|
||||
# Act
|
||||
result = crawl_tool(url)
|
||||
result = crawl_tool.invoke({"url": url})
|
||||
|
||||
# Assert
|
||||
assert isinstance(result, str)
|
||||
@@ -103,7 +103,7 @@ class TestCrawlTool:
|
||||
url = "https://example.com"
|
||||
|
||||
# Act
|
||||
result = crawl_tool(url)
|
||||
result = crawl_tool.invoke({"url": url})
|
||||
|
||||
# Assert
|
||||
assert isinstance(result, str)
|
||||
@@ -123,7 +123,7 @@ class TestCrawlTool:
|
||||
url = "https://example.com"
|
||||
|
||||
# Act
|
||||
result = crawl_tool(url)
|
||||
result = crawl_tool.invoke({"url": url})
|
||||
|
||||
# Assert
|
||||
assert isinstance(result, str)
|
||||
@@ -171,7 +171,7 @@ class TestPDFHandling:
|
||||
pdf_url = "https://example.com/document.pdf"
|
||||
|
||||
# Act
|
||||
result = crawl_tool(pdf_url)
|
||||
result = crawl_tool.invoke({"url": pdf_url})
|
||||
|
||||
# Assert
|
||||
assert isinstance(result, str)
|
||||
@@ -189,7 +189,7 @@ class TestPDFHandling:
|
||||
issue_pdf_url = "https://pdf.dfcfw.com/pdf/H3_AP202503071644153386_1.pdf"
|
||||
|
||||
# Act
|
||||
result = crawl_tool(issue_pdf_url)
|
||||
result = crawl_tool.invoke({"url": issue_pdf_url})
|
||||
|
||||
# Assert
|
||||
result_dict = json.loads(result)
|
||||
@@ -204,7 +204,7 @@ class TestPDFHandling:
|
||||
pdf_url = "https://example.com/document.pdf"
|
||||
|
||||
# Act
|
||||
result = crawl_tool(pdf_url)
|
||||
result = crawl_tool.invoke({"url": pdf_url})
|
||||
|
||||
# Assert
|
||||
# Crawler should not be instantiated for PDF URLs
|
||||
|
||||
@@ -20,7 +20,7 @@ class TestPythonReplTool:
|
||||
mock_repl.run.return_value = expected_output
|
||||
|
||||
# Act
|
||||
result = python_repl_tool(code)
|
||||
result = python_repl_tool.invoke({"code": code})
|
||||
|
||||
# Assert
|
||||
mock_repl.run.assert_called_once_with(code)
|
||||
@@ -38,7 +38,7 @@ class TestPythonReplTool:
|
||||
|
||||
# Act & Assert - expect ValidationError when passing invalid input
|
||||
with pytest.raises(Exception): # Could be ValidationError or similar
|
||||
python_repl_tool(invalid_code)
|
||||
python_repl_tool.invoke({"code": invalid_code})
|
||||
|
||||
mock_repl.run.assert_not_called()
|
||||
|
||||
@@ -52,7 +52,7 @@ class TestPythonReplTool:
|
||||
mock_repl.run.return_value = error_result
|
||||
|
||||
# Act
|
||||
result = python_repl_tool(code)
|
||||
result = python_repl_tool.invoke({"code": code})
|
||||
|
||||
# Assert
|
||||
mock_repl.run.assert_called_once_with(code)
|
||||
@@ -71,7 +71,7 @@ class TestPythonReplTool:
|
||||
mock_repl.run.return_value = exception_result
|
||||
|
||||
# Act
|
||||
result = python_repl_tool(code)
|
||||
result = python_repl_tool.invoke({"code": code})
|
||||
|
||||
# Assert
|
||||
mock_repl.run.assert_called_once_with(code)
|
||||
@@ -90,7 +90,7 @@ class TestPythonReplTool:
|
||||
mock_repl.run.side_effect = exception
|
||||
|
||||
# Act
|
||||
result = python_repl_tool(code)
|
||||
result = python_repl_tool.invoke({"code": code})
|
||||
|
||||
# Assert
|
||||
mock_repl.run.assert_called_once_with(code)
|
||||
@@ -109,7 +109,7 @@ class TestPythonReplTool:
|
||||
mock_repl.run.return_value = expected_output
|
||||
|
||||
# Act
|
||||
result = python_repl_tool(code)
|
||||
result = python_repl_tool.invoke({"code": code})
|
||||
|
||||
# Assert
|
||||
mock_repl.run.assert_called_once_with(code)
|
||||
@@ -128,7 +128,7 @@ class TestPythonReplTool:
|
||||
mock_repl.run.return_value = ""
|
||||
|
||||
# Act
|
||||
result = python_repl_tool(code)
|
||||
result = python_repl_tool.invoke({"code": code})
|
||||
|
||||
# Assert
|
||||
mock_repl.run.assert_called_once_with(code)
|
||||
@@ -144,7 +144,7 @@ class TestPythonReplTool:
|
||||
mock_repl.run.return_value = ""
|
||||
|
||||
# Act
|
||||
python_repl_tool(code)
|
||||
python_repl_tool.invoke({"code": code})
|
||||
|
||||
# Assert
|
||||
mock_logger.info.assert_any_call("Executing Python code")
|
||||
@@ -158,7 +158,7 @@ class TestPythonReplTool:
|
||||
code = "print('test')"
|
||||
|
||||
# Act
|
||||
result = python_repl_tool(code)
|
||||
result = python_repl_tool.invoke({"code": code})
|
||||
|
||||
# Assert
|
||||
mock_logger.warning.assert_called_with(
|
||||
@@ -176,7 +176,7 @@ class TestPythonReplTool:
|
||||
code = "print('test')"
|
||||
|
||||
# Act
|
||||
result = python_repl_tool(code)
|
||||
result = python_repl_tool.invoke({"code": code})
|
||||
|
||||
# Assert
|
||||
mock_logger.warning.assert_called_with(
|
||||
@@ -197,7 +197,7 @@ class TestPythonReplTool:
|
||||
mock_repl.run.return_value = expected_output
|
||||
|
||||
# Act
|
||||
result = python_repl_tool(code)
|
||||
result = python_repl_tool.invoke({"code": code})
|
||||
|
||||
# Assert
|
||||
mock_repl.run.assert_called_once_with(code)
|
||||
@@ -213,7 +213,7 @@ class TestPythonReplTool:
|
||||
code = "print('disabled')"
|
||||
|
||||
# Act
|
||||
result = python_repl_tool(code)
|
||||
result = python_repl_tool.invoke({"code": code})
|
||||
|
||||
# Assert
|
||||
mock_logger.warning.assert_called_with(
|
||||
|
||||
@@ -33,7 +33,7 @@ class TestGetWebSearchTool:
|
||||
def test_get_web_search_tool_brave(self):
|
||||
tool = get_web_search_tool(max_search_results=4)
|
||||
assert tool.name == "web_search"
|
||||
assert tool.search_wrapper.api_key == "test_api_key"
|
||||
assert tool.search_wrapper.api_key.get_secret_value() == "test_api_key"
|
||||
|
||||
@patch("src.tools.search.SELECTED_SEARCH_ENGINE", SearchEngine.ARXIV.value)
|
||||
def test_get_web_search_tool_arxiv(self):
|
||||
@@ -54,7 +54,7 @@ class TestGetWebSearchTool:
|
||||
@patch.dict(os.environ, {}, clear=True)
|
||||
def test_get_web_search_tool_brave_no_api_key(self):
|
||||
tool = get_web_search_tool(max_search_results=1)
|
||||
assert tool.search_wrapper.api_key == ""
|
||||
assert tool.search_wrapper.api_key.get_secret_value() == ""
|
||||
|
||||
@patch("src.tools.search.SELECTED_SEARCH_ENGINE", SearchEngine.TAVILY.value)
|
||||
@patch("src.tools.search.load_yaml_config")
|
||||
|
||||
Reference in New Issue
Block a user