DEV Community

Sourav Mukherjee
Sourav Mukherjee

Posted on

TypeError: Object of type AgentChatResponse is not JSON serializable

Getting this error while using chat_history for agent chat in Llama Index. Need a quick resolution. Any help on this? You can get the code below-

'''chat_history.append(ChatMessage(role= MessageRole.USER, content=user_message))

response = agent.chat(message=user_message, chat_history= chat_history)

chat_history.append(ChatMessage(role= MessageRole.ASSISTANT, content=response))'''

It is working fine for the 1st time query and giving the error from 2nd one.

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay