From 1e7df6b16f4bcd33469900584a2cb58e0738bbf6 Mon Sep 17 00:00:00 2001 From: r2rajan Date: Sun, 2 Nov 2025 10:47:57 -0800 Subject: [PATCH] Update crewai-travel-flows.ipynb 1. Added f-string prefix to the query strings 2. You pass {"city":"paris"} to kickoff_async(), but the flow doesn't have a city attribute. You need to access it from the input. Access city via self.state.get("city") instead of self.city 3. Added Display Markdown for the final output --- .../4-frameworks/crewai/crewai-travel-flows.ipynb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/workshops/diy-agents-with-sagemaker-and-bedrock/4-frameworks/crewai/crewai-travel-flows.ipynb b/workshops/diy-agents-with-sagemaker-and-bedrock/4-frameworks/crewai/crewai-travel-flows.ipynb index ede0c63..4ba3196 100644 --- a/workshops/diy-agents-with-sagemaker-and-bedrock/4-frameworks/crewai/crewai-travel-flows.ipynb +++ b/workshops/diy-agents-with-sagemaker-and-bedrock/4-frameworks/crewai/crewai-travel-flows.ipynb @@ -183,24 +183,25 @@ "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", @@ -208,7 +209,7 @@ "flow = TravelAgentFlow()\n", "final_output = await flow.kickoff_async({\"city\": \"Paris\"})\n", "print(\"---- Final Output ----\")\n", - "print(final_output)" + "display(Markdown(str(final_output)))" ] }, {