I'm using langchain python because I'm working on creating a custom knowledge chatbot. I have created the vecstores and everything works fine until I introduced LangChain's agents.
The CHAT_CONVERSATIONAL_REACT_DESCRIPTION works well but sometimes I get this error when asking query:
"json.decoder.JSONDecodeError: Unterminated string starting at: line 3 column 21 (char 52)
"
This is an example of what happens
`
Ask your question: suggest 2 vacation locations
response:
> Entering new AgentExecutor chain...
Traceback (most recent call last):
File "C:\Users\qais4\Desktop\chatbot test\tutor.py", line 372, in <module>
run_terminal()
File "C:\Users\qais4\Desktop\chatbot test\tutor.py", line 365, in run_terminal
get_response(agent, question)
File "C:\Users\qais4\Desktop\chatbot test\tutor.py", line 206, in get_response
result = agent.run(question)
^^^^^^^^^^^^^^^^^^^
File "C:\Users\qais4\Desktop\chatbot test\venv\Lib\site-packages\langchain\chains\base.py", line 236, in run
return self(args[0], callbacks=callbacks)[self.output_keys[0]]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\qais4\Desktop\chatbot test\venv\Lib\site-packages\langchain\chains\base.py", line 140, in __call__
raise e
This is how I set up the agent:
agent = initialize_agent(
agent=AgentType.CHAT_CONVERSATIONAL_REACT_DESCRIPTION,
tools=tools,
llm=ChatLLM,
verbose=True,
memory=conversational_memory,
)
Does anyone have any suggestions?
I pretty much tried all agent types but all of them get errors on some specific case. The only one without errors was CONVERSATIONAL_REACT_DESCRIPTION Agent type but that often makes bad decisions in terms of tools (choosing not to select knowledge base tool and saying "I dont know"). I have also tried following the examples on Langchain's documentation but that didn't work.