GuglielmoTor commited on
Commit
edbc1a6
·
verified ·
1 Parent(s): 1d6a5c0

Update features/chatbot/chatbot_prompts.py

Browse files
Files changed (1) hide show
  1. features/chatbot/chatbot_prompts.py +33 -33
features/chatbot/chatbot_prompts.py CHANGED
@@ -3,72 +3,72 @@ 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:
71
- suggestions.append(f"Tell me more about the trends in the {plot_label.lower()} data.")
72
  if len(suggestions) > 3:
73
  suggestions = suggestions[:3]
74
 
 
3
 
4
  def get_initial_insight_prompt_and_suggestions(plot_id: str, plot_label: str, plot_data_summary: str = None):
5
  """
6
+ Genera un prompt iniziale per l'LLM per fornire spunti su un grafico e domande suggerite.
7
  Args:
8
+ plot_id (str): L'identificatore univoco del grafico.
9
+ plot_label (str): L'etichetta di visualizzazione del grafico.
10
+ plot_data_summary (str, optional): Un riassunto testuale dei dati del grafico.
11
  Returns:
12
  tuple: (prompt_for_llm_str, list_of_suggestion_strings)
13
  """
14
+ logging.info(f"Generazione del prompt di analisi iniziale per plot_id: {plot_id}, etichetta: {plot_label}")
15
 
16
+ base_persona_prompt = "Sei un esperto di Employer Branding e di strategia per i social media di LinkedIn. Analizza i seguenti dati per il grafico '{plot_label}' e fornisci spunti chiave e consigli pratici. Concentrati sull'interpretazione dei dati forniti."
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:
24
+ prompt_text += f"Istantanea dei dati per '{plot_label}':\n```text\n{plot_data_summary}\n```\n\n"
25
+ prompt_text += "Sulla base di questi dati e della tua esperienza, quali sono le osservazioni più importanti e quali passi possono essere intrapresi per migliorare o sfruttare queste tendenze? Fornisci un'analisi iniziale concisa."
26
  else:
27
+ prompt_text += f"Nessuna istantanea di dati specifica è disponibile per '{plot_label}'. Fornisci spunti e consigli generali per migliorare le prestazioni relative a '{plot_label}' su LinkedIn, ipotizzando scenari tipici. Fornisci un'analisi iniziale concisa."
28
 
29
+ # Suggerimenti predefiniti
30
  suggestions = [
31
+ f"Quali sono i fattori chiave per {plot_label.lower()} in base ai dati?",
32
+ f"Come posso migliorare i miei risultati per {plot_label.lower()} secondo queste tendenze?",
33
+ f"Come si presenta una buona performance per {plot_label.lower()}?"
34
  ]
35
 
36
+ # Personalizza i suggerimenti per plot_id
37
  if plot_id == "followers_count":
38
  suggestions = [
39
+ "In base ai dati sui follower, qual è stato il nostro periodo di massima crescita?",
40
+ "Con quale frequenza dovrei pubblicare per massimizzare la crescita dei follower?",
41
+ "Quale tipo di contenuto ha tipicamente più risonanza tra i potenziali follower?"
42
  ]
43
  elif plot_id == "engagement_rate":
44
  suggestions = [
45
+ "Cosa ci dice l'andamento del coinvolgimento sulla performance dei contenuti recenti?",
46
+ "Quali tipi di post ottengono tipicamente il maggior coinvolgimento?",
47
+ "Puoi darmi esempi di inviti all'azione (call to action) efficaci?"
48
  ]
49
  elif plot_id == "reach_over_time":
50
  suggestions = [
51
+ "Cosa suggeriscono i dati sulla copertura (reach) riguardo alla visibilità dei nostri contenuti?",
52
+ "Quali sono le strategie organiche efficaci per aumentare la copertura dei post?",
53
+ "In che modo gli hashtag e le strategie di tagging influenzano la copertura?"
54
  ]
55
  elif plot_id == "impressions_over_time":
56
  suggestions = [
57
+ "Come si confrontano le impressioni attuali con i periodi precedenti in base ai dati?",
58
+ "Qual è la differenza tra copertura (reach) e impressioni (impressions)?",
59
+ "L'algoritmo di LinkedIn favorisce determinati tipi di contenuti per le impressioni?"
60
  ]
61
  elif plot_id == "comments_sentiment":
62
  suggestions = [
63
+ "Cosa indica l'analisi del sentiment sulla percezione del pubblico?",
64
+ "Come posso incoraggiare più commenti positivi?",
65
+ "Qual è il modo migliore per rispondere ai commenti negativi?"
66
  ]
67
+ # Aggiungi altri suggerimenti specifici per plot_id se necessario
68
 
69
+ # Assicura che ci siano esattamente 3 suggerimenti
70
  while len(suggestions) < 3:
71
+ suggestions.append(f"Dimmi di più sulle tendenze nei dati di {plot_label.lower()}.")
72
  if len(suggestions) > 3:
73
  suggestions = suggestions[:3]
74