From 899a76f82b600e133db31ee55b91091c451d139a Mon Sep 17 00:00:00 2001 From: Harrison Chase Date: Mon, 12 Feb 2024 12:46:06 -0800 Subject: [PATCH] add rewoo --- examples/rewoo/rewoo.ipynb | 319 +++++++++++++++++++++++++++++++++++++ 1 file changed, 319 insertions(+) create mode 100644 examples/rewoo/rewoo.ipynb diff --git a/examples/rewoo/rewoo.ipynb b/examples/rewoo/rewoo.ipynb new file mode 100644 index 000000000..092207771 --- /dev/null +++ b/examples/rewoo/rewoo.ipynb @@ -0,0 +1,319 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 23, + "id": "b3db60ea-d38b-4a55-a048-6c0222af6566", + "metadata": {}, + "outputs": [], + "source": [ + "from langchain_openai import ChatOpenAI\n", + "from langchain_community.tools.tavily_search import TavilySearchResults\n", + "search = TavilySearchResults()" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "c8836921-c89e-42b6-8c71-27aeaeac5368", + "metadata": {}, + "outputs": [], + "source": [ + "model = ChatOpenAI(temperature=0)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "7e7faa92-30a1-4942-b3c7-acd3a7bfccbc", + "metadata": {}, + "outputs": [], + "source": [ + "prompt = \"\"\"For the following task, make plans that can solve the problem step by step. For each plan, indicate \\\n", + "which external tool together with tool input to retrieve evidence. You can store the evidence into a \\\n", + "variable #E that can be called by later tools. (Plan, #E1, Plan, #E2, Plan, ...)\n", + "\n", + "Tools can be one of the following:\n", + "(1) Google[input]: Worker that searches results from Google. Useful when you need to find short\n", + "and succinct answers about a specific topic. The input should be a search query.\n", + "(2) LLM[input]: A pretrained LLM like yourself. Useful when you need to act with general\n", + "world knowledge and common sense. Prioritize it when you are confident in solving the problem\n", + "yourself. Input can be any instruction.\n", + "\n", + "For example,\n", + "Task: Thomas, Toby, and Rebecca worked a total of 157 hours in one week. Thomas worked x\n", + "hours. Toby worked 10 hours less than twice what Thomas worked, and Rebecca worked 8 hours\n", + "less than Toby. How many hours did Rebecca work?\n", + "Plan: Given Thomas worked x hours, translate the problem into algebraic expressions and solve\n", + "with Wolfram Alpha. #E1 = WolframAlpha[Solve x + (2x − 10) + ((2x − 10) − 8) = 157]\n", + "Plan: Find out the number of hours Thomas worked. #E2 = LLM[What is x, given #E1]\n", + "Plan: Calculate the number of hours Rebecca worked. #E3 = Calculator[(2 ∗ #E2 − 10) − 8]\n", + "\n", + "Begin! \n", + "Describe your plans with rich details. Each Plan should be followed by only one #E.\n", + "\n", + "Task: {task}\"\"\"" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "72b4ab0f-7215-4f4b-9407-0ebad8b13b92", + "metadata": {}, + "outputs": [], + "source": [ + "task = \"what is the hometown of the 2024 australian open winner\"" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "56ecb45b-ea76-4303-a4f3-51406fe8312a", + "metadata": {}, + "outputs": [], + "source": [ + "result = model.invoke(prompt.format(task=task))" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "8a733caa-d75b-422c-93aa-6ad913c995f3", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Plan: Use Google to search for the 2024 Australian Open winner.\n", + "#E1 = Google[2024 Australian Open winner]\n", + "\n", + "Plan: Retrieve the name of the 2024 Australian Open winner from the search results.\n", + "#E2 = LLM[What is the name of the 2024 Australian Open winner, given #E1]\n", + "\n", + "Plan: Use Google to search for the hometown of the 2024 Australian Open winner.\n", + "#E3 = Google[hometown of 2024 Australian Open winner, given #E2]\n", + "\n", + "Plan: Retrieve the hometown of the 2024 Australian Open winner from the search results.\n", + "#E4 = LLM[What is the hometown of the 2024 Australian Open winner, given #E3]\n" + ] + } + ], + "source": [ + "print(result.content)" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "8b14c889-0f96-40d3-9200-7dc9afc190ce", + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "from typing import TypedDict, Annotated, List\n", + "import operator" + ] + }, + { + "cell_type": "code", + "execution_count": 92, + "id": "a3a0a670-686b-4767-92b7-b16fca748730", + "metadata": {}, + "outputs": [], + "source": [ + "class ReWOO(TypedDict):\n", + " task: str\n", + " plan_string: str\n", + " steps: List\n", + " results: dict\n", + " result: str" + ] + }, + { + "cell_type": "code", + "execution_count": 93, + "id": "3412cfc4-6796-4295-aea4-7eeb304e10bd", + "metadata": {}, + "outputs": [], + "source": [ + "def _get_current_task(state):\n", + " if state[\"results\"] is None:\n", + " return 1\n", + " if len(state[\"results\"]) == len(state[\"steps\"]):\n", + " return None\n", + " else:\n", + " return len(state[\"results\"]) + 1" + ] + }, + { + "cell_type": "code", + "execution_count": 110, + "id": "aa96fbac-28bc-4afe-ae35-ddb3383d1147", + "metadata": {}, + "outputs": [], + "source": [ + "def tool_execution(state):\n", + " _step =_get_current_task(state)\n", + " _, step_name, tool, tool_input = state[\"steps\"][_step - 1]\n", + " _results = state[\"results\"] or {}\n", + " for k, v in _results.items():\n", + " tool_input = tool_input.replace(k, v)\n", + " if tool == \"Google\":\n", + " result = search.invoke(tool_input)\n", + " elif tool == \"LLM\":\n", + " result = model.invoke(tool_input)\n", + " else:\n", + " raise ValueError\n", + " _results[step_name] = str(result)\n", + " return {\"results\": _results}" + ] + }, + { + "cell_type": "code", + "execution_count": 111, + "id": "c0eba982-6b8c-4ad9-8971-10c18d7c9b75", + "metadata": {}, + "outputs": [], + "source": [ + "import re\n", + "# Regex to match expressions of the form E#... = ...[...]\n", + "regex_pattern = r\"Plan:\\s*(.+)\\s*(#E\\d+)\\s*=\\s*(\\w+)\\s*\\[([^\\]]+)\\]\"" + ] + }, + { + "cell_type": "code", + "execution_count": 112, + "id": "2791b020-c182-4b54-8912-f9e3396196b8", + "metadata": {}, + "outputs": [], + "source": [ + "def get_plan(state):\n", + " task = state[\"task\"]\n", + " result = model.invoke(prompt.format(task=task))\n", + " # Find all matches in the sample text\n", + " matches = re.findall(regex_pattern, result.content)\n", + " return {\"steps\": matches, \"plan_string\": result.content}" + ] + }, + { + "cell_type": "code", + "execution_count": 113, + "id": "9f60d611-9e15-4621-8c03-aabace7d2a8b", + "metadata": {}, + "outputs": [], + "source": [ + "solve_prompt = \"\"\"Solve the following task or problem. To solve the problem, we have made step-by-step Plan and \\\n", + "retrieved corresponding Evidence to each Plan. Use them with caution since long evidence might \\\n", + "contain irrelevant information.\n", + "\n", + "{plan}\n", + "\n", + "Now solve the question or task according to provided Evidence above. Respond with the answer\n", + "directly with no extra words.\n", + "\n", + "Task: {task}\n", + "Response:\"\"\"\n", + "def solve(state):\n", + " plan = \"\"\n", + " for _plan, step_name, tool, tool_input in state[\"steps\"]:\n", + " _results = state[\"results\"] or {}\n", + " for k, v in _results.items():\n", + " tool_input = tool_input.replace(k, v)\n", + " plan += f\"Plan: {_plan}\\n{step_name} = {tool}[{tool_input}]\"\n", + " prompt = solve_prompt.format(plan=plan, task=state[\"task\"])\n", + " result = model.invoke(prompt)\n", + " return {\"result\": result.content}" + ] + }, + { + "cell_type": "code", + "execution_count": 114, + "id": "73b235d7-fa83-4e84-9f2e-2908f16deb26", + "metadata": {}, + "outputs": [], + "source": [ + "def _route(state):\n", + " _step = _get_current_task(state)\n", + " if _step is None:\n", + " return \"solve\"\n", + " else:\n", + " return \"tool\"" + ] + }, + { + "cell_type": "code", + "execution_count": 115, + "id": "cf173aa1-ce31-4dca-8111-30c91e209652", + "metadata": {}, + "outputs": [], + "source": [ + "from langgraph.graph import StateGraph, END\n", + "\n", + "graph = StateGraph(ReWOO)\n", + "graph.add_node(\"plan\", get_plan)\n", + "graph.add_node(\"tool\", tool_execution)\n", + "graph.add_node(\"solve\", solve)\n", + "graph.add_edge(\"plan\", \"tool\")\n", + "graph.add_edge(\"solve\", END)\n", + "graph.add_conditional_edges(\"tool\", _route)\n", + "graph.set_entry_point(\"plan\")\n", + "app = graph.compile()" + ] + }, + { + "cell_type": "code", + "execution_count": 116, + "id": "badaca52-5d55-433f-8770-1bd50c10bf7f", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'plan': {'steps': [('Use Google to search for the 2024 Australian Open winner.', '#E1', 'Google', '2024 Australian Open winner'), ('Retrieve the name of the 2024 Australian Open winner from the search results.', '#E2', 'LLM', 'What is the name of the 2024 Australian Open winner, given #E1'), ('Use Google to search for the hometown of the 2024 Australian Open winner.', '#E3', 'Google', 'hometown of 2024 Australian Open winner, given #E2'), ('Retrieve the hometown of the 2024 Australian Open winner from the search results.', '#E4', 'LLM', 'What is the hometown of the 2024 Australian Open winner, given #E3')], 'plan_string': 'Plan: Use Google to search for the 2024 Australian Open winner.\\n#E1 = Google[2024 Australian Open winner]\\n\\nPlan: Retrieve the name of the 2024 Australian Open winner from the search results.\\n#E2 = LLM[What is the name of the 2024 Australian Open winner, given #E1]\\n\\nPlan: Use Google to search for the hometown of the 2024 Australian Open winner.\\n#E3 = Google[hometown of 2024 Australian Open winner, given #E2]\\n\\nPlan: Retrieve the hometown of the 2024 Australian Open winner from the search results.\\n#E4 = LLM[What is the hometown of the 2024 Australian Open winner, given #E3]'}}\n", + "{'tool': {'results': {'#E1': '[{\\'url\\': \\'https://www.cbssports.com/tennis/news/australian-open-2024-jannik-sinner-aryna-sabalenka-crowned-as-grand-slam-singles-champions-at-melbourne-park/\\', \\'content\\': \\'2024 Australian Open odds, Sinner vs. Medvedev picks Sabalenka defeats Zheng to win 2024 Australian Open Australian Open 2024: Jannik Sinner, Aryna Sabalenka crowned as Grand Slam singles champions at Melbourne Park 2024 Australian Open odds, Sabalenka vs. Zheng picks 2024 Australian Open odds, Medvedev vs. Zverev picks Sinner, Sabalenka win Australian Open singles titles Sinner makes epic comeback to win Australian OpenJan 28, 2024 — Jan 28, 2024Australian Open 2024: Jannik Sinner, Aryna Sabalenka crowned as Grand Slam singles champions at Melbourne Park ... Watch Now: Jannik Sinner came\\\\xa0...\\'}, {\\'url\\': \\'https://en.wikipedia.org/wiki/2024_Australian_Open\\', \\'content\\': \"Contents 2024 Australian Open The 2024 Australian Open was a Grand Slam level tennis tournament held at Melbourne Park, from 14–28 January 2024.[1] The Australian Open total prize money for 2024 increased by 13.07% year on year to a tournament record A$86,500,000. In the tournament\\'s 119-year history, this was the first Australian Open Tennis Championships to be held on an openingNovak Djokovic was the defending men\\'s singles champion. ... He was defeated in the semifinals by Jannik Sinner, who went on to beat Daniil Medvedev in a five-set\\\\xa0...\"}, {\\'url\\': \\'https://en.wikipedia.org/wiki/2024_Australian_Open_%E2%80%93_Men%27s_singles\\', \\'content\\': \"Contents 2024 Australian Open – Men\\'s singles The entry list was released by Tennis Australia based on the ATP rankings for the week of 4 December 2023.[15] matches, tying the Open Era record set at the 1983 US Open.[14] feature any of the Big Three members.[4] It was the second time Medvedev lost the Australian Open final after winningJannik Sinner defeated Daniil Medvedev in the final, 3–6, 3–6, 6–4, 6–4, 6–3, to win the men\\'s singles tennis title at the 2024 Australian Open.\"}]'}}}\n", + "{'tool': {'results': {'#E1': '[{\\'url\\': \\'https://www.cbssports.com/tennis/news/australian-open-2024-jannik-sinner-aryna-sabalenka-crowned-as-grand-slam-singles-champions-at-melbourne-park/\\', \\'content\\': \\'2024 Australian Open odds, Sinner vs. Medvedev picks Sabalenka defeats Zheng to win 2024 Australian Open Australian Open 2024: Jannik Sinner, Aryna Sabalenka crowned as Grand Slam singles champions at Melbourne Park 2024 Australian Open odds, Sabalenka vs. Zheng picks 2024 Australian Open odds, Medvedev vs. Zverev picks Sinner, Sabalenka win Australian Open singles titles Sinner makes epic comeback to win Australian OpenJan 28, 2024 — Jan 28, 2024Australian Open 2024: Jannik Sinner, Aryna Sabalenka crowned as Grand Slam singles champions at Melbourne Park ... Watch Now: Jannik Sinner came\\\\xa0...\\'}, {\\'url\\': \\'https://en.wikipedia.org/wiki/2024_Australian_Open\\', \\'content\\': \"Contents 2024 Australian Open The 2024 Australian Open was a Grand Slam level tennis tournament held at Melbourne Park, from 14–28 January 2024.[1] The Australian Open total prize money for 2024 increased by 13.07% year on year to a tournament record A$86,500,000. In the tournament\\'s 119-year history, this was the first Australian Open Tennis Championships to be held on an openingNovak Djokovic was the defending men\\'s singles champion. ... He was defeated in the semifinals by Jannik Sinner, who went on to beat Daniil Medvedev in a five-set\\\\xa0...\"}, {\\'url\\': \\'https://en.wikipedia.org/wiki/2024_Australian_Open_%E2%80%93_Men%27s_singles\\', \\'content\\': \"Contents 2024 Australian Open – Men\\'s singles The entry list was released by Tennis Australia based on the ATP rankings for the week of 4 December 2023.[15] matches, tying the Open Era record set at the 1983 US Open.[14] feature any of the Big Three members.[4] It was the second time Medvedev lost the Australian Open final after winningJannik Sinner defeated Daniil Medvedev in the final, 3–6, 3–6, 6–4, 6–4, 6–3, to win the men\\'s singles tennis title at the 2024 Australian Open.\"}]', '#E2': \"content='The name of the 2024 Australian Open winner is Jannik Sinner.'\"}}}\n", + "{'tool': {'results': {'#E1': '[{\\'url\\': \\'https://www.cbssports.com/tennis/news/australian-open-2024-jannik-sinner-aryna-sabalenka-crowned-as-grand-slam-singles-champions-at-melbourne-park/\\', \\'content\\': \\'2024 Australian Open odds, Sinner vs. Medvedev picks Sabalenka defeats Zheng to win 2024 Australian Open Australian Open 2024: Jannik Sinner, Aryna Sabalenka crowned as Grand Slam singles champions at Melbourne Park 2024 Australian Open odds, Sabalenka vs. Zheng picks 2024 Australian Open odds, Medvedev vs. Zverev picks Sinner, Sabalenka win Australian Open singles titles Sinner makes epic comeback to win Australian OpenJan 28, 2024 — Jan 28, 2024Australian Open 2024: Jannik Sinner, Aryna Sabalenka crowned as Grand Slam singles champions at Melbourne Park ... Watch Now: Jannik Sinner came\\\\xa0...\\'}, {\\'url\\': \\'https://en.wikipedia.org/wiki/2024_Australian_Open\\', \\'content\\': \"Contents 2024 Australian Open The 2024 Australian Open was a Grand Slam level tennis tournament held at Melbourne Park, from 14–28 January 2024.[1] The Australian Open total prize money for 2024 increased by 13.07% year on year to a tournament record A$86,500,000. In the tournament\\'s 119-year history, this was the first Australian Open Tennis Championships to be held on an openingNovak Djokovic was the defending men\\'s singles champion. ... He was defeated in the semifinals by Jannik Sinner, who went on to beat Daniil Medvedev in a five-set\\\\xa0...\"}, {\\'url\\': \\'https://en.wikipedia.org/wiki/2024_Australian_Open_%E2%80%93_Men%27s_singles\\', \\'content\\': \"Contents 2024 Australian Open – Men\\'s singles The entry list was released by Tennis Australia based on the ATP rankings for the week of 4 December 2023.[15] matches, tying the Open Era record set at the 1983 US Open.[14] feature any of the Big Three members.[4] It was the second time Medvedev lost the Australian Open final after winningJannik Sinner defeated Daniil Medvedev in the final, 3–6, 3–6, 6–4, 6–4, 6–3, to win the men\\'s singles tennis title at the 2024 Australian Open.\"}]', '#E2': \"content='The name of the 2024 Australian Open winner is Jannik Sinner.'\", '#E3': '[{\\'url\\': \\'https://www.tennis.com/news/articles/soccer-mad-italy-is-now-obsessed-with-tennis-player-jannik-sinner-after-his-australian-open-title\\', \\'content\\': \"Soccer-mad Italy is now obsessed with tennis player Jannik Sinner after his Australian Open title Play & Win Advertising Soccer-mad Italy is now obsessed with tennis player Jannik Sinner after his Australian Open title \\'Grandissimo\\': Italian Premier Giorgia Meloni welcomes home Australian Open champion Jannik Sinner First of many? Jannik Sinner\\'s five-set comeback sinks Daniil Medvedev in Australian Open finalJan 28, 2024 — Jan 28, 2024In Sinner\\'s tiny hometown of Sesto (population 1,860) near the Austrian border, about 70 people gathered inside the two-court indoor tennis\\\\xa0...\"}, {\\'url\\': \\'https://apnews.com/article/jannik-sinner-italy-australian-open-03573689c4c58c2851d1006e26546ac9\\', \\'content\\': \"Soccer-mad Italy is now obsessed with tennis player Jannik Sinner after his Australian Open title Jannik Sinner, left, of Italy gestures as he holds the Norman Brookes Challenge Cup after defeating Daniil Medvedev, Jannik Sinner, left, of Italy gestures as he holds the Norman Brookes Challenge Cup after defeating Daniil Medvedev, Jannik Sinner, left, of Italy gestures as he holds the Norman Brookes Challenge Cup after defeating Daniil Medvedev,Jan 28, 2024 — Jan 28, 2024Soccer-mad Italy has a new obsession. Jannik Sinner\\'s Australian Open performance on the tennis court has captured the country\\'s attention.\"}, {\\'url\\': \\'https://en.wikipedia.org/wiki/Jannik_Sinner\\', \\'content\\': \\'At the 2024 Australian Open, Sinner defeated world No. 1 Novak Djokovic in the semifinals to reach his first major Sinner is a major champion, having won the 2024 Australian Open.[3] He has won a further ten ATP Tour singles titles, Early in the year Sinner made the second round of the 2020 Australian Open, recording his first Grand Slam main draw a match since Janko Tipsarević in London in 2011.[59][60] Sinner played Daniil Medvedev next in the round robin stage,Since making his professional debut in 2018, Sinner has won 11 ATP Tour singles titles, including a Grand Slam at the 2024 Australian Open and a Masters 1000 at\\\\xa0...\\'}, {\\'url\\': \\'https://ausopen.com/players/italy/jannik-sinner\\', \\'content\\': \"Jannik Sinner weathered an early onslaught to reel in Daniil Medvedev, growing in potency to win the Australian Open the Australian Open 2024 final – his first Grand Slam singles title. Jannik Sinner will contest his first Grand Slam final after scuttling Novak Djokovic’s bid for a record-extending 11th Jannick Sinner has form and fitness on his side ahead of his meeting with Andrey Rublev.Jannik Sinner Press Conference | Australian Open 2024 Final. 15:02 · Player & Career Overview. Career Wins 73% · Men\\'s Singles. Final • Rod Laver Arena · Comeback\\\\xa0...\"}]'}}}\n", + "{'tool': {'results': {'#E1': '[{\\'url\\': \\'https://www.cbssports.com/tennis/news/australian-open-2024-jannik-sinner-aryna-sabalenka-crowned-as-grand-slam-singles-champions-at-melbourne-park/\\', \\'content\\': \\'2024 Australian Open odds, Sinner vs. Medvedev picks Sabalenka defeats Zheng to win 2024 Australian Open Australian Open 2024: Jannik Sinner, Aryna Sabalenka crowned as Grand Slam singles champions at Melbourne Park 2024 Australian Open odds, Sabalenka vs. Zheng picks 2024 Australian Open odds, Medvedev vs. Zverev picks Sinner, Sabalenka win Australian Open singles titles Sinner makes epic comeback to win Australian OpenJan 28, 2024 — Jan 28, 2024Australian Open 2024: Jannik Sinner, Aryna Sabalenka crowned as Grand Slam singles champions at Melbourne Park ... Watch Now: Jannik Sinner came\\\\xa0...\\'}, {\\'url\\': \\'https://en.wikipedia.org/wiki/2024_Australian_Open\\', \\'content\\': \"Contents 2024 Australian Open The 2024 Australian Open was a Grand Slam level tennis tournament held at Melbourne Park, from 14–28 January 2024.[1] The Australian Open total prize money for 2024 increased by 13.07% year on year to a tournament record A$86,500,000. In the tournament\\'s 119-year history, this was the first Australian Open Tennis Championships to be held on an openingNovak Djokovic was the defending men\\'s singles champion. ... He was defeated in the semifinals by Jannik Sinner, who went on to beat Daniil Medvedev in a five-set\\\\xa0...\"}, {\\'url\\': \\'https://en.wikipedia.org/wiki/2024_Australian_Open_%E2%80%93_Men%27s_singles\\', \\'content\\': \"Contents 2024 Australian Open – Men\\'s singles The entry list was released by Tennis Australia based on the ATP rankings for the week of 4 December 2023.[15] matches, tying the Open Era record set at the 1983 US Open.[14] feature any of the Big Three members.[4] It was the second time Medvedev lost the Australian Open final after winningJannik Sinner defeated Daniil Medvedev in the final, 3–6, 3–6, 6–4, 6–4, 6–3, to win the men\\'s singles tennis title at the 2024 Australian Open.\"}]', '#E2': \"content='The name of the 2024 Australian Open winner is Jannik Sinner.'\", '#E3': '[{\\'url\\': \\'https://www.tennis.com/news/articles/soccer-mad-italy-is-now-obsessed-with-tennis-player-jannik-sinner-after-his-australian-open-title\\', \\'content\\': \"Soccer-mad Italy is now obsessed with tennis player Jannik Sinner after his Australian Open title Play & Win Advertising Soccer-mad Italy is now obsessed with tennis player Jannik Sinner after his Australian Open title \\'Grandissimo\\': Italian Premier Giorgia Meloni welcomes home Australian Open champion Jannik Sinner First of many? Jannik Sinner\\'s five-set comeback sinks Daniil Medvedev in Australian Open finalJan 28, 2024 — Jan 28, 2024In Sinner\\'s tiny hometown of Sesto (population 1,860) near the Austrian border, about 70 people gathered inside the two-court indoor tennis\\\\xa0...\"}, {\\'url\\': \\'https://apnews.com/article/jannik-sinner-italy-australian-open-03573689c4c58c2851d1006e26546ac9\\', \\'content\\': \"Soccer-mad Italy is now obsessed with tennis player Jannik Sinner after his Australian Open title Jannik Sinner, left, of Italy gestures as he holds the Norman Brookes Challenge Cup after defeating Daniil Medvedev, Jannik Sinner, left, of Italy gestures as he holds the Norman Brookes Challenge Cup after defeating Daniil Medvedev, Jannik Sinner, left, of Italy gestures as he holds the Norman Brookes Challenge Cup after defeating Daniil Medvedev,Jan 28, 2024 — Jan 28, 2024Soccer-mad Italy has a new obsession. Jannik Sinner\\'s Australian Open performance on the tennis court has captured the country\\'s attention.\"}, {\\'url\\': \\'https://en.wikipedia.org/wiki/Jannik_Sinner\\', \\'content\\': \\'At the 2024 Australian Open, Sinner defeated world No. 1 Novak Djokovic in the semifinals to reach his first major Sinner is a major champion, having won the 2024 Australian Open.[3] He has won a further ten ATP Tour singles titles, Early in the year Sinner made the second round of the 2020 Australian Open, recording his first Grand Slam main draw a match since Janko Tipsarević in London in 2011.[59][60] Sinner played Daniil Medvedev next in the round robin stage,Since making his professional debut in 2018, Sinner has won 11 ATP Tour singles titles, including a Grand Slam at the 2024 Australian Open and a Masters 1000 at\\\\xa0...\\'}, {\\'url\\': \\'https://ausopen.com/players/italy/jannik-sinner\\', \\'content\\': \"Jannik Sinner weathered an early onslaught to reel in Daniil Medvedev, growing in potency to win the Australian Open the Australian Open 2024 final – his first Grand Slam singles title. Jannik Sinner will contest his first Grand Slam final after scuttling Novak Djokovic’s bid for a record-extending 11th Jannick Sinner has form and fitness on his side ahead of his meeting with Andrey Rublev.Jannik Sinner Press Conference | Australian Open 2024 Final. 15:02 · Player & Career Overview. Career Wins 73% · Men\\'s Singles. Final • Rod Laver Arena · Comeback\\\\xa0...\"}]', '#E4': \"content='The hometown of the 2024 Australian Open winner, Jannik Sinner, is Sesto, a small town near the Austrian border in Italy.'\"}}}\n", + "{'solve': {'result': 'The hometown of the 2024 Australian Open winner, Jannik Sinner, is Sesto, Italy.'}}\n", + "{'__end__': {'task': 'what is the hometown of the 2024 australian open winner', 'plan_string': 'Plan: Use Google to search for the 2024 Australian Open winner.\\n#E1 = Google[2024 Australian Open winner]\\n\\nPlan: Retrieve the name of the 2024 Australian Open winner from the search results.\\n#E2 = LLM[What is the name of the 2024 Australian Open winner, given #E1]\\n\\nPlan: Use Google to search for the hometown of the 2024 Australian Open winner.\\n#E3 = Google[hometown of 2024 Australian Open winner, given #E2]\\n\\nPlan: Retrieve the hometown of the 2024 Australian Open winner from the search results.\\n#E4 = LLM[What is the hometown of the 2024 Australian Open winner, given #E3]', 'steps': [('Use Google to search for the 2024 Australian Open winner.', '#E1', 'Google', '2024 Australian Open winner'), ('Retrieve the name of the 2024 Australian Open winner from the search results.', '#E2', 'LLM', 'What is the name of the 2024 Australian Open winner, given #E1'), ('Use Google to search for the hometown of the 2024 Australian Open winner.', '#E3', 'Google', 'hometown of 2024 Australian Open winner, given #E2'), ('Retrieve the hometown of the 2024 Australian Open winner from the search results.', '#E4', 'LLM', 'What is the hometown of the 2024 Australian Open winner, given #E3')], 'results': {'#E1': '[{\\'url\\': \\'https://www.cbssports.com/tennis/news/australian-open-2024-jannik-sinner-aryna-sabalenka-crowned-as-grand-slam-singles-champions-at-melbourne-park/\\', \\'content\\': \\'2024 Australian Open odds, Sinner vs. Medvedev picks Sabalenka defeats Zheng to win 2024 Australian Open Australian Open 2024: Jannik Sinner, Aryna Sabalenka crowned as Grand Slam singles champions at Melbourne Park 2024 Australian Open odds, Sabalenka vs. Zheng picks 2024 Australian Open odds, Medvedev vs. Zverev picks Sinner, Sabalenka win Australian Open singles titles Sinner makes epic comeback to win Australian OpenJan 28, 2024 — Jan 28, 2024Australian Open 2024: Jannik Sinner, Aryna Sabalenka crowned as Grand Slam singles champions at Melbourne Park ... Watch Now: Jannik Sinner came\\\\xa0...\\'}, {\\'url\\': \\'https://en.wikipedia.org/wiki/2024_Australian_Open\\', \\'content\\': \"Contents 2024 Australian Open The 2024 Australian Open was a Grand Slam level tennis tournament held at Melbourne Park, from 14–28 January 2024.[1] The Australian Open total prize money for 2024 increased by 13.07% year on year to a tournament record A$86,500,000. In the tournament\\'s 119-year history, this was the first Australian Open Tennis Championships to be held on an openingNovak Djokovic was the defending men\\'s singles champion. ... He was defeated in the semifinals by Jannik Sinner, who went on to beat Daniil Medvedev in a five-set\\\\xa0...\"}, {\\'url\\': \\'https://en.wikipedia.org/wiki/2024_Australian_Open_%E2%80%93_Men%27s_singles\\', \\'content\\': \"Contents 2024 Australian Open – Men\\'s singles The entry list was released by Tennis Australia based on the ATP rankings for the week of 4 December 2023.[15] matches, tying the Open Era record set at the 1983 US Open.[14] feature any of the Big Three members.[4] It was the second time Medvedev lost the Australian Open final after winningJannik Sinner defeated Daniil Medvedev in the final, 3–6, 3–6, 6–4, 6–4, 6–3, to win the men\\'s singles tennis title at the 2024 Australian Open.\"}]', '#E2': \"content='The name of the 2024 Australian Open winner is Jannik Sinner.'\", '#E3': '[{\\'url\\': \\'https://www.tennis.com/news/articles/soccer-mad-italy-is-now-obsessed-with-tennis-player-jannik-sinner-after-his-australian-open-title\\', \\'content\\': \"Soccer-mad Italy is now obsessed with tennis player Jannik Sinner after his Australian Open title Play & Win Advertising Soccer-mad Italy is now obsessed with tennis player Jannik Sinner after his Australian Open title \\'Grandissimo\\': Italian Premier Giorgia Meloni welcomes home Australian Open champion Jannik Sinner First of many? Jannik Sinner\\'s five-set comeback sinks Daniil Medvedev in Australian Open finalJan 28, 2024 — Jan 28, 2024In Sinner\\'s tiny hometown of Sesto (population 1,860) near the Austrian border, about 70 people gathered inside the two-court indoor tennis\\\\xa0...\"}, {\\'url\\': \\'https://apnews.com/article/jannik-sinner-italy-australian-open-03573689c4c58c2851d1006e26546ac9\\', \\'content\\': \"Soccer-mad Italy is now obsessed with tennis player Jannik Sinner after his Australian Open title Jannik Sinner, left, of Italy gestures as he holds the Norman Brookes Challenge Cup after defeating Daniil Medvedev, Jannik Sinner, left, of Italy gestures as he holds the Norman Brookes Challenge Cup after defeating Daniil Medvedev, Jannik Sinner, left, of Italy gestures as he holds the Norman Brookes Challenge Cup after defeating Daniil Medvedev,Jan 28, 2024 — Jan 28, 2024Soccer-mad Italy has a new obsession. Jannik Sinner\\'s Australian Open performance on the tennis court has captured the country\\'s attention.\"}, {\\'url\\': \\'https://en.wikipedia.org/wiki/Jannik_Sinner\\', \\'content\\': \\'At the 2024 Australian Open, Sinner defeated world No. 1 Novak Djokovic in the semifinals to reach his first major Sinner is a major champion, having won the 2024 Australian Open.[3] He has won a further ten ATP Tour singles titles, Early in the year Sinner made the second round of the 2020 Australian Open, recording his first Grand Slam main draw a match since Janko Tipsarević in London in 2011.[59][60] Sinner played Daniil Medvedev next in the round robin stage,Since making his professional debut in 2018, Sinner has won 11 ATP Tour singles titles, including a Grand Slam at the 2024 Australian Open and a Masters 1000 at\\\\xa0...\\'}, {\\'url\\': \\'https://ausopen.com/players/italy/jannik-sinner\\', \\'content\\': \"Jannik Sinner weathered an early onslaught to reel in Daniil Medvedev, growing in potency to win the Australian Open the Australian Open 2024 final – his first Grand Slam singles title. Jannik Sinner will contest his first Grand Slam final after scuttling Novak Djokovic’s bid for a record-extending 11th Jannick Sinner has form and fitness on his side ahead of his meeting with Andrey Rublev.Jannik Sinner Press Conference | Australian Open 2024 Final. 15:02 · Player & Career Overview. Career Wins 73% · Men\\'s Singles. Final • Rod Laver Arena · Comeback\\\\xa0...\"}]', '#E4': \"content='The hometown of the 2024 Australian Open winner, Jannik Sinner, is Sesto, a small town near the Austrian border in Italy.'\"}, 'result': 'The hometown of the 2024 Australian Open winner, Jannik Sinner, is Sesto, Italy.'}}\n" + ] + } + ], + "source": [ + "for s in app.stream({\"task\":task}):\n", + " print(s)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ba4a3cc6-ae26-47e5-aabe-5a30637c94b8", + "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.1" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}