From 7994cba18db4f6558d8deda97f92d3ec9f57798a Mon Sep 17 00:00:00 2001 From: Rahul Triptahi Date: Wed, 8 May 2024 03:15:58 +0530 Subject: [PATCH] [Community][Minor]: Fetch loader_source of GoogleDriveLoader in PebbloSafeLoader. (#21314) Description: This PR includes fix for loader_source to be fetched from metadata in case of GdriveLoaders. Documentation: NA Unit Test: NA Signed-off-by: Rahul Tripathi Co-authored-by: Rahul Tripathi --- .../langchain_community/utilities/pebblo.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libs/community/langchain_community/utilities/pebblo.py b/libs/community/langchain_community/utilities/pebblo.py index 4c82c63bec6..9ed43630c72 100644 --- a/libs/community/langchain_community/utilities/pebblo.py +++ b/libs/community/langchain_community/utilities/pebblo.py @@ -236,6 +236,27 @@ def get_loader_full_path(loader: BaseLoader) -> str: location = "in-memory" elif isinstance(loader, NotionDBLoader): location = f"notiondb://{loader.database_id}" + elif loader.__class__.__name__ == "GoogleDriveLoader": + if loader_dict.get("folder_id"): + folder_id = loader_dict.get("folder_id") + location = f"https://drive.google.com/drive/u/2/folders/{folder_id}" + elif loader_dict.get("file_ids"): + file_ids = loader_dict.get("file_ids", []) + location = ", ".join( + [ + f"https://drive.google.com/file/d/{file_id}/view" + for file_id in file_ids + ] + ) + elif loader_dict.get("document_ids"): + document_ids = loader_dict.get("document_ids", []) + location = ", ".join( + [ + f"https://docs.google.com/document/d/{doc_id}/edit" + for doc_id in document_ids + ] + ) + except Exception: pass return get_full_path(str(location))