Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -183,32 +183,33 @@
"source": [
"from crewai.flow.flow import Flow, listen, start\n",
"from pydantic import BaseModel\n",
"from IPython.display import Markdown, display\n",
"\n",
"\n",
"class TravelAgentFlow(Flow[str]):\n",
" @start()\n",
" async def search_online(self):\n",
" query = \"Best things to do in {self.city}\"\n",
" query = f\"Best things to do in {self.state.get(\"city\")}\"\n",
" result = await researcher_agent.kickoff_async(query)\n",
" return result\n",
"\n",
" @listen(search_online)\n",
" async def write_content(self, search_result):\n",
" query = \"{search_result}\\n\\n Based on the search results, write a listicle of 5 things to do in {self.city}\"\n",
" query = f\"{search_result}\\n\\n Based on the search results, write a listicle of 5 things to do in {self.state.get(\"city\")}\"\n",
" result = await content_writer.kickoff_async(query)\n",
" return result\n",
" \n",
" @listen(write_content)\n",
" async def edit_content(self, listicle):\n",
" query = \"Review and edit the top 5 listicle article about things to do in {self.city}.\\n\\nContent:\\n{listicle}\\n\\nMake sure the content is well-structured, engaging, and error-free.\"\n",
" query = f\"Review and edit the top 5 listicle article about things to do in {self.state.get(\"city\")}.\\n\\nContent:\\n{listicle}\\n\\nMake sure the content is well-structured, engaging, and error-free.\"\n",
" result = await editor_agent.kickoff_async(query)\n",
" return result\n",
"\n",
"# Run the flow\n",
"flow = TravelAgentFlow()\n",
"final_output = await flow.kickoff_async({\"city\": \"Paris\"})\n",
"print(\"---- Final Output ----\")\n",
"print(final_output)"
"display(Markdown(str(final_output)))"
]
},
{
Expand Down