Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alex gmail improvements #188

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
575f5f8
Improved gmail toolkit. Added support for threading in drafts replies…
TheMostlyGreat Jan 3, 2025
c980235
fixed doc string in list_email_by_header to be more concise and clear…
TheMostlyGreat Jan 3, 2025
04f7e67
merge main into alex-gmail-improvements; fix missing import
byrro Feb 6, 2025
62a7e07
Merge branch 'main' into alex-gmail-improvements
byrro Feb 10, 2025
b9a275f
centralize building email message in helper function
byrro Feb 10, 2025
7f838d6
remove unnecessary check of message object keys
byrro Feb 10, 2025
bdf7b23
improve error handling with more details from google api
byrro Feb 10, 2025
8307581
adjust util func to build reply email; implement reply to email tool
byrro Feb 11, 2025
a35b200
util function to build list of recipients for a reply email
byrro Feb 11, 2025
72704bc
evals for reply tools; remove unnecessary debug messgaes
byrro Feb 12, 2025
4f082dc
unit test for reply_to_email; remove excessive debug msgs in utils
byrro Feb 12, 2025
065ba24
better name for build gmail query str function
byrro Feb 13, 2025
a97ed13
handle reply-to and reply-to-all cases in Gmail replies
byrro Feb 13, 2025
b35b92d
make mypy happy
byrro Feb 13, 2025
4f0ae5b
Merge branch 'main' into alex-gmail-improvements
byrro Feb 13, 2025
22cdcfc
remove space char making pytest fail
byrro Feb 13, 2025
f8b6dff
fix bug in building message object for drafts
byrro Feb 18, 2025
1664408
fix error in send_email docstring mentioning 'reply
byrro Feb 18, 2025
9073f5e
move helper function to utils.py
byrro Feb 18, 2025
5769bd6
move helper function to utils.py
byrro Feb 18, 2025
35b1ab7
fix scope for create_label tool
byrro Feb 18, 2025
cab6c37
update pytests
byrro Feb 18, 2025
f6519a1
use enum value instead of hard coded string
byrro Feb 18, 2025
3684659
change scope for tool
byrro Feb 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions toolkits/google/arcade_google/tools/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os

from arcade_google.tools.models import GmailReplyToWhom

# The default reply in Gmail is to only the sender. Since Gmail also offers the possibility of
# changing the default to 'reply to all', we support both options through an env variable.
# https://support.google.com/mail/answer/6585?hl=en&sjid=15399867888091633568-SA#null
try:
GMAIL_DEFAULT_REPLY_TO = GmailReplyToWhom(
byrro marked this conversation as resolved.
Show resolved Hide resolved
# Values accepted are defined in the arcade_google.tools.models.GmailReplyToWhom Enum
os.getenv("ARCADE_GMAIL_DEFAULT_REPLY_TO", GmailReplyToWhom.ONLY_THE_SENDER.value).lower()
)
except ValueError as e:
raise ValueError(
"Invalid value for ARCADE_GMAIL_DEFAULT_REPLY_TO: "
f"'{os.getenv('ARCADE_GMAIL_DEFAULT_REPLY_TO')}'. Expected one of "
f"{list(GmailReplyToWhom.__members__.keys())}"
) from e
43 changes: 43 additions & 0 deletions toolkits/google/arcade_google/tools/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
class GoogleToolError(Exception):
"""Base exception for Google tool errors."""

def __init__(self, message: str, developer_message: str | None = None):
self.message = message
self.developer_message = developer_message
super().__init__(self.message)

def __str__(self) -> str:
base_message = self.message
if self.developer_message:
return f"{base_message} (Developer: {self.developer_message})"
return base_message


class GoogleServiceError(GoogleToolError):
"""Raised when there's an error building or using the Google service."""

pass


class GmailToolError(GoogleToolError):
"""Raised when there's an error in the Gmail tools."""

pass


class GoogleCalendarToolError(GoogleToolError):
"""Raised when there's an error in the Google Calendar tools."""

pass


class GoogleDriveToolError(GoogleToolError):
"""Raised when there's an error in the Google Drive tools."""

pass


class GoogleDocsToolError(GoogleToolError):
"""Raised when there's an error in the Google Docs tools."""

pass
Loading