I am trying to bind a DuckDuckGo search tool to ChatGoogleGenerativeAI
. It is not working as expected and I am getting empty response in content when I try invoke the llm. Following is my code.
from langchain_google_genai import ChatGoogleGenerativeAI
from dotenv import load_dotenv
from langchain_community.tools import DuckDuckGoSearchRun
load_dotenv()
search = DuckDuckGoSearchRun()
llm = ChatGoogleGenerativeAI(model="gemini-1.5-flash", verbose=True)
llm_with_tools = llm.bind_tools([search])
response = llm_with_tools.invoke('Which is largest state in India')
print(response)
After executing this I get following response:
content='' additional_kwargs={'function_call': {'name': 'duckduckgo_search', 'arguments': '{"query": "Which is largest state in India"}'}} response_metadata={'prompt_feedback': {'block_reason': 0, 'safety_ratings': []}, 'finish_reason': 'STOP', 'safety_ratings': [{'category': 'HARM_CATEGORY_HATE_SPEECH', 'probability': 'NEGLIGIBLE', 'blocked': False}, {'category': 'HARM_CATEGORY_SEXUALLY_EXPLICIT', 'probability': 'NEGLIGIBLE', 'blocked': False}, {'category': 'HARM_CATEGORY_DANGEROUS_CONTENT', 'probability': 'NEGLIGIBLE', 'blocked': False}, {'category': 'HARM_CATEGORY_HARASSMENT', 'probability': 'NEGLIGIBLE', 'blocked': False}]} id='run-9b206745-4b1a-4600-b66c-fd874004f5e0-0' tool_calls=[{'name': 'duckduckgo_search', 'args': {'query': 'Which is largest state in India'}, 'id': '573e38e8-9985-4b23-99a8-b915f4d2c1b8', 'type': 'tool_call'}] usage_metadata={'input_tokens': 72, 'output_tokens': 22, 'total_tokens': 94}
New contributor
Pankaj Wahane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.