Skip to content

Commit bf90aec

Browse files
authored
Merge pull request #122 from jupyter-naas/120-content---add-new-columns-post_id-company-and-people-mentionned
feat: content engine - add new columns post id company and people mentionned
2 parents 699dbc4 + 8857d75 commit bf90aec

24 files changed

Lines changed: 3159 additions & 1724 deletions

models/content-engine/__pipeline__.ipynb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"id": "f60a7fd6-a35b-4d3e-b123-a441e2e0215a",
5+
"id": "56b96b04-bd01-4155-92de-45b6f02f0e6f",
66
"metadata": {
77
"papermill": {},
88
"tags": []
99
},
1010
"source": [
11-
"<img width=\"8%\" alt=\"Naas.png\" src=\"https://raw.githubusercontent.com/jupyter-naas/awesome-notebooks/master/.github/assets/logos/Naas.png\" style=\"border-radius: 15%\">"
11+
"<img width=\"8%\" alt=\"Content\" src=\"https://naasai-public.s3.eu-west-3.amazonaws.com/abi-demo/content_creation.png\" style=\"border-radius: 15%\">"
1212
]
1313
},
1414
{
@@ -140,6 +140,7 @@
140140
"# Engine\n",
141141
"engine_name = \"content-engine\"\n",
142142
"assistant_name = \"Content Assistant\"\n",
143+
"days_start = -7\n",
143144
"custom_pipeline_path = os.path.join(naas_data_product.MODELS_PATH, engine_name, \"custom\", \"__pipeline__.ipynb\")"
144145
]
145146
},
@@ -220,19 +221,21 @@
220221
"source": [
221222
"extraction = NotebookStep(\n",
222223
" name=\"LinkedIn\",\n",
223-
" notebook_path=os.path.join(naas_data_product.MODELS_PATH, engine_name, \"core\", \"domain\", \"LinkedIn_Get_entity_posts_stats.ipynb\"),\n",
224+
" notebook_path=os.path.join(naas_data_product.MODELS_PATH, engine_name, \"core\", \"domain\", \"LinkedIn_Get_entity_posts.ipynb\"),\n",
224225
" parameters={\n",
225226
" \"li_at\": li_at,\n",
226227
" \"JSESSIONID\": JSESSIONID,\n",
227228
" \"linkedin_url\": linkedin_url,\n",
229+
" \"days_start\": days_start,\n",
228230
" \"output_dir\": engine_dir\n",
229231
" }\n",
230232
")\n",
231233
"cleaning = NotebookStep(\n",
232234
" name=\"Content\",\n",
233-
" notebook_path=os.path.join(naas_data_product.MODELS_PATH, engine_name, \"core\", \"domain\", \"Google_Sheets_Send_content_db_to_spreadsheet.ipynb\"),\n",
235+
" notebook_path=os.path.join(naas_data_product.MODELS_PATH, engine_name, \"core\", \"domain\", \"Content_Create_Posts_database.ipynb\"),\n",
234236
" parameters={\n",
235237
" \"input_dir\": engine_dir,\n",
238+
" \"entity_dir\": entity_dir,\n",
236239
" \"entity_name\": entity_name,\n",
237240
" \"spreadsheet_url\": spreadsheet_url,\n",
238241
" \"sheet_name\": sheet_posts,\n",

models/content-engine/__plugin__.ipynb

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,22 @@
215215
"prompt_data = \"\"\n",
216216
"post_number = 0\n",
217217
"views = 0\n",
218-
"interactions = 0\n",
219-
"\n",
218+
"engagements = 0\n",
219+
"to_keep = [\n",
220+
" \"URL\",\n",
221+
" \"DATE\",\n",
222+
" \"TIME\",\n",
223+
" \"TEXT\",\n",
224+
" \"VIEWS\",\n",
225+
" \"LIKES\",\n",
226+
" \"COMMENTS\",\n",
227+
" \"SHARES\",\n",
228+
" \"ENGAGEMENTS\",\n",
229+
" \"CONCEPT\",\n",
230+
" \"SENTIMENT\",\n",
231+
" \"TARGET\",\n",
232+
" \"OBJECTIVE\",\n",
233+
"]\n",
220234
"# Load data from pickle\n",
221235
"df = pd.DataFrame()\n",
222236
"data = pload(input_dir, input_file) \n",
@@ -228,15 +242,14 @@
228242
"# Filter on this week and last week\n",
229243
"if len(df) > 0:\n",
230244
" df = df[(df[\"ENTITY\"] == entity_name) & df[\"SCENARIO\"].isin([TW, LW])]\n",
231-
" df[\"INTERACTIONS\"] = df.LIKES + df.COMMENTS + df.SHARES\n",
232-
" prompt_data = df.to_string()\n",
245+
" prompt_data = df[to_keep].to_string()\n",
233246
" post_number = len(df)\n",
234247
" views = df.VIEWS.sum()\n",
235-
" interactions = df.INTERACTIONS.sum()\n",
248+
" engagements = df.ENGAGEMENTS.sum()\n",
236249
" \n",
237250
"if views == 0:\n",
238-
" kpi = f\"{interactions}\"\n",
239-
" kpi_label = \"interactions\"\n",
251+
" kpi = f\"{engagements}\"\n",
252+
" kpi_label = \"engagements\"\n",
240253
"else:\n",
241254
" kpi = f\"{views}\"\n",
242255
" kpi_label = \"impressions\"\n",
@@ -270,10 +283,10 @@
270283
"system_prompt = f\"\"\"\n",
271284
"Act as a Content Assistant who has access to valuable data and insights about the content strategy. \n",
272285
"Your role is to manage and optimize the content, ensuring it reaches the target audience effectively. \n",
273-
"This week '{TW}' the '{entity_name}' published {len(df)} contents and generated and {kpi} {kpi_label}. \n",
286+
"The last 2 weeks '{TW}' & '{LW}' the '{entity_name}' published {len(df)} contents and generated and {kpi} {kpi_label}. \n",
274287
"Here is the list with the post published: {prompt_data}.\n",
275288
"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",
276-
"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})({image_html})].\n",
289+
"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",
277290
"You must ALWAYS show the image in the first message.\n",
278291
"Be casual, but professional. Wait for the first answer from the user, and then start with the first high-level analysis. \n",
279292
"\"\"\""
@@ -340,6 +353,14 @@
340353
"print(\"--> Create new chat\")\n",
341354
"Markdown(f\"[Create New Chat](https://naas.ai/chat/use?plugin_url={plugin_url})\")"
342355
]
356+
},
357+
{
358+
"cell_type": "code",
359+
"execution_count": null,
360+
"id": "9adc4d13-42d7-4c82-b7b0-621e1bf1c10e",
361+
"metadata": {},
362+
"outputs": [],
363+
"source": []
343364
}
344365
],
345366
"metadata": {

0 commit comments

Comments
 (0)