The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.
Python agentic-memoryagentic-memory-systemagentsaiai-agentschatgptgenaillmlong-term-memorymemorymemory-managementpythonragstate-management
[Bug fix] Fix missing dependency issue with gmail (#862)
Deshraj Yadav29bd03857969
diff --git a/embedchain/loaders/gmail.py b/embedchain/loaders/gmail.pyindex 604f785e5..43798f151 100644--- a/embedchain/loaders/gmail.py+++ b/embedchain/loaders/gmail.py@@ -7,9 +7,9 @@ from textwrap import dedentfrom bs4 import BeautifulSouptry:- from llama_index import download_loader+ from llama_hub.gmail.base import GmailReaderexcept ImportError:- raise ImportError("Notion requires extra dependencies. Install with `pip install embedchain[community]`") from None+ raise ImportError("Gmail requires extra dependencies. Install with `pip install embedchain[gmail]`") from Nonefrom embedchain.loaders.base_loader import BaseLoaderfrom embedchain.utils import clean_string@@ -32,7 +32,6 @@ class GmailLoader(BaseLoader):dev account. Refer this `https://cloud.google.com/docs/authentication/api-keys`")- GmailReader = download_loader("GmailReader")loader = GmailReader(query=query, service=None, results_per_page=20)documents = loader.load_data()logging.info(f"Gmail Loader: {len(documents)} mails found for query- {query}")diff --git a/pyproject.toml b/pyproject.tomlindex b0fdfce75..b9b6a6183 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -1,6 +1,6 @@[tool.poetry]name = "embedchain"-version = "0.0.79"+version = "0.0.80"description = "Data platform for LLMs - Load, index, retrieve and sync any unstructured data"authors = ["Taranjeet Singh, Deshraj Yadav"]license = "Apache License"@@ -173,12 +173,12 @@ dataloaders=[vertexai = ["google-cloud-aiplatform"]llama2 = ["replicate"]gmail = [- "llama-hub",- "requests",- "google-api-python-client",- "google-auth",- "google-auth-oauthlib",- "google-auth-httplib2",+ "llama-hub",+ "requests",+ "google-api-python-client",+ "google-auth",+ "google-auth-oauthlib",+ "google-auth-httplib2","google-api-core",]diff --git a/tests/loaders/test_gmail.py b/tests/loaders/test_gmail.pyindex 678568eaf..a41e28c96 100644--- a/tests/loaders/test_gmail.py+++ b/tests/loaders/test_gmail.py@@ -1,14 +1,9 @@import pytest-from llama_index.readers.schema.base import Document+from llama_hub.readwise.base import Documentfrom embedchain.loaders.gmail import GmailLoader-def mock_download_loader(mocker):- return mocker.patch("embedchain.loaders.gmail.download_loader")--@pytest.fixturedef mock_quopri(mocker):return mocker.patch("embedchain.loaders.gmail.quopri.decodestring", return_value=b"your_test_decoded_string")@@ -20,7 +15,7 @@ def mock_beautifulsoup(mocker):@pytest.fixture-def gmail_loader(mock_download_loader, mock_quopri, mock_beautifulsoup):+def gmail_loader(mock_quopri, mock_beautifulsoup):return GmailLoader()@@ -30,7 +25,8 @@ def test_load_data_file_not_found(gmail_loader, mocker):gmail_loader.load_data("your_query")-def test_load_data(gmail_loader, mock_download_loader, mocker):[email protected](reason="TODO: Fix this test. Failing due to some googleapiclient import issue.")+def test_load_data(gmail_loader, mocker):mock_gmail_reader_instance = mocker.MagicMock()text = "your_test_email_text"metadata = {@@ -38,7 +34,6 @@ def test_load_data(gmail_loader, mock_download_loader, mocker):"snippet": "your_test_snippet",}mock_gmail_reader_instance.load_data.return_value = [Document(text=text, extra_info=metadata)]- mock_download_loader.return_value = mock_gmail_reader_instancewith mocker.patch("os.path.isfile", return_value=True):response_data = gmail_loader.load_data("your_query")