-
Notifications
You must be signed in to change notification settings - Fork 6.9k
updating poem to content use case #5286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| planner: | ||
| role: > | ||
| Content Planner | ||
| goal: > | ||
| Plan a detailed and engaging blog post outline on {topic} | ||
| backstory: > | ||
| You're an experienced content strategist who excels at creating | ||
| structured outlines for blog posts. You know how to organize ideas | ||
| into a logical flow that keeps readers engaged from start to finish. | ||
|
|
||
| writer: | ||
| role: > | ||
| Content Writer | ||
| goal: > | ||
| Write a compelling and well-structured blog post on {topic} | ||
| based on the provided outline | ||
| backstory: > | ||
| You're a skilled writer with a talent for turning outlines into | ||
| engaging, informative blog posts. Your writing is clear, conversational, | ||
| and backed by solid reasoning. You adapt your tone to the subject matter | ||
| while keeping things accessible to a broad audience. | ||
|
|
||
| editor: | ||
| role: > | ||
| Content Editor | ||
| goal: > | ||
| Review and polish the blog post on {topic} to ensure it is | ||
| publication-ready | ||
| backstory: > | ||
| You're a meticulous editor with years of experience refining written | ||
| content. You have an eye for clarity, flow, grammar, and consistency. | ||
| You improve prose without changing the author's voice and ensure every | ||
| piece you touch is polished and professional. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| planning_task: | ||
| description: > | ||
| Create a detailed outline for a blog post about {topic}. | ||
|
|
||
| The outline should include: | ||
| - A compelling title | ||
| - An introduction hook | ||
| - 3-5 main sections with key points to cover in each | ||
| - A conclusion with a call to action | ||
|
|
||
| Make the outline detailed enough that a writer can produce | ||
| a full blog post from it without additional research. | ||
| expected_output: > | ||
| A structured blog post outline with a title, introduction notes, | ||
| detailed section breakdowns, and conclusion notes. | ||
| agent: planner | ||
|
|
||
| writing_task: | ||
| description: > | ||
| Using the outline provided, write a full blog post about {topic}. | ||
|
|
||
| Requirements: | ||
| - Follow the outline structure closely | ||
| - Write in a clear, engaging, and conversational tone | ||
| - Each section should be 2-3 paragraphs | ||
| - Include a strong introduction and conclusion | ||
| - Target around 800-1200 words | ||
| expected_output: > | ||
| A complete blog post in markdown format, ready for editing. | ||
| The post should follow the outline and be well-written with | ||
| clear transitions between sections. | ||
| agent: writer | ||
|
|
||
| editing_task: | ||
| description: > | ||
| Review and edit the blog post about {topic}. | ||
|
|
||
| Focus on: | ||
| - Fixing any grammar or spelling errors | ||
| - Improving sentence clarity and flow | ||
| - Ensuring consistent tone throughout | ||
| - Strengthening the introduction and conclusion | ||
| - Removing any redundancy | ||
|
|
||
| Do not rewrite the post — refine and polish it. | ||
| expected_output: > | ||
| The final, polished blog post in markdown format without '```'. | ||
| Publication-ready with clean formatting and professional prose. | ||
| agent: editor | ||
| output_file: output/post.md |
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,59 +1,60 @@ | ||
| #!/usr/bin/env python | ||
| from random import randint | ||
|
|
||
| from pydantic import BaseModel | ||
|
|
||
| from crewai.flow import Flow, listen, start | ||
|
|
||
| from {{folder_name}}.crews.poem_crew.poem_crew import PoemCrew | ||
| from {{folder_name}}.crews.content_crew.content_crew import ContentCrew | ||
|
|
||
|
|
||
|
|
||
| class PoemState(BaseModel): | ||
| sentence_count: int = 1 | ||
| poem: str = "" | ||
| class ContentState(BaseModel): | ||
| topic: str = "" | ||
| outline: str = "" | ||
| draft: str = "" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused
|
||
| final_post: str = "" | ||
|
|
||
|
|
||
| class PoemFlow(Flow[PoemState]): | ||
| class ContentFlow(Flow[ContentState]): | ||
|
|
||
| @start() | ||
| def generate_sentence_count(self, crewai_trigger_payload: dict = None): | ||
| print("Generating sentence count") | ||
| def plan_content(self, crewai_trigger_payload: dict = None): | ||
| print("Planning content") | ||
|
|
||
| # Use trigger payload if available | ||
| if crewai_trigger_payload: | ||
| # Example: use trigger data to influence sentence count | ||
| self.state.sentence_count = crewai_trigger_payload.get('sentence_count', randint(1, 5)) | ||
| self.state.topic = crewai_trigger_payload.get("topic", "AI Agents") | ||
| print(f"Using trigger payload: {crewai_trigger_payload}") | ||
| else: | ||
| self.state.sentence_count = randint(1, 5) | ||
| self.state.topic = "AI Agents" | ||
|
|
||
| print(f"Topic: {self.state.topic}") | ||
|
|
||
| @listen(generate_sentence_count) | ||
| def generate_poem(self): | ||
| print("Generating poem") | ||
| @listen(plan_content) | ||
| def generate_content(self): | ||
| print(f"Generating content on: {self.state.topic}") | ||
| result = ( | ||
| PoemCrew() | ||
| ContentCrew() | ||
| .crew() | ||
| .kickoff(inputs={"sentence_count": self.state.sentence_count}) | ||
| .kickoff(inputs={"topic": self.state.topic}) | ||
| ) | ||
|
|
||
| print("Poem generated", result.raw) | ||
| self.state.poem = result.raw | ||
| print("Content generated") | ||
| self.state.final_post = result.raw | ||
|
|
||
| @listen(generate_poem) | ||
| def save_poem(self): | ||
| print("Saving poem") | ||
| with open("poem.txt", "w") as f: | ||
| f.write(self.state.poem) | ||
| @listen(generate_content) | ||
| def save_content(self): | ||
| print("Saving content") | ||
| with open("output/post.md", "w") as f: | ||
| f.write(self.state.final_post) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Writing to subdirectory without ensuring it existsMedium Severity
Reviewed by Cursor Bugbot for commit 824586e. Configure here. |
||
| print("Post saved to output/post.md") | ||
|
|
||
|
|
||
| def kickoff(): | ||
| poem_flow = PoemFlow() | ||
| poem_flow.kickoff() | ||
| content_flow = ContentFlow() | ||
| content_flow.kickoff() | ||
|
|
||
|
|
||
| def plot(): | ||
| poem_flow = PoemFlow() | ||
| poem_flow.plot() | ||
| content_flow = ContentFlow() | ||
| content_flow.plot() | ||
|
|
||
|
|
||
| def run_with_trigger(): | ||
|
|
@@ -74,10 +75,10 @@ def run_with_trigger(): | |
|
|
||
| # Create flow and kickoff with trigger payload | ||
| # The @start() methods will automatically receive crewai_trigger_payload parameter | ||
| poem_flow = PoemFlow() | ||
| content_flow = ContentFlow() | ||
|
|
||
| try: | ||
| result = poem_flow.kickoff({"crewai_trigger_payload": trigger_payload}) | ||
| result = content_flow.kickoff({"crewai_trigger_payload": trigger_payload}) | ||
| return result | ||
| except Exception as e: | ||
| raise Exception(f"An error occurred while running the flow with trigger: {e}") | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing
__init__.pyforcontent_crewpackageMedium Severity
The old
poem_crew/__init__.pywas deleted but no correspondingcontent_crew/__init__.pywas created. Thecreate_flow.pycopies crew folders usingrglob("*"), so the generated project'scontent_crewdirectory will lack an__init__.py. The flow'smain.pyimportsfrom {{folder_name}}.crews.content_crew.content_crew import ContentCrew, which may fail or behave unexpectedly without a proper package marker depending on the Python/packaging setup.Reviewed by Cursor Bugbot for commit cf49b3f. Configure here.