From b1ed00359446e605b44a207534d2a76fa6a4b08b Mon Sep 17 00:00:00 2001 From: rjambrecic <32619626+rjambrecic@users.noreply.github.com> Date: Thu, 25 Jul 2024 14:44:05 +0200 Subject: [PATCH 1/2] Prompt updates (#860) --- captn/captn_agents/backend/teams/_gbb_google_sheets_team.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/captn/captn_agents/backend/teams/_gbb_google_sheets_team.py b/captn/captn_agents/backend/teams/_gbb_google_sheets_team.py index fdda67b7..d08fdf0c 100644 --- a/captn/captn_agents/backend/teams/_gbb_google_sheets_team.py +++ b/captn/captn_agents/backend/teams/_gbb_google_sheets_team.py @@ -116,6 +116,8 @@ def _guidelines(self) -> str: 7. Once you have all the necessary information, use 'process_spreadsheet_process_spreadsheet_post' endpoint to process the spreadsheet. - query parameters: user_id, template_spreadsheet_id, new_campaign_spreadsheet_id, new_campaign_sheet_title 8. Once the endpoint is successful write the message to the client that the new sheet has been created in the same spreadsheet as the new routes sheet. +- If you are informed that the new sheet contains 'Issues' column, you must inform the client that the 'Issues' column has been added to the new sheet and that the client should check it and try to resolve it manually. +- Do NOT proceed with the next steps until the client confirms that has resolved the issues. Use only ONE smart suggestion 'I have resolved the issues' and do not offer to help with the issues because you are not experienced in that area. 9. If the user verifies that everything is correct the team should do the following: - List accessible customers by using the 'list_accessible_customers_with_account_types' function. (this should be done by the Google_ads_expert) - Ask the user choose the correct customer id (This should be done by the Account_manager) From cdf2001b5a5a8164930159610c0c93ea2d1974a0 Mon Sep 17 00:00:00 2001 From: rjambrecic <32619626+rjambrecic@users.noreply.github.com> Date: Fri, 26 Jul 2024 13:37:46 +0200 Subject: [PATCH 2/2] Re login if access token has expired (#861) * Add function for changing google account or re-login when the token expires * Prompt updates --- .../backend/teams/_gbb_google_sheets_team.py | 12 ++++++++++++ .../backend/tools/_gbb_google_sheets_team_tools.py | 9 +++++++++ .../backend/teams/test_gbb_google_sheets_team.py | 4 ++-- .../tools/test_gbb_google_sheets_team_tools.py | 3 ++- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/captn/captn_agents/backend/teams/_gbb_google_sheets_team.py b/captn/captn_agents/backend/teams/_gbb_google_sheets_team.py index d08fdf0c..86ac1333 100644 --- a/captn/captn_agents/backend/teams/_gbb_google_sheets_team.py +++ b/captn/captn_agents/backend/teams/_gbb_google_sheets_team.py @@ -111,8 +111,10 @@ def _guidelines(self) -> str: 4. Once you have the file names, you must determine the id of the Google spreadsheet template and the id of the spreadsheet with new routes. - Use reply_to_client command to check if you found the correct files by providing the file names. Do NOT mention all the files, only the ones that are relevant. - Do NOT forget this step, because the client needs to confirm that you have found the correct files, otherwise you will be penalized! +- ALWAYS add final sentence "If these are NOT the correct files, please paste the whole URL of the correct files." 5. In the template spreadsheet, you must must check that 'Campaigns', 'ad Groups', 'Keywords' and 'Ads' titles exist (by using 'get_all_sheet_titles_get_all_sheet_titles_get'). 6. In the spreadsheet with new routes, you must find the title of the sheet with new routes (by using 'get_all_sheet_titles_get_all_sheet_titles_get'). +- If there are multiple sheets within the spreadsheet, ask the client to choose the correct sheet. 7. Once you have all the necessary information, use 'process_spreadsheet_process_spreadsheet_post' endpoint to process the spreadsheet. - query parameters: user_id, template_spreadsheet_id, new_campaign_spreadsheet_id, new_campaign_sheet_title 8. Once the endpoint is successful write the message to the client that the new sheet has been created in the same spreadsheet as the new routes sheet. @@ -129,6 +131,13 @@ def _guidelines(self) -> str: OFTEN MISTAKES: - Do NOT forget the 'modification_function_parameters' when calling 'ask_client_for_permission' function! +- If the client wants to change the Google Ads account or refresh token, use 'change_google_ads_account_or_refresh_token' function. +- If the client wants to change the Google Sheets account, use 'get_login_url_login_get' function with 'force_new_login' parameter set to True. + +ADDITIONAL NOTES: +- ALWAYS use hyperlinks to the Google Sheets UI when referring it to the client. +e.g. "Are these the correct files?\n\n1. ROUTES: [new-routes](https://docs.google.com/spreadsheets/d/insert_correct_sheet_id) \n\n2. TEMPLATES: [template](https://docs.google.com/spreadsheets/d/insert_correct_sheet_id)" +- ALWAYS use names of the sheets and google ads customer account names when referring them to the client. You can add id-s in the brackets. """ @property @@ -158,11 +167,14 @@ def _commands(self) -> str: 3. Only Google_sheets_expert has access to Google Sheets API and can read and edit Google Sheets. +- 'get_login_url_login_get' - which will return the login url for the Google Sheets API (This can't be used for Google Ads account) +If you want to refresh google sheets token or change google sheets use 'get_login_url_login_get' with 'force_new_login' parameter set to True. 4. Only Google_ads_expert has access to the following commands: - 'list_accessible_customers_with_account_types' (to list accessible Google Ads customers with account types) - 'list_sub_accounts' (to list sub-accounts of a Google Ads customer, use it if the client wants to use Manager Account) - 'create_google_ads_resources' +- 'change_google_ads_account_or_refresh_token' - to change Google Ads account or refresh token (This can't be used for Google Sheets account) """ @classmethod diff --git a/captn/captn_agents/backend/tools/_gbb_google_sheets_team_tools.py b/captn/captn_agents/backend/tools/_gbb_google_sheets_team_tools.py index 40a7d12e..944007e8 100644 --- a/captn/captn_agents/backend/tools/_gbb_google_sheets_team_tools.py +++ b/captn/captn_agents/backend/tools/_gbb_google_sheets_team_tools.py @@ -45,6 +45,7 @@ reply_to_client, ) from ._google_ads_team_tools import ( + change_google_account, get_resource_id_from_response, ) @@ -742,4 +743,12 @@ def create_google_sheets_team_toolbox( create_google_ads_resources ) + change_google_ads_account_description = ( + "Change Google Ads account or refresh access token" + ) + toolbox.add_function( + description=change_google_ads_account_description, + name="change_google_ads_account_or_refresh_token", + )(change_google_account) + return toolbox diff --git a/tests/ci/captn/captn_agents/backend/teams/test_gbb_google_sheets_team.py b/tests/ci/captn/captn_agents/backend/teams/test_gbb_google_sheets_team.py index 39c7e543..101740e7 100644 --- a/tests/ci/captn/captn_agents/backend/teams/test_gbb_google_sheets_team.py +++ b/tests/ci/captn/captn_agents/backend/teams/test_gbb_google_sheets_team.py @@ -129,8 +129,8 @@ def test_init(self, mock_get_conv_uuid: Iterator[Any]) -> None: ) agent_number_of_functions_dict = { "google_sheets_expert": 8, - "account_manager": 5, - "google_ads_expert": 5, + "account_manager": 6, + "google_ads_expert": 6, "user_proxy": 0, } diff --git a/tests/ci/captn/captn_agents/backend/tools/test_gbb_google_sheets_team_tools.py b/tests/ci/captn/captn_agents/backend/tools/test_gbb_google_sheets_team_tools.py index 15e9ca16..170ae4b3 100644 --- a/tests/ci/captn/captn_agents/backend/tools/test_gbb_google_sheets_team_tools.py +++ b/tests/ci/captn/captn_agents/backend/tools/test_gbb_google_sheets_team_tools.py @@ -98,7 +98,7 @@ def test_llm_config(self) -> None: self.toolbox.add_to_agent(agent, user_proxy) llm_config = agent.llm_config - check_llm_config_total_tools(llm_config, 5) + check_llm_config_total_tools(llm_config, 6) check_llm_config_descriptions( llm_config, { @@ -107,6 +107,7 @@ def test_llm_config(self) -> None: "list_accessible_customers_with_account_types": "List accessible customers with account types", "list_sub_accounts": "Use this function to list sub accounts of a Google Ads manager account", "create_google_ads_resources": "Creates Google Ads resources", + "change_google_ads_account_or_refresh_token": "Change Google Ads account or refresh access token", }, )