pprados / langchain-googledrive

An external version of a pull request for langchain.
Apache License 2.0
26 stars 10 forks source link

Processing ' suggestions' when loading a Google Doc #12

Closed pve closed 4 months ago

pve commented 4 months ago

Feature request

from langchain_googledrive.document_loaders import GoogleDriveLoader

working with file_type=["application/vnd.google-apps.document"]

Google Docs can have suggestions embedded.

The current drive loader exports as markdown both the old and the new version of each suggestion. In markdown, I'd like to see the newer version only (or have a choice for that matter).

Motivation

In my application I am indexing files that are being edited. I want either the original or the final version of these edits (suggestions), not a blur of both. Note that this is independent of GDrive's revisions history.

Your contribution

I can review updates to the source or documentation.

pve commented 4 months ago

This should demonstrate it:

#https://docs.google.com/document/d/1kZr95WfvPSckVFh_HJ32AbuWy0eSt2YvkZcM6NntD7k/edit?usp=sharing

from langchain_googledrive.document_loaders import GoogleDriveLoader

doc_id='1kZr95WfvPSckVFh_HJ32AbuWy0eSt2YvkZcM6NntD7k'
folder_id='1VLBA1kJtaaP507-jrIjKnEmggn6Hy1tH'

loader = GoogleDriveLoader(
    folder_id=folder_id,
    recursive=False,
    num_results=2,  # Maximum number of file to load
    file_type=["application/vnd.google-apps.document"],
    includeItemsFromAllDrives=True
)
docs = loader.load()
print(docs[0].page_content)
pprados commented 4 months ago

Hello, The version v0.2.5 proposes a new parameter: suggestionsViewMode.

You can set suggestionsViewMode="PREVIEW_SUGGESTIONS_ACCEPTED"

pve commented 4 months ago

perfect!