{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "492f050f-3dc3-44fa-8fdc-03362afd5488",
   "metadata": {},
   "source": [
    "# Reflection\n",
    "\n",
    "\n",
    "In the context of LLM agent building, reflection refers to the process of prompting an LLM to observe its past steps (along with potential observations from tools/the environment) to assess the quality of the chosen actions.\n",
    "This is then used downstream for things like re-planning, search, or evaluation.\n",
    "\n",
    "![Reflection](./img/reflection.png)\n",
    "\n",
    "This notebook demonstrates a very simple form of reflection in LangGraph."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3ef94e7e-c9a5-4eee-a865-acf411b5c235",
   "metadata": {},
   "source": [
    "#### Prerequisites\n",
    "\n",
    "We will be using a basic agent with a search tool here."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "8b323f43-328b-4b4b-88b0-6c84dc0a1d60",
   "metadata": {},
   "outputs": [],
   "source": [
    "%pip install -U --quiet  langgraph langchain-fireworks\n",
    "%pip install -U --quiet tavily-python"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "3368f330-cad6-4d35-a291-68fbf4389d98",
   "metadata": {},
   "outputs": [],
   "source": [
    "import getpass\n",
    "import os\n",
    "\n",
    "\n",
    "def _set_if_undefined(var: str) -> None:\n",
    "    if os.environ.get(var):\n",
    "        return\n",
    "    os.environ[var] = getpass.getpass(var)\n",
    "\n",
    "\n",
    "# Optional: Configure tracing to visualize and debug the agent\n",
    "_set_if_undefined(\"LANGCHAIN_API_KEY\")\n",
    "os.environ[\"LANGCHAIN_TRACING_V2\"] = \"true\"\n",
    "os.environ[\"LANGCHAIN_PROJECT\"] = \"Reflection\"\n",
    "\n",
    "_set_if_undefined(\"FIREWORKS_API_KEY\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f27bcc4a-aaa5-46bd-8163-3e0e90cb66e6",
   "metadata": {},
   "source": [
    "## Generate\n",
    "\n",
    "For our example, we will create a \"5 paragraph essay\" generator. First, create the generator:\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "cc10028f-9cef-4936-9419-cbdf06d24f1e",
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain_core.messages import AIMessage, BaseMessage, HumanMessage\n",
    "from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder\n",
    "from langchain_fireworks import ChatFireworks\n",
    "\n",
    "prompt = ChatPromptTemplate.from_messages(\n",
    "    [\n",
    "        (\n",
    "            \"system\",\n",
    "            \"You are an essay assistant tasked with writing excellent 5-paragraph essays.\"\n",
    "            \" Generate the best essay possible for the user's request.\"\n",
    "            \" If the user provides critique, respond with a revised version of your previous attempts.\",\n",
    "        ),\n",
    "        MessagesPlaceholder(variable_name=\"messages\"),\n",
    "    ]\n",
    ")\n",
    "llm = ChatFireworks(\n",
    "    model=\"accounts/fireworks/models/mixtral-8x7b-instruct\",\n",
    "    model_kwargs={\"max_tokens\": 32768},\n",
    ")\n",
    "generate = prompt | llm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "9bbe25dc-fd1e-4ed5-a3c8-fed830b46d12",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Title: The Relevance of The Little Prince in Modern Childhood\n",
      "\n",
      "The Little Prince, a novella by Antoine de Saint-Exupéry, has been a childhood favorite for generations. Despite being published over seven decades ago, its timeless themes continue to resonate with modern children, making it highly relevant in contemporary childhood.\n",
      "\n",
      "Firstly, the story explores the complex nature of human relationships, which is particularly relevant for modern children growing up in an increasingly connected yet impersonal world. Through the little prince's encounters with various grown-ups on different planets, the book highlights the importance of genuine connections and understanding. In an age where digital communication often replaces face-to-face interaction, this message is more pertinent than ever. The Little Prince encourages children to look beyond superficial relationships and seek deeper connections, fostering empathy and emotional intelligence.\n",
      "\n",
      "Secondly, the book deals with the concept of responsibility and self-discovery, elements that are integral to a child's growth. The little prince's journey is essentially a quest for self-discovery, leading him to realize his responsibility towards his beloved rose. This narrative encourages modern children to embrace their individuality while understanding the significance of their actions. In a society that often overlooks the emotional well-being of children, The Little Prince offers a refreshing perspective on personal growth and responsibility.\n",
      "\n",
      "Thirdly, the book addresses the challenging theme of loss and bereavement. The little prince's departure from his asteroid and his subsequent encounters with the fox and the snake are profound reflections on the inevitability of loss and the importance of cherishing relationships. In a time when children are exposed to various forms of loss, from the death of loved ones to environmental degradation, The Little Prince provides a gentle yet powerful way to understand and cope with these experiences.\n",
      "\n",
      "However, some critics argue that the book's pace and abstract concepts might be challenging for modern children with short attention spans. To address this, a revised version could incorporate more visual elements and interactive activities to engage young readers better. Additionally, supplementary materials explaining the book's themes in simpler terms could be provided for parents and educators to use in discussions with children.\n",
      "\n",
      "In conclusion, The Little Prince remains relevant in modern childhood due to its exploration of human relationships, self-discovery, and loss. These themes, wrapped in a captivating narrative, offer valuable lessons for modern children. While some adaptations may be necessary to cater to the preferences of today's children, the essence of the story remains a powerful tool for teaching emotional intelligence, personal growth, and resilience."
     ]
    }
   ],
   "source": [
    "essay = \"\"\n",
    "request = HumanMessage(\n",
    "    content=\"Write an essay on why the little prince is relevant in modern childhood\"\n",
    ")\n",
    "for chunk in generate.stream({\"messages\": [request]}):\n",
    "    print(chunk.content, end=\"\")\n",
    "    essay += chunk.content"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b0b276e7-c392-4eec-be75-c77bd130379d",
   "metadata": {},
   "source": [
    "### Reflect"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "a705be92-88c0-4f4f-b4c2-cdcd9af8cb2c",
   "metadata": {},
   "outputs": [],
   "source": [
    "reflection_prompt = ChatPromptTemplate.from_messages(\n",
    "    [\n",
    "        (\n",
    "            \"system\",\n",
    "            \"You are a teacher grading an essay submission. Generate critique and recommendations for the user's submission.\"\n",
    "            \" Provide detailed recommendations, including requests for length, depth, style, etc.\",\n",
    "        ),\n",
    "        MessagesPlaceholder(variable_name=\"messages\"),\n",
    "    ]\n",
    ")\n",
    "reflect = reflection_prompt | llm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "16c5eb2a-8bce-48ab-b87d-9dacb9b64ac6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Essay Grade: B+\n",
      "\n",
      "The essay you submitted provides a clear and well-structured argument about the relevance of The Little Prince in modern childhood. You have demonstrated a strong understanding of the text and its themes, and have effectively applied them to the context of contemporary childhood. However, there are some areas where improvement could be made to enhance the depth, style, and overall flow of your essay.\n",
      "\n",
      "1. Length: While your essay is well-written and informative, it is relatively brief. Expanding on each point with more detailed analysis and examples would strengthen your argument and demonstrate a more comprehensive understanding of the text. Aim for a minimum of 500 words to allow for a more in-depth exploration of your ideas.\n",
      "\n",
      "2. Depth: Although you have touched upon the relevance of the novel's themes, further analysis is needed to truly establish its significance in modern childhood. For example, when discussing the complex nature of human relationships, delve into how the digital age affects children's communication skills, and how The Little Prince addresses this issue. Providing concrete examples from the text and connecting them to real-world scenarios will make your argument more compelling.\n",
      "\n",
      "3. Style: To engage your readers more effectively, consider varying your sentence structure and length. Using a mix of simple, compound, and complex sentences will improve the flow of your essay and make it more engaging to read. Additionally, watch your tense consistency. Ensure that you maintain the same tense throughout your essay to avoid confusion.\n",
      "\n",
      "4. Recommendations: While your suggestions for adaptation are a good start, they could be expanded upon to provide more comprehensive recommendations. For example, you may want to discuss different methods of incorporating visual elements and interactive activities, such as illustrations, quizzes, or discussion questions. This will demonstrate that you have thoughtfully considered the needs of modern children and have developed strategies to address these challenges.\n",
      "\n",
      "5. Conclusion: Your conclusion could benefit from a stronger summarization of your key points and an assertive final statement about the relevance of The Little Prince in modern childhood. Tying all your arguments together in a concise and powerful manner will leave a lasting impression on your readers and solidify your position.\n",
      "\n",
      "Overall, your essay is well-researched and provides a solid foundation for a compelling argument about the relevance of The Little Prince in modern childhood. With some expansion, deeper analysis, and stylistic improvements, your essay can achieve an even higher level of excellence."
     ]
    }
   ],
   "source": [
    "reflection = \"\"\n",
    "for chunk in reflect.stream({\"messages\": [request, HumanMessage(content=essay)]}):\n",
    "    print(chunk.content, end=\"\")\n",
    "    reflection += chunk.content"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6daf926c-1174-4e96-91b9-57c57cfce40d",
   "metadata": {},
   "source": [
    "### Repeat\n",
    "\n",
    "And... that's all there is too it! You can repeat in a loop for a fixed number of steps, or use an LLM (or other check) to decide when the finished product is good enough."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "dfbf99a8-3aa0-4e09-936e-8452c35fa84d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Title: The Relevance of The Little Prince in Modern Childhood: A Contemporary Analysis\n",
      "\n",
      "In the digital age, where human connections are often overshadowed by virtual communication, Antoine de Saint-Exupéry's The Little Prince remains a timeless classic that offers invaluable insights for modern children. This essay aims to delve deeper into the relevance of this novella in contemporary childhood, focusing on the complex nature of human relationships, self-discovery, and the inevitability of loss.\n",
      "\n",
      "Firstly, The Little Prince offers a powerful critique of the superficiality that permeates the digital world. Through the little prince's encounters with various grown-ups, the book emphasizes the importance of genuine connections and understanding. Despite being published in 1943, Saint-Exupéry's work uncannily predicts the isolating effects of technology on human interaction. It encourages children to seek deeper connections, fostering empathy and emotional intelligence. For instance, the little prince's relationship with the fox teaches him that \"the eyes are blind, and you have to look with the heart\" (Saint-Exupéry, 1943, p. 48). In the context of modern childhood, where children are increasingly dependent on digital devices, this message is more pertinent than ever.\n",
      "\n",
      "Secondly, The Little Prince addresses the challenges of self-discovery and responsibility faced by modern children. The little prince's journey to Earth can be seen as an exploration of his individuality and understanding of his role in the world. His relationship with the rose illustrates the significance of taking responsibility for one's actions. In the current world, where children are often left to navigate their personal growth without proper guidance, the book offers a refreshing perspective on self-discovery, responsibility, and the importance of inner beauty.\n",
      "\n",
      "Thirdly, The Little Prince offers a nuanced understanding of loss and bereavement, which is increasingly relevant to modern children. Through the little prince's departure from his asteroid and his subsequent encounters with the fox and the snake, Saint-Exupéry delivers a profound reflection on the inevitability of loss and the importance of cherishing relationships. As children grapple with issues like environmental degradation, bullying, or the death of loved ones, The Little Prince provides a gentle yet powerful way to understand and cope with these experiences.\n",
      "\n",
      "However, as noted by critics, the book's abstract language and lengthy monologues may present challenges for some modern children. To address this, adaptations can be made to better align the book with their preferences and needs. For instance, incorporating more visual elements such as illustrations can help maintain engagement, while interactive activities like quizzes or discussion questions can deepen understanding. Furthermore, supplementary materials explaining the book's themes in simpler terms can aid parents and educators in guiding children through complex discussions.\n",
      "\n",
      "In conclusion, The Little Prince remains a powerful and enduring narrative for modern children as it delves into the complex nature of human relationships, self-discovery, and loss. With thoughtful adaptations and insightful guidance, this timeless classic can continue to guide young readers through their personal growth and emotional development. The Little Prince truly is a testament to the power of literature as a vehicle for conveying universal truths and emotions, making it an indispensable part of childhood reading experiences."
     ]
    }
   ],
   "source": [
    "for chunk in generate.stream(\n",
    "    {\"messages\": [request, AIMessage(content=essay), HumanMessage(content=reflection)]}\n",
    "):\n",
    "    print(chunk.content, end=\"\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b63a9d93-a14d-4e41-a4bb-a4cd31713f44",
   "metadata": {},
   "source": [
    "## Define graph\n",
    "\n",
    "Now that we've shown each step in isolation, we can wire it up in a graph."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "9e9a9d7c-5d2e-4194-b745-4511ec20db76",
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import Annotated, List, Sequence\n",
    "from langgraph.graph import END, StateGraph, START\n",
    "from langgraph.graph.message import add_messages\n",
    "from typing_extensions import TypedDict\n",
    "\n",
    "\n",
    "class State(TypedDict):\n",
    "    messages: Annotated[list, add_messages]\n",
    "\n",
    "    \n",
    "async def generation_node(state: Sequence[BaseMessage]):\n",
    "    return await generate.ainvoke({\"messages\": state})\n",
    "\n",
    "\n",
    "async def reflection_node(messages: Sequence[BaseMessage]) -> List[BaseMessage]:\n",
    "    # Other messages we need to adjust\n",
    "    cls_map = {\"ai\": HumanMessage, \"human\": AIMessage}\n",
    "    # First message is the original user request. We hold it the same for all nodes\n",
    "    translated = [messages[0]] + [\n",
    "        cls_map[msg.type](content=msg.content) for msg in messages[1:]\n",
    "    ]\n",
    "    res = await reflect.ainvoke({\"messages\": translated})\n",
    "    # We treat the output of this as human feedback for the generator\n",
    "    return HumanMessage(content=res.content)\n",
    "\n",
    "\n",
    "builder = StateGraph(State)\n",
    "builder.add_node(\"generate\", generation_node)\n",
    "builder.add_node(\"reflect\", reflection_node)\n",
    "builder.add_edge(START, \"generate\")\n",
    "\n",
    "\n",
    "def should_continue(state: List[BaseMessage]):\n",
    "    if len(state) > 6:\n",
    "        # End after 3 iterations\n",
    "        return END\n",
    "    return \"reflect\"\n",
    "\n",
    "\n",
    "builder.add_conditional_edges(\"generate\", should_continue)\n",
    "builder.add_edge(\"reflect\", \"generate\")\n",
    "graph = builder.compile()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "06263a07-8a15-4ec3-b692-1c6cef3b1c1f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'generate': AIMessage(content=\"Title: The Enduring Relevance of The Little Prince: A Timeless Message for Modern Life\\n\\nIntroduction:\\nAntoine de Saint-Exupéry's The Little Prince is a canonical work of literature, beloved by generations since its publication in 1943. The novella has been translated into more than 250 languages and sold over 140 million copies, making it one of the best-selling books of all time. Its enchanting story transcends cultural boundaries and continues to captivate audiences of all ages. The Little Prince's timeless message remains relevant in modern life, offering insightful commentary on themes such as love, loneliness, responsibility, and the superficiality of the adult world. In this essay, we will discuss the topicality of The Little Prince and its enduring message in today's fast-paced, digitally-connected society.\\n\\nBody Paragraph 1 - Love and Loneliness:\\nOne of the most enduring aspects of The Little Prince is its exploration of love and relationships in a world plagued by superficiality. The Little Prince's encounters with the fox, the rose, and his pilot reveal the importance of genuine connections and the pain of loss. In today's modern era, characterized by increasing social isolation, the message of The Little Prince serves as a reminder of the crucial role empathy and understanding play in fostering meaningful relationships. The consequences of isolation, depression, and loneliness continue to grow in modern life, making Saint-Exupéry's exploration of love and loneliness as vital now as it was then.\\n\\nBody Paragraph 2 - Responsibility and Self-Discovery:\\nThroughout the novella, Saint-Exupéry emphasizes the significance of taking responsibility and learning from one's experiences—core components of personal growth and self-discovery. The Little Prince's journey to various planets, each inhabited by an absurd, self-absorbed grown-up, reflects on the responsibility people have to learn from their actions and understand their impact on others. The modern world demands people to navigate complex social, professional, and personal situations daily. Thus, The Little Prince's lessons in responsibility and self-discovery are essential when addressing pressing issues like mental health, self-awareness, and communication in contemporary society.\\n\\nBody Paragraph 3 - The Superficiality of the Adult World:\\nCritics often discuss the novella's critique of the superficiality of the adult world, which remains relevant today, given society's heightened emphasis on materialism and status. The Little Prince's encounters with businessmen and geographers represent the folly of misunderstanding values and blindly pursuing worldly possessions. Today's capitalist societies frequently struggle to balance priorities, often rewarding materialistic pursuits over the development of meaningful relationships. The Little Prince serves as a profound reminder to maintain a sense of perspective, recognize the importance of intangible connections, and avoid the trappings of superficiality.\\n\\nConclusion:\\nUltimately, The Little Prince continues to top bestseller lists because its themes of love, loneliness, responsibility, and the superficiality of the adult world resonate with people across time and culture. The novella's resilient popularity and topicality reflect its relevance in tackling contemporary societal issues, making it a timeless masterpiece that transcends generations. As we navigate the complexities of modern life, The Little Prince's message is one we should keep close to our hearts: we must never lose sight of the simple, yet profound, lessons the story teaches us about cherishing meaningful connections, embracing personal growth, and resisting the shallow temptations of adult life.\\n\\nRevised Essay:\\n\\nTitle: The Enduring Relevance of The Little Prince: Timeless Lessons for the 21st Century\\n\\nIntroduction:\\nAntoine de Saint-Exupéry's The Little Prince is an enduring classic that has touched the hearts of millions since its publication in 1943. The novella has been translated into more than 300 languages, and over 200 million copies have been sold, making it one of the bestselling books ever written. The Little Prince's timeless message about love, friendship, responsibility, and the adult world remains incredibly relevant in the 21st century. This essay will analyze the topicality of The Little Prince and explore the many ways its universal themes connect with modern life.\\n\\nBody Paragraph 1 - Love, Loss, and Friendship:\\nThe Little Prince teaches powerful lessons about love, friendship, and loss that continue to resonate with readers today. The novella's exploration of grief and heartache is as poignant today as it was when it was first published. The tales of the Little Prince's encounters with the fox, the rose, and his pilot highlight the transcendent power of meaningful connections and the pain of losing those we care about. In a digital age where fleeting online interactions can dominate our time, The Little Prince serves as a reminder to cherish genuine friendships and treasure the connections we make with others.\\n\\nBody Paragraph 2 - Responsibility, Personal Growth, and Emotional Intelligence:\\nThroughout the story, Saint-Exupéry highlights the significance of taking responsibility and engaging in self-discovery. The Little Prince's journey to various planets, each inhabited by a reductive grown-up, teaches the reader about the impact actions can have on others. In a world where emotional intelligence and empathy are increasingly vital due to ever-evolving social, professional, and personal obligations, The Little Prince's lessons on responsibility and personal growth remain crucial. Mental health, self-awareness, and communication are critical issues in modern society, making the exploration of these themes as essential in today's world as when the book was first published.\\n\\nBody Paragraph 3 - Rejecting the Superficiality of the Adult World:\\nThe Little Prince's critique of the superficiality of the adult world remains strikingly relevant in modern society. The novel's portrait of grown-ups consumed by materialism, social status, and vanity rings true today, more than ever, as individuals and societies race to acquire wealth, status, and possessions. The Little Prince serves as a poignant reminder to resist the superficiality of the adult world and maintain a balanced perspective, cherishing meaningful connections and eschewing the trappings of materialism.\\n\\nConclusion:\\nThe Little Prince's universal themes continue to captivate and inspire readers because the lessons it teaches about love, friendship, responsibility, and the adult world are still incredibly pertinent today. The novel's topicality and enduring popularity validate its relevance in addressing contemporary societal issues like mental health, self-awareness, communication, and materialism. As we maneuver the challenges of the 21st century, The Little Prince's enduring wisdom—to cherish deep relationships, value personal growth, and reject the superficiality of adult life—continues to resonate and encourage readers to reassess their priorities and find meaning in connection and experience.\")}\n",
      "---\n",
      "{'reflect': HumanMessage(content=\"Introduction:\\nThe essay provides a solid introduction to the topic, clearly stating the book's significance and its continued relevance in modern life. I would suggest providing more specific connections to the present day to emphasize the enduring relevance of The Little Prince. For instance, you could mention current events or issues that are directly related to the themes discussed in Saint-Exupéry's work (e.g., studies on loneliness and mental health in the digital age).\\n\\nBody Paragraph 1 - Love and Loneliness:\\nThe paragraph effectively explains how the themes of love and loneliness resonate with the modern era. However, I would like to see more concrete examples from the book to strengthen the analysis. Consider providing a specific interaction or quote from The Little Prince to more directly tie it to the concepts of isolation, depression, and loneliness in today's world.\\n\\nBody Paragraph 2 - Responsibility and Self-Discovery:\\nThis paragraph provides a good analysis of how Saint-Exupéry emphasizes responsibility and self-discovery. However, it could benefit from a stronger connection to contemporary society. It would be helpful to provide examples from real-life situations or psychological studies that demonstrate the importance of mental health, self-awareness, and communication in today's world.\\n\\nBody Paragraph 3 - The Superficiality of the Adult World:\\nThe criticism of materialism and status in modern society is well-presented in this paragraph. However, you could strengthen the analysis by offering specific examples of the adult world's superficiality in the context of the 21st century, such as a focus on social media and online presence. Moreover, consider further elaborating on the contrast between the materialistic world and The Little Prince's emphasis on meaningful relationships.\\n\\nConclusion:\\nThe conclusion effectively summarizes the importance of the themes addressed in the novel. Nonetheless, it could benefit from a stronger final statement that reiterates the significance of the stories and lessons from The Little Prince in the modern context. Consider restating the main ideas in a way that reinforces the parallels between the book and contemporary life.\\n\\nOverall, I would encourage you to strengthen the connections between the novel's themes and modern society by providing more specific examples and relevant real-world issues. Furthermore, I recommend a word count of around 1,200-1,500 words for your essay to provide enough space to thoroughly analyze and discuss the topics presented. By offering a more in-depth analysis, your argument would become more persuasive and the relevance of the novel even more apparent.\")}\n",
      "---\n",
      "{'generate': AIMessage(content='Title: The Enduring Relevance of The Little Prince: Timeless Lessons for the 21st Century\\n\\nIntroduction:\\nAntoine de Saint-Exupéry\\'s The Little Prince continues to hold significance in modern life, touching the hearts of millions since its publication in 1943. With over 200 million copies sold and translations in more than 300 languages, its universal themes of love, friendship, responsibility, and the adult world resonate profoundly today (Soucy & Vedel, 2018). Today\\'s society faces a myriad of challenges, including increasing social isolation, mental health issues, and materialism. This essay will explore the novel\\'s powerful impact by offering concrete examples of its relevance in modern life and discussing the themes in the context of studies on loneliness, personal growth, and superficiality in the digital age.\\n\\nBody Paragraph 1 - Love, Loneliness, and Isolation:\\nThe Little Prince\\'s depiction of love and loneliness in various forms—between the prince and his rose, the fox, and the pilot—provides powerful insights into addressing isolation in the 21st century. In a study conducted by McPherson, Smith-Lovin, and Brashears (2006), they revealed an alarming decline in the number of confidants in individuals\\' lives, indicating growing isolation. Specifically, over the past two decades, the percentage of people who claim to have no one they can discuss important issues with has doubled (McPherson, Smith-Lovin, & Brashears, 2006). The Little Prince\\'s portrayal of the prince\\'s loneliness and his encounters with a variety of inhabitants emphasizes the importance of genuine companionship, transcending cultural barriers.\\n\\nBody Paragraph 2 - Responsibility, Personal Growth, and Emotional Intelligence:\\nPersonal growth, responsibility, and self-awareness are vital themes in The Little Prince, which remain crucial for navigating the challenges of the 21st century. With increasing emphasis on mental health and well-being worldwide, Saint-Exupéry\\'s exploration of self-awareness and personal growth is highly relevant. The Little Prince\\'s encounters with grown-ups on various planets reveal the trappings of vanity, authority, and materialism (Soucy & Vedel, 2018). In response to the pressures of adulthood and rigid expectations, the novel advocates for personal growth and responsibility as essential ingredients for emotional intelligence. Research connecting emotional intelligence to mental health underscores the significance of the ideas presented in The Little Prince, demonstrating that higher emotional intelligence is positively associated with mental health and well-being (Schutte et al., 2001). This research supports the notion that the personal growth explored in The Little Prince remains a vital part of addressing mental health issues.\\n\\nBody Paragraph 3 - Materialism, Superficiality, and Social Media:\\nThe Little Prince critiques the materialistic and superficial nature of the adult world, which is acutely visible in today\\'s digital age and social media-dominated society. For instance, the novel\\'s third chapter introduces the businessman, who spends his life counting stars, believing that \"owning\" them brings him both fame and fortune. This behavior can be likened to the modern obsession with online presence and an obsession with acquiring digital \"followers\" and \"likes.\" By highlighting the emptiness of the materialistic pursuits, The Little Prince shows readers the importance of genuine human connections and rejecting superficial distractions (Soucy & Vedel, 2018). These themes are particularly relevant today, as younger generations struggle to find balance between their online and offline lives, frequently confronted with issues related to superficiality, self-promotion, and digital personas.\\n\\nConclusion:\\nThe Little Prince is an enduring classic that offers timeless lessons on love, friendship, responsibility, and the superficiality of the adult world, which remain highly relevant today. In the context of the digital age and its myriad challenges, the novel\\'s exploration of personal growth, mental health, materialism, and loneliness provides critical insights for contemporary society. The Little Prince reminds us to cherish and foster deep, meaningful relationships, engage in self-discovery, and resist the superficiality of the adult world. By doing so, we can preserve the essence of human connection and continue to find relevance in the novel\\'s wisdom and the importance of its messages in our  daily lives.')}\n",
      "---\n",
      "{'reflect': HumanMessage(content=\"The revised essay now provides a more in-depth analysis of the novel's themes and their relevance in the context of modern society, studies on loneliness, personal growth, and superficiality. The addition of specific examples from both the book and real-world research strengthens the argument, bolstering the claim that The Little Prince remains a timeless and relevant work in the 21st century. Overall, the essay conveys a thorough exploration of the novel's impact and significance.\")}\n",
      "---\n",
      "{'generate': AIMessage(content='Title: The Enduring Relevance of The Little Prince: Timeless Lessons for the 21st Century\\n\\nIntroduction:\\nAntoine de Saint-Exupéry\\'s The Little Prince continues to hold significance in modern life, touching the hearts of millions since its publication in 1943. With over 200 million copies sold and translations in more than 300 languages, its universal themes of love, friendship, responsibility, and the adult world resonate profoundly today (Soucy & Vedel, 2018). Today\\'s society faces a myriad of challenges, including increasing social isolation, mental health issues, and materialism. This essay will explore the novel\\'s powerful impact by offering concrete examples of its relevance in modern life and discussing the themes in the context of studies on loneliness, personal growth, and superficiality in the digital age.\\n\\nBody Paragraph 1 - Love, Loneliness, and Isolation:\\nThe Little Prince\\'s depiction of love and loneliness in various forms—between the prince and his rose, the fox, and the pilot—provides powerful insights into addressing isolation in the 21st century. In a study conducted by McPherson, Smith-Lovin, and Brashears (2006), they revealed an alarming decline in the number of confidants in individuals\\' lives, indicating growing isolation. Specifically, over the past two decades, the percentage of people who claim to have no one they can discuss important issues with has doubled (McPherson, Smith-Lovin, & Brashears, 2006). The Little Prince\\'s portrayal of the prince\\'s loneliness and his encounters with a variety of inhabitants emphasizes the importance of genuine companionship, transcending cultural barriers.\\n\\nOne scene that highlights the emotional impact of loneliness is the Little Prince\\'s relationship with his rose, which illustrates the often-complex nature of human relationships. The prince\\'s devotion to the rose, despite her shortcomings, underscores how even the most frustrating relationships can bring solace to those yearning for connection. In the digital age, social media and other online platforms can be sources of isolation, rather than connection, and The Little Prince challenges readers to cherish in-person interactions and prioritize genuine human relationships over superficial online exchanges.\\n\\nBody Paragraph 2 - Responsibility, Personal Growth, and Emotional Intelligence:\\nPersonal growth, responsibility, and self-awareness are vital themes in The Little Prince, which remain crucial for navigating the challenges of the 21st century. With increasing emphasis on mental health and well-being worldwide, Saint-Exupéry\\'s exploration of self-awareness and personal growth is highly relevant. The Little Prince\\'s encounters with grown-ups on various planets reveal the trappings of vanity, authority, and materialism (Soucy & Vedel, 2018). In response to the pressures of adulthood and rigid expectations, the novel advocates for personal growth and responsibility as essential ingredients for emotional intelligence.\\n\\nStudies have consistently linked emotional intelligence to mental health, providing further support for the themes present in The Little Prince. Research conducted by Schutte and colleagues (2001) found that higher emotional intelligence was positively associated with mental health and well-being, suggesting that the novel\\'s focus on personal growth and responsibility provides valuable insights for today\\'s 21st-century society. The novel challenges readers to question the adult world\\'s superficiality, pursue self-awareness, and foster emotional intelligence as a means of developing resilience in the face of modern-day challenges.\\n\\nBody Paragraph 3 - Materialism, Superficiality, and Social Media:\\nThe Little Prince critiques the materialistic and superficial nature of the adult world, which is acutely visible in today\\'s digital age and social media-dominated society. For instance, the novel\\'s third chapter introduces the businessman, who spends his life counting stars, believing that \"owning\" them brings him both fame and fortune. This behavior can be likened to the modern obsession with online presence, where people often focus on the accumulation of \"likes\" and \"followers.\" \\n\\nResearch suggests that Facebook, Instagram, and Twitter use may contribute to decreased well-being and increased loneliness, underscoring Saint-Exupéry\\'s prescient examination of the superficiality of modern society (Kross et al., 2013). The Little Prince encourages its readers to seek genuine connections and engage with the world around them, minimizing the allure of superficial distractions. As digital natives grapple with maintaining healthy digital personas, the novel\\'s messages about the importance of meaningful relationships and personal responsibility remain more relevant than ever.\\n\\nConclusion:\\nThe Little Prince is an enduring classic that offers timeless lessons on love, friendship, responsibility, and the superficiality of the adult world, which remain highly relevant today. In the context of the digital age and its myriad challenges, the novel\\'s exploration of personal growth, mental health, materialism, and loneliness provides critical insights for contemporary society. The Little Prince reminds us to cherish and foster deep, meaningful relationships, engage in self-discovery, and resist the superficiality of the adult world. By doing so, we can preserve the essence of human connection and continue to find relevance in the novel\\'s wisdom and the importance of its messages in our daily lives.')}\n",
      "---\n",
      "{'reflect': HumanMessage(content=\"The revised essay expands on the themes presented in the novel and their relevance to modern society, integrating real-world research, specific examples from The Little Prince, and addressing the issues of social media and materialism in an insightful manner. The essay demonstrates a thorough understanding of the novel's impact and significance in the 21st century, offering a compelling analysis of its continued relevance.\")}\n",
      "---\n",
      "{'generate': AIMessage(content='Title: The Enduring Relevance of The Little Prince: Timeless Lessons for the 21st Century\\n\\nIntroduction:\\nAntoine de Saint-Exupéry\\'s The Little Prince continues to captivate readers as a classic tale that carries significant implications for contemporary society. With over 200 million copies sold and translations in more than 300 languages, its universal themes of love, friendship, responsibility, and the superficiality of the adult world remain profoundly relevant in the 21st century. As society grapples with increasing social isolation, mental health issues, and materialism, this essay explores the novel\\'s powerful impact by discussing its themes in the context of studies on loneliness, personal growth, and superficiality in the digital age.\\n\\nBody Paragraph 1 - Love, Loneliness, and Isolation:\\nThe Little Prince addresses themes of love and loneliness that still resonate strongly in today\\'s world. The novel\\'s portrayal of the prince\\'s relationships emphasizes the significance of in-person connections in a time when digital communication dominates many aspects of everyday life. In a study conducted by McPherson, Smith-Lovin, and Brashears (2006), the authors revealed an alarming decline in the number of confidants in individuals\\' lives, indicating growing isolation. The Little Prince challenges readers to prioritize genuine human relationships over superficial online exchanges.\\n\\nOne notable scene in The Little Prince portrays the emotional impact of loneliness. The little prince\\'s devotion to his rose, despite her flaws, highlights the value of even the most frustrating relationships in providing solace to those yearning for connection. The novel encourages readers to seek and maintain in-person interactions and forge emotional bonds that can help mitigate the feelings of loneliness and isolation that may arise in the modern age.\\n\\nBody Paragraph 2 - Responsibility, Personal Growth, and Emotional Intelligence:\\nThe Little Prince emphasizes responsibility, self-awareness, and personal growth as critical components of emotional intelligence, which remains salient in modern society. Research consistently links emotional intelligence to mental health and well-being. A 2001 study conducted by Schutte and colleagues found that higher emotional intelligence was associated with fewer symptoms of anxiety and depression, suggesting that the novel\\'s focus on personal growth and self-awareness offers valuable insights in the face of today\\'s challenges.\\n\\nIn response to the pressures of adulthood and rigid expectations, the novel underscores the importance of pursuing personal growth and responsibility, embracing self-discovery, and nurturing emotional intelligence as a means of coping with the complexities of life in contemporary society. According to Salovey and Mayer (1990), growing emotional intelligence allows individuals to understand their own emotions and those of others more deeply, which contributes to overall mental well-being.\\n\\nBody Paragraph 3 - Materialism, Superficiality, and Social Media:\\nThe Little Prince critiques the materialistic and superficial nature of the adult world, which becomes more apparent in the digital age and social media-dominated society. The novel introduces characters like the businessman, who devotes his life to counting stars while prioritizing material possessions and wealth over genuine relationships. This behavior can be likened to the modern trend of cultivating an online presence and seeking validation through the accumulation of \"likes\" and \"followers.\"\\n\\nResearch suggests that social media use may have detrimental effects on mental health and well-being. For example, a study conducted by Kross et al. (2013) found that frequent Facebook use was associated with decreased well-being and increased loneliness, supporting The Little Prince\\'s assertion that superficiality and materialism can have damaging consequences on mental health. The novel encourages readers to engage with the world around them and seek genuine connections that transcend superficial distractions.\\n\\nConclusion:\\nThe Little Prince remains a timeless and relevant work in the 21st century. The novel\\'s exploration of topics such as personal growth, mental health, materialism, and loneliness continues to offer valuable insights for contemporary society. The novel challenges readers to cherish and foster deep, meaningful relationships, engage in self-discovery, and resist the superficiality and materialism prevalent in today\\'s world. By doing so, The Little Prince reminds us of the wisdom it possesses and the importance of its themes in our daily lives.')}\n",
      "---\n",
      "{'__end__': [HumanMessage(content='Generate an essay on the topicality of The Little Prince and its message in modern life'), AIMessage(content=\"Title: The Enduring Relevance of The Little Prince: A Timeless Message for Modern Life\\n\\nIntroduction:\\nAntoine de Saint-Exupéry's The Little Prince is a canonical work of literature, beloved by generations since its publication in 1943. The novella has been translated into more than 250 languages and sold over 140 million copies, making it one of the best-selling books of all time. Its enchanting story transcends cultural boundaries and continues to captivate audiences of all ages. The Little Prince's timeless message remains relevant in modern life, offering insightful commentary on themes such as love, loneliness, responsibility, and the superficiality of the adult world. In this essay, we will discuss the topicality of The Little Prince and its enduring message in today's fast-paced, digitally-connected society.\\n\\nBody Paragraph 1 - Love and Loneliness:\\nOne of the most enduring aspects of The Little Prince is its exploration of love and relationships in a world plagued by superficiality. The Little Prince's encounters with the fox, the rose, and his pilot reveal the importance of genuine connections and the pain of loss. In today's modern era, characterized by increasing social isolation, the message of The Little Prince serves as a reminder of the crucial role empathy and understanding play in fostering meaningful relationships. The consequences of isolation, depression, and loneliness continue to grow in modern life, making Saint-Exupéry's exploration of love and loneliness as vital now as it was then.\\n\\nBody Paragraph 2 - Responsibility and Self-Discovery:\\nThroughout the novella, Saint-Exupéry emphasizes the significance of taking responsibility and learning from one's experiences—core components of personal growth and self-discovery. The Little Prince's journey to various planets, each inhabited by an absurd, self-absorbed grown-up, reflects on the responsibility people have to learn from their actions and understand their impact on others. The modern world demands people to navigate complex social, professional, and personal situations daily. Thus, The Little Prince's lessons in responsibility and self-discovery are essential when addressing pressing issues like mental health, self-awareness, and communication in contemporary society.\\n\\nBody Paragraph 3 - The Superficiality of the Adult World:\\nCritics often discuss the novella's critique of the superficiality of the adult world, which remains relevant today, given society's heightened emphasis on materialism and status. The Little Prince's encounters with businessmen and geographers represent the folly of misunderstanding values and blindly pursuing worldly possessions. Today's capitalist societies frequently struggle to balance priorities, often rewarding materialistic pursuits over the development of meaningful relationships. The Little Prince serves as a profound reminder to maintain a sense of perspective, recognize the importance of intangible connections, and avoid the trappings of superficiality.\\n\\nConclusion:\\nUltimately, The Little Prince continues to top bestseller lists because its themes of love, loneliness, responsibility, and the superficiality of the adult world resonate with people across time and culture. The novella's resilient popularity and topicality reflect its relevance in tackling contemporary societal issues, making it a timeless masterpiece that transcends generations. As we navigate the complexities of modern life, The Little Prince's message is one we should keep close to our hearts: we must never lose sight of the simple, yet profound, lessons the story teaches us about cherishing meaningful connections, embracing personal growth, and resisting the shallow temptations of adult life.\\n\\nRevised Essay:\\n\\nTitle: The Enduring Relevance of The Little Prince: Timeless Lessons for the 21st Century\\n\\nIntroduction:\\nAntoine de Saint-Exupéry's The Little Prince is an enduring classic that has touched the hearts of millions since its publication in 1943. The novella has been translated into more than 300 languages, and over 200 million copies have been sold, making it one of the bestselling books ever written. The Little Prince's timeless message about love, friendship, responsibility, and the adult world remains incredibly relevant in the 21st century. This essay will analyze the topicality of The Little Prince and explore the many ways its universal themes connect with modern life.\\n\\nBody Paragraph 1 - Love, Loss, and Friendship:\\nThe Little Prince teaches powerful lessons about love, friendship, and loss that continue to resonate with readers today. The novella's exploration of grief and heartache is as poignant today as it was when it was first published. The tales of the Little Prince's encounters with the fox, the rose, and his pilot highlight the transcendent power of meaningful connections and the pain of losing those we care about. In a digital age where fleeting online interactions can dominate our time, The Little Prince serves as a reminder to cherish genuine friendships and treasure the connections we make with others.\\n\\nBody Paragraph 2 - Responsibility, Personal Growth, and Emotional Intelligence:\\nThroughout the story, Saint-Exupéry highlights the significance of taking responsibility and engaging in self-discovery. The Little Prince's journey to various planets, each inhabited by a reductive grown-up, teaches the reader about the impact actions can have on others. In a world where emotional intelligence and empathy are increasingly vital due to ever-evolving social, professional, and personal obligations, The Little Prince's lessons on responsibility and personal growth remain crucial. Mental health, self-awareness, and communication are critical issues in modern society, making the exploration of these themes as essential in today's world as when the book was first published.\\n\\nBody Paragraph 3 - Rejecting the Superficiality of the Adult World:\\nThe Little Prince's critique of the superficiality of the adult world remains strikingly relevant in modern society. The novel's portrait of grown-ups consumed by materialism, social status, and vanity rings true today, more than ever, as individuals and societies race to acquire wealth, status, and possessions. The Little Prince serves as a poignant reminder to resist the superficiality of the adult world and maintain a balanced perspective, cherishing meaningful connections and eschewing the trappings of materialism.\\n\\nConclusion:\\nThe Little Prince's universal themes continue to captivate and inspire readers because the lessons it teaches about love, friendship, responsibility, and the adult world are still incredibly pertinent today. The novel's topicality and enduring popularity validate its relevance in addressing contemporary societal issues like mental health, self-awareness, communication, and materialism. As we maneuver the challenges of the 21st century, The Little Prince's enduring wisdom—to cherish deep relationships, value personal growth, and reject the superficiality of adult life—continues to resonate and encourage readers to reassess their priorities and find meaning in connection and experience.\"), HumanMessage(content=\"Introduction:\\nThe essay provides a solid introduction to the topic, clearly stating the book's significance and its continued relevance in modern life. I would suggest providing more specific connections to the present day to emphasize the enduring relevance of The Little Prince. For instance, you could mention current events or issues that are directly related to the themes discussed in Saint-Exupéry's work (e.g., studies on loneliness and mental health in the digital age).\\n\\nBody Paragraph 1 - Love and Loneliness:\\nThe paragraph effectively explains how the themes of love and loneliness resonate with the modern era. However, I would like to see more concrete examples from the book to strengthen the analysis. Consider providing a specific interaction or quote from The Little Prince to more directly tie it to the concepts of isolation, depression, and loneliness in today's world.\\n\\nBody Paragraph 2 - Responsibility and Self-Discovery:\\nThis paragraph provides a good analysis of how Saint-Exupéry emphasizes responsibility and self-discovery. However, it could benefit from a stronger connection to contemporary society. It would be helpful to provide examples from real-life situations or psychological studies that demonstrate the importance of mental health, self-awareness, and communication in today's world.\\n\\nBody Paragraph 3 - The Superficiality of the Adult World:\\nThe criticism of materialism and status in modern society is well-presented in this paragraph. However, you could strengthen the analysis by offering specific examples of the adult world's superficiality in the context of the 21st century, such as a focus on social media and online presence. Moreover, consider further elaborating on the contrast between the materialistic world and The Little Prince's emphasis on meaningful relationships.\\n\\nConclusion:\\nThe conclusion effectively summarizes the importance of the themes addressed in the novel. Nonetheless, it could benefit from a stronger final statement that reiterates the significance of the stories and lessons from The Little Prince in the modern context. Consider restating the main ideas in a way that reinforces the parallels between the book and contemporary life.\\n\\nOverall, I would encourage you to strengthen the connections between the novel's themes and modern society by providing more specific examples and relevant real-world issues. Furthermore, I recommend a word count of around 1,200-1,500 words for your essay to provide enough space to thoroughly analyze and discuss the topics presented. By offering a more in-depth analysis, your argument would become more persuasive and the relevance of the novel even more apparent.\"), AIMessage(content='Title: The Enduring Relevance of The Little Prince: Timeless Lessons for the 21st Century\\n\\nIntroduction:\\nAntoine de Saint-Exupéry\\'s The Little Prince continues to hold significance in modern life, touching the hearts of millions since its publication in 1943. With over 200 million copies sold and translations in more than 300 languages, its universal themes of love, friendship, responsibility, and the adult world resonate profoundly today (Soucy & Vedel, 2018). Today\\'s society faces a myriad of challenges, including increasing social isolation, mental health issues, and materialism. This essay will explore the novel\\'s powerful impact by offering concrete examples of its relevance in modern life and discussing the themes in the context of studies on loneliness, personal growth, and superficiality in the digital age.\\n\\nBody Paragraph 1 - Love, Loneliness, and Isolation:\\nThe Little Prince\\'s depiction of love and loneliness in various forms—between the prince and his rose, the fox, and the pilot—provides powerful insights into addressing isolation in the 21st century. In a study conducted by McPherson, Smith-Lovin, and Brashears (2006), they revealed an alarming decline in the number of confidants in individuals\\' lives, indicating growing isolation. Specifically, over the past two decades, the percentage of people who claim to have no one they can discuss important issues with has doubled (McPherson, Smith-Lovin, & Brashears, 2006). The Little Prince\\'s portrayal of the prince\\'s loneliness and his encounters with a variety of inhabitants emphasizes the importance of genuine companionship, transcending cultural barriers.\\n\\nBody Paragraph 2 - Responsibility, Personal Growth, and Emotional Intelligence:\\nPersonal growth, responsibility, and self-awareness are vital themes in The Little Prince, which remain crucial for navigating the challenges of the 21st century. With increasing emphasis on mental health and well-being worldwide, Saint-Exupéry\\'s exploration of self-awareness and personal growth is highly relevant. The Little Prince\\'s encounters with grown-ups on various planets reveal the trappings of vanity, authority, and materialism (Soucy & Vedel, 2018). In response to the pressures of adulthood and rigid expectations, the novel advocates for personal growth and responsibility as essential ingredients for emotional intelligence. Research connecting emotional intelligence to mental health underscores the significance of the ideas presented in The Little Prince, demonstrating that higher emotional intelligence is positively associated with mental health and well-being (Schutte et al., 2001). This research supports the notion that the personal growth explored in The Little Prince remains a vital part of addressing mental health issues.\\n\\nBody Paragraph 3 - Materialism, Superficiality, and Social Media:\\nThe Little Prince critiques the materialistic and superficial nature of the adult world, which is acutely visible in today\\'s digital age and social media-dominated society. For instance, the novel\\'s third chapter introduces the businessman, who spends his life counting stars, believing that \"owning\" them brings him both fame and fortune. This behavior can be likened to the modern obsession with online presence and an obsession with acquiring digital \"followers\" and \"likes.\" By highlighting the emptiness of the materialistic pursuits, The Little Prince shows readers the importance of genuine human connections and rejecting superficial distractions (Soucy & Vedel, 2018). These themes are particularly relevant today, as younger generations struggle to find balance between their online and offline lives, frequently confronted with issues related to superficiality, self-promotion, and digital personas.\\n\\nConclusion:\\nThe Little Prince is an enduring classic that offers timeless lessons on love, friendship, responsibility, and the superficiality of the adult world, which remain highly relevant today. In the context of the digital age and its myriad challenges, the novel\\'s exploration of personal growth, mental health, materialism, and loneliness provides critical insights for contemporary society. The Little Prince reminds us to cherish and foster deep, meaningful relationships, engage in self-discovery, and resist the superficiality of the adult world. By doing so, we can preserve the essence of human connection and continue to find relevance in the novel\\'s wisdom and the importance of its messages in our  daily lives.'), HumanMessage(content=\"The revised essay now provides a more in-depth analysis of the novel's themes and their relevance in the context of modern society, studies on loneliness, personal growth, and superficiality. The addition of specific examples from both the book and real-world research strengthens the argument, bolstering the claim that The Little Prince remains a timeless and relevant work in the 21st century. Overall, the essay conveys a thorough exploration of the novel's impact and significance.\"), AIMessage(content='Title: The Enduring Relevance of The Little Prince: Timeless Lessons for the 21st Century\\n\\nIntroduction:\\nAntoine de Saint-Exupéry\\'s The Little Prince continues to hold significance in modern life, touching the hearts of millions since its publication in 1943. With over 200 million copies sold and translations in more than 300 languages, its universal themes of love, friendship, responsibility, and the adult world resonate profoundly today (Soucy & Vedel, 2018). Today\\'s society faces a myriad of challenges, including increasing social isolation, mental health issues, and materialism. This essay will explore the novel\\'s powerful impact by offering concrete examples of its relevance in modern life and discussing the themes in the context of studies on loneliness, personal growth, and superficiality in the digital age.\\n\\nBody Paragraph 1 - Love, Loneliness, and Isolation:\\nThe Little Prince\\'s depiction of love and loneliness in various forms—between the prince and his rose, the fox, and the pilot—provides powerful insights into addressing isolation in the 21st century. In a study conducted by McPherson, Smith-Lovin, and Brashears (2006), they revealed an alarming decline in the number of confidants in individuals\\' lives, indicating growing isolation. Specifically, over the past two decades, the percentage of people who claim to have no one they can discuss important issues with has doubled (McPherson, Smith-Lovin, & Brashears, 2006). The Little Prince\\'s portrayal of the prince\\'s loneliness and his encounters with a variety of inhabitants emphasizes the importance of genuine companionship, transcending cultural barriers.\\n\\nOne scene that highlights the emotional impact of loneliness is the Little Prince\\'s relationship with his rose, which illustrates the often-complex nature of human relationships. The prince\\'s devotion to the rose, despite her shortcomings, underscores how even the most frustrating relationships can bring solace to those yearning for connection. In the digital age, social media and other online platforms can be sources of isolation, rather than connection, and The Little Prince challenges readers to cherish in-person interactions and prioritize genuine human relationships over superficial online exchanges.\\n\\nBody Paragraph 2 - Responsibility, Personal Growth, and Emotional Intelligence:\\nPersonal growth, responsibility, and self-awareness are vital themes in The Little Prince, which remain crucial for navigating the challenges of the 21st century. With increasing emphasis on mental health and well-being worldwide, Saint-Exupéry\\'s exploration of self-awareness and personal growth is highly relevant. The Little Prince\\'s encounters with grown-ups on various planets reveal the trappings of vanity, authority, and materialism (Soucy & Vedel, 2018). In response to the pressures of adulthood and rigid expectations, the novel advocates for personal growth and responsibility as essential ingredients for emotional intelligence.\\n\\nStudies have consistently linked emotional intelligence to mental health, providing further support for the themes present in The Little Prince. Research conducted by Schutte and colleagues (2001) found that higher emotional intelligence was positively associated with mental health and well-being, suggesting that the novel\\'s focus on personal growth and responsibility provides valuable insights for today\\'s 21st-century society. The novel challenges readers to question the adult world\\'s superficiality, pursue self-awareness, and foster emotional intelligence as a means of developing resilience in the face of modern-day challenges.\\n\\nBody Paragraph 3 - Materialism, Superficiality, and Social Media:\\nThe Little Prince critiques the materialistic and superficial nature of the adult world, which is acutely visible in today\\'s digital age and social media-dominated society. For instance, the novel\\'s third chapter introduces the businessman, who spends his life counting stars, believing that \"owning\" them brings him both fame and fortune. This behavior can be likened to the modern obsession with online presence, where people often focus on the accumulation of \"likes\" and \"followers.\" \\n\\nResearch suggests that Facebook, Instagram, and Twitter use may contribute to decreased well-being and increased loneliness, underscoring Saint-Exupéry\\'s prescient examination of the superficiality of modern society (Kross et al., 2013). The Little Prince encourages its readers to seek genuine connections and engage with the world around them, minimizing the allure of superficial distractions. As digital natives grapple with maintaining healthy digital personas, the novel\\'s messages about the importance of meaningful relationships and personal responsibility remain more relevant than ever.\\n\\nConclusion:\\nThe Little Prince is an enduring classic that offers timeless lessons on love, friendship, responsibility, and the superficiality of the adult world, which remain highly relevant today. In the context of the digital age and its myriad challenges, the novel\\'s exploration of personal growth, mental health, materialism, and loneliness provides critical insights for contemporary society. The Little Prince reminds us to cherish and foster deep, meaningful relationships, engage in self-discovery, and resist the superficiality of the adult world. By doing so, we can preserve the essence of human connection and continue to find relevance in the novel\\'s wisdom and the importance of its messages in our daily lives.'), HumanMessage(content=\"The revised essay expands on the themes presented in the novel and their relevance to modern society, integrating real-world research, specific examples from The Little Prince, and addressing the issues of social media and materialism in an insightful manner. The essay demonstrates a thorough understanding of the novel's impact and significance in the 21st century, offering a compelling analysis of its continued relevance.\"), AIMessage(content='Title: The Enduring Relevance of The Little Prince: Timeless Lessons for the 21st Century\\n\\nIntroduction:\\nAntoine de Saint-Exupéry\\'s The Little Prince continues to captivate readers as a classic tale that carries significant implications for contemporary society. With over 200 million copies sold and translations in more than 300 languages, its universal themes of love, friendship, responsibility, and the superficiality of the adult world remain profoundly relevant in the 21st century. As society grapples with increasing social isolation, mental health issues, and materialism, this essay explores the novel\\'s powerful impact by discussing its themes in the context of studies on loneliness, personal growth, and superficiality in the digital age.\\n\\nBody Paragraph 1 - Love, Loneliness, and Isolation:\\nThe Little Prince addresses themes of love and loneliness that still resonate strongly in today\\'s world. The novel\\'s portrayal of the prince\\'s relationships emphasizes the significance of in-person connections in a time when digital communication dominates many aspects of everyday life. In a study conducted by McPherson, Smith-Lovin, and Brashears (2006), the authors revealed an alarming decline in the number of confidants in individuals\\' lives, indicating growing isolation. The Little Prince challenges readers to prioritize genuine human relationships over superficial online exchanges.\\n\\nOne notable scene in The Little Prince portrays the emotional impact of loneliness. The little prince\\'s devotion to his rose, despite her flaws, highlights the value of even the most frustrating relationships in providing solace to those yearning for connection. The novel encourages readers to seek and maintain in-person interactions and forge emotional bonds that can help mitigate the feelings of loneliness and isolation that may arise in the modern age.\\n\\nBody Paragraph 2 - Responsibility, Personal Growth, and Emotional Intelligence:\\nThe Little Prince emphasizes responsibility, self-awareness, and personal growth as critical components of emotional intelligence, which remains salient in modern society. Research consistently links emotional intelligence to mental health and well-being. A 2001 study conducted by Schutte and colleagues found that higher emotional intelligence was associated with fewer symptoms of anxiety and depression, suggesting that the novel\\'s focus on personal growth and self-awareness offers valuable insights in the face of today\\'s challenges.\\n\\nIn response to the pressures of adulthood and rigid expectations, the novel underscores the importance of pursuing personal growth and responsibility, embracing self-discovery, and nurturing emotional intelligence as a means of coping with the complexities of life in contemporary society. According to Salovey and Mayer (1990), growing emotional intelligence allows individuals to understand their own emotions and those of others more deeply, which contributes to overall mental well-being.\\n\\nBody Paragraph 3 - Materialism, Superficiality, and Social Media:\\nThe Little Prince critiques the materialistic and superficial nature of the adult world, which becomes more apparent in the digital age and social media-dominated society. The novel introduces characters like the businessman, who devotes his life to counting stars while prioritizing material possessions and wealth over genuine relationships. This behavior can be likened to the modern trend of cultivating an online presence and seeking validation through the accumulation of \"likes\" and \"followers.\"\\n\\nResearch suggests that social media use may have detrimental effects on mental health and well-being. For example, a study conducted by Kross et al. (2013) found that frequent Facebook use was associated with decreased well-being and increased loneliness, supporting The Little Prince\\'s assertion that superficiality and materialism can have damaging consequences on mental health. The novel encourages readers to engage with the world around them and seek genuine connections that transcend superficial distractions.\\n\\nConclusion:\\nThe Little Prince remains a timeless and relevant work in the 21st century. The novel\\'s exploration of topics such as personal growth, mental health, materialism, and loneliness continues to offer valuable insights for contemporary society. The novel challenges readers to cherish and foster deep, meaningful relationships, engage in self-discovery, and resist the superficiality and materialism prevalent in today\\'s world. By doing so, The Little Prince reminds us of the wisdom it possesses and the importance of its themes in our daily lives.')]}\n",
      "---\n"
     ]
    }
   ],
   "source": [
    "async for event in graph.astream(\n",
    "    [\n",
    "        HumanMessage(\n",
    "            content=\"Generate an essay on the topicality of The Little Prince and its message in modern life\"\n",
    "        )\n",
    "    ],\n",
    "):\n",
    "    print(event)\n",
    "    print(\"---\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "394bf0df-fc28-4104-a278-a56c9cb8b10c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "================================\u001b[1m Human Message \u001b[0m=================================\n",
      "\n",
      "Generate an essay on the topicality of The Little Prince and its message in modern life\n",
      "\n",
      "==================================\u001b[1m Ai Message \u001b[0m==================================\n",
      "\n",
      "Title: The Enduring Relevance of The Little Prince: A Timeless Message for Modern Life\n",
      "\n",
      "Introduction:\n",
      "Antoine de Saint-Exupéry's The Little Prince is a canonical work of literature, beloved by generations since its publication in 1943. The novella has been translated into more than 250 languages and sold over 140 million copies, making it one of the best-selling books of all time. Its enchanting story transcends cultural boundaries and continues to captivate audiences of all ages. The Little Prince's timeless message remains relevant in modern life, offering insightful commentary on themes such as love, loneliness, responsibility, and the superficiality of the adult world. In this essay, we will discuss the topicality of The Little Prince and its enduring message in today's fast-paced, digitally-connected society.\n",
      "\n",
      "Body Paragraph 1 - Love and Loneliness:\n",
      "One of the most enduring aspects of The Little Prince is its exploration of love and relationships in a world plagued by superficiality. The Little Prince's encounters with the fox, the rose, and his pilot reveal the importance of genuine connections and the pain of loss. In today's modern era, characterized by increasing social isolation, the message of The Little Prince serves as a reminder of the crucial role empathy and understanding play in fostering meaningful relationships. The consequences of isolation, depression, and loneliness continue to grow in modern life, making Saint-Exupéry's exploration of love and loneliness as vital now as it was then.\n",
      "\n",
      "Body Paragraph 2 - Responsibility and Self-Discovery:\n",
      "Throughout the novella, Saint-Exupéry emphasizes the significance of taking responsibility and learning from one's experiences—core components of personal growth and self-discovery. The Little Prince's journey to various planets, each inhabited by an absurd, self-absorbed grown-up, reflects on the responsibility people have to learn from their actions and understand their impact on others. The modern world demands people to navigate complex social, professional, and personal situations daily. Thus, The Little Prince's lessons in responsibility and self-discovery are essential when addressing pressing issues like mental health, self-awareness, and communication in contemporary society.\n",
      "\n",
      "Body Paragraph 3 - The Superficiality of the Adult World:\n",
      "Critics often discuss the novella's critique of the superficiality of the adult world, which remains relevant today, given society's heightened emphasis on materialism and status. The Little Prince's encounters with businessmen and geographers represent the folly of misunderstanding values and blindly pursuing worldly possessions. Today's capitalist societies frequently struggle to balance priorities, often rewarding materialistic pursuits over the development of meaningful relationships. The Little Prince serves as a profound reminder to maintain a sense of perspective, recognize the importance of intangible connections, and avoid the trappings of superficiality.\n",
      "\n",
      "Conclusion:\n",
      "Ultimately, The Little Prince continues to top bestseller lists because its themes of love, loneliness, responsibility, and the superficiality of the adult world resonate with people across time and culture. The novella's resilient popularity and topicality reflect its relevance in tackling contemporary societal issues, making it a timeless masterpiece that transcends generations. As we navigate the complexities of modern life, The Little Prince's message is one we should keep close to our hearts: we must never lose sight of the simple, yet profound, lessons the story teaches us about cherishing meaningful connections, embracing personal growth, and resisting the shallow temptations of adult life.\n",
      "\n",
      "Revised Essay:\n",
      "\n",
      "Title: The Enduring Relevance of The Little Prince: Timeless Lessons for the 21st Century\n",
      "\n",
      "Introduction:\n",
      "Antoine de Saint-Exupéry's The Little Prince is an enduring classic that has touched the hearts of millions since its publication in 1943. The novella has been translated into more than 300 languages, and over 200 million copies have been sold, making it one of the bestselling books ever written. The Little Prince's timeless message about love, friendship, responsibility, and the adult world remains incredibly relevant in the 21st century. This essay will analyze the topicality of The Little Prince and explore the many ways its universal themes connect with modern life.\n",
      "\n",
      "Body Paragraph 1 - Love, Loss, and Friendship:\n",
      "The Little Prince teaches powerful lessons about love, friendship, and loss that continue to resonate with readers today. The novella's exploration of grief and heartache is as poignant today as it was when it was first published. The tales of the Little Prince's encounters with the fox, the rose, and his pilot highlight the transcendent power of meaningful connections and the pain of losing those we care about. In a digital age where fleeting online interactions can dominate our time, The Little Prince serves as a reminder to cherish genuine friendships and treasure the connections we make with others.\n",
      "\n",
      "Body Paragraph 2 - Responsibility, Personal Growth, and Emotional Intelligence:\n",
      "Throughout the story, Saint-Exupéry highlights the significance of taking responsibility and engaging in self-discovery. The Little Prince's journey to various planets, each inhabited by a reductive grown-up, teaches the reader about the impact actions can have on others. In a world where emotional intelligence and empathy are increasingly vital due to ever-evolving social, professional, and personal obligations, The Little Prince's lessons on responsibility and personal growth remain crucial. Mental health, self-awareness, and communication are critical issues in modern society, making the exploration of these themes as essential in today's world as when the book was first published.\n",
      "\n",
      "Body Paragraph 3 - Rejecting the Superficiality of the Adult World:\n",
      "The Little Prince's critique of the superficiality of the adult world remains strikingly relevant in modern society. The novel's portrait of grown-ups consumed by materialism, social status, and vanity rings true today, more than ever, as individuals and societies race to acquire wealth, status, and possessions. The Little Prince serves as a poignant reminder to resist the superficiality of the adult world and maintain a balanced perspective, cherishing meaningful connections and eschewing the trappings of materialism.\n",
      "\n",
      "Conclusion:\n",
      "The Little Prince's universal themes continue to captivate and inspire readers because the lessons it teaches about love, friendship, responsibility, and the adult world are still incredibly pertinent today. The novel's topicality and enduring popularity validate its relevance in addressing contemporary societal issues like mental health, self-awareness, communication, and materialism. As we maneuver the challenges of the 21st century, The Little Prince's enduring wisdom—to cherish deep relationships, value personal growth, and reject the superficiality of adult life—continues to resonate and encourage readers to reassess their priorities and find meaning in connection and experience.\n",
      "\n",
      "================================\u001b[1m Human Message \u001b[0m=================================\n",
      "\n",
      "Introduction:\n",
      "The essay provides a solid introduction to the topic, clearly stating the book's significance and its continued relevance in modern life. I would suggest providing more specific connections to the present day to emphasize the enduring relevance of The Little Prince. For instance, you could mention current events or issues that are directly related to the themes discussed in Saint-Exupéry's work (e.g., studies on loneliness and mental health in the digital age).\n",
      "\n",
      "Body Paragraph 1 - Love and Loneliness:\n",
      "The paragraph effectively explains how the themes of love and loneliness resonate with the modern era. However, I would like to see more concrete examples from the book to strengthen the analysis. Consider providing a specific interaction or quote from The Little Prince to more directly tie it to the concepts of isolation, depression, and loneliness in today's world.\n",
      "\n",
      "Body Paragraph 2 - Responsibility and Self-Discovery:\n",
      "This paragraph provides a good analysis of how Saint-Exupéry emphasizes responsibility and self-discovery. However, it could benefit from a stronger connection to contemporary society. It would be helpful to provide examples from real-life situations or psychological studies that demonstrate the importance of mental health, self-awareness, and communication in today's world.\n",
      "\n",
      "Body Paragraph 3 - The Superficiality of the Adult World:\n",
      "The criticism of materialism and status in modern society is well-presented in this paragraph. However, you could strengthen the analysis by offering specific examples of the adult world's superficiality in the context of the 21st century, such as a focus on social media and online presence. Moreover, consider further elaborating on the contrast between the materialistic world and The Little Prince's emphasis on meaningful relationships.\n",
      "\n",
      "Conclusion:\n",
      "The conclusion effectively summarizes the importance of the themes addressed in the novel. Nonetheless, it could benefit from a stronger final statement that reiterates the significance of the stories and lessons from The Little Prince in the modern context. Consider restating the main ideas in a way that reinforces the parallels between the book and contemporary life.\n",
      "\n",
      "Overall, I would encourage you to strengthen the connections between the novel's themes and modern society by providing more specific examples and relevant real-world issues. Furthermore, I recommend a word count of around 1,200-1,500 words for your essay to provide enough space to thoroughly analyze and discuss the topics presented. By offering a more in-depth analysis, your argument would become more persuasive and the relevance of the novel even more apparent.\n",
      "\n",
      "==================================\u001b[1m Ai Message \u001b[0m==================================\n",
      "\n",
      "Title: The Enduring Relevance of The Little Prince: Timeless Lessons for the 21st Century\n",
      "\n",
      "Introduction:\n",
      "Antoine de Saint-Exupéry's The Little Prince continues to hold significance in modern life, touching the hearts of millions since its publication in 1943. With over 200 million copies sold and translations in more than 300 languages, its universal themes of love, friendship, responsibility, and the adult world resonate profoundly today (Soucy & Vedel, 2018). Today's society faces a myriad of challenges, including increasing social isolation, mental health issues, and materialism. This essay will explore the novel's powerful impact by offering concrete examples of its relevance in modern life and discussing the themes in the context of studies on loneliness, personal growth, and superficiality in the digital age.\n",
      "\n",
      "Body Paragraph 1 - Love, Loneliness, and Isolation:\n",
      "The Little Prince's depiction of love and loneliness in various forms—between the prince and his rose, the fox, and the pilot—provides powerful insights into addressing isolation in the 21st century. In a study conducted by McPherson, Smith-Lovin, and Brashears (2006), they revealed an alarming decline in the number of confidants in individuals' lives, indicating growing isolation. Specifically, over the past two decades, the percentage of people who claim to have no one they can discuss important issues with has doubled (McPherson, Smith-Lovin, & Brashears, 2006). The Little Prince's portrayal of the prince's loneliness and his encounters with a variety of inhabitants emphasizes the importance of genuine companionship, transcending cultural barriers.\n",
      "\n",
      "Body Paragraph 2 - Responsibility, Personal Growth, and Emotional Intelligence:\n",
      "Personal growth, responsibility, and self-awareness are vital themes in The Little Prince, which remain crucial for navigating the challenges of the 21st century. With increasing emphasis on mental health and well-being worldwide, Saint-Exupéry's exploration of self-awareness and personal growth is highly relevant. The Little Prince's encounters with grown-ups on various planets reveal the trappings of vanity, authority, and materialism (Soucy & Vedel, 2018). In response to the pressures of adulthood and rigid expectations, the novel advocates for personal growth and responsibility as essential ingredients for emotional intelligence. Research connecting emotional intelligence to mental health underscores the significance of the ideas presented in The Little Prince, demonstrating that higher emotional intelligence is positively associated with mental health and well-being (Schutte et al., 2001). This research supports the notion that the personal growth explored in The Little Prince remains a vital part of addressing mental health issues.\n",
      "\n",
      "Body Paragraph 3 - Materialism, Superficiality, and Social Media:\n",
      "The Little Prince critiques the materialistic and superficial nature of the adult world, which is acutely visible in today's digital age and social media-dominated society. For instance, the novel's third chapter introduces the businessman, who spends his life counting stars, believing that \"owning\" them brings him both fame and fortune. This behavior can be likened to the modern obsession with online presence and an obsession with acquiring digital \"followers\" and \"likes.\" By highlighting the emptiness of the materialistic pursuits, The Little Prince shows readers the importance of genuine human connections and rejecting superficial distractions (Soucy & Vedel, 2018). These themes are particularly relevant today, as younger generations struggle to find balance between their online and offline lives, frequently confronted with issues related to superficiality, self-promotion, and digital personas.\n",
      "\n",
      "Conclusion:\n",
      "The Little Prince is an enduring classic that offers timeless lessons on love, friendship, responsibility, and the superficiality of the adult world, which remain highly relevant today. In the context of the digital age and its myriad challenges, the novel's exploration of personal growth, mental health, materialism, and loneliness provides critical insights for contemporary society. The Little Prince reminds us to cherish and foster deep, meaningful relationships, engage in self-discovery, and resist the superficiality of the adult world. By doing so, we can preserve the essence of human connection and continue to find relevance in the novel's wisdom and the importance of its messages in our  daily lives.\n",
      "\n",
      "================================\u001b[1m Human Message \u001b[0m=================================\n",
      "\n",
      "The revised essay now provides a more in-depth analysis of the novel's themes and their relevance in the context of modern society, studies on loneliness, personal growth, and superficiality. The addition of specific examples from both the book and real-world research strengthens the argument, bolstering the claim that The Little Prince remains a timeless and relevant work in the 21st century. Overall, the essay conveys a thorough exploration of the novel's impact and significance.\n",
      "\n",
      "==================================\u001b[1m Ai Message \u001b[0m==================================\n",
      "\n",
      "Title: The Enduring Relevance of The Little Prince: Timeless Lessons for the 21st Century\n",
      "\n",
      "Introduction:\n",
      "Antoine de Saint-Exupéry's The Little Prince continues to hold significance in modern life, touching the hearts of millions since its publication in 1943. With over 200 million copies sold and translations in more than 300 languages, its universal themes of love, friendship, responsibility, and the adult world resonate profoundly today (Soucy & Vedel, 2018). Today's society faces a myriad of challenges, including increasing social isolation, mental health issues, and materialism. This essay will explore the novel's powerful impact by offering concrete examples of its relevance in modern life and discussing the themes in the context of studies on loneliness, personal growth, and superficiality in the digital age.\n",
      "\n",
      "Body Paragraph 1 - Love, Loneliness, and Isolation:\n",
      "The Little Prince's depiction of love and loneliness in various forms—between the prince and his rose, the fox, and the pilot—provides powerful insights into addressing isolation in the 21st century. In a study conducted by McPherson, Smith-Lovin, and Brashears (2006), they revealed an alarming decline in the number of confidants in individuals' lives, indicating growing isolation. Specifically, over the past two decades, the percentage of people who claim to have no one they can discuss important issues with has doubled (McPherson, Smith-Lovin, & Brashears, 2006). The Little Prince's portrayal of the prince's loneliness and his encounters with a variety of inhabitants emphasizes the importance of genuine companionship, transcending cultural barriers.\n",
      "\n",
      "One scene that highlights the emotional impact of loneliness is the Little Prince's relationship with his rose, which illustrates the often-complex nature of human relationships. The prince's devotion to the rose, despite her shortcomings, underscores how even the most frustrating relationships can bring solace to those yearning for connection. In the digital age, social media and other online platforms can be sources of isolation, rather than connection, and The Little Prince challenges readers to cherish in-person interactions and prioritize genuine human relationships over superficial online exchanges.\n",
      "\n",
      "Body Paragraph 2 - Responsibility, Personal Growth, and Emotional Intelligence:\n",
      "Personal growth, responsibility, and self-awareness are vital themes in The Little Prince, which remain crucial for navigating the challenges of the 21st century. With increasing emphasis on mental health and well-being worldwide, Saint-Exupéry's exploration of self-awareness and personal growth is highly relevant. The Little Prince's encounters with grown-ups on various planets reveal the trappings of vanity, authority, and materialism (Soucy & Vedel, 2018). In response to the pressures of adulthood and rigid expectations, the novel advocates for personal growth and responsibility as essential ingredients for emotional intelligence.\n",
      "\n",
      "Studies have consistently linked emotional intelligence to mental health, providing further support for the themes present in The Little Prince. Research conducted by Schutte and colleagues (2001) found that higher emotional intelligence was positively associated with mental health and well-being, suggesting that the novel's focus on personal growth and responsibility provides valuable insights for today's 21st-century society. The novel challenges readers to question the adult world's superficiality, pursue self-awareness, and foster emotional intelligence as a means of developing resilience in the face of modern-day challenges.\n",
      "\n",
      "Body Paragraph 3 - Materialism, Superficiality, and Social Media:\n",
      "The Little Prince critiques the materialistic and superficial nature of the adult world, which is acutely visible in today's digital age and social media-dominated society. For instance, the novel's third chapter introduces the businessman, who spends his life counting stars, believing that \"owning\" them brings him both fame and fortune. This behavior can be likened to the modern obsession with online presence, where people often focus on the accumulation of \"likes\" and \"followers.\" \n",
      "\n",
      "Research suggests that Facebook, Instagram, and Twitter use may contribute to decreased well-being and increased loneliness, underscoring Saint-Exupéry's prescient examination of the superficiality of modern society (Kross et al., 2013). The Little Prince encourages its readers to seek genuine connections and engage with the world around them, minimizing the allure of superficial distractions. As digital natives grapple with maintaining healthy digital personas, the novel's messages about the importance of meaningful relationships and personal responsibility remain more relevant than ever.\n",
      "\n",
      "Conclusion:\n",
      "The Little Prince is an enduring classic that offers timeless lessons on love, friendship, responsibility, and the superficiality of the adult world, which remain highly relevant today. In the context of the digital age and its myriad challenges, the novel's exploration of personal growth, mental health, materialism, and loneliness provides critical insights for contemporary society. The Little Prince reminds us to cherish and foster deep, meaningful relationships, engage in self-discovery, and resist the superficiality of the adult world. By doing so, we can preserve the essence of human connection and continue to find relevance in the novel's wisdom and the importance of its messages in our daily lives.\n",
      "\n",
      "================================\u001b[1m Human Message \u001b[0m=================================\n",
      "\n",
      "The revised essay expands on the themes presented in the novel and their relevance to modern society, integrating real-world research, specific examples from The Little Prince, and addressing the issues of social media and materialism in an insightful manner. The essay demonstrates a thorough understanding of the novel's impact and significance in the 21st century, offering a compelling analysis of its continued relevance.\n",
      "\n",
      "==================================\u001b[1m Ai Message \u001b[0m==================================\n",
      "\n",
      "Title: The Enduring Relevance of The Little Prince: Timeless Lessons for the 21st Century\n",
      "\n",
      "Introduction:\n",
      "Antoine de Saint-Exupéry's The Little Prince continues to captivate readers as a classic tale that carries significant implications for contemporary society. With over 200 million copies sold and translations in more than 300 languages, its universal themes of love, friendship, responsibility, and the superficiality of the adult world remain profoundly relevant in the 21st century. As society grapples with increasing social isolation, mental health issues, and materialism, this essay explores the novel's powerful impact by discussing its themes in the context of studies on loneliness, personal growth, and superficiality in the digital age.\n",
      "\n",
      "Body Paragraph 1 - Love, Loneliness, and Isolation:\n",
      "The Little Prince addresses themes of love and loneliness that still resonate strongly in today's world. The novel's portrayal of the prince's relationships emphasizes the significance of in-person connections in a time when digital communication dominates many aspects of everyday life. In a study conducted by McPherson, Smith-Lovin, and Brashears (2006), the authors revealed an alarming decline in the number of confidants in individuals' lives, indicating growing isolation. The Little Prince challenges readers to prioritize genuine human relationships over superficial online exchanges.\n",
      "\n",
      "One notable scene in The Little Prince portrays the emotional impact of loneliness. The little prince's devotion to his rose, despite her flaws, highlights the value of even the most frustrating relationships in providing solace to those yearning for connection. The novel encourages readers to seek and maintain in-person interactions and forge emotional bonds that can help mitigate the feelings of loneliness and isolation that may arise in the modern age.\n",
      "\n",
      "Body Paragraph 2 - Responsibility, Personal Growth, and Emotional Intelligence:\n",
      "The Little Prince emphasizes responsibility, self-awareness, and personal growth as critical components of emotional intelligence, which remains salient in modern society. Research consistently links emotional intelligence to mental health and well-being. A 2001 study conducted by Schutte and colleagues found that higher emotional intelligence was associated with fewer symptoms of anxiety and depression, suggesting that the novel's focus on personal growth and self-awareness offers valuable insights in the face of today's challenges.\n",
      "\n",
      "In response to the pressures of adulthood and rigid expectations, the novel underscores the importance of pursuing personal growth and responsibility, embracing self-discovery, and nurturing emotional intelligence as a means of coping with the complexities of life in contemporary society. According to Salovey and Mayer (1990), growing emotional intelligence allows individuals to understand their own emotions and those of others more deeply, which contributes to overall mental well-being.\n",
      "\n",
      "Body Paragraph 3 - Materialism, Superficiality, and Social Media:\n",
      "The Little Prince critiques the materialistic and superficial nature of the adult world, which becomes more apparent in the digital age and social media-dominated society. The novel introduces characters like the businessman, who devotes his life to counting stars while prioritizing material possessions and wealth over genuine relationships. This behavior can be likened to the modern trend of cultivating an online presence and seeking validation through the accumulation of \"likes\" and \"followers.\"\n",
      "\n",
      "Research suggests that social media use may have detrimental effects on mental health and well-being. For example, a study conducted by Kross et al. (2013) found that frequent Facebook use was associated with decreased well-being and increased loneliness, supporting The Little Prince's assertion that superficiality and materialism can have damaging consequences on mental health. The novel encourages readers to engage with the world around them and seek genuine connections that transcend superficial distractions.\n",
      "\n",
      "Conclusion:\n",
      "The Little Prince remains a timeless and relevant work in the 21st century. The novel's exploration of topics such as personal growth, mental health, materialism, and loneliness continues to offer valuable insights for contemporary society. The novel challenges readers to cherish and foster deep, meaningful relationships, engage in self-discovery, and resist the superficiality and materialism prevalent in today's world. By doing so, The Little Prince reminds us of the wisdom it possesses and the importance of its themes in our daily lives.\n"
     ]
    }
   ],
   "source": [
    "ChatPromptTemplate.from_messages(event[END]).pretty_print()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0fa62df2-e8ee-40dd-ac95-9d982eae6079",
   "metadata": {},
   "source": [
    "## Conclusion\n",
    "\n",
    "Now that you've applied reflection to an LLM agent, I'll note one thing: self-reflection is inherently cyclic: it is much more effective if the reflection step has additional context or feedback (from tool observations, checks, etc.). If, like in the scenario above, the reflection step simply prompts the LLM to reflect on its output, it can still benefit the output quality (since the LLM then has multiple \"shots\" at getting a good output), but it's less guaranteed.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7c0e3efd-7f54-410e-bd31-36185a46b9a8",
   "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
}
