From aad28bdc60ccf698caceca0a28b91630f0f4dcb3 Mon Sep 17 00:00:00 2001 From: Robert Jambrecic Date: Tue, 21 May 2024 15:43:36 +0200 Subject: [PATCH] Propose maximum 3 actions in the weekly analysis --- .../backend/teams/_weekly_analysis_team.py | 11 ++++++----- captn/captn_agents/backend/tools/_functions.py | 8 ++++++-- .../backend/tools/test_functions.py | 18 ++++++++++++++++++ 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/captn/captn_agents/backend/teams/_weekly_analysis_team.py b/captn/captn_agents/backend/teams/_weekly_analysis_team.py index d3ae5d5d..43646b56 100644 --- a/captn/captn_agents/backend/teams/_weekly_analysis_team.py +++ b/captn/captn_agents/backend/teams/_weekly_analysis_team.py @@ -739,10 +739,11 @@ def _guidelines(self) -> str: 11. The client can NOT see your conversation, he only receives the message which you send him by using the 'send_email' command Here an example on how to use the 'send_email' command: -{ +'proposed_user_actions' must contain a list with MIN 1 and MAX 3 strings. We suggest to use the MAXIMUM number of proposed actions. +{"actions": { "proposed_user_actions": ["Remove 'Free' keyword because it is not performing well", "Increase budget from $10/day to $20/day", "Remove the headline 'New product' and replace it with 'Very New product' in the 'Adgroup 1'", "Select some or all of them"] -} +}} propose_user_actions should NOT be general, but specific. 'proposed_user_actions' BAD EXAMPLES: @@ -793,7 +794,7 @@ def _guidelines(self) -> str: 23. Once you have completed weekly analysis, you must send a summary of the work done to the client by using the 'send_email' command. Here is a list of things which you CAN do after the client responds to your email. -So please recommend some of these changes to the client by using the 'proposed_user_actions' parameter in the 'send_email' command: +So please recommend some of these changes to the client by using the 'actions' parameter in the 'send_email' command: - update the status (ENABLED / PAUSED) of the campaign, ad group and ad - create/update/remove headlines and descriptions in the Ad Copy. Make sure to follow the restrictions for the headlines and descriptions (MAXIMUM 30 characters for headlines and MAXIMUM 90 characters for descriptions) - create/update/remove new keywords @@ -822,8 +823,8 @@ def _commands(self) -> str: Just suggest calling function 'function_name'. All team members have access to the following command: -1. send_email: Send email to the client, params: (proposed_user_actions: List[str]]) -Each message in the 'proposed_user_actions' parameter must contain all information useful to the client, because the client does not see your team's conversation +1. send_email: Send email to the client, params: (actions: Actions(BaseModel)) +Each message in the actions.proposed_user_actions parameter must contain all information useful to the client, because the client does not see your team's conversation As we send this message to the client, pay attention to the content inside it. We are a digital agency and the messages we send must be professional. 2. {GET_INFO_FROM_THE_WEB_COMMAND} diff --git a/captn/captn_agents/backend/tools/_functions.py b/captn/captn_agents/backend/tools/_functions.py index 7605832c..925d4a94 100644 --- a/captn/captn_agents/backend/tools/_functions.py +++ b/captn/captn_agents/backend/tools/_functions.py @@ -800,13 +800,17 @@ def get_info_from_the_web_page( send_email_description = "Send email to the client." +class Actions(BaseModel): + proposed_user_actions: Annotated[List[str], Len(min_length=1, max_length=3)] + + def send_email( - proposed_user_actions: Annotated[List[str], "List of proposed user actions"], + actions: Actions, ) -> Dict[str, Any]: return_msg = { "subject": "Capt’n.ai Weekly Analysis", "email_content": "", - "proposed_user_action": proposed_user_actions, + "proposed_user_action": actions.proposed_user_actions, "terminate_groupchat": True, } return return_msg diff --git a/tests/ci/captn/captn_agents/backend/tools/test_functions.py b/tests/ci/captn/captn_agents/backend/tools/test_functions.py index 8a6153ce..8132baf0 100644 --- a/tests/ci/captn/captn_agents/backend/tools/test_functions.py +++ b/tests/ci/captn/captn_agents/backend/tools/test_functions.py @@ -11,6 +11,7 @@ AdGroupWithAdAndKeywords, ) from captn.captn_agents.backend.tools._functions import ( + Actions, Summary, WebPageSummary, WebUrl, @@ -18,6 +19,7 @@ _validate_modification_parameters, get_get_info_from_the_web_page, get_webpage_status_code, + send_email, ) @@ -218,3 +220,19 @@ def create_ad_group_with_ad_and_keywords( modification_function_parameters=modification_function_parameters, ) assert expected_output in str(e._excinfo[1]) + + +@pytest.mark.parametrize( + "proposed_user_actions", + [[], ["1"], ["1", "2"], ["1", "2", "3"], ["1", "2", "3", "4"]], +) +def test_send_email_with_proposed_user_actions(proposed_user_actions): + actions_count = len(proposed_user_actions) + if actions_count < 1 or actions_count > 3: + with pytest.raises(ValidationError): + actions = Actions(proposed_user_actions=proposed_user_actions) + else: + actions = Actions(proposed_user_actions=proposed_user_actions) + + result = send_email(actions=actions) + assert result["proposed_user_action"] == proposed_user_actions