Spaces:
Running
Running
Update chatbot_prompts.py
Browse files- chatbot_prompts.py +38 -29
chatbot_prompts.py
CHANGED
@@ -1,79 +1,88 @@
|
|
1 |
# chatbot_prompts.py
|
2 |
import logging
|
3 |
|
4 |
-
def get_initial_insight_and_suggestions(plot_id: str, plot_label: str, plot_data_summary=None):
|
5 |
"""
|
6 |
-
Generates an initial insight 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:
|
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 |
|
16 |
base_persona = "As an expert in Employer Branding and LinkedIn social media strategy, here's an insight on your "
|
17 |
insight_text = f"{base_persona}**{plot_label}**:\n\n"
|
18 |
|
19 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
suggestions = [
|
21 |
-
f"What are key drivers for {plot_label.lower()}?",
|
22 |
-
f"How can I improve my {plot_label.lower()}?",
|
23 |
f"What does good performance look like for {plot_label.lower()}?"
|
24 |
]
|
25 |
|
26 |
# Customize insights and suggestions per plot_id
|
|
|
27 |
if plot_id == "followers_count":
|
28 |
-
insight_text += ("Tracking your 'Numero di Follower nel Tempo' is crucial. A steady increase indicates growing brand reach and influence. "
|
29 |
-
|
30 |
-
|
31 |
suggestions = [
|
32 |
-
"
|
33 |
-
"How often should I post to maximize follower growth?",
|
34 |
-
"
|
35 |
]
|
36 |
elif plot_id == "engagement_rate":
|
37 |
-
insight_text += ("Your 'Tasso di Engagement nel Tempo' is a vital indicator of how compelling your audience finds your content. Higher rates signify that your posts are sparking meaningful
|
38 |
-
|
39 |
suggestions = [
|
|
|
40 |
"What types of posts typically get the highest engagement on LinkedIn?",
|
41 |
-
"How does posting time affect engagement rates for my audience?",
|
42 |
"Can you give me examples of strong calls to action for LinkedIn posts?"
|
43 |
]
|
44 |
elif plot_id == "reach_over_time":
|
45 |
-
insight_text += ("The 'Copertura nel Tempo' (Reach) shows how many unique LinkedIn members are seeing your posts. Expanding reach is fundamental for brand awareness
|
46 |
-
|
47 |
suggestions = [
|
|
|
48 |
"What are effective organic strategies to increase post reach on LinkedIn?",
|
49 |
-
"Should I consider paid promotion to boost reach for key content?",
|
50 |
"How do hashtags and tagging strategies impact reach on LinkedIn?"
|
51 |
]
|
52 |
elif plot_id == "impressions_over_time":
|
53 |
-
insight_text += ("'Visualizzazioni nel Tempo' (Impressions) indicates the total number of times your posts have been seen.
|
54 |
-
|
55 |
suggestions = [
|
|
|
56 |
"What's the difference between reach and impressions, and which is more important?",
|
57 |
-
"How can I increase the virality of my posts to get more impressions?",
|
58 |
"Does LinkedIn's algorithm favor certain types of content for impressions?"
|
59 |
]
|
60 |
elif plot_id == "comments_sentiment":
|
61 |
-
insight_text += ("Analyzing the 'Ripartizione Commenti per Sentiment' provides qualitative insights
|
62 |
-
|
63 |
suggestions = [
|
|
|
64 |
"How can I encourage more positive comments on my posts?",
|
65 |
-
"What's the best way to respond to negative comments?"
|
66 |
-
"Can sentiment analysis help refine my content topics?"
|
67 |
]
|
68 |
else: # Default fallback for other plots
|
69 |
-
insight_text += (f"This chart on '{plot_label}' provides valuable data. Analyzing its trends, peaks, and troughs can help you refine your LinkedIn strategy. "
|
70 |
-
|
71 |
|
72 |
# Ensure exactly 3 suggestions
|
73 |
while len(suggestions) < 3:
|
74 |
-
suggestions.append("Tell me more about
|
75 |
if len(suggestions) > 3:
|
76 |
suggestions = suggestions[:3]
|
77 |
|
78 |
-
initial_chat_message = {"role": "assistant", "content": insight_text}
|
79 |
return initial_chat_message, suggestions
|
|
|
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:
|
83 |
+
suggestions.append(f"Tell me more about the trends in the {plot_label.lower()} 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
|