Spaces:
Sleeping
Sleeping
File size: 3,142 Bytes
6f40147 e0cf105 6f40147 e0cf105 6f40147 e0cf105 7df6567 e0cf105 6f40147 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
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"
"### PROVIDE FINAL LINKEDIN POST OUTPUT BELOW:"
)
return prompt
def __init__(self, *args, **kwargs):
self.is_initialized = False |