Skip to content

Commit

Permalink
Merge pull request #985 from airtai/dev
Browse files Browse the repository at this point in the history
5 PRs
  • Loading branch information
kumaranvpl authored Oct 14, 2024
2 parents 4ec6dbd + c09fd85 commit fc92e46
Show file tree
Hide file tree
Showing 13 changed files with 834 additions and 121 deletions.
6 changes: 2 additions & 4 deletions captn/captn_agents/backend/teams/_gbb_google_sheets_team.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,8 @@ def _commands(self) -> str:

@classmethod
def get_capabilities(cls) -> str:
return "Able to read and edit Google Sheets."
return "Able to read Google Sheets and create NEW Google Ads campaigns."

@classmethod
def get_brief_template(cls) -> str:
return (
"The client wants to create new campaigns using a Google Sheets template."
)
return "The client wants to create new Google Ads campaigns from the Google Sheets template."
2 changes: 1 addition & 1 deletion captn/captn_agents/backend/teams/_gbb_initial_team.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _guidelines(self) -> str:
If you fail to choose the appropriate team, you will be penalized!
3. Here is a list of teams you can choose from after you determine which one is the most appropriate for the task:
{self.construct_team_names_and_descriptions_message(use_only_team_names={"gbb_google_sheets_team"})}
{self.construct_team_names_and_descriptions_message(use_only_team_names={"gbb_google_sheets_team", "gbb_page_feed_team"})}
Guidelines SUMMARY:
- Write a detailed step-by-step plan
Expand Down
13 changes: 9 additions & 4 deletions captn/captn_agents/backend/teams/_gbb_page_feed_team.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
from ..tools._gbb_page_feed_team_tools import create_page_feed_team_toolbox
from ._gbb_google_sheets_team import GOOGLE_SHEETS_OPENAPI_URL, GBBGoogleSheetsTeam
from ._shared_prompts import REPLY_TO_CLIENT_COMMAND
from ._team import Team


# @Team.register_team("gbb_page_feed_team")
@Team.register_team("gbb_page_feed_team")
class GBBPageFeedTeam(GBBGoogleSheetsTeam):
def __init__(
self,
Expand Down Expand Up @@ -71,8 +72,12 @@ def _guidelines(self) -> str:
- mandatory input parameters: user_id, spreadsheet_id
6. In the spreadsheet with page feeds, you must find the title of the sheet with page feeds (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 the correct sheet title, you must validate the data in the page feed sheet by using 'validate_page_feed_data' function.
7. Once you have the correct sheet title, you must validate the data in the page feed sheet by using 'get_and_validate_page_feed_data' function.
8. If the data is correct, you must update the page feeds in Google Ads by using 'update_page_feeds' function.
9. Before EACH update_page_feeds call also repeat the get_and_validate_page_feed_data call to ensure the data is still correct.
- If the user asks you to repeat the process, it might be because the data has changed, so ALWAYS validate the data before updating.
10. Once you have updated the page feeds, you must inform the client which page feeds have been updated and you must list ALL the changes which the client needs to do manually.
- Do not write few changes and "etc." or "[Additional URLs]". You MUST list ALL the changes (both complete and the ones that need to be done manually).
ALL ENDPOINT PARAMETERS ARE MANDATORY (even if the documentation says they are optional).
Expand Down Expand Up @@ -115,7 +120,7 @@ def _commands(self) -> str:
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:
- 'validate_page_feed_data':
- 'get_and_validate_page_feed_data':
parameters: template_spreadsheet_id, page_feed_spreadsheet_id, page_feed_sheet_title
- 'update_page_feeds':
parameters: customer_id, login_customer_id
Expand All @@ -124,7 +129,7 @@ def _commands(self) -> str:

@classmethod
def get_capabilities(cls) -> str:
return "Able update Google Ads Page Feeds."
return "Able to update Google Ads Page Feeds."

@classmethod
def get_brief_template(cls) -> str:
Expand Down
14 changes: 10 additions & 4 deletions captn/captn_agents/backend/tools/_gbb_google_sheets_team_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class GoogleSheetsTeamContext(Context):
]


def _check_mandatory_columns(
def check_mandatory_columns(
df: pd.DataFrame, mandatory_columns: List[str], table_title: str
) -> str:
missing_columns = [col for col in mandatory_columns if col not in df.columns]
Expand All @@ -169,7 +169,7 @@ def _validat_and_convert_to_df(
values.values[1:],
columns=values.values[0],
)
mandatory_columns_error_msg = _check_mandatory_columns(df, mandatory_columns, title)
mandatory_columns_error_msg = check_mandatory_columns(df, mandatory_columns, title)
return df, mandatory_columns_error_msg


Expand Down Expand Up @@ -778,6 +778,10 @@ def _update_campaign_with_additional_settings(
)


def get_time() -> str:
return datetime.now(ZAGREB_TIMEZONE).strftime("%Y-%m-%d %H:%M:%S")


def _setup_campaign(
customer_id: str,
login_customer_id: str,
Expand Down Expand Up @@ -895,13 +899,15 @@ def _setup_campaign(
)
campaign["ad_groups"][row["ad group name"]] = ad_group_ad.ad_group_id

message = f"[{datetime.now(ZAGREB_TIMEZONE).strftime('%Y-%m-%d %H:%M:%S')}] Created campaign: {campaign_name}"
message = f"[{get_time()}] Created campaign: {campaign_name}"
iostream.print(colored(message, "green"), flush=True)
return True, None

except Exception as e:
error_msg = str(e)
message = f"[{datetime.now(ZAGREB_TIMEZONE).strftime('%Y-%m-%d %H:%M:%S')}] Failed to create campaign: {campaign_name}: {error_msg}"
message = (
f"[{get_time()}] Failed to create campaign: {campaign_name}: {error_msg}"
)
iostream.print(colored(message, "red"), flush=True)

try:
Expand Down
Loading

0 comments on commit fc92e46

Please sign in to comment.