Skip to content

Commit

Permalink
feat: send plugin to multiples workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
FRV-SERVICES committed Apr 25, 2024
1 parent 4197199 commit 57fd5d2
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 88 deletions.
17 changes: 10 additions & 7 deletions __pipeline__.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,14 @@
" 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",
" 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 +215,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 +229,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 +292,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 +360,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
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
16 changes: 10 additions & 6 deletions models/opendata-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 = \"Open Data Assistant\"\n",
"model = \"gpt-4-1106-preview\"\n",
"temperature = 0\n",
"description = \"Harness external data for enriching business intelligence and supporting strategic adaptation.\"\n",
"avatar = \"https://naasai-public.s3.eu-west-3.amazonaws.com/abi-demo/open_data_intelligence.png\"\n",
"model_dir = os.path.join(naas_data_product.ROOT_PATH, \"models\", \"opendata-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 @@ -176,8 +181,7 @@
},
"outputs": [],
"source": [
"system_prompt = f\"\"\"\n",
"Act as a Open Data Assitant who has access to a list of indicators from financial, extra-financial data and alternative data.\n",
"system_prompt = f\"\"\"Act as a Open Data Assitant who has access to a list of indicators from financial, extra-financial data and alternative data.\n",
"Your role is to help people follow the portfolio of indicators that makes sense for them.\n",
"Start by presenting yourself.\n",
"\"\"\""
Expand Down Expand Up @@ -237,7 +241,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
16 changes: 10 additions & 6 deletions models/operations-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 = \"Operations Assistant\"\n",
"model = \"gpt-3.5-turbo-16k\"\n",
"temperature = 0\n",
"description = \"Automate and optimize operational tasks and meeting management, ensuring enhanced efficiency and streamlined workflows.\"\n",
"avatar = \"https://naasai-public.s3.eu-west-3.amazonaws.com/abi-demo/operations_efficiency.png\"\n",
"model_dir = os.path.join(naas_data_product.ROOT_PATH, \"models\", \"operations-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 @@ -176,8 +181,7 @@
},
"outputs": [],
"source": [
"system_prompt = f\"\"\"\n",
"Act as an Operations Efficiency Assistant with access to comprehensive data sources, including detailed GitHub contributor activity. \n",
"system_prompt = f\"\"\"Act as an Operations Efficiency Assistant with access to comprehensive data sources, including detailed GitHub contributor activity. \n",
"Your primary role is to analyze and optimize the list of contributors, ensuring you identify the most active and influential individuals to guide collaborative strategies. \n",
"Leverage the data to decipher patterns, contributions, and engagement levels to strategize on operations and collaborations.\n",
"Your ultimate goal is to foster a high-performing and cohesive community, playing a pivotal role in the overall success of the project's development and growth.\n",
Expand Down Expand Up @@ -239,7 +243,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

0 comments on commit 57fd5d2

Please sign in to comment.