Improved gmail toolkit. Added support for threading in draft replies, multipart email parsing, and label management. Fixed the DateRange parameter issue in list_emails_by_headers. Added logging and removed print statements. Created custom exceptions for each specific google toolkit. ----- Summary of changes by @byrro: - Fixed minor bug related to the `date_range` argument of `list_emails_by_header` - A few utility functions (`build_email_message`, `build_reply_recipients`, `build_reply_body`) to centralize logic and remove repeated code from email-sending tools - New `reply_to_email` tool (apart from `write_draft_reply_email`, implemented by Alex) to keep the toolkit consistent - Evals and unit tests - Handling of reply-to (only sender) and reply-to-all recipients - Removed some unnecessary debug messages, which Alex had added to replace print statements - Removed HTML handling implemented by Alex in `write_draft_reply_email` > I think we should either support HTML across all applicable tools or not at all; I decided to remove it and leave this feature for a future PR. --------- Co-authored-by: Renato Byrro <rmbyrro@gmail.com>
43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
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
|