{"cells": [{"cell_type": "markdown", "id": "4f4b3e2a", "metadata": {}, "source": ["\"在\n"]}, {"attachments": {}, "cell_type": "markdown", "id": "318d3e6d-8155-4f86-ac16-bdacaf041bb9", "metadata": {}, "source": ["# OnDemandLoaderTool 教程\n", "\n", "我们的 `OnDemandLoaderTool` 是一个强大的代理工具,允许从 LlamaHub 上的任何数据源进行“按需”数据查询。\n", "\n", "该工具接受一个 `BaseReader` 数据加载器,当调用时将 1) 加载数据,2) 索引数据,和 3) 查询数据。\n", "\n", "在本教程中,我们将展示如何使用 `OnDemandLoaderTool` 将我们的维基百科数据加载器转换为一个可访问的搜索工具,供 LangChain 代理使用。\n"]}, {"cell_type": "markdown", "id": "31bb896a", "metadata": {}, "source": ["如果您在colab上打开这个笔记本,您可能需要安装LlamaIndex 🦙。\n"]}, {"cell_type": "code", "execution_count": null, "id": "b3cb7c29", "metadata": {}, "outputs": [], "source": ["%pip install llama-index-readers-wikipedia"]}, {"cell_type": "code", "execution_count": null, "id": "d6815113", "metadata": {}, "outputs": [], "source": ["!pip install llama-index"]}, {"cell_type": "code", "execution_count": null, "id": "d1680fc8-1904-4ea8-b8da-88306b365e7f", "metadata": {}, "outputs": [], "source": ["from llama_index.core.tools.ondemand_loader_tool import OnDemandLoaderTool\n", "from llama_index.readers.wikipedia import WikipediaReader\n", "from typing import List\n", "\n", "from pydantic import BaseModel"]}, {"attachments": {}, "cell_type": "markdown", "id": "e167e7ed-92ba-4662-b6f6-24dc36ea4805", "metadata": {}, "source": ["### 定义工具\n", "\n", "首先我们定义`WikipediaReader`。请注意,`WikipediaReader`的`load_data`接口接受一个`pages`列表作为输入。默认情况下,这会查询维基百科搜索端点,该端点将自动建议相关页面。\n", "\n", "然后我们将其包装到我们的`OnDemandLoaderTool`中。\n", "\n", "默认情况下,由于我们没有指定`index_cls`,将初始化一个简单的向量存储索引。\n"]}, {"cell_type": "code", "execution_count": null, "id": "7c5caf3b-3544-4a39-be69-35e18ef12172", "metadata": {}, "outputs": [], "source": ["reader = WikipediaReader()"]}, {"cell_type": "code", "execution_count": null, "id": "ea9169ad-fe61-47da-bbdf-ce3a89c371a3", "metadata": {}, "outputs": [], "source": ["tool = OnDemandLoaderTool.from_defaults(\n", " reader,\n", " name=\"Wikipedia Tool\",\n", " description=\"A tool for loading and querying articles from Wikipedia\",\n", ")"]}, {"attachments": {}, "cell_type": "markdown", "id": "0f8e6bb2-b019-4b23-9b4b-bd5e6f436bcb", "metadata": {}, "source": ["#### 测试\n", "\n", "我们可以尝试单独运行该工具(或作为LangChain工具),以展示接口的样子!\n", "\n", "请注意,除了数据加载器需要的参数之外,该工具还接受一个`query_str`,这将是针对索引的查询。\n"]}, {"cell_type": "code", "execution_count": null, "id": "46fc86a2-0d25-4673-9d2c-a12ba10de5f4", "metadata": {}, "outputs": [{"data": {"text/plain": ["\"\\nBerlin has a vibrant and diverse arts and culture scene. It is home to 44 theaters and stages, three major opera houses, and numerous art galleries. The cityscape of Berlin displays large quantities of urban street art, and the Berlin Wall has become one of the largest open-air canvasses in the world. Berlin also has a long history of gay culture, and is an important birthplace of the LGBT rights movement. There are many festivals and events throughout the year, such as the Berlin International Film Festival, the Karneval der Kulturen, the Berlin Festival, and the New Year's Eve celebrations. The city is also home to many museums, such as the Museum Island, the Gemäldegalerie, the Neue Nationalgalerie, the Pergamon Museum, the Bode Museum, the Hamburger Bahnhof, the German Museum of Technology, the Jewish Museum, the Museum für Naturkunde, the Kupferstichkabinett Berlin, the Museum Berggruen, and the Beate Uhse Erotic Museum.\""]}, "execution_count": null, "metadata": {}, "output_type": "execute_result"}], "source": ["# 单独运行工具", "tool([\"Berlin\"], query_str=\"柏林的艺术和文化场景是什么样的?\")"]}, {"cell_type": "code", "execution_count": null, "id": "e22b8acd-e619-4ec7-925e-8e5d517214f3", "metadata": {}, "outputs": [], "source": ["# 作为langchain结构化工具运行工具", "lc_tool = tool.to_langchain_structured_tool(verbose=True)"]}, {"cell_type": "code", "execution_count": null, "id": "c5c48344-2a57-4b4a-8faa-1d7a9a450208", "metadata": {}, "outputs": [], "source": ["lc_tool.run(\n", " tool_input={\n", " \"pages\": [\"Berlin\"],\n", " \"query_str\": \"What's the arts and culture scene in Berlin?\",\n", " }\n", ")"]}, {"attachments": {}, "cell_type": "markdown", "id": "2bac4007-7121-4ab4-91e3-6706e59de6b7", "metadata": {}, "source": ["### 初始化LangChain代理\n", "\n", "在教程中,代理只能访问一个工具 - 维基百科阅读器\n", "\n", "请注意,我们需要使用LangChain的结构化工具。\n"]}, {"cell_type": "code", "execution_count": null, "id": "bd77d986-23be-49d9-9522-d19b41f66a32", "metadata": {}, "outputs": [], "source": ["from langchain.agents import initialize_agent\n", "from langchain.chat_models import ChatOpenAI"]}, {"cell_type": "code", "execution_count": null, "id": "8a789712-a285-495e-bf71-b61856e0848a", "metadata": {}, "outputs": [], "source": ["llm = ChatOpenAI(temperature=0, model_name=\"gpt-3.5-turbo\", streaming=True)"]}, {"cell_type": "code", "execution_count": null, "id": "8a6ff85e-81ae-4b66-a83b-4d066eded32a", "metadata": {}, "outputs": [], "source": ["agent = initialize_agent(\n", " [lc_tool],\n", " llm=llm,\n", " agent=\"structured-chat-zero-shot-react-description\",\n", " verbose=True,\n", ")"]}, {"attachments": {}, "cell_type": "markdown", "id": "56b88449-1291-470c-8b7c-cb49d2edbede", "metadata": {}, "source": ["# 现在让我们运行一些查询!\n", "\n", "OnDemandLoaderTool允许代理同时1) 从维基百科加载数据,2) 查询该数据。\n"]}, {"cell_type": "code", "execution_count": null, "id": "76e7a99f-2802-4e7e-ac8b-3810797fdc3c", "metadata": {}, "outputs": [{"name": "stderr", "output_type": "stream", "text": ["Retrying langchain.chat_models.openai.ChatOpenAI.completion_with_retry.._completion_with_retry in 1.0 seconds as it raised APIConnectionError: Error communicating with OpenAI: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')).\n"]}, {"name": "stdout", "output_type": "stream", "text": ["\n", "\n", "\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n", "\u001b[32;1m\u001b[1;3mAction:\n", "```\n", "{\n", " \"action\": \"Wikipedia Tool\",\n", " \"action_input\": {\n", " \"pages\": [\"Culture in Berlin\"],\n", " \"query_str\": \"What is the arts and culture scene like in Berlin?\"\n", " }\n", "}\n", "```\n", "\u001b[0m\n", "Observation: \u001b[36;1m\u001b[1;3m\n", "The arts and culture scene in Berlin is vibrant and diverse. The city is home to over 600 art galleries, 153 museums, and numerous cultural institutions. It is a world city of culture and creative industries, and is home to many international and regional television and radio stations. Berlin is also home to two major German-language publishing houses, and is an important center of the European and German film industry. The city is also known for its nightlife, with many clubs and festivals, such as the Berlin International Film Festival, the Karneval der Kulturen, and the Christopher Street Day. Berlin is also home to the largest gay fetish festivals in Europe.\u001b[0m\n", "Thought:\u001b[32;1m\u001b[1;3mThe human may want more specific information about certain aspects of Berlin's arts and culture scene. \n", "\n", "Action:\n", "```\n", "{\n", " \"action\": \"Wikipedia Tool\",\n", " \"action_input\": {\n", " \"pages\": [\"Culture in Berlin\"],\n", " \"query_str\": \"What are some notable museums in Berlin?\"\n", " }\n", "}\n", "```\n", "\n", "\u001b[0m\n", "Observation: \u001b[36;1m\u001b[1;3m\n", "Some notable museums in Berlin include the Deutsches Historisches Museum, the Bauhaus Archive, the Jewish Museum, the German Museum of Technology, the Museum für Naturkunde, the Museum of Asian Art, the Ethnological Museum, the Museum of European Cultures, the Allied Museum, the Brücke Museum, the Stasi Museum, the Beate Uhse Erotic Museum, and the Pergamon Museum.\u001b[0m\n", "Thought:\u001b[32;1m\u001b[1;3mThe human may also be interested in learning about the music scene in Berlin.\n", "\n", "Action:\n", "```\n", "{\n", " \"action\": \"Wikipedia Tool\",\n", " \"action_input\": {\n", " \"pages\": [\"Music in Berlin\"],\n", " \"query_str\": \"What is the music scene like in Berlin?\"\n", " }\n", "}\n", "```\n", "\n", "\u001b[0m\n", "Observation: \u001b[36;1m\u001b[1;3m\n", "The music scene in Berlin is vibrant and diverse. It is home to many nightclubs, including Kunst Haus Tacheles, Cookies, Tresor, WMF, Ufo, E-Werk, KitKatClub and Berghain, which are known for their long parties. It is also home to many concert music institutions, such as the Berlin Philharmonic Orchestra, the Konzerthausorchester Berlin, the Berlin Radio Symphony Orchestra, the Staatskapelle Berlin, and the SO36 in Kreuzberg. The city is also known for its influence on rock music, with bands like U2 recording at Hansa Studios near the Berlin Wall. Additionally, Berlin is home to many creative industries, such as music, film, advertising, architecture, art, design, fashion, performing arts, publishing, TV, radio, and video games. It is also home to many important musical figures, such as Johann Joachim Quantz, Carl Philipp Emanuel Bach, the Graun brothers, Wilhelm Friedemann Bach, Carl Friedrich Christian Fasch, Johann Friedrich Reichardt, Carl Friedrich Zelter, Friedrich Heinrich Himmel, Vincenzo Righini, Felix Mendelssohn Bartholdy, Spontini, Meyerbeer, Richard Strauss, Arnold Schoenberg, Friedrich Wilhelm Marpurg, Johann Philipp Kirnberger, Reichardt, E. T. A. Hoffmann, Ludwig Rellstab, and A. B. Marx. There are also three major opera houses in Berlin: the Deutsche Oper, the Berlin State Opera, and the Komische Oper.\u001b[0m\n", "Thought:\u001b[32;1m\u001b[1;3mThe human may want to know more about the theater scene in Berlin.\n", "\n", "Action:\n", "```\n", "{\n", " \"action\": \"Wikipedia Tool\",\n", " \"action_input\": {\n", " \"pages\": [\"Theatre in Berlin\"],\n", " \"query_str\": \"What is the theater scene like in Berlin?\"\n", " }\n", "}\n", "```\n", "\n", "\n", "\u001b[0m\n", "Observation: \u001b[36;1m\u001b[1;3m\n", "The theater scene in Berlin is vibrant and diverse. There are a variety of venues, from traditional theaters to modern cinemas, as well as a range of genres and styles. The Berlin Wintergarten theatre, which opened in 1887 and was destroyed during the Second World War, was the first Bioscop movie theater in history. The theatre was restarted, relocated and the title licensed in 1992, and is now located on Potsdamer Straße just South of Potsdamer Platz in Berlin. There are also many other theaters in the city, including the Berliner Ensemble, the Volksbühne, and the Schaubühne.\u001b[0m\n", "Thought:\u001b[32;1m\u001b[1;3mThe human may want to know more about the street art scene in Berlin.\n", "\n", "Action:\n", "```\n", "{\n", " \"action\": \"Wikipedia Tool\",\n", " \"action_input\": {\n", " \"pages\": [\"Street art in Berlin\"],\n", " \"query_str\": \"What is the street art scene like in Berlin?\"\n", " }\n", "}\n", "```\n", "\n", "\n", "\u001b[0m\n", "Observation: \u001b[36;1m\u001b[1;3m\n", "The street art scene in Berlin is vibrant and diverse. It has been home to street artists such as Thierry Noir Tavar Zawacki a.k.a. ABOVE and SP 38, and post-communism, cheap rents, and ramshackle buildings have given rise to street art in areas such as Mitte, Prenzlauer Berg, Kreuzberg, and Friedrichshain. In 2016, StreetArtNews initiated an urban artwork in the name of Urban Nation Berlin, in which several famous artists participated. Street art by Bleepsgr, whose work has been categorized as \"artivism\", can be found in neighborhoods such as Psiri.\u001b[0m\n", "Thought:\u001b[32;1m\u001b[1;3mThe human may want to know more about the film industry in Berlin.\n", "\n", "Action:\n", "```\n", "{\n", " \"action\": \"Wikipedia Tool\",\n", " \"action_input\": {\n", " \"pages\": [\"Cinema of Germany\"],\n", " \"query_str\": \"What is the film industry like in Berlin?\"\n", " }\n", "}\n", "```\n", "\n", "\n", "\u001b[0m\n", "Observation: \u001b[36;1m\u001b[1;3m\n", "The film industry in Berlin is thriving and has a long history. It is home to the Berlin International Film Festival, the Deutsche Filmakademie, and several film schools. Berlin is also home to many prominent personalities in the film industry, such as Dieter Kosslick, director of the Berlin International Film Festival, and Fritz Lang, a renowned director. The city is also home to several production companies, and is a major hub for the German film industry. Berlin is known for its diverse range of films, from silent films to contemporary works, and is a major center for the production of both feature films and television series.\u001b[0m\n", "Thought:\u001b[32;1m\u001b[1;3mThe human may want to know more about the literature scene in Berlin.\n", "\n", "Action:\n", "```\n", "{\n", " \"action\": \"Wikipedia Tool\",\n", " \"action_input\": {\n", " \"pages\": [\"Literature in Berlin\"],\n", " \"query_str\": \"What is the literature scene like in Berlin?\"\n", " }\n", "}\n", "```\n", "\n", "\n", "\n", "\u001b[0m\n", "Observation: \u001b[36;1m\u001b[1;3m\n", "The literature scene in Berlin is quite diverse and vibrant. There are a variety of literary genres represented in the city, from poetry to prose to children's literature. Berlin is home to a number of literary festivals, book fairs, and other events that celebrate the written word. There are also a number of independent bookstores, libraries, and other literary institutions that promote the reading and writing of literature. Berlin is also home to a number of renowned authors, including Nobel Prize winners Günter Grass and Herta Müller.\u001b[0m\n", "Thought:\u001b[32;1m\u001b[1;3mThe human may want to know more about the architecture scene in Berlin.\n", "\n", "Action:\n", "```\n", "{\n", " \"action\": \"Wikipedia Tool\",\n", " \"action_input\": {\n", " \"pages\": [\"Architecture in Berlin\"],\n", " \"query_str\": \"What is the architecture scene like in Berlin?\"\n", " }\n", "}\n", "```\n", "\n", "\n", "\n", "\u001b[0m\n", "Observation: \u001b[36;1m\u001b[1;3m\n", "Berlin's architecture scene is incredibly diverse and eclectic. The city has been shaped by its history, with each of the governments based in Berlin initiating ambitious construction programs that have left their distinct mark on the city. There are many Plattenbauten in Eastern Berlin, as well as the iconic East Side Gallery, Fernsehturm, Gendarmenmarkt, Museum Island, Unter den Linden, Brandenburg Gate, Potsdamer Platz, Hackescher Markt, Straße des 17. Juni, Kurfürstendamm, Schloss Bellevue, and Funkturm Berlin. These landmarks are a mix of classical, modern, and postmodern architecture, and many of them have been restored after suffering damage during World War II.\u001b[0m\n", "Thought:\u001b[32;1m\u001b[1;3mThe human may want to know more about the fashion scene in Berlin.\n", "\n", "Action:\n", "```\n", "{\n", " \"action\": \"Wikipedia Tool\",\n", " \"action_input\": {\n", " \"pages\": [\"Fashion in Berlin\"],\n", " \"query_str\": \"What is the fashion scene like in Berlin?\"\n", " }\n", "}\n", "```\n", "\n", "\n", "\n", "\u001b[0m\n", "Observation: \u001b[36;1m\u001b[1;3m\n", "The fashion scene in Berlin is vibrant and creative, with many young designers flourishing in the fashion capital. Mercedes-Benz is the main sponsor of the fashion week, which takes place twice a year in January and July. There are a variety of fashion fairs, such as BREAD & BUTTER, Premium Fair, Bright Tradeshow, (capsule), Show&Order, PanoramaBerlin and The Gallery Berlin. The StyleNite by Berlin-based designer Michael Michalsky is a popular event, featuring unusual performances of different art disciplines combined with state-of-the-art fashion. Models of all ages and abilities are featured in the shows, including disabled models and models aged over 60.\u001b[0m\n", "Thought:\u001b[32;1m\u001b[1;3mThe human may want to know more about the food scene in Berlin.\n", "\n", "Action:\n", "```\n", "{\n", " \"action\": \"Wikipedia Tool\",\n", " \"action_input\": {\n", " \"pages\": [\"Cuisine of Berlin\"],\n", " \"query_str\": \"What is the food scene like in Berlin?\"\n", " }\n", "}\n", "```\n", "\n", "\n", "\u001b[0m\n", "Observation: \u001b[36;1m\u001b[1;3m\n", "The food scene in Berlin is very diverse and international. It is home to a wide variety of cuisines, including German, Turkish, Arab, Vietnamese, Chinese, Thai, Indian, Korean, Japanese, Spanish, Italian, and Greek. There are numerous restaurants, pubs, bakeries, and delicatessen markets, as well as fast-food versions of the doner kebab sandwich. Berlin is also well known for its vegetarian and vegan cuisine, innovative food scene, pop-up street food markets, supper clubs, and food festivals. Additionally, there are seven restaurants that have been awarded two Michelin stars and 14 restaurants that have been awarded one Michelin star.\u001b[0m\n", "Thought:\u001b[32;1m\u001b[1;3mThe human may want to know more about the dance scene in Berlin.\n", "\n", "Action:\n", "```\n", "{\n", " \"action\": \"Wikipedia Tool\",\n", " \"action_input\": {\n", " \"pages\": [\"Dance in Germany\"],\n", " \"query_str\": \"What is the dance scene like in Berlin?\"\n", " }\n", "}\n", "```\n", "\n", "\n", "\n", "\u001b[0m"]}, {"name": "stderr", "output_type": "stream", "text": ["/Users/jerryliu/Programming/gpt_index/.venv/lib/python3.10/site-packages/wikipedia/wikipedia.py:389: GuessedAtParserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system (\"lxml\"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently.\n", "\n", "The code that caused this warning is on line 389 of the file /Users/jerryliu/Programming/gpt_index/.venv/lib/python3.10/site-packages/wikipedia/wikipedia.py. To get rid of this warning, pass the additional argument 'features=\"lxml\"' to the BeautifulSoup constructor.\n", "\n", " lis = BeautifulSoup(html).find_all('li')\n"]}, {"ename": "DisambiguationError", "evalue": "\"Dance, Dance, Dance\" may refer to: \n\"Dance, Dance, Dance\" (The Beach Boys song)\n\"Dance, Dance, Dance\" (Neil Young song)\n\"Dance, Dance, Dance\" (Yowsah, Yowsah, Yowsah)\n\"Dance Dance Dance\" (James Cottriall song)\n\"Dance Dance Dance\" (E-girls song)\nDance Dance Dance/My Lady\nsoundtrack\nWhy Do You Have to Go/Dance, Dance, Dance\nYouth Novels\nFly Like an Eagle\nDance Dance Dance (German TV series)\nDance Dance Dance (British TV series)\nDance Dance Dance (novel)\nDance, Dance, Dance: The Best of Chic\nDance, Dance (disambiguation)", "output_type": "error", "traceback": ["\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mDisambiguationError\u001b[0m Traceback (most recent call last)", "Cell \u001b[0;32mIn[12], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43magent\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mTell me about the arts and culture of Berlin\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n", "File \u001b[0;32m~/Programming/gpt_index/.venv/lib/python3.10/site-packages/langchain/chains/base.py:236\u001b[0m, in \u001b[0;36mChain.run\u001b[0;34m(self, callbacks, *args, **kwargs)\u001b[0m\n\u001b[1;32m 234\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(args) \u001b[38;5;241m!=\u001b[39m \u001b[38;5;241m1\u001b[39m:\n\u001b[1;32m 235\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m`run` supports only one positional argument.\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m--> 236\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43margs\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcallbacks\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcallbacks\u001b[49m\u001b[43m)\u001b[49m[\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39moutput_keys[\u001b[38;5;241m0\u001b[39m]]\n\u001b[1;32m 238\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m kwargs \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m args:\n\u001b[1;32m 239\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m(kwargs, callbacks\u001b[38;5;241m=\u001b[39mcallbacks)[\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39moutput_keys[\u001b[38;5;241m0\u001b[39m]]\n", "File \u001b[0;32m~/Programming/gpt_index/.venv/lib/python3.10/site-packages/langchain/chains/base.py:140\u001b[0m, in \u001b[0;36mChain.__call__\u001b[0;34m(self, inputs, return_only_outputs, callbacks)\u001b[0m\n\u001b[1;32m 138\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m (\u001b[38;5;167;01mKeyboardInterrupt\u001b[39;00m, \u001b[38;5;167;01mException\u001b[39;00m) \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m 139\u001b[0m run_manager\u001b[38;5;241m.\u001b[39mon_chain_error(e)\n\u001b[0;32m--> 140\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m e\n\u001b[1;32m 141\u001b[0m run_manager\u001b[38;5;241m.\u001b[39mon_chain_end(outputs)\n\u001b[1;32m 142\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mprep_outputs(inputs, outputs, return_only_outputs)\n", "File \u001b[0;32m~/Programming/gpt_index/.venv/lib/python3.10/site-packages/langchain/chains/base.py:134\u001b[0m, in \u001b[0;36mChain.__call__\u001b[0;34m(self, inputs, return_only_outputs, callbacks)\u001b[0m\n\u001b[1;32m 128\u001b[0m run_manager \u001b[38;5;241m=\u001b[39m callback_manager\u001b[38;5;241m.\u001b[39mon_chain_start(\n\u001b[1;32m 129\u001b[0m {\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mname\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__class__\u001b[39m\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m},\n\u001b[1;32m 130\u001b[0m inputs,\n\u001b[1;32m 131\u001b[0m )\n\u001b[1;32m 132\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 133\u001b[0m outputs \u001b[38;5;241m=\u001b[39m (\n\u001b[0;32m--> 134\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_call\u001b[49m\u001b[43m(\u001b[49m\u001b[43minputs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mrun_manager\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrun_manager\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 135\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m new_arg_supported\n\u001b[1;32m 136\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_call(inputs)\n\u001b[1;32m 137\u001b[0m )\n\u001b[1;32m 138\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m (\u001b[38;5;167;01mKeyboardInterrupt\u001b[39;00m, \u001b[38;5;167;01mException\u001b[39;00m) \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m 139\u001b[0m run_manager\u001b[38;5;241m.\u001b[39mon_chain_error(e)\n", "File \u001b[0;32m~/Programming/gpt_index/.venv/lib/python3.10/site-packages/langchain/agents/agent.py:951\u001b[0m, in \u001b[0;36mAgentExecutor._call\u001b[0;34m(self, inputs, run_manager)\u001b[0m\n\u001b[1;32m 949\u001b[0m \u001b[38;5;66;03m# We now enter the agent loop (until it returns something).\u001b[39;00m\n\u001b[1;32m 950\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_should_continue(iterations, time_elapsed):\n\u001b[0;32m--> 951\u001b[0m next_step_output \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_take_next_step\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 952\u001b[0m \u001b[43m \u001b[49m\u001b[43mname_to_tool_map\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 953\u001b[0m \u001b[43m \u001b[49m\u001b[43mcolor_mapping\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 954\u001b[0m \u001b[43m \u001b[49m\u001b[43minputs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 955\u001b[0m \u001b[43m \u001b[49m\u001b[43mintermediate_steps\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 956\u001b[0m \u001b[43m \u001b[49m\u001b[43mrun_manager\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrun_manager\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 957\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 958\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(next_step_output, AgentFinish):\n\u001b[1;32m 959\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_return(\n\u001b[1;32m 960\u001b[0m next_step_output, intermediate_steps, run_manager\u001b[38;5;241m=\u001b[39mrun_manager\n\u001b[1;32m 961\u001b[0m )\n", "File \u001b[0;32m~/Programming/gpt_index/.venv/lib/python3.10/site-packages/langchain/agents/agent.py:818\u001b[0m, in \u001b[0;36mAgentExecutor._take_next_step\u001b[0;34m(self, name_to_tool_map, color_mapping, inputs, intermediate_steps, run_manager)\u001b[0m\n\u001b[1;32m 816\u001b[0m tool_run_kwargs[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mllm_prefix\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 817\u001b[0m \u001b[38;5;66;03m# We then call the tool on the tool input to get an observation\u001b[39;00m\n\u001b[0;32m--> 818\u001b[0m observation \u001b[38;5;241m=\u001b[39m \u001b[43mtool\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 819\u001b[0m \u001b[43m \u001b[49m\u001b[43magent_action\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtool_input\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 820\u001b[0m \u001b[43m \u001b[49m\u001b[43mverbose\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mverbose\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 821\u001b[0m \u001b[43m \u001b[49m\u001b[43mcolor\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcolor\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 822\u001b[0m \u001b[43m \u001b[49m\u001b[43mcallbacks\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrun_manager\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_child\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mrun_manager\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01melse\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 823\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mtool_run_kwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 824\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 825\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 826\u001b[0m tool_run_kwargs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39magent\u001b[38;5;241m.\u001b[39mtool_run_logging_kwargs()\n", "File \u001b[0;32m~/Programming/gpt_index/.venv/lib/python3.10/site-packages/langchain/tools/base.py:255\u001b[0m, in \u001b[0;36mBaseTool.run\u001b[0;34m(self, tool_input, verbose, start_color, color, callbacks, **kwargs)\u001b[0m\n\u001b[1;32m 253\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m (\u001b[38;5;167;01mException\u001b[39;00m, \u001b[38;5;167;01mKeyboardInterrupt\u001b[39;00m) \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m 254\u001b[0m run_manager\u001b[38;5;241m.\u001b[39mon_tool_error(e)\n\u001b[0;32m--> 255\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m e\n\u001b[1;32m 256\u001b[0m run_manager\u001b[38;5;241m.\u001b[39mon_tool_end(\u001b[38;5;28mstr\u001b[39m(observation), color\u001b[38;5;241m=\u001b[39mcolor, name\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mname, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m 257\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m observation\n", "File \u001b[0;32m~/Programming/gpt_index/.venv/lib/python3.10/site-packages/langchain/tools/base.py:249\u001b[0m, in \u001b[0;36mBaseTool.run\u001b[0;34m(self, tool_input, verbose, start_color, color, callbacks, **kwargs)\u001b[0m\n\u001b[1;32m 246\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 247\u001b[0m tool_args, tool_kwargs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_to_args_and_kwargs(parsed_input)\n\u001b[1;32m 248\u001b[0m observation \u001b[38;5;241m=\u001b[39m (\n\u001b[0;32m--> 249\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_run\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mtool_args\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mrun_manager\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mrun_manager\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mtool_kwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 250\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m new_arg_supported\n\u001b[1;32m 251\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_run(\u001b[38;5;241m*\u001b[39mtool_args, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mtool_kwargs)\n\u001b[1;32m 252\u001b[0m )\n\u001b[1;32m 253\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m (\u001b[38;5;167;01mException\u001b[39;00m, \u001b[38;5;167;01mKeyboardInterrupt\u001b[39;00m) \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m 254\u001b[0m run_manager\u001b[38;5;241m.\u001b[39mon_tool_error(e)\n", "File \u001b[0;32m~/Programming/gpt_index/.venv/lib/python3.10/site-packages/langchain/tools/base.py:436\u001b[0m, in \u001b[0;36mStructuredTool._run\u001b[0;34m(self, run_manager, *args, **kwargs)\u001b[0m\n\u001b[1;32m 427\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"Use the tool.\"\"\"\u001b[39;00m\n\u001b[1;32m 428\u001b[0m new_argument_supported \u001b[38;5;241m=\u001b[39m signature(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mfunc)\u001b[38;5;241m.\u001b[39mparameters\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcallbacks\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 429\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m (\n\u001b[1;32m 430\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mfunc(\n\u001b[1;32m 431\u001b[0m \u001b[38;5;241m*\u001b[39margs,\n\u001b[1;32m 432\u001b[0m callbacks\u001b[38;5;241m=\u001b[39mrun_manager\u001b[38;5;241m.\u001b[39mget_child() \u001b[38;5;28;01mif\u001b[39;00m run_manager \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m,\n\u001b[1;32m 433\u001b[0m \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs,\n\u001b[1;32m 434\u001b[0m )\n\u001b[1;32m 435\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m new_argument_supported\n\u001b[0;32m--> 436\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 437\u001b[0m )\n", "File \u001b[0;32m~/Programming/gpt_index/llama_index/tools/ondemand_loader_tool.py:114\u001b[0m, in \u001b[0;36mOnDemandLoaderTool.__call__\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 112\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 113\u001b[0m query_str \u001b[38;5;241m=\u001b[39m kwargs\u001b[38;5;241m.\u001b[39mpop(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_query_str_kwargs_key)\n\u001b[0;32m--> 114\u001b[0m docs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_reader\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mload_data\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 115\u001b[0m index \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_index_cls\u001b[38;5;241m.\u001b[39mfrom_documents(docs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_index_kwargs)\n\u001b[1;32m 116\u001b[0m \u001b[38;5;66;03m# TODO: add query kwargs\u001b[39;00m\n", "File \u001b[0;32m~/Programming/gpt_index/llama_index/readers/wikipedia.py:35\u001b[0m, in \u001b[0;36mWikipediaReader.load_data\u001b[0;34m(self, pages, **load_kwargs)\u001b[0m\n\u001b[1;32m 33\u001b[0m results \u001b[38;5;241m=\u001b[39m []\n\u001b[1;32m 34\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m page \u001b[38;5;129;01min\u001b[39;00m pages:\n\u001b[0;32m---> 35\u001b[0m page_content \u001b[38;5;241m=\u001b[39m \u001b[43mwikipedia\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mpage\u001b[49m\u001b[43m(\u001b[49m\u001b[43mpage\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mload_kwargs\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241m.\u001b[39mcontent\n\u001b[1;32m 36\u001b[0m results\u001b[38;5;241m.\u001b[39mappend(Document(page_content))\n\u001b[1;32m 37\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m results\n", "File \u001b[0;32m~/Programming/gpt_index/.venv/lib/python3.10/site-packages/wikipedia/wikipedia.py:276\u001b[0m, in \u001b[0;36mpage\u001b[0;34m(title, pageid, auto_suggest, redirect, preload)\u001b[0m\n\u001b[1;32m 273\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mIndexError\u001b[39;00m:\n\u001b[1;32m 274\u001b[0m \u001b[38;5;66;03m# if there is no suggestion or search results, the page doesn't exist\u001b[39;00m\n\u001b[1;32m 275\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m PageError(title)\n\u001b[0;32m--> 276\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mWikipediaPage\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtitle\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mredirect\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mredirect\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpreload\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpreload\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 277\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m pageid \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 278\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m WikipediaPage(pageid\u001b[38;5;241m=\u001b[39mpageid, preload\u001b[38;5;241m=\u001b[39mpreload)\n", "File \u001b[0;32m~/Programming/gpt_index/.venv/lib/python3.10/site-packages/wikipedia/wikipedia.py:299\u001b[0m, in \u001b[0;36mWikipediaPage.__init__\u001b[0;34m(self, title, pageid, redirect, preload, original_title)\u001b[0m\n\u001b[1;32m 296\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 297\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mEither a title or a pageid must be specified\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m--> 299\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m__load\u001b[49m\u001b[43m(\u001b[49m\u001b[43mredirect\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mredirect\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpreload\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpreload\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 301\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m preload:\n\u001b[1;32m 302\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m prop \u001b[38;5;129;01min\u001b[39;00m (\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mcontent\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124msummary\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mimages\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mreferences\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mlinks\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124msections\u001b[39m\u001b[38;5;124m'\u001b[39m):\n", "File \u001b[0;32m~/Programming/gpt_index/.venv/lib/python3.10/site-packages/wikipedia/wikipedia.py:393\u001b[0m, in \u001b[0;36mWikipediaPage.__load\u001b[0;34m(self, redirect, preload)\u001b[0m\n\u001b[1;32m 390\u001b[0m filtered_lis \u001b[38;5;241m=\u001b[39m [li \u001b[38;5;28;01mfor\u001b[39;00m li \u001b[38;5;129;01min\u001b[39;00m lis \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mtocsection\u001b[39m\u001b[38;5;124m'\u001b[39m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m.\u001b[39mjoin(li\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mclass\u001b[39m\u001b[38;5;124m'\u001b[39m, []))]\n\u001b[1;32m 391\u001b[0m may_refer_to \u001b[38;5;241m=\u001b[39m [li\u001b[38;5;241m.\u001b[39ma\u001b[38;5;241m.\u001b[39mget_text() \u001b[38;5;28;01mfor\u001b[39;00m li \u001b[38;5;129;01min\u001b[39;00m filtered_lis \u001b[38;5;28;01mif\u001b[39;00m li\u001b[38;5;241m.\u001b[39ma]\n\u001b[0;32m--> 393\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m DisambiguationError(\u001b[38;5;28mgetattr\u001b[39m(\u001b[38;5;28mself\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mtitle\u001b[39m\u001b[38;5;124m'\u001b[39m, page[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mtitle\u001b[39m\u001b[38;5;124m'\u001b[39m]), may_refer_to)\n\u001b[1;32m 395\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 396\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mpageid \u001b[38;5;241m=\u001b[39m pageid\n", "\u001b[0;31mDisambiguationError\u001b[0m: \"Dance, Dance, Dance\" may refer to: \n\"Dance, Dance, Dance\" (The Beach Boys song)\n\"Dance, Dance, Dance\" (Neil Young song)\n\"Dance, Dance, Dance\" (Yowsah, Yowsah, Yowsah)\n\"Dance Dance Dance\" (James Cottriall song)\n\"Dance Dance Dance\" (E-girls song)\nDance Dance Dance/My Lady\nsoundtrack\nWhy Do You Have to Go/Dance, Dance, Dance\nYouth Novels\nFly Like an Eagle\nDance Dance Dance (German TV series)\nDance Dance Dance (British TV series)\nDance Dance Dance (novel)\nDance, Dance, Dance: The Best of Chic\nDance, Dance (disambiguation)"]}], "source": ["agent.run(\"Tell me about the arts and culture of Berlin\")"]}, {"cell_type": "code", "execution_count": null, "id": "3ef18513-9261-4916-8592-a5dea0ffcf0e", "metadata": {}, "outputs": [{"name": "stdout", "output_type": "stream", "text": ["\n", "\n", "\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n", "\u001b[32;1m\u001b[1;3mAction:\n", "```\n", "{\n", " \"action\": \"Wikipedia Tool\",\n", " \"action_input\": {\n", " \"pages\": [\"The Departed\"],\n", " \"query_str\": \"critical reception\"\n", " }\n", "}\n", "```\n", "\n", "\u001b[0m\n", "Observation: \u001b[36;1m\u001b[1;3m\n", "The critical reception of The Departed was overwhelmingly positive. On review aggregator Rotten Tomatoes, the film holds a 91% approval rating based on 284 reviews, with an average rating of 8.3/10. The website's critics consensus reads, \"Featuring outstanding work from an excellent cast, The Departed is a thoroughly engrossing gangster drama with the gritty authenticity and soupy morality we have come to expect from Martin Scorsese.\" Metacritic, which uses a weighted average, assigned the film a score of 85 out of 100 based on 39 critics, indicating \"universal acclaim\". Audiences polled by CinemaScore gave the film an average grade of \"A−\" on an A+ to F scale. Entertainment Weekly ranked it on its end-of-the-decade \"Best of\" list, saying: \"If they're lucky, directors make one classic film in their career. Martin Scorsese has one per decade (Taxi Driver in the '70s, Raging Bull in the '80s, Goodfellas in the '90s). His 2006 Irish Mafia masterpiece kept the streak alive.\" Roger Ebert gave the film four stars out of four, praising Scorsese for thematically differentiating his film from the original. Online critic James Berardinelli awarded the film four stars out of four, praising it as \"an American epic tragedy.\" He went on to claim that the film deserves to be ranked alongside Scorsese's past successes, including Taxi Driver, Raging Bull and Goodfellas.\u001b[0m\n", "Thought:\u001b[32;1m\u001b[1;3mThe critical reception to The Departed was very positive. \n", "Action:\n", "```\n", "{\n", " \"action\": \"Final Answer\",\n", " \"action_input\": \"The critical reception to The Departed was overwhelmingly positive, with an approval rating of 91% on Rotten Tomatoes and a score of 85 out of 100 on Metacritic. It was praised for its outstanding cast, gritty authenticity, and soupy morality. Many critics ranked it alongside Scorsese's past successes, including Taxi Driver, Raging Bull, and Goodfellas.\"\n", "}\n", "```\n", "\u001b[0m\n", "\n", "\u001b[1m> Finished chain.\u001b[0m\n"]}, {"data": {"text/plain": ["\"The critical reception to The Departed was overwhelmingly positive, with an approval rating of 91% on Rotten Tomatoes and a score of 85 out of 100 on Metacritic. It was praised for its outstanding cast, gritty authenticity, and soupy morality. Many critics ranked it alongside Scorsese's past successes, including Taxi Driver, Raging Bull, and Goodfellas.\""]}, "execution_count": null, "metadata": {}, "output_type": "execute_result"}], "source": ["agent.run(\"Tell me about the critical reception to The Departed\")"]}], "metadata": {"kernelspec": {"display_name": "venv", "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"}}, "nbformat": 4, "nbformat_minor": 5}