8000 fix: gmail list drafts tool fix by tybalex · Pull Request #683 · obot-platform/tools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: gmail list drafts tool fix #683

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

Merged
merged 1 commit into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions google/gmail/apis/drafts.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async def list_drafts(service, max_results=None):
)

dataset_id = await gptscript_client.add_dataset_elements(
elements, name=f"gmail_drafts"
elements, name=f"gmail_drafts", description=f"list of drafts in Gmail"
)

print(f"Created dataset with ID {dataset_id} with {len(elements)} drafts")
Expand All @@ -65,7 +65,7 @@ def draft_to_string(service, draft):
draft_id = draft["id"]
draft_msg = service.users().drafts().get(userId="me", id=draft_id).execute()
msg = draft_msg["message"]
subject, sender, to, cc, bcc, date = extract_message_headers(msg)
subject, sender, to, cc, bcc, date, _ = extract_message_headers(msg)
return (
draft_id,
f"Draft ID: {draft_id}, From: {sender}, Subject: {subject}, To: {to}, CC: {cc}, Bcc: {bcc}, Saved: {date}",
Expand Down
1 change: 1 addition & 0 deletions google/gmail/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
from commands.update_label import update_label_tool
from commands.delete_label import delete_label_tool
from commands.modify_message_labels import modify_message_labels_tool
from commands.list_drafts import list_drafts_tool
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@
from apis.helpers import client


async def main():
async def list_drafts_tool():
max_results = os.getenv("MAX_RESULTS", "100")
if max_results is not None:
max_results = int(max_results)

service = client("gmail", "v1")

await list_drafts(service, max_results)


if __name__ == "__main__":
asyncio.run(main())
4 changes: 3 additions & 1 deletion google/gmail/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
update_label_tool,
delete_label_tool,
modify_message_labels_tool,
list_drafts_tool,
)


async def main():

if len(sys.argv) != 2:
Expand All @@ -33,6 +33,8 @@ async def main():
delete_label_tool()
case "modify_message_labels":
modify_message_labels_tool()
case "list_drafts":
await list_drafts_tool()
case _:
print(f"Command {command} not found")
except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion google/gmail/tool.gpt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Tools: github.com/gptscript-ai/datasets/filter
Param: max_results: Maximum number of drafts to list (Optional: Default will list 100 drafts)
Param: attachments: A comma separated list of workspace file paths to attach to the email (Optional)

#!/usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/listDrafts.py
#!/usr/bin/env python3 ${GPTSCRIPT_TOOL_DIR}/main.py list_drafts

---
Name: Create Draft
Expand Down
Loading
0