langchain-ai / langchain

🦜🔗 Build context-aware reasoning applications
https://python.langchain.com
MIT License
88.82k stars 13.97k forks source link

AttributeError: 'ChatGoogleGenerativeAI' object has no attribute 'bind_tools' #19868

Closed seyi33 closed 8 hours ago

seyi33 commented 3 months ago

Checked other resources

Example Code

import getpass import os from langchain_core.pydantic_v1 import BaseModel, Field

Note that the docstrings here are crucial, as they will be passed along

to the model along with the class name.

class Multiply(BaseModel): """Multiply two integers together."""

a: int = Field(..., description="First integer")
b: int = Field(..., description="Second integer")

os.environ["GOOGLE_API_KEY"] = getpass.getpass() from langchain_google_genai import ChatGoogleGenerativeAI

llm = ChatGoogleGenerativeAI(model="gemini-pro") llm_with_tools = llm.bind_tools([Multiply]) llm_with_tools.invoke("what's 3 * 12")

Error Message and Stack Trace (if applicable)

langchaingemsample.py", line 20, in llm_with_tools = llm.bind_tools([Multiply]) ^^^^^^^^^^^^^^ AttributeError: 'ChatGoogleGenerativeAI' object has no attribute 'bind_tools'

Description

i was using using langchain examples in this url https://python.langchain.com/docs/modules/model_io/chat/function_calling on function calling using google, i got this error "AttributeError: 'ChatGoogleGenerativeAI' object has no attribute 'bind_tools'", what i'm i doing wrong?

System Info

System Information

OS: Windows OS Version: 10.0.19045 Python Version: 3.11.4 (tags/v3.11.4:d2340ef, Jun 7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)]

Package Information

langchain_core: 0.1.37 langchain: 0.1.13 langchain_community: 0.0.29 langsmith: 0.1.31 langchain_experimental: 0.0.50 langchain_google_genai: 1.0.1 langchain_google_vertexai: 0.1.1 langchain_openai: 0.1.1 langchain_text_splitters: 0.0.1 langchaingemsample: Installed. No version info available. langchainhub: 0.1.14 langgraph: 0.0.30

Packages not installed (Not Necessarily a Problem)

The following packages were not found:

langserve

sepiatone commented 3 months ago

bind_tools is not (yet) implemented for ChatGoogleGenerativeAI. Please see https://github.com/langchain-ai/langchain/discussions/19806

liugddx commented 3 months ago

Does it realize this function? You need to check it.