Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pull main to branch #131

Merged
merged 4 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions __pipeline__.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,15 @@
" print(\"- Entity:\", entity_name)\n",
" print(\"- Emails:\", emails)\n",
" print(\"- LinkedIn URL:\", linkedin_url)\n",
" print(\"- LinkedIn li_at:\", li_at)\n",
" print(\"- LinkedIn JSESSIONID:\", JSESSIONID)\n",
" entity_code = unidecode(row.ENTITY.lower().replace(\" \", \"_\").replace(\".\", \"\"))\n",
" entity_dir = os.path.join(datalake_dir, entity_code)\n",
" os.makedirs(entity_dir, exist_ok=True) # Create dirs\n",
" os.makedirs(os.path.join(entity_dir, \"plugins\"), exist_ok=True) # Create dirs\n",
" print(\"- Directory:\", entity_dir)\n",
" workspace_ids = []\n",
" if \"WORKSPACE_IDS\" in df_gsheet.columns and row.WORKSPACE_IDS != \"NA\":\n",
" workspace_ids = row.WORKSPACE_IDS.split(\",\")\n",
" print(\"- Workspace IDs:\", workspace_ids)\n",
" print()\n",
" \n",
" # Save entity data\n",
Expand All @@ -214,7 +216,9 @@
" naas.dependency.add(os.path.join(output_dir, \"linkedin_url.pickle\"))\n",
" pdump(output_dir, entity_dir, \"entity_dir\")\n",
" naas.dependency.add(os.path.join(output_dir, \"entity_dir.pickle\"))\n",
" \n",
" pdump(output_dir, workspace_ids, \"workspace_ids\")\n",
" naas.dependency.add(os.path.join(output_dir, \"workspace_ids.pickle\"))\n",
"\n",
" # Save secrets\n",
" for x in [\"LINKEDIN_LI_AT\", \"LINKEDIN_JSESSIONID\"]:\n",
" value = df_gsheet.loc[index, x]\n",
Expand All @@ -226,7 +230,9 @@
" if li_at == \"NA\":\n",
" li_at = naas.secret.get(\"li_at\")\n",
" if JSESSIONID == \"NA\":\n",
" JSESSIONID = naas.secret.get(\"JSESSIONID\")\n",
" JSESSIONID = naas.secret.get(\"JSESSIONID\").replace('\"', '')\n",
" print(\"- LinkedIn li_at:\", li_at)\n",
" print(\"- LinkedIn JSESSIONID:\", JSESSIONID)\n",
" \n",
" # Set timezone: Timezone will be defined from the first profile region's and country's\n",
" if index == 0:\n",
Expand Down Expand Up @@ -287,8 +293,6 @@
" \"entity_name\": entity_name,\n",
" \"emails\": emails,\n",
" \"linkedin_url\": linkedin_url,\n",
" \"li_at\": li_at,\n",
" \"JSESSIONID\": JSESSIONID,\n",
" \"entity_dir\": entity_dir\n",
" }\n",
" )\n",
Expand Down Expand Up @@ -357,7 +361,7 @@
"outputs": [],
"source": [
"# Schedule pipeline\n",
"cron = \"0 12 * * *\"\n",
"cron = \"0 8 * * *\"\n",
"print(\"⏰ Scheduler:\", cron)\n",
"naas.scheduler.add(cron=cron)\n",
"# naas.scheduler.delete()"
Expand Down
11 changes: 7 additions & 4 deletions models/content-engine/__plugin__.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@
"- `description`: Plugin description.\n",
"- `avatar`: Plugin avatar image.\n",
"- `model_dir`: Models directory.\n",
"- `api_key`: Naas API Key.\n",
"- `workspace_ids`: Workspace IDs to push the plugin in.\n",
"- `personal_workspace`: Plugin sent to personal workspace.\n",
"\n",
"**Outputs**\n",
"- `output_dir`: Output directory where output files are stored. \n",
Expand Down Expand Up @@ -149,6 +152,8 @@
"avatar = \"https://naasai-public.s3.eu-west-3.amazonaws.com/abi-demo/content_creation.png\"\n",
"model_dir = os.path.join(naas_data_product.ROOT_PATH, \"models\", \"content-engine\")\n",
"api_key = naas.secret.get('NAAS_API_TOKEN')\n",
"workspace_ids = pload(os.path.join(naas_data_product.OUTPUTS_PATH, \"entities\", entity_index), \"workspace_ids\") or \"\"\n",
"personal_workspace = True\n",
"\n",
"# Outputs\n",
"output_dir = os.path.join(entity_dir, \"plugins\")\n",
Expand Down Expand Up @@ -281,14 +286,12 @@
},
"outputs": [],
"source": [
"system_prompt = f\"\"\"\n",
"Act as a Content Assistant who has access to valuable data and insights about the content strategy. \n",
"system_prompt = f\"\"\"Act as a Content Assistant who has access to valuable data and insights about the content strategy. \n",
"Your role is to manage and optimize the content, ensuring it reaches the target audience effectively. \n",
"The last 2 weeks '{TW}' & '{LW}' the '{entity_name}' published {len(df)} contents and generated and {kpi} {kpi_label}. \n",
"Here is the list with the post published: {prompt_data}.\n",
"The first message should be about presenting yourself and analyze '{entity_name}' contents published based on best post/topics by {kpi_label}, by date and time with a maximum of 3 bullet points.\n",
"Then, you will display the image inside the markdown of the chat about the evolution of content {kpi_label} over the last 2 weeks: ![Content KPI]({image_url}).\n",
"You must ALWAYS show the image in the first message.\n",
"Be casual, but professional. Wait for the first answer from the user, and then start with the first high-level analysis. \n",
"\"\"\""
]
Expand Down Expand Up @@ -347,7 +350,7 @@
"\n",
"# Push plugin to Personal workspace\n",
"print(\"--> Push plugin to Personal workspace\")\n",
"push_plugin_to_workspace(api_key, plugin)\n",
"push_plugin_to_workspace(api_key, plugin, workspace_ids, personal_workspace)\n",
"print()\n",
"\n",
"# Create new chat\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,26 +371,26 @@
" df_init[\"AUTHOR_URL\"] = tmp_df.loc[0, \"AUTHOR_URL\"]\n",
" df_init[\"ENGAGEMENTS\"] = df_init[\"LIKES\"] + df_init[\"COMMENTS\"] + df_init[\"SHARES\"]\n",
" \n",
" df_init[\"ID\"] = df_init.apply(lambda row: create_sha_256_hash(str(row[\"URL\"].split(\":activity:\")[1].split(\"/\")[0])), axis=1) \n",
" # Add KG data columns\n",
" col_ref = [\n",
" \"ID\",\n",
" \"CONCEPT\",\n",
" \"SENTIMENT\",\n",
" \"TARGET\",\n",
" \"OBJECTIVE\",\n",
" ] \n",
" for c in col_ref:\n",
" if len(df_init) == 0 and c != \"ID\":\n",
" df[c] = \"TBD\"\n",
" elif not c in df_init.columns:\n",
" df_init[c] = \"TBD\"\n",
" \n",
" if len(df_init) > 0:\n",
" # Get meta data from existing people\n",
" col_ref = [\n",
" \"ID\",\n",
" \"CONCEPT\",\n",
" \"SENTIMENT\",\n",
" \"TARGET\",\n",
" \"OBJECTIVE\",\n",
" ]\n",
" for c in col_ref:\n",
" # If columns does not exist, init value to be determined (TBD)\n",
" if not c in df_init.columns:\n",
" df_init[c] = \"TBD\"\n",
" # Merge to get meta data\n",
" ref = df_init[col_ref]\n",
" \n",
" # Merge to get meta data\n",
" df = pd.merge(df, ref, on=\"ID\", how=\"left\")\n",
" for c in col_ref:\n",
" df[c] = df[c].fillna(\"TBD\")\n",
" df = pd.merge(df, ref, on=\"ID\", how=\"left\")\n",
" for c in col_ref:\n",
" df[c] = df[c].fillna(\"TBD\")\n",
"\n",
" # Concat new posts with init\n",
" df = pd.concat([df, df_init], axis=0).reset_index(drop=True)\n",
Expand Down
16 changes: 10 additions & 6 deletions models/finance-engine/__plugin__.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@
"- `description`: This variable holds a string that describes the plugin.\n",
"- `avatar`: This variable holds a URL to an image to be displayed in your plugin as avatar.\n",
"- `model_dir`: This variable holds a relative path to the directory where input notebooks with commands will be stored.\n",
"- `api_key`: Naas API Key.\n",
"- `workspace_ids`: Workspace IDs to push the plugin in.\n",
"- `personal_workspace`: Plugin sent to personal workspace.\n",
"\n",
"**Outputs**\n",
"- `output_dir`: This variable holds a relative path to the directory where output files will be stored. \n",
Expand All @@ -130,19 +133,21 @@
"outputs": [],
"source": [
"# Inputs\n",
"entity_id = \"0\"\n",
"entity_dir = pload(os.path.join(naas_data_product.OUTPUTS_PATH, \"entities\", entity_id), \"entity_dir\")\n",
"entity_index = \"0\"\n",
"entity_dir = pload(os.path.join(naas_data_product.OUTPUTS_PATH, \"entities\", entity_index), \"entity_dir\")\n",
"name = \"Finance Assistant\"\n",
"model = \"gpt-3.5-turbo-16k\"\n",
"temperature = 0\n",
"description = \"Manage financial transactions accurately and maintain comprehensive records for informed financial planning and analysis.\"\n",
"avatar = \"https://naasai-public.s3.eu-west-3.amazonaws.com/abi-demo/finance_management.png\"\n",
"model_dir = os.path.join(naas_data_product.ROOT_PATH, \"models\", \"finance-engine\")\n",
"api_key = naas.secret.get('NAAS_API_TOKEN')\n",
"workspace_ids = pload(os.path.join(naas_data_product.OUTPUTS_PATH, \"entities\", entity_index), \"workspace_ids\") or \"\"\n",
"personal_workspace = True\n",
"\n",
"# Outputs\n",
"output_dir = os.path.join(entity_dir, \"plugins\")\n",
"entity_name = pload(os.path.join(naas_data_product.OUTPUTS_PATH, \"entities\", entity_id), \"entity_name\") or \"\""
"entity_name = pload(os.path.join(naas_data_product.OUTPUTS_PATH, \"entities\", entity_index), \"entity_name\") or \"\""
]
},
{
Expand Down Expand Up @@ -173,8 +178,7 @@
},
"outputs": [],
"source": [
"system_prompt = f\"\"\"\n",
"Act as a Financial Assistant with access to comprehensive financial data sources. \n",
"system_prompt = f\"\"\"Act as a Financial Assistant with access to comprehensive financial data sources. \n",
"Your primary objective is to analyze and optimize financial transactions, ensuring you identify key insights and trends to guide financial strategies. \n",
"Leverage the data to decipher patterns, customer behavior, and payment methods to strategize on revenue growth and financial operations.\n",
"Your ultimate goal is to maximize revenue, minimize risks, and contribute to the overall financial success of the organization.\n",
Expand Down Expand Up @@ -236,7 +240,7 @@
"\n",
"# Push plugin to Personal workspace\n",
"print(\"--> Push plugin to Personal workspace\")\n",
"push_plugin_to_workspace(api_key, plugin)\n",
"push_plugin_to_workspace(api_key, plugin, workspace_ids, personal_workspace)\n",
"print()\n",
"\n",
"# Create new chat\n",
Expand Down
11 changes: 7 additions & 4 deletions models/growth-engine/__plugin__.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@
"- `description`: Plugin description.\n",
"- `avatar`: Plugin avatar image.\n",
"- `model_dir`: Models directory.\n",
"- `api_key`: Naas API Key.\n",
"- `workspace_ids`: Workspace IDs to push the plugin in.\n",
"- `personal_workspace`: Plugin sent to personal workspace.\n",
"\n",
"**Outputs**\n",
"- `output_dir`: Output directory where output files are stored. \n",
Expand Down Expand Up @@ -150,6 +153,8 @@
"avatar = \"https://naasai-public.s3.eu-west-3.amazonaws.com/abi-demo/growth_marketing.png\"\n",
"model_dir = os.path.join(naas_data_product.ROOT_PATH, \"models\", \"growth-engine\")\n",
"api_key = naas.secret.get('NAAS_API_TOKEN')\n",
"workspace_ids = pload(os.path.join(naas_data_product.OUTPUTS_PATH, \"entities\", entity_index), \"workspace_ids\") or \"\"\n",
"personal_workspace = True\n",
"\n",
"# Outputs\n",
"output_dir = os.path.join(entity_dir, \"plugins\")\n",
Expand Down Expand Up @@ -321,15 +326,13 @@
},
"outputs": [],
"source": [
"system_prompt = f\"\"\"\n",
"Act as a Growth assistant who has access to a list of interactions from content that enable the user to get marketing qualified contacts.\n",
"system_prompt = f\"\"\"Act as a Growth assistant who has access to a list of interactions from content that enable the user to get marketing qualified contacts.\n",
"Your role is to manage and optimize the list of people who interacted on the content, ensuring to extract only the most qualified contacts to feed the sales representative.\n",
"The last 2 weeks '{TW}' & '{LW}' the '{entity_name}' generated {total_leads} new leads ({new_leads} on {TW}) by the following posts published: {post_data}. \n",
"Here is the list of leads with the highest interaction score: {df.to_string()}.\n",
"Please remember the user that you don't have access to all the list due to the limit of the context window.\n",
"The first message should be about presenting yourself and analyze briefly '{entity_name}' new interactions with a maximum of 3 bullet points.\n",
"Then, you will display the image inside the markdown of the chat about the contacts reached over the weeks: ![Contacts Reached]({image_url}).\n",
"You must ALWAYS show the image in the first message.\n",
"Be casual, but professional. Wait for the first answer from the user, and then start with the first high-level analysis. \n",
"\"\"\""
]
Expand Down Expand Up @@ -388,7 +391,7 @@
"\n",
"# Push plugin to Personal workspace\n",
"print(\"--> Push plugin to Personal workspace\")\n",
"push_plugin_to_workspace(api_key, plugin)\n",
"push_plugin_to_workspace(api_key, plugin, workspace_ids, personal_workspace)\n",
"print()\n",
"\n",
"# Create new chat\n",
Expand Down
Loading
Loading