langchain
8977ac5a - community[fix]: Handle None value in raw_content from Tavily API response (#30021)

Commit
310 days ago
community[fix]: Handle None value in raw_content from Tavily API response (#30021) ## **Description:** When using the Tavily retriever with include_raw_content=True, the retriever occasionally fails with a Pydantic ValidationError because raw_content can be None. The Document model in langchain_core/documents/base.py requires page_content to be a non-None value, but the Tavily API sometimes returns None for raw_content. This PR fixes the issue by ensuring that even when raw_content is None, an empty string is used instead: ```python page_content=result.get("content", "") if not self.include_raw_content else (result.get("raw_content") or ""),
Author
Parents
Loading