would you please help me to get output in pydantic format for following agent task
from typing import List, Dict
from pydantic import BaseModel, Field
class CampaignIdea(BaseModel):
post_title: str = Field(…, description=“Title for the post”)
media_type: str = Field(…, description=“Media Type (e.g., Blog, Video)”)
description: str = Field(…, description=“Brief description of the post content”)
class Campaign(BaseModel):
title: str = Field(…, description=“Campaign title”)
content_focus: str = Field(…, description=“Briefly describe the main focus”)
campaign_ideas: List[CampaignIdea] = Field(…, description=“List of campaign ideas”)
class ContentStrategy(BaseModel):
strategy: Dict[str, Campaign] = Field(…, description=“Dictionary of campaigns keyed by campaign ID, starting from 1”)
Define the agent
content_strategy_agent = Agent(
role=“Employer Brand Content Strategist”,
goal=“Create a content strategy that enhances {company}'s employer brand by leveraging employee sentiment data. Focus on attracting new talent by showcasing {company}'s strengths and addressing any negative perceptions.”,
backstory=“An experienced brand strategist skilled in using sentiment data to develop targeted content strategies for talent attraction, emphasizing {company}'s strengths and addressing areas for improvement.”,
verbose=True,
max_iter=3
)
Define the task
content_strategy_task = Task(
description=“”"Given sentiment data about {company}:
- Create a content plan to showcase {company}'s strengths and address any concerns to attract new talent.
- For each sentiment theme (e.g., work culture, management, benefits, etc.), provide content ideas that emphasize {company}'s positive aspects and effectively address areas needing improvement.
Each content idea should include:
- **Title**: A catchy title or theme for the content or campaign.
- **Content Focus**: Briefly describe the focus of the content (e.g., promoting work-life balance or highlighting benefits, etc).
- **Campaign Ideas**: Specific content ideas with post titles, recommended media types, and content overview/description.
Sentiment Data:
{sentiments}
""",
expected_output="""The output should be a structured JSON content strategy for {company} in the following format:
```josn{{
"1":{{
"title":// Campaign title, e.g., "Highlighting Positive Work Culture"
"content_focus": // Briefly describe the main focus, e.g., emphasize {company}'s supportive culture and work-life balance etc.
"campaign_ideas":[ // List of dictionary contains compaign ideas
{{
"post_title": // Title for the post,
"media_type"://Media Type (e.g., Blog, Video),
"description", // Brief description of the post content.
}}
...
]
}}
"2":{{
...
}}
...
}}```
Note: Do not add any pre or post text; directly provide JSON output,
and ensure each section aligns with the provided sentiment data, highlighting {company}'s strengths and addressing any concerns without adding extra context.
""",
output_pydantic = ContentStrategy,
agent=content_strategy_agent
)
content_strategist_crew = Crew(
agents=[content_strategy_agent],
tasks=[
content_strategy_task
],
verbose=2,
)
content_strategist_input = {
‘company’:company_name,
‘sentiments’:company_sentiments
}
content_strategist_response = content_strategist_crew.kickoff(inputs=content_strategist_input)