Private Ryan (1998)</movie>    <movie>Cast Away (2000)</movie>    <movie>The Da Vinci Code (2006)</movie>    <movie>Toy Story 3 (2010)</movie>    <movie>Captain Phillips (2013)</movie>    <movie>Bridge of Spies (2015)</movie>    <movie>Toy Story 4 (2019)</movie>Now we will use the XMLOutputParser in order to get the structured output.parser = XMLOutputParser()prompt = PromptTemplate(    template="""        Human:    {query}    {format_instructions}    Assistant:""",    input_variables=["query"],    partial_variables={"format_instructions": parser.get_format_instructions()},)chain = prompt | model | parseroutput = chain.invoke({"query": actor_query})print(output)    {'filmography': [{'movie': [{'title': 'Splash'}, {'year': '1984'}]}, {'movie': [{'title': 'Big'}, {'year': '1988'}]}, {'movie': [{'title': 'A League of Their Own'}, {'year': '1992'}]}, {'movie': [{'title': 'Sleepless in Seattle'}, {'year': '1993'}]}, {'movie': [{'title': 'Forrest Gump'}, {'year': '1994'}]}, {'movie': [{'title': 'Toy Story'}, {'year': '1995'}]}, {'movie': [{'title': 'Apollo 13'}, {'year': '1995'}]}, {'movie': [{'title': 'Saving Private Ryan'}, {'year': '1998'}]}, {'movie': [{'title': 'Cast Away'}, {'year': '2000'}]}, {'movie': [{'title': 'Catch Me If You Can'}, {'year': '2002'}]}, {'movie': [{'title': 'The Polar Express'}, {'year': '2004'}]}, {'movie': [{'title': 'Bridge of Spies'}, {'year': '2015'}]}]}Finally, let's add some tags to tailor the output to our needs.parser = XMLOutputParser(tags=["movies", "actor", "film", "name", "genre"])prompt = PromptTemplate(    template="""        Human:    {query}    {format_instructions}    Assistant:""",    input_variables=["query"],    partial_variables={"format_instructions": parser.get_format_instructions()},)chain = prompt | model | parseroutput = chain.invoke({"query": actor_query})print(output)    {'movies': [{'actor': [{'name': 'Tom Hanks'}, {'film': [{'name': 'Splash'}, {'genre': 'Comedy'}]}, {'film': [{'name': 'Big'}, {'genre':
This output parser allows users to obtain results from LLM in the popular XML format.
This output parser allows users to obtain results from LLM in the popular XML format. ->: Private Ryan (1998)</movie>    <movie>Cast Away (2000)</movie>    <movie>The Da Vinci Code (2006)</movie>    <movie>Toy Story 3 (2010)</movie>    <movie>Captain Phillips (2013)</movie>    <movie>Bridge of Spies (2015)</movie>    <movie>Toy Story 4 (2019)</movie>Now we will use the XMLOutputParser in order to get the structured output.parser = XMLOutputParser()prompt = PromptTemplate(    template="""        Human:    {query}    {format_instructions}    Assistant:""",    input_variables=["query"],    partial_variables={"format_instructions": parser.get_format_instructions()},)chain = prompt | model | parseroutput = chain.invoke({"query": actor_query})print(output)    {'filmography': [{'movie': [{'title': 'Splash'}, {'year': '1984'}]}, {'movie': [{'title': 'Big'}, {'year': '1988'}]}, {'movie': [{'title': 'A League of Their Own'}, {'year': '1992'}]}, {'movie': [{'title': 'Sleepless in Seattle'}, {'year': '1993'}]}, {'movie': [{'title': 'Forrest Gump'}, {'year': '1994'}]}, {'movie': [{'title': 'Toy Story'}, {'year': '1995'}]}, {'movie': [{'title': 'Apollo 13'}, {'year': '1995'}]}, {'movie': [{'title': 'Saving Private Ryan'}, {'year': '1998'}]}, {'movie': [{'title': 'Cast Away'}, {'year': '2000'}]}, {'movie': [{'title': 'Catch Me If You Can'}, {'year': '2002'}]}, {'movie': [{'title': 'The Polar Express'}, {'year': '2004'}]}, {'movie': [{'title': 'Bridge of Spies'}, {'year': '2015'}]}]}Finally, let's add some tags to tailor the output to our needs.parser = XMLOutputParser(tags=["movies", "actor", "film", "name", "genre"])prompt = PromptTemplate(    template="""        Human:    {query}    {format_instructions}    Assistant:""",    input_variables=["query"],    partial_variables={"format_instructions": parser.get_format_instructions()},)chain = prompt | model | parseroutput = chain.invoke({"query": actor_query})print(output)    {'movies': [{'actor': [{'name': 'Tom Hanks'}, {'film': [{'name': 'Splash'}, {'genre': 'Comedy'}]}, {'film': [{'name': 'Big'}, {'genre':