GuglielmoTor commited on
Commit
520f04f
·
verified ·
1 Parent(s): d2de44b

Update chatbot_prompts.py

Browse files
Files changed (1) hide show
  1. chatbot_prompts.py +28 -41
chatbot_prompts.py CHANGED
@@ -1,82 +1,70 @@
1
  # chatbot_prompts.py
2
  import logging
3
 
4
- def get_initial_insight_and_suggestions(plot_id: str, plot_label: str, plot_data_summary: str = None):
5
  """
6
- Generates an initial insight (now including a data summary) and suggested questions for a given plot.
7
  Args:
8
  plot_id (str): The unique identifier for the plot.
9
  plot_label (str): The display label for the plot.
10
  plot_data_summary (str, optional): A textual summary of the data for the plot.
11
  Returns:
12
- tuple: (initial_chat_message_dict, list_of_suggestion_strings)
13
  """
14
- logging.info(f"Generating initial insight for plot_id: {plot_id}, label: {plot_label}")
15
- # logging.debug(f"Data summary for initial insight of '{plot_label}':\n{plot_data_summary}")
16
 
 
 
17
 
18
- base_persona = "As an expert in Employer Branding and LinkedIn social media strategy, here's an insight on your "
19
- insight_text = f"{base_persona}**{plot_label}**:\n\n"
20
-
21
- # Include the data summary if available
22
- if plot_data_summary and plot_data_summary.strip() and "No data summary available" not in plot_data_summary and "Error generating data summary" not in plot_data_summary and "Accesso negato" not in plot_data_summary:
23
- insight_text += f"Here is a snapshot of the data for your '{plot_label}' chart:\n```text\n{plot_data_summary}\n```\n\n"
 
24
  else:
25
- insight_text += f"Currently, no specific data snapshot is available for '{plot_label}' to include here. General insights apply.\n\n"
26
 
27
- # Default suggestions - these can be made more dynamic later if needed
28
  suggestions = [
29
  f"What are the key drivers for {plot_label.lower()} based on the data?",
30
  f"How can I improve my {plot_label.lower()} according to these trends?",
31
  f"What does good performance look like for {plot_label.lower()}?"
32
  ]
33
 
34
- # Customize insights and suggestions per plot_id
35
- # These specific insights can now refer to the data summary provided above.
36
  if plot_id == "followers_count":
37
- insight_text += ("Tracking your 'Numero di Follower nel Tempo' is crucial. A steady increase, as potentially shown in the data snapshot, indicates growing brand reach and influence. "
38
- "If you observe stagnation or decline, it might be time to review your content strategy, posting frequency, or engagement tactics with your target audience. "
39
- "Consider running campaigns or promoting your LinkedIn page on other channels.")
40
  suggestions = [
41
  "Based on the follower data, what was our peak growth period?",
42
- "How often should I post to maximize follower growth according to LinkedIn best practices?",
43
- "What content typically resonates most with potential followers on LinkedIn?"
44
  ]
45
  elif plot_id == "engagement_rate":
46
- insight_text += ("Your 'Tasso di Engagement nel Tempo' is a vital indicator of how compelling your audience finds your content. Higher rates, reflected in the data, signify that your posts are sparking meaningful interactions. "
47
- "If engagement is low, re-evaluate content relevance, the types of media used, and the clarity of your calls to action. Experiment with questions, polls, and interactive content.")
48
  suggestions = [
49
  "What does the engagement trend tell us about recent content performance?",
50
- "What types of posts typically get the highest engagement on LinkedIn?",
51
- "Can you give me examples of strong calls to action for LinkedIn posts?"
52
  ]
53
  elif plot_id == "reach_over_time":
54
- insight_text += ("The 'Copertura nel Tempo' (Reach) shows how many unique LinkedIn members are seeing your posts. Expanding reach is fundamental for brand awareness. "
55
- "If this metric is flat or declining in the provided data, explore content sharing strategies, encourage employees to share company posts, utilize relevant hashtags, and consider targeted LinkedIn advertising.")
56
  suggestions = [
57
  "What does the reach data suggest about our content visibility?",
58
- "What are effective organic strategies to increase post reach on LinkedIn?",
59
- "How do hashtags and tagging strategies impact reach on LinkedIn?"
60
  ]
61
  elif plot_id == "impressions_over_time":
62
- insight_text += ("'Visualizzazioni nel Tempo' (Impressions) indicates the total number of times your posts have been seen. "
63
- "High impressions are good, but also analyze them in conjunction with engagement (check the engagement rate chart) to ensure visibility translates to interaction.")
64
  suggestions = [
65
  "How do current impressions compare to previous periods based on the data?",
66
- "What's the difference between reach and impressions, and which is more important?",
67
- "Does LinkedIn's algorithm favor certain types of content for impressions?"
68
  ]
69
  elif plot_id == "comments_sentiment":
70
- insight_text += ("Analyzing the 'Ripartizione Commenti per Sentiment' provides qualitative insights. The data snapshot should show the distribution. "
71
- "A high volume of positive sentiment is ideal. Pay close attention to neutral and negative comments to understand concerns or areas for improvement.")
72
  suggestions = [
73
  "What does the sentiment breakdown indicate about audience perception?",
74
- "How can I encourage more positive comments on my posts?",
75
- "What's the best way to respond to negative comments effectively?"
76
  ]
77
- else: # Default fallback for other plots
78
- insight_text += (f"This chart on '{plot_label}' provides valuable data. Analyzing its trends, peaks, and troughs, as seen in the snapshot, can help you refine your LinkedIn strategy. "
79
- f"Look for patterns and correlate them with your activities or external events to understand performance drivers.")
80
 
81
  # Ensure exactly 3 suggestions
82
  while len(suggestions) < 3:
@@ -84,5 +72,4 @@ def get_initial_insight_and_suggestions(plot_id: str, plot_label: str, plot_data
84
  if len(suggestions) > 3:
85
  suggestions = suggestions[:3]
86
 
87
- initial_chat_message = {"role": "assistant", "content": insight_text.strip()}
88
- return initial_chat_message, suggestions
 
1
  # chatbot_prompts.py
2
  import logging
3
 
4
+ def get_initial_insight_prompt_and_suggestions(plot_id: str, plot_label: str, plot_data_summary: str = None):
5
  """
6
+ Generates an initial prompt for the LLM to provide insights on a plot and suggested questions.
7
  Args:
8
  plot_id (str): The unique identifier for the plot.
9
  plot_label (str): The display label for the plot.
10
  plot_data_summary (str, optional): A textual summary of the data for the plot.
11
  Returns:
12
+ tuple: (prompt_for_llm_str, list_of_suggestion_strings)
13
  """
14
+ logging.info(f"Generating initial insight prompt for plot_id: {plot_id}, label: {plot_label}")
 
15
 
16
+ base_persona_prompt = "You are an expert in Employer Branding and LinkedIn social media strategy. Analyze the following data for the chart '{plot_label}' and provide key insights and actionable advice. Focus on interpreting the provided data snapshot."
17
+ prompt_text = f"{base_persona_prompt.format(plot_label=plot_label)}\n\n"
18
 
19
+ if plot_data_summary and plot_data_summary.strip() and \
20
+ "No data summary available" not in plot_data_summary and \
21
+ "Error generating data summary" not in plot_data_summary and \
22
+ "Accesso negato" not in plot_data_summary and \
23
+ f"Nessun sommario dati specifico disponibile per '{plot_label}'" not in plot_data_summary : # Added check for this specific no data message
24
+ prompt_text += f"Data Snapshot for '{plot_label}':\n```text\n{plot_data_summary}\n```\n\n"
25
+ prompt_text += "Based on this data and your expertise, what are the most important observations and what steps can be taken to improve or capitalize on these trends? Please provide a concise initial analysis."
26
  else:
27
+ prompt_text += f"No specific data snapshot is available for '{plot_label}'. Provide general insights and advice for improving performance related to '{plot_label}' on LinkedIn, assuming typical scenarios. Please provide a concise initial analysis."
28
 
29
+ # Default suggestions
30
  suggestions = [
31
  f"What are the key drivers for {plot_label.lower()} based on the data?",
32
  f"How can I improve my {plot_label.lower()} according to these trends?",
33
  f"What does good performance look like for {plot_label.lower()}?"
34
  ]
35
 
36
+ # Customize suggestions per plot_id
 
37
  if plot_id == "followers_count":
 
 
 
38
  suggestions = [
39
  "Based on the follower data, what was our peak growth period?",
40
+ "How often should I post to maximize follower growth?",
41
+ "What content typically resonates most with potential followers?"
42
  ]
43
  elif plot_id == "engagement_rate":
 
 
44
  suggestions = [
45
  "What does the engagement trend tell us about recent content performance?",
46
+ "What types of posts typically get the highest engagement?",
47
+ "Can you give me examples of strong calls to action?"
48
  ]
49
  elif plot_id == "reach_over_time":
 
 
50
  suggestions = [
51
  "What does the reach data suggest about our content visibility?",
52
+ "What are effective organic strategies to increase post reach?",
53
+ "How do hashtags and tagging strategies impact reach?"
54
  ]
55
  elif plot_id == "impressions_over_time":
 
 
56
  suggestions = [
57
  "How do current impressions compare to previous periods based on the data?",
58
+ "What's the difference between reach and impressions?",
59
+ "Does LinkedIn's algorithm favor certain content for impressions?"
60
  ]
61
  elif plot_id == "comments_sentiment":
 
 
62
  suggestions = [
63
  "What does the sentiment breakdown indicate about audience perception?",
64
+ "How can I encourage more positive comments?",
65
+ "What's the best way to respond to negative comments?"
66
  ]
67
+ # Add more plot_id specific suggestions if needed
 
 
68
 
69
  # Ensure exactly 3 suggestions
70
  while len(suggestions) < 3:
 
72
  if len(suggestions) > 3:
73
  suggestions = suggestions[:3]
74
 
75
+ return prompt_text, suggestions