I implemented chatbot by referring to langchain.agents.agent.AgentExecutor
like this,
prompt = ...
model = model.bind_tools([tool], tool_choice=tool_name)
parser = OpenAIToolsAgentOutputParser()
chain = prompt | model | parser
while self._should_continue(params):
response = invoke_chain(...)
if isinstance(response, AgentFinish):
# final response
...
else:
# function calling invoked
...
model = model.bind_tools([tool], tool_choice=tool_name)
Here, this syntax(tool_choice
) always invokes function calling, but I want to get final response(AgentFinish) after forcing function calling(OpenAIToolAgentAction).
Is there anything to do it?
If not, is it the best way to use separate models/chains(binded one and not binded one)?