Skip to content

Commit

Permalink
Addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
edwinjosechittilappilly authored and ogabrielluiz committed Aug 8, 2024
1 parent 65f5f37 commit 397ca76
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/backend/base/langflow/components/data/GoogleDrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,29 @@
from google.auth.exceptions import RefreshError
from langflow.custom import Component
from langflow.inputs import MessageTextInput
from langflow.io import SecretStrInput
from langflow.template import Output
from langflow.schema import Data
from langchain_google_community import GoogleDriveLoader
from langflow.helpers.data import docs_to_data

from json.decoder import JSONDecodeError


class GoogleDriveComponent(Component):
display_name = "Google Drive Loader"
description = "Loads documents from Google Drive using provided credentials."
icon = "Google" # You can choose an appropriate icon later
icon = "Google"

inputs = [
MessageTextInput(
SecretStrInput(
name="json_string",
display_name="JSON String of the Service Account Token",
info="JSON string containing OAuth 2.0 access token information for service account access",
required=True,
),
MessageTextInput(
name="document_id", display_name="Document IDs", info="Single Google Drive document ID", required=True
name="document_id", display_name="Document ID", info="Single Google Drive document ID", required=True
),
]

Expand Down Expand Up @@ -77,7 +80,8 @@ class Config:
raise ValueError(f"Error loading documents: {e}") from e

assert len(docs) == 1, "Expected a single document to be loaded."
data = [Data(text=doc.page_content, **doc.metadata) for doc in docs]

data = docs_to_data(docs)
# Return the loaded documents
self.status = data
return Data(data={"text": data})

0 comments on commit 397ca76

Please sign in to comment.