Skip to content

Commit

Permalink
Propose maximum 3 actions in the weekly analysis (#705)
Browse files Browse the repository at this point in the history
  • Loading branch information
rjambrecic authored May 22, 2024
1 parent dbdac36 commit 8150c45
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
11 changes: 6 additions & 5 deletions captn/captn_agents/backend/teams/_weekly_analysis_team.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down
8 changes: 6 additions & 2 deletions captn/captn_agents/backend/tools/_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,13 +801,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": "<html></html>",
"proposed_user_action": proposed_user_actions,
"proposed_user_action": actions.proposed_user_actions,
"terminate_groupchat": True,
}
return return_msg
18 changes: 18 additions & 0 deletions tests/ci/captn/captn_agents/backend/tools/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
AdGroupWithAdAndKeywords,
)
from captn.captn_agents.backend.tools._functions import (
Actions,
Summary,
WebPageSummary,
WebUrl,
_find_value_in_nested_dict,
_validate_modification_parameters,
get_get_info_from_the_web_page,
get_webpage_status_code,
send_email,
)


Expand Down Expand Up @@ -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

0 comments on commit 8150c45

Please sign in to comment.