GoogleCloudPlatform / generative-ai

Sample code and notebooks for Generative AI on Google Cloud, with Gemini on Vertex AI
https://cloud.google.com/vertex-ai/docs/generative-ai/learn/overview
Apache License 2.0
8.01k stars 2.26k forks source link

[Bug]: ImportError in Reasoning Engine sample notebooks when using latest version of langchain-core #955

Closed koverholt closed 3 months ago

koverholt commented 3 months ago

File Name

gemini/reasoning-engine/*.ipynb

What happened?

When running the Reasoning Engine sample notebooks such as https://github.com/GoogleCloudPlatform/generative-ai/blob/main/gemini/reasoning-engine/intro_reasoning_engine.ipynb and installing the latest version of google-cloud-aiplatform[langchain,reasoningengine], querying the agent results in the following error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-8-42a3d8c314c1> in <cell line: 1>()
----> 1 agent.query(input="What's the exchange rate from US dollars to Swedish currency today?")

7 frames
/usr/local/lib/python3.10/dist-packages/langchain/tools/render.py in <module>
      7 
      8 # For backwards compatibility
----> 9 from langchain_core.tools import (
     10     ToolsRenderer,
     11     render_text_description,

ImportError: cannot import name 'ToolsRenderer' from 'langchain_core.tools' (/usr/local/lib/python3.10/dist-packages/langchain_core/tools/__init__.py)

Relevant log output

No response

Code of Conduct

koverholt commented 3 months ago

The problematic package was langchain-core==0.2.31, which was yanked from PyPI and a new version langchain-core==0.2.32 was published just now that fixes the issue (see https://github.com/langchain-ai/langchain/issues/25413). Tested Reasoning Engine notebooks and they are all working as expected again. 🙂

ccurme commented 3 months ago

Thanks for flagging!