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

'requested_tool_name': 'directly_answer', 'available_tool_names': ['google_search_tool'] #498

Open
stigmat4j opened this issue May 12, 2024 · 2 comments

Comments

@stigmat4j
Copy link

stigmat4j commented May 12, 2024

Hello. I need help.

I need google_search_tool only as in the context of the message there are launches like "search", "find". How to call agent_executor with such questions, everything works fine, but how to ask a normal question without search, then I get the error directly_answer is not a valid tool, try one of [google_search_tool]., latencies are higher than 6 times, but the model gave a normal response.

class Chat:
 
    def __init__(self):
        model = ChatCohere()
        agent = create_cohere_react_agent(llm=model, tools=[], prompt=prompt)
        self.agent_executor = AgentExecutor(agent=agent, tools=[google_search_tool], verbose=True)
        self.chain = prompt | model
 
    def prediction(self, question, history):
        return self.agent_executor.astream({
            "question": question,
            "chat_history": history
        }, config={"callbacks": [langfuse_handler]})
 
    def invoke(self, question):
        return self.chain.invoke({"question": question})
 
 
cohere = Chat()
from langchain_google_community import GoogleSearchAPIWrapper
from langchain_core.tools import Tool

from config import GOOGLE_API_KEY

search = GoogleSearchAPIWrapper(google_api_key=GOOGLE_API_KEY)


google_search_tool = Tool(
    name="google_search_tool",
    description="Search Google for recent results.",
    func=search.run
)

image

@stigmat4j stigmat4j changed the title 'requested_tool_name': 'directly_answer', 'available_tool_names': ['google_search_tool']} 'requested_tool_name': 'directly_answer', 'available_tool_names': ['google_search_tool'] May 12, 2024
Copy link

elaineg commented May 14, 2024

Hi there, you don't need to input directly_answer as a tool. It is automatically added. Does removing it solve your problem?

@elaineg elaineg self-assigned this May 14, 2024
@stigmat4j
Copy link
Author

Hi there, you don't need to input directly_answer as a tool. It is automatically added. Does removing it solve your problem?

I did not specify the "directly_answer" tool anywhere. I wrote all the code related to the model

@elaineg elaineg removed their assignment May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants