This tool will be useful in scenarios akin to RAG, where someone wants to ask questions or request the production of a summary, for instance, about a bunch of documents related to a particular topic. Currently, to fulfill such requests, the LLM needs to first `list_documents`, then `get_document_by_id` for each document. We also implement a utility functions to return documents in Markdown and HTML, since the Drive API JSON is verbose and would waste too many tokens unnecessarily. Limitations: the Markdown/HTML utilities do not handle table of contents (which I think aren't really useful here), headers, footers, or footnotes. --- This PR deprecates `list_documents` and implements `search_documents`, apart from `search_and_retrieve_documents`). This configuration makes it easier for LLMs to understand when to call each tool. Both tools had their interfaces refactored to remove Google API-specific arguments that were confusing LLMs sometimes, such as "corpora" and "support_all_drives". It now accepts arguments that better relate to expected user requests. --------- Co-authored-by: Eric Gustin <eric@arcade.dev>
21 lines
872 B
Python
21 lines
872 B
Python
import os
|
|
|
|
from arcade_google.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(
|
|
# 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
|
|
|
|
|
|
DEFAULT_SEARCH_CONTACTS_LIMIT = 30
|