diff --git a/ex_app/lib/agent.py b/ex_app/lib/agent.py index 4c10b76..2667fa4 100644 --- a/ex_app/lib/agent.py +++ b/ex_app/lib/agent.py @@ -90,7 +90,6 @@ def export_conversation(checkpointer): # prepare the to-serialize blob state = {"last_config": last_config, "last_checkpoint": last_checkpoint} serialized_state = JsonPlusSerializer().dumps(state) - print(serialized_state) # sign the serialized state conversation_token = add_signature(serialized_state.decode('utf-8'), key) return conversation_token @@ -139,6 +138,8 @@ async def call_model( system_prompt_text += "Use the find_person_in_users tool to find a person's userId and user details.\n" if tool_enabled("find_details_of_current_user"): system_prompt_text += "Use the find_details_of_current_user tool to find the current user's location.\n" + if tool_enabled("list_mails"): + system_prompt_text += "Always check for the mail account id before requesting a folder list.\n" if task['input'].get('memories', None) is not None: system_prompt_text += "You can remember things from other conversations with the user. If relevant, take into account the following memories:\n\n" + "\n".join(task['input']['memories']) + "\n\n" diff --git a/ex_app/lib/all_tools/mail.py b/ex_app/lib/all_tools/mail.py index bf7838c..cc59877 100644 --- a/ex_app/lib/all_tools/mail.py +++ b/ex_app/lib/all_tools/mail.py @@ -53,11 +53,35 @@ async def get_mail_account_list(): """ return await nc.ocs('GET', '/ocs/v2.php/apps/mail/account/list') + + + @tool + @safe_tool + async def get_mail_folder_list(account_id: int): + """ + Lists all mail folders for an email account + :param account_id: The id of the account to list as integer, obtainable via get_mail_account_list + """ + return await nc.ocs('GET', '/ocs/v2.php/apps/mail/ocs/mailboxes', json={'accountId': account_id}) + + + @tool + @safe_tool + async def list_mails(folder_id: int, n_mails: int = 30): + """ + Lists all messages in a mailbox folder + :param folder_id: The id of the folder to list as integer, obtainable via get_mail_folder_list + :param n_mails: The number of mails to receive. Optional, default is 30 + :return: a list of mails/messages, including timestamps + """ + return await nc.ocs('GET', f'/ocs/v2.php/apps/mail/ocs/mailboxes/{folder_id}/messages', json={'limit': n_mails}) return [ send_email, - get_mail_account_list + get_mail_account_list, + get_mail_folder_list, + list_mails, ] def get_category_name():