Skip to content

Commit d1d8fac

Browse files
committed
Update TextLoader
1 parent ae689e0 commit d1d8fac

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Tool/Sources/LangChain/DocumentLoader/TextLoader.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ public struct TextLoader: DocumentLoader {
2323
options: options,
2424
documentAttributes: nil
2525
)
26+
let modificationDate = try? url.resourceValues(forKeys: [.contentModificationDateKey])
27+
.contentModificationDate
2628
return [Document(pageContent: attributedString.string, metadata: [
2729
"filename": url.lastPathComponent,
2830
"extension": url.pathExtension,
29-
"contentModificationDate": (try? url.resourceValues(forKeys: [.contentModificationDateKey]).contentModificationDate) ?? Date()
31+
"contentModificationDate": modificationDate ?? Date(),
3032
])]
3133
}
3234
}

0 commit comments

Comments
 (0)