Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make LangChain bind_tools work with Granite function calling #130

Open
adampingel opened this issue Sep 19, 2024 · 3 comments
Open

Make LangChain bind_tools work with Granite function calling #130

adampingel opened this issue Sep 19, 2024 · 3 comments

Comments

@adampingel
Copy link
Contributor

adampingel commented Sep 19, 2024

While using Replicate Granite model via Langchain Langgraph following error is encountered for agent creation

from langchain_community.llms import Replicate
from ibm_granite_community.notebook_utils import set_env_var, get_env_var
   
llm = Replicate (
    model = "ibm-granite/granite-20b-code-instruct-8k",
    model_kwargs={"temperature": 0.3,}
)

AttributeError: 'Replicate' object has no attribute 'bind_tools'

# Research agent and node
research_agent = create_agent(
    llm,
    [tavily_tool],
    system_message="You should provide accurate data for the chart_generator to use.",
)
@adampingel adampingel converted this from a draft issue Sep 19, 2024
@fayvor fayvor self-assigned this Oct 23, 2024
@fayvor
Copy link

fayvor commented Oct 23, 2024

Taking a look at this.

@fayvor
Copy link

fayvor commented Oct 23, 2024

It looks like we can just bypass bind_tools if we want to, when using the Granite models (on Replicate or WatsonX). This PR of the Function_Calling recipe just calls invoke() on the WatsonX llm client, using a properly-constructed prompt.

The same thing works for Replicate; I've tested that.

@fayvor fayvor assigned adampingel and unassigned fayvor Oct 31, 2024
@adampingel adampingel moved this from In Current Milestone to Backlog in Granite Cookbooks Nov 7, 2024
@adampingel adampingel removed their assignment Dec 9, 2024
@sree24lakshmi
Copy link

sree24lakshmi commented Dec 10, 2024

Hi @fayvor ,

If we were to use simple sql agents from langchain to leverage its specialized text-to-sql capabilities (tool-calling) below error is encountered.
In addition while building agentic workflow using langgraph for tool invocation, bind_tools seems to be a requirement.

Can you please advise if/when tool-calling can be supported/integrated.

agent_executor = create_sql_agent(llm, toolkit=toolkit, agent_type="tool-calling", verbose=True)

ValueError: This function requires a .bind_tools method be implemented on the LLM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

No branches or pull requests

3 participants