{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "79b5811c-1074-495f-9722-8325b5e717d3",
   "metadata": {},
   "source": [
    "# Plan-and-Execute\n",
    "\n",
    "This notebook shows how to create a \"plan-and-execute\" style agent. This is heavily inspired by the [Plan-and-Solve](https://arxiv.org/abs/2305.04091) paper as well as the [Baby-AGI](https://github.com/yoheinakajima/babyagi) project.\n",
    "\n",
    "The core idea is to first come up with a multi-step plan, and then go through that plan one item at a time.\n",
    "After accomplishing a particular task, you can then revisit the plan and modify as appropriate.\n",
    "\n",
    "\n",
    "The general computational graph looks like the following:\n",
    "\n",
    "\n",
    "![plan-and-execute diagram](./img/plan-and-execute.png)\n",
    "\n",
    "\n",
    "This compares to a typical [ReAct](https://arxiv.org/abs/2210.03629) style agent where you think one step at a time.\n",
    "The advantages of this \"plan-and-execute\" style agent are:\n",
    "\n",
    "1. Explicit long term planning (which even really strong LLMs can struggle with)\n",
    "2. Ability to use smaller/weaker models for the execution step, only using larger/better models for the planning step\n",
    "\n",
    "\n",
    "The following walkthrough demonstrates how to do so in LangGraph. The resulting agent will leave a trace like the following example: ([link](https://smith.langchain.com/public/d46e24d3-dda6-44d5-9550-b618fca4e0d4/r))."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a44a72d6-7e0c-4478-9d20-4c09000420a8",
   "metadata": {},
   "source": [
    "## Setup\n",
    "\n",
    "First, we need to install the packages required."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b451b58a-89bd-424f-8c06-0d9fe325e01b",
   "metadata": {},
   "outputs": [],
   "source": ["%%capture --no-stderr\n%pip install --quiet -U langgraph langchain-community langchain-openai tavily-python"]
  },
  {
   "cell_type": "markdown",
   "id": "35f267b0-98db-4a59-8b2c-a23f795576ff",
   "metadata": {},
   "source": [
    "Next, we need to set API keys for OpenAI (the LLM we will use) and Tavily (the search tool we will use)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ce438281-08d5-4804-afe7-e4089f7b016b",
   "metadata": {},
   "outputs": [],
   "source": ["import getpass\nimport os\n\n\ndef _set_env(var: str):\n    if not os.environ.get(var):\n        os.environ[var] = getpass.getpass(f\"{var}: \")\n\n\n_set_env(\"OPENAI_API_KEY\")\n_set_env(\"TAVILY_API_KEY\")"]
  },
  {
   "cell_type": "markdown",
   "id": "be2d7981-3737-4134-8bef-d00d18d4e91d",
   "metadata": {},
   "source": [
    "Optionally, we can set API key for LangSmith tracing, which will give us best-in-class observability."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "01f460d1-f26f-47d1-ae76-de74d5d851de",
   "metadata": {},
   "outputs": [],
   "source": ["os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n_set_env(\"LANGCHAIN_API_KEY\")\nos.environ[\"LANGCHAIN_PROJECT\"] = \"Plan-and-execute\""]
  },
  {
   "cell_type": "markdown",
   "id": "6c5fb09a-0311-44c2-b243-d0e80de78902",
   "metadata": {},
   "source": [
    "## Define Tools\n",
    "\n",
    "We will first define the tools we want to use. For this simple example, we will use a built-in search tool via Tavily. However, it is really easy to create your own tools - see documentation [here](https://python.langchain.com/v0.2/docs/how_to/custom_tools) on how to do that."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "25b9ec62-0675-4715-811c-9b32c635b22f",
   "metadata": {},
   "outputs": [],
   "source": ["from langchain_community.tools.tavily_search import TavilySearchResults\n\ntools = [TavilySearchResults(max_results=3)]"]
  },
  {
   "cell_type": "markdown",
   "id": "3dcda478-fa80-4e3e-bb35-0f622fe73a31",
   "metadata": {},
   "source": [
    "## Define our Execution Agent\n",
    "\n",
    "Now we will create the execution agent we want to use to execute tasks. \n",
    "Note that for this example, we will be using the same execution agent for each task, but this doesn't HAVE to be the case."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "72d233ca-1dbf-4b43-b680-b3bf39e3691f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "================================\u001b[1m System Message \u001b[0m================================\n",
      "\n",
      "You are a helpful assistant.\n",
      "\n",
      "=============================\u001b[1m Messages Placeholder \u001b[0m=============================\n",
      "\n",
      "\u001b[33;1m\u001b[1;3m{{messages}}\u001b[0m\n"
     ]
    }
   ],
   "source": ["from langchain import hub\nfrom langchain_openai import ChatOpenAI\n\nfrom langgraph.prebuilt import create_react_agent\n\n# Get the prompt to use - you can modify this!\nprompt = hub.pull(\"wfh/react-agent-executor\")\nprompt.pretty_print()\n\n# Choose the LLM that will drive the agent\nllm = ChatOpenAI(model=\"gpt-4-turbo-preview\")\nagent_executor = create_react_agent(llm, tools, messages_modifier=prompt)"]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "746e697a-dec4-4342-a814-9b3456828169",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'messages': [HumanMessage(content='who is the winnner of the us open', id='7c491c9f-cdbe-4761-b93b-3e4eeb526c97'),\n",
       "  AIMessage(content='', additional_kwargs={'tool_calls': [{'id': 'call_MMmwmxwxRH2hrmMbuBeMGsXW', 'function': {'arguments': '{\"query\":\"US Open 2023 winner\"}', 'name': 'tavily_search_results_json'}, 'type': 'function'}]}, response_metadata={'token_usage': {'completion_tokens': 23, 'prompt_tokens': 97, 'total_tokens': 120}, 'model_name': 'gpt-4-turbo-preview', 'system_fingerprint': None, 'finish_reason': 'tool_calls', 'logprobs': None}, id='run-855f7cff-62a2-4dd8-b71b-707b507b00a4-0', tool_calls=[{'name': 'tavily_search_results_json', 'args': {'query': 'US Open 2023 winner'}, 'id': 'call_MMmwmxwxRH2hrmMbuBeMGsXW'}]),\n",
       "  ToolMessage(content='[{\"url\": \"https://www.bbc.com/sport/tennis/66766337\", \"content\": \": Stephen Nolan goes in to find out\\\\nRelated Topics\\\\nTop Stories\\\\nTen Hag on Rashford plus transfer news, WSL deadline day\\\\nSpinner Leach doubtful for second Test in India\\\\nMcIlroy \\'changes tune\\' on LIV players\\' punishment\\\\nElsewhere on the BBC\\\\nDiscover the tropical paradise of Thailand\\\\nFrom the secrets of the South to the mysterious North...\\\\n Djokovic offered to help up Medvedev when the Russian fell to the court in the third set\\\\nDjokovic\\'s relentless returning continued to draw mistakes out of Medvedev, who was serving poorly and making loose errors, at the start of the second set.\\\\n It was clear to see Medvedev had needed to level by taking that second set to stand any real chance of victory and the feeling of the inevitable was heightened by the Russian needing treatment on a shoulder injury before the third set.\\\\n Djokovic shows again why he can never be written off\\\\nWhen Djokovic lost to 20-year-old Carlos Alcaraz in the Wimbledon final it felt like a changing-of-the-guard moment in the men\\'s game.\\\\n The inside story of Putin\\\\u2019s invasion of Ukraine\\\\nTold by the Presidents and Prime Ministers tasked with making the critical decisions\\\\nSurvival of the wittiest!\\\\n\"}, {\"url\": \"https://www.usopen.org/en_US/news/articles/2023-09-10/novak_djokovic_wins_24th_grand_slam_singles_title_at_2023_us_open.html\", \"content\": \"WHAT HAPPENED: Novak Djokovic handled the weight of history to defeat Daniil Medvedev on Sunday in the 2023 US Open men\\'s singles final. With a 6-3, 7-6(5), 6-3 victory, the 36-year-old won his 24th Grand Slam singles title, tying Margaret Court\\'s record and bolstering his case to be considered the greatest tennis player of all time.\"}, {\"url\": \"https://apnews.com/article/us-open-final-live-updates-djokovic-medvedev-8a4a26f8d77ef9ab2fb3efe1096dce7e\", \"content\": \"Novak Djokovic wins the US Open for his 24th Grand Slam title by beating Daniil Medvedev\\\\nNovak Djokovic, of Serbia, holds up the championship trophy after defeating Daniil Medvedev, of Russia, in the men\\\\u2019s singles final of the U.S. Open tennis championships, Sunday, Sept. 10, 2023, in New York. (AP Photo/Manu Fernandez)\\\\nDaniil Medvedev, of Russia, sits on the court after a rally against Novak Djokovic, of Serbia, during the men\\\\u2019s singles final of the U.S. Open tennis championships, Sunday, Sept. 10, 2023, in New York. (AP Photo/Manu Fernandez)\\\\nDaniil Medvedev, of Russia, sits on the court after a rally against Novak Djokovic, of Serbia, during the men\\\\u2019s singles final of the U.S. Open tennis championships, Sunday, Sept. 10, 2023, in New York. (AP Photo/Manu Fernandez)\\\\nDaniil Medvedev, of Russia, sits on the court after a rally against Novak Djokovic, of Serbia, during the men\\\\u2019s singles final of the U.S. Open tennis championships, Sunday, Sept. 10, 2023, in New York. Novak Djokovic, of Serbia, reveals a t-shirt honoring the number 24 and Kobe Bryant after defeating Daniil Medvedev, of Russia, in the men\\\\u2019s singles final of the U.S. Open tennis championships, Sunday, Sept. 10, 2023, in New York.\"}]', name='tavily_search_results_json', id='ca0ff812-6c7f-43c1-9d0e-427cfe8da332', tool_call_id='call_MMmwmxwxRH2hrmMbuBeMGsXW'),\n",
       "  AIMessage(content=\"The winner of the 2023 US Open men's singles was Novak Djokovic. He defeated Daniil Medvedev with a score of 6-3, 7-6(5), 6-3 in the final, winning his 24th Grand Slam singles title. This victory tied Margaret Court's record and bolstered Djokovic's claim to be considered one of the greatest tennis players of all time.\", response_metadata={'token_usage': {'completion_tokens': 89, 'prompt_tokens': 972, 'total_tokens': 1061}, 'model_name': 'gpt-4-turbo-preview', 'system_fingerprint': None, 'finish_reason': 'stop', 'logprobs': None}, id='run-ef37a655-1ea6-470e-a310-8f125ca48015-0')]}"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": ["agent_executor.invoke({\"messages\": [(\"user\", \"who is the winnner of the us open\")]})"]
  },
  {
   "cell_type": "markdown",
   "id": "5cf66804-44b2-4904-b1a7-17ad70b551f5",
   "metadata": {},
   "source": [
    "## Define the State\n",
    "\n",
    "Let's now start by defining the state the track for this agent.\n",
    "\n",
    "First, we will need to track the current plan. Let's represent that as a list of strings.\n",
    "\n",
    "Next, we should track previously executed steps. Let's represent that as a list of tuples (these tuples will contain the step and then the result)\n",
    "\n",
    "Finally, we need to have some state to represent the final response as well as the original input."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "8eeeaeea-8f10-4fbe-8e24-4e1a2381a009",
   "metadata": {},
   "outputs": [],
   "source": ["import operator\nfrom typing import Annotated, List, Tuple, TypedDict\n\n\nclass PlanExecute(TypedDict):\n    input: str\n    plan: List[str]\n    past_steps: Annotated[List[Tuple], operator.add]\n    response: str"]
  },
  {
   "cell_type": "markdown",
   "id": "1dbd770a-9941-40a9-977e-4d55359eee21",
   "metadata": {},
   "source": [
    "## Planning Step\n",
    "\n",
    "Let's now think about creating the planning step. This will use function calling to create a plan."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "4a88626d-6dfd-4488-87f0-a9a0dd6da44c",
   "metadata": {},
   "outputs": [],
   "source": ["from langchain_core.pydantic_v1 import BaseModel, Field\n\n\nclass Plan(BaseModel):\n    \"\"\"Plan to follow in future\"\"\"\n\n    steps: List[str] = Field(\n        description=\"different steps to follow, should be in sorted order\"\n    )"]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "ec7b1867-1ea3-4df3-9a98-992a1c32ec49",
   "metadata": {},
   "outputs": [],
   "source": ["from langchain_core.prompts import ChatPromptTemplate\n\nplanner_prompt = ChatPromptTemplate.from_messages(\n    [\n        (\n            \"system\",\n            \"\"\"For the given objective, come up with a simple step by step plan. \\\nThis plan should involve individual tasks, that if executed correctly will yield the correct answer. Do not add any superfluous steps. \\\nThe result of the final step should be the final answer. Make sure that each step has all the information needed - do not skip steps.\"\"\",\n        ),\n        (\"placeholder\", \"{messages}\"),\n    ]\n)\nplanner = planner_prompt | ChatOpenAI(\n    model=\"gpt-4o\", temperature=0\n).with_structured_output(Plan)"]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "67ce37b7-e089-479b-bcb8-c3f5d9874613",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Plan(steps=['Identify the current winner of the Australian Open.', 'Determine the hometown of the identified winner.'])"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": ["planner.invoke(\n    {\n        \"messages\": [\n            (\"user\", \"what is the hometown of the current Australia open winner?\")\n        ]\n    }\n)"]
  },
  {
   "cell_type": "markdown",
   "id": "6e09ad9d-6f90-4bdc-bb43-b1ce94517c29",
   "metadata": {},
   "source": [
    "## Re-Plan Step\n",
    "\n",
    "Now, let's create a step that re-does the plan based on the result of the previous step."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "ec2d12cc-016a-44d1-aa08-4c5ce1e8fe2a",
   "metadata": {},
   "outputs": [],
   "source": ["from typing import Union\n\n\nclass Response(BaseModel):\n    \"\"\"Response to user.\"\"\"\n\n    response: str\n\n\nclass Act(BaseModel):\n    \"\"\"Action to perform.\"\"\"\n\n    action: Union[Response, Plan] = Field(\n        description=\"Action to perform. If you want to respond to user, use Response. \"\n        \"If you need to further use tools to get the answer, use Plan.\"\n    )\n\n\nreplanner_prompt = ChatPromptTemplate.from_template(\n    \"\"\"For the given objective, come up with a simple step by step plan. \\\nThis plan should involve individual tasks, that if executed correctly will yield the correct answer. Do not add any superfluous steps. \\\nThe result of the final step should be the final answer. Make sure that each step has all the information needed - do not skip steps.\n\nYour objective was this:\n{input}\n\nYour original plan was this:\n{plan}\n\nYou have currently done the follow steps:\n{past_steps}\n\nUpdate your plan accordingly. If no more steps are needed and you can return to the user, then respond with that. Otherwise, fill out the plan. Only add steps to the plan that still NEED to be done. Do not return previously done steps as part of the plan.\"\"\"\n)\n\n\nreplanner = replanner_prompt | ChatOpenAI(\n    model=\"gpt-4o\", temperature=0\n).with_structured_output(Act)"]
  },
  {
   "cell_type": "markdown",
   "id": "859abd13-6ba0-45ad-b341-e652dd5f755b",
   "metadata": {},
   "source": [
    "## Create the Graph\n",
    "\n",
    "We can now create the graph!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "6c8e0dad-bcea-4c9a-8922-0d820892e2d0",
   "metadata": {},
   "outputs": [],
   "source": ["from typing import Literal\n\n\nasync def execute_step(state: PlanExecute):\n    plan = state[\"plan\"]\n    plan_str = \"\\n\".join(f\"{i+1}. {step}\" for i, step in enumerate(plan))\n    task = plan[0]\n    task_formatted = f\"\"\"For the following plan:\n{plan_str}\\n\\nYou are tasked with executing step {1}, {task}.\"\"\"\n    agent_response = await agent_executor.ainvoke(\n        {\"messages\": [(\"user\", task_formatted)]}\n    )\n    return {\n        \"past_steps\": (task, agent_response[\"messages\"][-1].content),\n    }\n\n\nasync def plan_step(state: PlanExecute):\n    plan = await planner.ainvoke({\"messages\": [(\"user\", state[\"input\"])]})\n    return {\"plan\": plan.steps}\n\n\nasync def replan_step(state: PlanExecute):\n    output = await replanner.ainvoke(state)\n    if isinstance(output.action, Response):\n        return {\"response\": output.action.response}\n    else:\n        return {\"plan\": output.action.steps}\n\n\ndef should_end(state: PlanExecute) -> Literal[\"agent\", \"__end__\"]:\n    if \"response\" in state and state[\"response\"]:\n        return \"__end__\"\n    else:\n        return \"agent\""]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "e954cea0-5ccc-46c2-a27b-f5b7185b597d",
   "metadata": {},
   "outputs": [],
   "source": ["from langgraph.graph import StateGraph, START\n\nworkflow = StateGraph(PlanExecute)\n\n# Add the plan node\nworkflow.add_node(\"planner\", plan_step)\n\n# Add the execution step\nworkflow.add_node(\"agent\", execute_step)\n\n# Add a replan node\nworkflow.add_node(\"replan\", replan_step)\n\nworkflow.add_edge(START, \"planner\")\n\n# From plan we go to agent\nworkflow.add_edge(\"planner\", \"agent\")\n\n# From agent, we replan\nworkflow.add_edge(\"agent\", \"replan\")\n\nworkflow.add_conditional_edges(\n    \"replan\",\n    # Next, we pass in the function that will determine which node is called next.\n    should_end,\n)\n\n# Finally, we compile it!\n# This compiles it into a LangChain Runnable,\n# meaning you can use it as you would any other runnable\napp = workflow.compile()"]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "7363e528",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/jpeg": "[encoded data, 12544 characters]",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": ["from IPython.display import Image, display\n\ndisplay(Image(app.get_graph(xray=True).draw_mermaid_png()))"]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "b8ac1f67-e87a-427c-b4f7-44351295b788",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'plan': ['Identify the winner of the 2024 Australian Open.', 'Determine the hometown of the identified winner.']}\n",
      "{'past_steps': ('Identify the winner of the 2024 Australian Open.', 'The winner of the 2024 Australian Open is Jannik Sinner. He claimed his first Grand Slam title in an epic comeback win over Daniil Medvedev.')}\n",
      "{'plan': ['Determine the hometown of Jannik Sinner.']}\n",
      "{'past_steps': ('Determine the hometown of Jannik Sinner.', \"Jannik Sinner's hometown is not directly mentioned in the provided excerpts. To ensure accurate information, it's advisable to check a reliable source like his official ATP profile or a detailed biography which often includes personal background details such as hometown.\")}\n",
      "{'plan': [\"Check Jannik Sinner's official ATP profile or a detailed biography to find his hometown.\", 'Return the hometown of Jannik Sinner.']}\n",
      "{'past_steps': (\"Check Jannik Sinner's official ATP profile or a detailed biography to find his hometown.\", \"Jannik Sinner's official ATP profile can be found at this URL: [ATP Tour - Jannik Sinner](https://www.atptour.com/en/players/jannik-sinner/s0ag/overview). This profile will contain detailed information including his biography, rankings, playing activity, and potentially his hometown.\")}\n",
      "{'plan': [\"Visit Jannik Sinner's official ATP profile or a detailed biography to find his hometown.\", 'Return the hometown of Jannik Sinner.']}\n",
      "{'past_steps': (\"Visit Jannik Sinner's official ATP profile or a detailed biography to find his hometown.\", \"Jannik Sinner's official ATP profile and other reliable sources do not explicitly mention his hometown in the search results provided. For detailed information, visiting his ATP profile directly or consulting a comprehensive biography would be recommended to find this specific information.\")}\n",
      "{'plan': [\"Visit Jannik Sinner's official ATP profile or a detailed biography to find his hometown.\", 'Return the hometown of Jannik Sinner.']}\n",
      "{'past_steps': (\"Visit Jannik Sinner's official ATP profile or a detailed biography to find his hometown.\", \"Jannik Sinner's official ATP profile can be accessed [here](https://www.atptour.com/en/players/jannik-sinner/s0ag/overview), although it does not directly provide his hometown in the snippet. For detailed information, such as his hometown, it might be necessary to visit the profile directly or consult other detailed biographies like the one available on [Wikipedia](https://en.wikipedia.org/wiki/Jannik_Sinner), which often include personal details such as hometowns.\")}\n",
      "{'plan': [\"Visit Jannik Sinner's official ATP profile or his Wikipedia page to find his hometown.\", 'Return the hometown of Jannik Sinner.']}\n",
      "{'past_steps': (\"Visit Jannik Sinner's official ATP profile or his Wikipedia page to find his hometown.\", \"Jannik Sinner's official ATP profile and Wikipedia page did not directly mention his hometown in the provided excerpts. However, further information can typically be found by visiting the full pages directly through the provided links:\\n\\n- [Jannik Sinner's ATP Tour Profile](https://www.atptour.com/en/players/jannik-sinner/s0ag/overview)\\n- [Jannik Sinner's Wikipedia Page](https://en.wikipedia.org/wiki/Jannik_Sinner)\\n\\nFor detailed information, including his hometown, I recommend checking these sources.\")}\n",
      "{'response': 'The necessary steps to find the hometown of the 2024 Australian Open winner, Jannik Sinner, have already been completed. His hometown is Innichen, Italy.'}\n"
     ]
    }
   ],
   "source": ["config = {\"recursion_limit\": 50}\ninputs = {\"input\": \"what is the hometown of the 2024 Australia open winner?\"}\nasync for event in app.astream(inputs, config=config):\n    for k, v in event.items():\n        if k != \"__end__\":\n            print(v)"]
  },
  {
   "cell_type": "markdown",
   "id": "8bf585a9-0f1e-4910-bd00-65e7bb05b6e6",
   "metadata": {},
   "source": [
    "## Conclusion\n",
    "\n",
    "Congrats on making a plan-and-execute agent! One known limitations of the above design is that each task is still executed in sequence, meaning embarrassingly parallel operations all add to the total execution time. You could improve on this by having each task represented as a DAG (similar to LLMCompiler), rather than a regular list."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ad8f7955-2cc9-4ebb-8c41-13abb3351a24",
   "metadata": {},
   "outputs": [],
   "source": [""]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
