Skip to content

Commit f8ba740

Browse files
Feat: Alter gmail tool call names to include gmail prefix (#3493)
1 parent 35c54d9 commit f8ba740

File tree

3 files changed

+102
-102
lines changed

3 files changed

+102
-102
lines changed

camel/toolkits/gmail_toolkit.py

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def people_service(self, service: Any) -> None:
7373
r"""Allow overriding/injecting the People service (e.g., in tests)."""
7474
self._people_service = service
7575

76-
def send_email(
76+
def gmail_send_email(
7777
self,
7878
to: Union[str, List[str]],
7979
subject: str,
@@ -138,7 +138,7 @@ def send_email(
138138
logger.error("Failed to send email: %s", e)
139139
return {"error": f"Failed to send email: {e!s}"}
140140

141-
def reply_to_email(
141+
def gmail_reply_to_email(
142142
self,
143143
message_id: str,
144144
reply_body: str,
@@ -225,7 +225,7 @@ def reply_to_email(
225225

226226
# Get current user's email and remove it from recipients
227227
try:
228-
profile_result = self.get_profile()
228+
profile_result = self.gmail_get_profile()
229229
if profile_result.get('success'):
230230
current_user_email = profile_result['profile'][
231231
'email_address'
@@ -280,7 +280,7 @@ def reply_to_email(
280280
logger.error("Failed to reply to email: %s", e)
281281
return {"error": f"Failed to reply to email: {e!s}"}
282282

283-
def forward_email(
283+
def gmail_forward_email(
284284
self,
285285
message_id: str,
286286
to: Union[str, List[str]],
@@ -385,7 +385,7 @@ def forward_email(
385385
temp_files.append(temp_file.name)
386386

387387
# Download attachment
388-
result = self.get_attachment(
388+
result = self.gmail_get_attachment(
389389
message_id=message_id,
390390
attachment_id=att['attachment_id'],
391391
save_path=temp_file.name,
@@ -440,7 +440,7 @@ def forward_email(
440440
logger.error("Failed to forward email: %s", e)
441441
return {"error": f"Failed to forward email: {e!s}"}
442442

443-
def create_email_draft(
443+
def gmail_create_draft(
444444
self,
445445
to: Union[str, List[str]],
446446
subject: str,
@@ -505,7 +505,7 @@ def create_email_draft(
505505
logger.error("Failed to create draft: %s", e)
506506
return {"error": f"Failed to create draft: {e!s}"}
507507

508-
def send_draft(self, draft_id: str) -> Dict[str, Any]:
508+
def gmail_send_draft(self, draft_id: str) -> Dict[str, Any]:
509509
r"""Send a draft email.
510510
511511
Args:
@@ -537,7 +537,7 @@ def send_draft(self, draft_id: str) -> Dict[str, Any]:
537537
logger.error("Failed to send draft: %s", e)
538538
return {"error": f"Failed to send draft: {e!s}"}
539539

540-
def fetch_emails(
540+
def gmail_fetch_emails(
541541
self,
542542
query: str = "",
543543
max_results: int = 10,
@@ -616,7 +616,7 @@ def fetch_emails(
616616
logger.error("Failed to fetch emails: %s", e)
617617
return {"error": f"Failed to fetch emails: {e!s}"}
618618

619-
def fetch_thread_by_id(self, thread_id: str) -> Dict[str, Any]:
619+
def gmail_fetch_thread_by_id(self, thread_id: str) -> Dict[str, Any]:
620620
r"""Fetch a thread by ID.
621621
622622
Args:
@@ -653,7 +653,7 @@ def fetch_thread_by_id(self, thread_id: str) -> Dict[str, Any]:
653653
logger.error("Failed to fetch thread: %s", e)
654654
return {"error": f"Failed to fetch thread: {e!s}"}
655655

656-
def modify_email_labels(
656+
def gmail_modify_email_labels(
657657
self,
658658
message_id: str,
659659
add_labels: Optional[List[str]] = None,
@@ -710,7 +710,7 @@ def modify_email_labels(
710710
logger.error("Failed to modify labels: %s", e)
711711
return {"error": f"Failed to modify labels: {e!s}"}
712712

713-
def move_to_trash(self, message_id: str) -> Dict[str, Any]:
713+
def gmail_move_to_trash(self, message_id: str) -> Dict[str, Any]:
714714
r"""Move a message to trash.
715715
716716
Args:
@@ -742,7 +742,7 @@ def move_to_trash(self, message_id: str) -> Dict[str, Any]:
742742
logger.error("Failed to move message to trash: %s", e)
743743
return {"error": f"Failed to move message to trash: {e!s}"}
744744

745-
def get_attachment(
745+
def gmail_get_attachment(
746746
self,
747747
message_id: str,
748748
attachment_id: str,
@@ -802,7 +802,7 @@ def get_attachment(
802802
logger.error("Failed to get attachment: %s", e)
803803
return {"error": f"Failed to get attachment: {e!s}"}
804804

805-
def list_threads(
805+
def gmail_list_threads(
806806
self,
807807
query: str = "",
808808
max_results: int = 10,
@@ -884,7 +884,7 @@ def list_threads(
884884
logger.error("Failed to list threads: %s", e)
885885
return {"error": f"Failed to list threads: {e!s}"}
886886

887-
def list_drafts(
887+
def gmail_list_drafts(
888888
self, max_results: int = 10, page_token: Optional[str] = None
889889
) -> Dict[str, Any]:
890890
r"""List email drafts.
@@ -932,7 +932,7 @@ def list_drafts(
932932
logger.error("Failed to list drafts: %s", e)
933933
return {"error": f"Failed to list drafts: {e!s}"}
934934

935-
def list_gmail_labels(self) -> Dict[str, Any]:
935+
def gmail_list_labels(self) -> Dict[str, Any]:
936936
r"""List all Gmail labels.
937937
938938
Returns:
@@ -968,7 +968,7 @@ def list_gmail_labels(self) -> Dict[str, Any]:
968968
logger.error("Failed to list labels: %s", e)
969969
return {"error": f"Failed to list labels: {e!s}"}
970970

971-
def create_label(
971+
def gmail_create_label(
972972
self,
973973
name: str,
974974
label_list_visibility: Literal["labelShow", "labelHide"] = "labelShow",
@@ -1015,7 +1015,7 @@ def create_label(
10151015
logger.error("Failed to create label: %s", e)
10161016
return {"error": f"Failed to create label: {e!s}"}
10171017

1018-
def delete_label(self, label_id: str) -> Dict[str, Any]:
1018+
def gmail_delete_label(self, label_id: str) -> Dict[str, Any]:
10191019
r"""Delete a Gmail label.
10201020
10211021
Args:
@@ -1044,7 +1044,7 @@ def delete_label(self, label_id: str) -> Dict[str, Any]:
10441044
logger.error("Failed to delete label: %s", e)
10451045
return {"error": f"Failed to delete label: {e!s}"}
10461046

1047-
def modify_thread_labels(
1047+
def gmail_modify_thread_labels(
10481048
self,
10491049
thread_id: str,
10501050
add_labels: Optional[List[str]] = None,
@@ -1102,7 +1102,7 @@ def modify_thread_labels(
11021102
logger.error("Failed to modify thread labels: %s", e)
11031103
return {"error": f"Failed to modify thread labels: {e!s}"}
11041104

1105-
def get_profile(self) -> Dict[str, Any]:
1105+
def gmail_get_profile(self) -> Dict[str, Any]:
11061106
r"""Get Gmail profile information.
11071107
11081108
Returns:
@@ -1127,7 +1127,7 @@ def get_profile(self) -> Dict[str, Any]:
11271127
logger.error("Failed to get profile: %s", e)
11281128
return {"error": f"Failed to get profile: {e!s}"}
11291129

1130-
def get_contacts(
1130+
def gmail_get_contacts(
11311131
self,
11321132
max_results: int = 100,
11331133
page_token: Optional[str] = None,
@@ -1187,7 +1187,7 @@ def get_contacts(
11871187
logger.error("Failed to get contacts: %s", e)
11881188
return {"error": f"Failed to get contacts: {e!s}"}
11891189

1190-
def search_people(
1190+
def gmail_search_people(
11911191
self,
11921192
query: str,
11931193
max_results: int = 10,
@@ -1817,23 +1817,23 @@ def get_tools(self) -> List[FunctionTool]:
18171817
representing the functions in the toolkit.
18181818
"""
18191819
return [
1820-
FunctionTool(self.send_email),
1821-
FunctionTool(self.reply_to_email),
1822-
FunctionTool(self.forward_email),
1823-
FunctionTool(self.create_email_draft),
1824-
FunctionTool(self.send_draft),
1825-
FunctionTool(self.fetch_emails),
1826-
FunctionTool(self.fetch_thread_by_id),
1827-
FunctionTool(self.modify_email_labels),
1828-
FunctionTool(self.move_to_trash),
1829-
FunctionTool(self.get_attachment),
1830-
FunctionTool(self.list_threads),
1831-
FunctionTool(self.list_drafts),
1832-
FunctionTool(self.list_gmail_labels),
1833-
FunctionTool(self.create_label),
1834-
FunctionTool(self.delete_label),
1835-
FunctionTool(self.modify_thread_labels),
1836-
FunctionTool(self.get_profile),
1837-
FunctionTool(self.get_contacts),
1838-
FunctionTool(self.search_people),
1820+
FunctionTool(self.gmail_send_email),
1821+
FunctionTool(self.gmail_reply_to_email),
1822+
FunctionTool(self.gmail_forward_email),
1823+
FunctionTool(self.gmail_create_draft),
1824+
FunctionTool(self.gmail_send_draft),
1825+
FunctionTool(self.gmail_fetch_emails),
1826+
FunctionTool(self.gmail_fetch_thread_by_id),
1827+
FunctionTool(self.gmail_modify_email_labels),
1828+
FunctionTool(self.gmail_move_to_trash),
1829+
FunctionTool(self.gmail_get_attachment),
1830+
FunctionTool(self.gmail_list_threads),
1831+
FunctionTool(self.gmail_list_drafts),
1832+
FunctionTool(self.gmail_list_labels),
1833+
FunctionTool(self.gmail_create_label),
1834+
FunctionTool(self.gmail_delete_label),
1835+
FunctionTool(self.gmail_modify_thread_labels),
1836+
FunctionTool(self.gmail_get_profile),
1837+
FunctionTool(self.gmail_get_contacts),
1838+
FunctionTool(self.gmail_search_people),
18391839
]

examples/toolkits/gmail_toolkit.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,27 +68,27 @@
6868
Example: Sending an email
6969
==================================================
7070
Agent Response:
71-
Done — your message has been sent to [email protected]. Message ID:
71+
Done — your message has been sent to [email protected]. Message ID:
7272
1998015e3157fdee.
7373
7474
Tool calls:
7575
[ToolCallingRecord(
76-
tool_name='send_email',
76+
tool_name='gmail_send_email',
7777
args={
78-
79-
'subject': 'Hello from Gmail Toolkit',
80-
'body': 'This is a test email sent using the CAMEL Gmail toolkit.',
81-
'cc': None,
82-
'bcc': None,
83-
'attachments': None,
78+
79+
'subject': 'Hello from Gmail Toolkit',
80+
'body': 'This is a test email sent using the CAMEL Gmail toolkit.',
81+
'cc': None,
82+
'bcc': None,
83+
'attachments': None,
8484
'is_html': False
85-
},
85+
},
8686
result={
87-
'success': True,
88-
'message_id': '1998015e3157fdee',
87+
'success': True,
88+
'message_id': '1998015e3157fdee',
8989
'thread_id': '1998015e3157fdee',
9090
'message': 'Email sent successfully'
91-
},
91+
},
9292
tool_call_id='call_4VzMM1JkKjGN8J5rfT4wH2sF',
9393
images=None
9494
)]

0 commit comments

Comments
 (0)