llama-index-readers-google


Namellama-index-readers-google JSON
Version 0.4.3 PyPI version JSON
download
home_pageNone
Summaryllama-index readers google integration
upload_time2024-11-11 22:24:17
maintainerbbornsztein
docs_urlNone
authorYour Name
requires_python<4.0,>=3.10
licenseMIT
keywords email gmail google keep google maps google notes
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # LlamaIndex Integration: Google Readers

Effortlessly incorporate Google-based data loaders into your Python workflow using LlamaIndex. It now supports more advanced operations through the implementation of ResourcesReaderMixin and FileSystemReaderMixin.
Unlock the potential of various readers to enhance your data loading capabilities, including:

- Google Calendar
- Google Chat
- Google Docs
- Google Drive
- Gmail
- Google Keep
- Google Maps
- Google Sheets

## Installation

```bash
pip install llama-index-readers-google
```

## Authentication

You will need a `credentials.json` file from Google Cloud to interact with Google Services. To get this file, follow these steps:

- Create a new project in the [Google Cloud Console](https://console.cloud.google.com/)
- Go to APIs & Services -> Library and search for the API you want, e.g. Gmail
- Go to APIs & Services -> Credentials and create a new OAuth client ID
  - Application type: Web application
  - Authorized redirect URIs: http://localhost:8080/ (the last slash seems important)
- Go to APIs & Services -> OAuth consent screen and make the app external, which allows you to connect your personal Google data once you explicitly add yourself as an allowed test user
- Download the credentials JSON file from this screen and save it as `credentials.json` in the root of your project

See [this example](https://github.com/run-llama/gmail-extractor/blob/main/gmail.py) for a sample of code that successfully authenticates with Gmail once you have the `credentials.json` file.

## Examples

### Google Drive Reader

```python
from llama_index.readers.google import GoogleDriveReader

# Initialize the reader
reader = GoogleDriveReader(
    folder_id="folder_id",
    service_account_key="[SERVICE_ACCOUNT_KEY_JSON]",
)

# Load data
documents = reader.load_data()

# List resources in the drive
resources = reader.list_resources()

# Get information about a specific resource
resource_info = reader.get_resource_info("file.txt")

# Load a specific resource
specific_doc = reader.load_resource("file.txt")

# Read file content directly
file_content = reader.read_file_content("path/to/file.txt")

print(f"Loaded {len(documents)} documents")
print(f"Found {len(resources)} resources")
print(f"Resource info: {resource_info}")
print(f"Specific document: {specific_doc}")
print(f"File content length: {len(file_content)} bytes")
```

### Google Docs Reader

```python
from llama_index.readers.google import GoogleDocsReader

# Specify the document IDs you want to load
document_ids = ["<document_id>"]

# Load data from Google Docs
documents = GoogleDocsReader().load_data(document_ids=document_ids)
```

### Google Sheets Reader (Documents and Dataframes)

```python
from llama_index.readers.google import GoogleSheetsReader

# Specify the list of sheet IDs you want to load
list_of_sheets = ["spreadsheet_id"]

# Create a Google Sheets Reader instance
sheets_reader = GoogleSheetsReader()

# Load data into Pandas in Data Classes of choice (Documents or Dataframes)
documents = sheets.load_data(list_of_sheets)
dataframes = sheets_reader.load_data_in_pandas(list_of_sheets)
```

Integrate these readers seamlessly to efficiently manage and process your data within your Python environment, providing a robust foundation for your data-driven workflows with LlamaIndex.

### Google Maps Text Search Reader

```python
from llama_index.readers.google import GoogleMapsTextSearchReader
from llama_index.core import VectorStoreIndex

loader = GoogleMapsTextSearchReader()
documents = loader.load_data(
    text="I want to eat quality Turkish food in Istanbul",
    number_of_results=160,
)


index = VectorStoreIndex.from_documents(documents)
index.query("Which Turkish restaurant has the best reviews?")
```

### Google Chat Reader

```py
from llama_index.readers.google import GoogleChatReader
from llama_index.core import VectorStoreIndex

space_names = ["<CHAT_ID>"]
chatReader = GoogleChatReader()
docs = chatReader.load_data(space_names=space_names)
index = VectorStoreIndex.from_documents(docs)
query_eng = index.as_query_engine()
print(query_eng.query("What was this conversation about?"))
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "llama-index-readers-google",
    "maintainer": "bbornsztein",
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "email, gmail, google keep, google maps, google notes",
    "author": "Your Name",
    "author_email": "you@example.com",
    "download_url": "https://files.pythonhosted.org/packages/f4/e9/4840fe3dfe7689c2aa51130152959b3daad90041da83d53304f66ef6c1a7/llama_index_readers_google-0.4.3.tar.gz",
    "platform": null,
    "description": "# LlamaIndex Integration: Google Readers\n\nEffortlessly incorporate Google-based data loaders into your Python workflow using LlamaIndex. It now supports more advanced operations through the implementation of ResourcesReaderMixin and FileSystemReaderMixin.\nUnlock the potential of various readers to enhance your data loading capabilities, including:\n\n- Google Calendar\n- Google Chat\n- Google Docs\n- Google Drive\n- Gmail\n- Google Keep\n- Google Maps\n- Google Sheets\n\n## Installation\n\n```bash\npip install llama-index-readers-google\n```\n\n## Authentication\n\nYou will need a `credentials.json` file from Google Cloud to interact with Google Services. To get this file, follow these steps:\n\n- Create a new project in the [Google Cloud Console](https://console.cloud.google.com/)\n- Go to APIs & Services -> Library and search for the API you want, e.g. Gmail\n- Go to APIs & Services -> Credentials and create a new OAuth client ID\n  - Application type: Web application\n  - Authorized redirect URIs: http://localhost:8080/ (the last slash seems important)\n- Go to APIs & Services -> OAuth consent screen and make the app external, which allows you to connect your personal Google data once you explicitly add yourself as an allowed test user\n- Download the credentials JSON file from this screen and save it as `credentials.json` in the root of your project\n\nSee [this example](https://github.com/run-llama/gmail-extractor/blob/main/gmail.py) for a sample of code that successfully authenticates with Gmail once you have the `credentials.json` file.\n\n## Examples\n\n### Google Drive Reader\n\n```python\nfrom llama_index.readers.google import GoogleDriveReader\n\n# Initialize the reader\nreader = GoogleDriveReader(\n    folder_id=\"folder_id\",\n    service_account_key=\"[SERVICE_ACCOUNT_KEY_JSON]\",\n)\n\n# Load data\ndocuments = reader.load_data()\n\n# List resources in the drive\nresources = reader.list_resources()\n\n# Get information about a specific resource\nresource_info = reader.get_resource_info(\"file.txt\")\n\n# Load a specific resource\nspecific_doc = reader.load_resource(\"file.txt\")\n\n# Read file content directly\nfile_content = reader.read_file_content(\"path/to/file.txt\")\n\nprint(f\"Loaded {len(documents)} documents\")\nprint(f\"Found {len(resources)} resources\")\nprint(f\"Resource info: {resource_info}\")\nprint(f\"Specific document: {specific_doc}\")\nprint(f\"File content length: {len(file_content)} bytes\")\n```\n\n### Google Docs Reader\n\n```python\nfrom llama_index.readers.google import GoogleDocsReader\n\n# Specify the document IDs you want to load\ndocument_ids = [\"<document_id>\"]\n\n# Load data from Google Docs\ndocuments = GoogleDocsReader().load_data(document_ids=document_ids)\n```\n\n### Google Sheets Reader (Documents and Dataframes)\n\n```python\nfrom llama_index.readers.google import GoogleSheetsReader\n\n# Specify the list of sheet IDs you want to load\nlist_of_sheets = [\"spreadsheet_id\"]\n\n# Create a Google Sheets Reader instance\nsheets_reader = GoogleSheetsReader()\n\n# Load data into Pandas in Data Classes of choice (Documents or Dataframes)\ndocuments = sheets.load_data(list_of_sheets)\ndataframes = sheets_reader.load_data_in_pandas(list_of_sheets)\n```\n\nIntegrate these readers seamlessly to efficiently manage and process your data within your Python environment, providing a robust foundation for your data-driven workflows with LlamaIndex.\n\n### Google Maps Text Search Reader\n\n```python\nfrom llama_index.readers.google import GoogleMapsTextSearchReader\nfrom llama_index.core import VectorStoreIndex\n\nloader = GoogleMapsTextSearchReader()\ndocuments = loader.load_data(\n    text=\"I want to eat quality Turkish food in Istanbul\",\n    number_of_results=160,\n)\n\n\nindex = VectorStoreIndex.from_documents(documents)\nindex.query(\"Which Turkish restaurant has the best reviews?\")\n```\n\n### Google Chat Reader\n\n```py\nfrom llama_index.readers.google import GoogleChatReader\nfrom llama_index.core import VectorStoreIndex\n\nspace_names = [\"<CHAT_ID>\"]\nchatReader = GoogleChatReader()\ndocs = chatReader.load_data(space_names=space_names)\nindex = VectorStoreIndex.from_documents(docs)\nquery_eng = index.as_query_engine()\nprint(query_eng.query(\"What was this conversation about?\"))\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "llama-index readers google integration",
    "version": "0.4.3",
    "project_urls": null,
    "split_keywords": [
        "email",
        " gmail",
        " google keep",
        " google maps",
        " google notes"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3c9e57c8c268141c7163b88b601d69474119f63001a641524a98b84d0a046a7b",
                "md5": "9d57934f6e165ffa73dcb9c257549261",
                "sha256": "074480aa8b566e735779a42565a215b55b189bc8a65e3b8973dd266f153187e2"
            },
            "downloads": -1,
            "filename": "llama_index_readers_google-0.4.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9d57934f6e165ffa73dcb9c257549261",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 33352,
            "upload_time": "2024-11-11T22:24:16",
            "upload_time_iso_8601": "2024-11-11T22:24:16.267019Z",
            "url": "https://files.pythonhosted.org/packages/3c/9e/57c8c268141c7163b88b601d69474119f63001a641524a98b84d0a046a7b/llama_index_readers_google-0.4.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f4e94840fe3dfe7689c2aa51130152959b3daad90041da83d53304f66ef6c1a7",
                "md5": "a39d70e36aed6654d6b0401e10bbae9c",
                "sha256": "a13c772f2680ea70512eef69e3a9258cd48c52f49a45f66404327dc3b4a1c76a"
            },
            "downloads": -1,
            "filename": "llama_index_readers_google-0.4.3.tar.gz",
            "has_sig": false,
            "md5_digest": "a39d70e36aed6654d6b0401e10bbae9c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 24016,
            "upload_time": "2024-11-11T22:24:17",
            "upload_time_iso_8601": "2024-11-11T22:24:17.212034Z",
            "url": "https://files.pythonhosted.org/packages/f4/e9/4840fe3dfe7689c2aa51130152959b3daad90041da83d53304f66ef6c1a7/llama_index_readers_google-0.4.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-11 22:24:17",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "llama-index-readers-google"
}
        
Elapsed time: 0.65439s