Replies: 1 comment 7 replies
-
Hey there, @Drexx56! I'm a bot here to help you with bug fixes, questions, and contributions. Let's tackle this issue together while we wait for a human maintainer. To resolve the "TypeError: Object of type FieldInfo is not JSON serializable" error when running your RAG code using ChatNvidia as the LLM, you need to ensure that all objects being serialized to JSON are properly converted to serializable types. In the provided code, the Here is the relevant part of the code that handles the conversion: def _convert_message_to_dict(message: BaseMessage) -> dict:
message_dict: Dict[str, Any]
if isinstance(message, ChatMessage):
message_dict = {"role": message.role, "content": message.content}
elif isinstance(message, SystemMessage):
message_dict = {"role": "system", "content": message.content}
elif isinstance(message, HumanMessage):
message_dict = {"role": "user", "content": message.content}
elif isinstance(message, AIMessage):
message_dict = {"role": "assistant", "content": message.content}
else:
raise TypeError(f"Got unknown type {message}")
return message_dict Ensure that this function is correctly converting all message types to dictionaries before they are included in the payload. The def _get_payload(self, prompt: str) -> dict:
params = self._invocation_params
messages = self.prefix_messages + [HumanMessage(content=prompt)]
params.update(
{
"messages": [_convert_message_to_dict(m) for m in messages],
}
)
return params By ensuring that all |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am building a simple RAG usin ChatNvidia as my llm but I keep getting this error:
TypeError: Object of type FieldInfo is not JSON serializable
each time I try running this code:
can someone please help me out.
Beta Was this translation helpful? Give feedback.
All reactions