Spaces:
Sleeping
Sleeping
| from smolagents.tools import Tool | |
| class LinkedInPostPromptComposerTool(Tool): | |
| name = "linkedin_post_prompt_composer" | |
| description = ( | |
| "Generates a detailed prompt by synthesizing conversation context, extracted webpage insights, " | |
| "and additional instructions. This prompt is intended for a final answer tool that produces a polished LinkedIn post." | |
| ) | |
| inputs = { | |
| "context": { | |
| "type": "string", | |
| "description": ( | |
| "A summary of your brainstorming or discussion context. Include key ideas, opinions, " | |
| "and relevant back-and-forth that should influence the final post." | |
| ) | |
| }, | |
| "extracted_info": { | |
| "type": "string", | |
| "description": ( | |
| "Key points, data, or insights extracted from webpages, reports, or articles that provide " | |
| "the factual basis for the post." | |
| ) | |
| }, | |
| "instructions": { | |
| "type": "string", | |
| "description": ( | |
| "Additional guidance such as desired tone, target audience, style, or specific calls-to-action. " | |
| "For example: 'Make it conversational yet authoritative, include a compelling hook, and end with a question.'" | |
| ), | |
| "nullable": True | |
| } | |
| } | |
| output_type = "string" | |
| def forward(self, context: str, extracted_info: str, instructions: str = "") -> str: | |
| prompt = ( | |
| "You are an experienced LinkedIn content strategist and influencer. Using the inputs provided, " | |
| "generate a comprehensive final LinkedIn post that meets the following criteria:\n\n" | |
| "1. **Compelling Hook:** Begin with a strong headline or opening line that grabs attention.\n" | |
| "2. **Coherent Narrative:** Seamlessly blend the discussion context and the extracted information into a clear, engaging story.\n" | |
| "3. **Actionable Insights:** Offer actionable advice or takeaways that provide real value to a professional audience.\n" | |
| "4. **Call-to-Action:** Include a call-to-action to encourage comments, shares, or further engagement.\n" | |
| "5. **Trending Hashtags:** Append 3-5 relevant and trending LinkedIn hashtags at the end.\n\n" | |
| "The final post should be approximately 200–300 words, using a professional yet conversational tone.\n\n" | |
| "### Input Sections:\n" | |
| "**Discussion Context:**\n" + context + "\n\n" | |
| "**Extracted Information:**\n" + extracted_info + "\n\n" | |
| ) | |
| if instructions: | |
| prompt += "**Additional Instructions:**\n" + instructions + "\n\n" | |
| prompt += ( | |
| "Now, **do not repeat any of the above input or instructions**. " | |
| "Produce **only the final LinkedIn post** text below. " | |
| "Ensure that your output is a polished, self-contained LinkedIn post without any extraneous text.\n\n" | |
| "### FINAL LINKEDIN POST OUTPUT BELOW:\n" | |
| ) | |
| return prompt | |
| def __init__(self, *args, **kwargs): | |
| self.is_initialized = False |