Skip to content

Commit c850da3

Browse files
xuanyang15copybara-github
authored andcommitted
fix: Fix the broken langchain importing caused their 1.0.0 release
PiperOrigin-RevId: 822279014
1 parent ed37e34 commit c850da3

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

contributing/samples/langchain_structured_tool_agent/agent.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,19 @@
1717
"""
1818
from google.adk.agents.llm_agent import Agent
1919
from google.adk.tools.langchain_tool import LangchainTool
20-
from langchain.tools import tool
20+
from langchain_core.tools import tool
2121
from langchain_core.tools.structured import StructuredTool
2222
from pydantic import BaseModel
2323

2424

2525
async def add(x, y) -> int:
26+
"""Adds two numbers."""
2627
return x + y
2728

2829

2930
@tool
3031
def minus(x, y) -> int:
32+
"""Subtracts two numbers."""
3133
return x - y
3234

3335

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ test = [
114114
"anthropic>=0.43.0", # For anthropic model tests
115115
"kubernetes>=29.0.0", # For GkeCodeExecutor
116116
"langchain-community>=0.3.17",
117-
"langgraph>=0.2.60, <= 0.4.10", # For LangGraphAgent
117+
"langgraph>=0.2.60, <0.4.8", # For LangGraphAgent
118118
"litellm>=1.75.5, <2.0.0", # For LiteLLM tests
119119
"llama-index-readers-file>=0.4.0", # For retrieval tests
120120
"openai>=1.100.2", # For LiteLLM
@@ -144,7 +144,7 @@ extensions = [
144144
"crewai[tools];python_version>='3.10'", # For CrewaiTool
145145
"docker>=7.0.0", # For ContainerCodeExecutor
146146
"kubernetes>=29.0.0", # For GkeCodeExecutor
147-
"langgraph>=0.2.60", # For LangGraphAgent
147+
"langgraph>=0.2.60, <0.4.8", # For LangGraphAgent
148148
"litellm>=1.75.5", # For LiteLlm class. Currently has OpenAI limitations. TODO: once LiteLlm fix it
149149
"llama-index-readers-file>=0.4.0", # For retrieval using LlamaIndex.
150150
"llama-index-embeddings-google-genai>=0.3.0",# For files retrieval using LlamaIndex.

src/google/adk/tools/langchain_tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
from typing import Union
1919

2020
from google.genai import types
21-
from langchain.agents import Tool
2221
from langchain_core.tools import BaseTool as LangchainBaseTool
22+
from langchain_core.tools import Tool
2323
from langchain_core.tools.structured import StructuredTool
2424
from typing_extensions import override
2525

tests/unittests/tools/test_langchain_tool.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import pytest
16-
17-
# TODO: Re-enable this test after verifying LangchainTool and
18-
# LangGraphAgent against langchain's 1.0.0 release.
19-
pytest.skip(
20-
allow_module_level=True,
21-
reason="Langchain just made 1.0.0 release that breaks existing import.",
22-
)
23-
24-
2515
from unittest.mock import MagicMock
2616

2717
from google.adk.tools.langchain_tool import LangchainTool
28-
from langchain.tools import tool
18+
from langchain_core.tools import tool
2919
from langchain_core.tools.structured import StructuredTool
3020
from pydantic import BaseModel
21+
import pytest
3122

3223

3324
@tool

0 commit comments

Comments
 (0)