Closed glejdis closed 7 months ago
🤖
Based on the code you've shared and the error message you're encountering, it seems like the issue is related to how you're using the Response
class in your LangChain application.
In your code, you're trying to use Response
as a tool in the following line:
convert_pydantic_to_openai_function(Response),
However, Response
is not a tool, but a Pydantic model that you've defined to structure the final response to the question being asked. The error message you're seeing is indicating that Response
is not recognized as a valid tool, and it suggests using Retriever
instead, which is a valid tool in your application.
To resolve this issue, you should remove the line where you're trying to convert Response
to an OpenAI function. Instead, you should use Response
to structure the final output of your agent after all the tools have been executed and the final answer has been determined.
Here's how you can modify your code:
# Remove this line
# convert_pydantic_to_openai_function(Response),
# ...
# Use Response to structure the final output
final_output = Response(answer=final_answer)
In this modified code, Response
is used to structure the final output of your agent, not as a tool. This should resolve the error you're seeing.
Please note that this is based on the information you've provided and the current version of LangChain (v0.1.3). If you're using a different version or if there are other parts of your code that might be causing this issue, please provide more information so I can give a more accurate solution.
For more information on how to use tools in LangChain, you can refer to the LangChain documentation. Specifically, the Tools section provides detailed information on how to define and use tools in your LangChain application.
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
@glejdis have you found the solution?
@ZuzooVn no solution yet :(
🤖
It seems like this issue requires a deeper look, @baskaryan could you please lend your expertise?
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
Checked other resources
Example Code
The following code: ''' from langchain.agents.output_parsers import OpenAIFunctionsAgentOutputParser from langchain.agents.agent import AgentOutputParser from langchain.agents.chat.output_parser import ChatOutputParser
def creat_ai_search_new_agent(embeddings, llm, class_name_rich):
'''
It gives you the error: Response is not a valid tool, try one of [Retriever]. and then after going into a loop reaches the agent limit. The final steps of the agent look like this:
Invoking:
Response
with{'answer': "XXXXXXX", 'sources': [58, 15, 57, 29]}
Response is not a valid tool, try one of [Retriever].
Description
langchain == 0.1.1 openai==1.7.0
System Info
Using model GPT-4 32K
Related Components