Spaces:
Sleeping
Sleeping
| # chatbot_prompts.py | |
| import logging | |
| def get_initial_insight_prompt_and_suggestions(plot_id: str, plot_label: str, plot_data_summary: str = None): | |
| """ | |
| Generates an initial prompt for the LLM to provide insights on a plot and suggested questions. | |
| Args: | |
| plot_id (str): The unique identifier for the plot. | |
| plot_label (str): The display label for the plot. | |
| plot_data_summary (str, optional): A textual summary of the data for the plot. | |
| Returns: | |
| tuple: (prompt_for_llm_str, list_of_suggestion_strings) | |
| """ | |
| logging.info(f"Generating initial insight prompt for plot_id: {plot_id}, label: {plot_label}") | |
| 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." | |
| prompt_text = f"{base_persona_prompt.format(plot_label=plot_label)}\n\n" | |
| 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 and \ | |
| f"Nessun sommario dati specifico disponibile per '{plot_label}'" not in plot_data_summary : # Added check for this specific no data message | |
| prompt_text += f"Data Snapshot for '{plot_label}':\n```text\n{plot_data_summary}\n```\n\n" | |
| 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." | |
| else: | |
| 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." | |
| # Default suggestions | |
| suggestions = [ | |
| f"What are the key drivers for {plot_label.lower()} based on the data?", | |
| f"How can I improve my {plot_label.lower()} according to these trends?", | |
| f"What does good performance look like for {plot_label.lower()}?" | |
| ] | |
| # Customize suggestions per plot_id | |
| if plot_id == "followers_count": | |
| suggestions = [ | |
| "Based on the follower data, what was our peak growth period?", | |
| "How often should I post to maximize follower growth?", | |
| "What content typically resonates most with potential followers?" | |
| ] | |
| elif plot_id == "engagement_rate": | |
| suggestions = [ | |
| "What does the engagement trend tell us about recent content performance?", | |
| "What types of posts typically get the highest engagement?", | |
| "Can you give me examples of strong calls to action?" | |
| ] | |
| elif plot_id == "reach_over_time": | |
| suggestions = [ | |
| "What does the reach data suggest about our content visibility?", | |
| "What are effective organic strategies to increase post reach?", | |
| "How do hashtags and tagging strategies impact reach?" | |
| ] | |
| elif plot_id == "impressions_over_time": | |
| suggestions = [ | |
| "How do current impressions compare to previous periods based on the data?", | |
| "What's the difference between reach and impressions?", | |
| "Does LinkedIn's algorithm favor certain content for impressions?" | |
| ] | |
| elif plot_id == "comments_sentiment": | |
| suggestions = [ | |
| "What does the sentiment breakdown indicate about audience perception?", | |
| "How can I encourage more positive comments?", | |
| "What's the best way to respond to negative comments?" | |
| ] | |
| # Add more plot_id specific suggestions if needed | |
| # Ensure exactly 3 suggestions | |
| while len(suggestions) < 3: | |
| suggestions.append(f"Tell me more about the trends in the {plot_label.lower()} data.") | |
| if len(suggestions) > 3: | |
| suggestions = suggestions[:3] | |
| return prompt_text, suggestions |