Skip to content

Commit

Permalink
Langchain_community: Small Fix when loading facebook messages (#15358)
Browse files Browse the repository at this point in the history
- **Description:** SingleFileFacebookMessengerChatLoader did not handle
the case for when messages had stickers and/or photos so fixed that.
  - **Issue:** #15356

---------

Co-authored-by: Harrison Chase <[email protected]>
  • Loading branch information
keenborder786 and hwchase17 authored Jan 2, 2024
1 parent cbfaccc commit b6c57d3
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ def lazy_load(self) -> Iterator[ChatSession]:
data = json.load(f)
sorted_data = sorted(data["messages"], key=lambda x: x["timestamp_ms"])
messages = []
for m in sorted_data:
for index, m in enumerate(sorted_data):
if "content" not in m:
logger.info(
f"""Skipping Message No.
{index+1} as no content is present in the message"""
)
continue
messages.append(
HumanMessage(
content=m["content"], additional_kwargs={"sender": m["sender_name"]}
Expand Down

0 comments on commit b6c57d3

Please sign in to comment.