Fixing merge conflicts

pull/1077/head
Colin Jarvis 1 year ago
commit 54d9af7d1f

@ -7,28 +7,33 @@
"source": [
"# How to build a tool-using agent with LangChain\n",
"\n",
"This notebook takes you through how to build an end-to-end LLM application powered by Langchain and OpenAI models, with access to external tools. This is a common design pattern for building products with LLMs that require:\n",
"- Access to proprietary information and APIs\n",
"- Multi-step logical reasoning\n",
"- Enhanced reliability\n",
"\n",
"By the end of this cookbook you'll be able to create tailored LLM agents that use custom tools to solve user queries.\n",
"This notebook takes you through how to use LangChain to augment an OpenAI model with access to external tools. In particular, you'll be able to create LLM agents that use custom tools to answer user queries.\n",
"\n",
"\n",
<<<<<<< HEAD:examples/How_to_build_a_tool-using_agent_with_Langchain.ipynb
"## What is Langchain?\n",
"[LangChain](https://python.langchain.com/en/latest/index.html) is a framework for developing applications powered by language models. Their framework enables you to build layered LLM-powered applications that are context-aware and able to interact dynamically with their environment as agents, leading to simplified code for you and a more dynamic user experience for your customers.\n",
"\n",
"## Why do LLMs need to use Tools?\n",
"One of the most common challenges with LLMs is overcoming the lack of recency and specificity in their training data - answers can be out of date, and they are prone to hallucinations given the huge variety in their knowledge base. Tools are a great method of allowing an LLM to answer within a controlled context that draws on your existing knowledge bases and internal APIs - instead of trying to prompt engineer the LLM all the way to your intended answer, you allow it access to tools that it calls on dynamically for info, parses, and serves to customer. \n",
=======
"## What is Langchain\n",
"\n",
"LangChain is a [framework](https://python.langchain.com/en/latest/index.html) for developing applications powered by language models. Its main features include prompt chaining (running a sequence of language model queries in which outputs of earlier queries are made part of the input of later queries) and utilities for converting language models into tool-using agents.\n",
"\n",
"\n",
"## Why do LLMs need to use Tools\n",
>>>>>>> 2b6f6392b1ff679ed0ff246202f9a2cf5b3f9b12:examples/Conversational_agents_using_tools.ipynb
"\n",
"A classic example is Search, where rather than answering using stale training data your LLM can use a browser to source information and summarise the answer back. Tools can also work [together](https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl_chat.html), with a Search tool to return numbers and a Calculator to execute mathematical functions being one common example.\n",
"Providing LLMs access to tools can enable them to answer questions with context directly from search engines, APIs or your own databases. Instead of answering directly, an LLM with access to tools can perform intermediate steps to gather relevant information. Tools can also be used in combination. [For example](https://python.langchain.com/en/latest/modules/agents/agents/examples/mrkl_chat.html), a language model can be made to use a search tool to lookup quantitative information and a calculator to execute calculations.\n",
"\n",
"### Flow\n",
"- **Setup:** Import packages, set any required variables and connect to a vector database.\n",
"## Notebook Sections\n",
"\n",
"- **Setup:** Import packages and connect to a Pinecone vector database.\n",
"- **LLM Agent:** Build an agent that leverages a modified version of the [ReAct](https://react-lm.github.io/) framework to do chain-of-thought reasoning.\n",
"- **LLM Agent with History:** Add the concept of memory so the LLM can draw on conversation context.\n",
"- **Knowledge Base:** Create a knowledge base of Stuff You Should Know podcast episodes that we can use as a tool.\n",
"- **LLM Agent with Tools:** Extend the agent with access to two tools and test that it uses both to answer questions."
"- **LLM Agent with History:** Provide the LLM with access to previous steps in the conversation.\n",
"- **Knowledge Base:** Create a knowledge base of \"Stuff You Should Know\" podcast episodes, to be accessed through a tool.\n",
"- **LLM Agent with Tools:** Extend the agent with access to multiple tools and test that it uses both to answer questions."
]
},
{
@ -84,7 +89,6 @@
"metadata": {},
"outputs": [],
"source": [
"# Imports\n",
"import os\n",
"import pinecone\n",
"import openai\n",
@ -96,16 +100,15 @@
"from tqdm.auto import tqdm\n",
"import datetime\n",
"\n",
"\n",
"# Langchain imports\n",
"from langchain.agents import Tool, AgentExecutor, LLMSingleActionAgent, AgentOutputParser\n",
"from langchain.prompts import BaseChatPromptTemplate, ChatPromptTemplate\n",
"from langchain import SerpAPIWrapper, LLMChain\n",
"from langchain.schema import AgentAction, AgentFinish, HumanMessage, SystemMessage\n",
"## LLM\n",
"# LLM wrapper\n",
"from langchain.chat_models import ChatOpenAI\n",
"from langchain import OpenAI\n",
"## Langchain memory\n",
"# Conversational memory\n",
"from langchain.memory import ConversationBufferWindowMemory\n",
"# Embeddings and vectorstore\n",
"from langchain.embeddings.openai import OpenAIEmbeddings\n",
@ -177,12 +180,19 @@
"\n",
"An [LLM agent](https://python.langchain.com/en/latest/modules/agents/agents/custom_llm_agent.html) in Langchain has many configurable components, which are detailed in the Langchain documentation.\n",
"\n",
<<<<<<< HEAD:examples/How_to_build_a_tool-using_agent_with_Langchain.ipynb
"We'll employ a few of the core concepts to make an agent who talks in the way we want, can use tools to answer questions, and uses the appropriate language model to power the conversation.\n",
"- **Prompt Template:** The input template to control the LLM's behaviour and how it accepts inputs and produces outputs - this is the brain that drives your application ([docs](https://python.langchain.com/en/latest/modules/prompts/prompt_templates.html)).\n",
"- **Output Parser:** A method of parsing the output from the prompt. If the LLM produces output using certain headers, you can enable complex interactions where variables are generated by the LLM in their response and passed into the next step of the chain ([docs](https://python.langchain.com/en/latest/modules/prompts/output_parsers.html)).\n",
"- **LLM Chain:** A Chain brings together a prompt template with an LLM that will execute it - in this case we'll be using ```gpt-3.5-turbo``` but this framework can be used with OpenAI completions models, or other LLMs entirely ([docs](https://python.langchain.com/en/latest/modules/chains.html)).\n",
=======
"We'll employ a few of the core concepts to make an agent who talks in the way we want, can use tools to answer questions, and uses the right base LLM to power the conversation.\n",
"- **Prompt Template:** The template to control the LLM's behaviour, in particular what inputs it expects and what outputs it produces ([docs](https://python.langchain.com/en/latest/modules/prompts/prompt_templates.html)).\n",
"- **Output Parser:** The LLM can specify actions to be taken but these actions need to be parsed from its outputs ([docs](https://python.langchain.com/en/latest/modules/prompts/output_parsers.html)).\n",
"- **LLM Chain:** A Chain brings together a prompt template with a LLM that will execute it - in this case we'll be using ```gpt-3.5-turbo```([docs](https://python.langchain.com/en/latest/modules/chains.html)).\n",
>>>>>>> 2b6f6392b1ff679ed0ff246202f9a2cf5b3f9b12:examples/Conversational_agents_using_tools.ipynb
"- **Tool:** An external service that the LLM can use to retrieve information or execute commands should the user require it ([docs](https://python.langchain.com/en/latest/modules/agents/tools.html)).\n",
"- **Agent:** The glue that brings all of this together, an agent can call multiple LLM Chains, each with their own tools. Agents can be extended with your own logic to allow retries, error handling and any other methods you choose to add durability to your application ([docs](https://python.langchain.com/en/latest/modules/agents.html)).\n",
"- **Agent:** The glue that brings all of this together, an agent can call multiple LLM Chains, each with their own tools. Agents can be extended with your own logic to allow retries, error handling and any other methods you choose to add reliability to your application ([docs](https://python.langchain.com/en/latest/modules/agents.html)).\n",
"\n",
"**NB:** Before using this cookbook with the Search tool you'll need to sign up on https://serpapi.com/ and generate an API key. Once you have it, store it in an environment variable named ```SERPAPI_API_KEY```"
]
@ -197,7 +207,7 @@
"# Initiate a Search tool - note you'll need to have set SERPAPI_API_KEY as an environment variable as per the above instructions\n",
"search = SerpAPIWrapper()\n",
"\n",
"# Define a list of \n",
"# Define a list of tools\n",
"tools = [\n",
" Tool(\n",
" name = \"Search\",\n",
@ -369,19 +379,24 @@
"text": [
"\n",
"\n",
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
"\u001b[32;1m\u001b[1;3mThought: Hmm, I be not sure of the answer to that one. Let me think.\n",
"\u001B[1m> Entering new AgentExecutor chain...\u001B[0m\n",
"\u001B[32;1m\u001B[1;3mThought: Hmm, I be not sure of the answer to that one. Let me think.\n",
"Action: Search\n",
"Action Input: \"Canada population 2023\"\u001b[0m\n",
"Action Input: \"Canada population 2023\"\u001B[0m\n",
"\n",
<<<<<<< HEAD:examples/How_to_build_a_tool-using_agent_with_Langchain.ipynb
"Observation:\u001b[36;1m\u001b[1;3m39,566,248\u001b[0m\u001b[32;1m\u001b[1;3mAhoy, that be a lot of people! But I need to make sure this be true.\n",
"Action: Search\n",
"Action Input: \"Canada population 2023 official source\"\u001b[0m\n",
"\n",
"Observation:\u001b[36;1m\u001b[1;3mThe current population of Canada is 38,664,637 as of Wednesday, April 19, 2023, based on Worldometer elaboration of the latest United Nations data.\u001b[0m\u001b[32;1m\u001b[1;3mArrr, that be the official number! I be confident in me answer now.\n",
"Final Answer: The population of Canada as of 2023 is 38,664,637. Arg!\u001b[0m\n",
=======
"Observation:\u001B[36;1m\u001B[1;3mThe current population of Canada is 38,662,830 as of Monday, April 17, 2023, based on Worldometer elaboration of the latest United Nations data.\u001B[0m\u001B[32;1m\u001B[1;3mAhoy, that be the answer I was lookin' for!\n",
"Final Answer: The population of Canada as of 2023 be 38,662,830, Arg!\u001B[0m\n",
>>>>>>> 2b6f6392b1ff679ed0ff246202f9a2cf5b3f9b12:examples/Conversational_agents_using_tools.ipynb
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n"
"\u001B[1m> Finished chain.\u001B[0m\n"
]
},
{
@ -538,19 +553,24 @@
"text": [
"\n",
"\n",
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
"\u001b[32;1m\u001b[1;3mThought: I need to find the most recent population data for Canada.\n",
"\u001B[1m> Entering new AgentExecutor chain...\u001B[0m\n",
"\u001B[32;1m\u001B[1;3mThought: I need to find the most recent population data for Canada.\n",
"Action: Search\n",
"Action Input: \"Canada population 2023\"\u001b[0m\n",
"Action Input: \"Canada population 2023\"\u001B[0m\n",
"\n",
<<<<<<< HEAD:examples/How_to_build_a_tool-using_agent_with_Langchain.ipynb
"Observation:\u001b[36;1m\u001b[1;3m39,566,248\u001b[0m\u001b[32;1m\u001b[1;3mThis data seems reliable, but I should double-check the source.\n",
"Action: Search\n",
"Action Input: \"Source of Canada population 2023\"\u001b[0m\n",
"\n",
"Observation:\u001b[36;1m\u001b[1;3mThe current population of Canada is 38,664,637 as of Wednesday, April 19, 2023, based on Worldometer elaboration of the latest United Nations data. Canada 2020 population is estimated at 37,742,154 people at mid year according to UN data. Canada population is equivalent to 0.48% of the total world population.\u001b[0m\u001b[32;1m\u001b[1;3mI now know the final answer\n",
"Final Answer: As of April 19, 2023, the population of Canada is 38,664,637.\u001b[0m\n",
=======
"Observation:\u001B[36;1m\u001B[1;3mThe current population of Canada is 38,662,830 as of Monday, April 17, 2023, based on Worldometer elaboration of the latest United Nations data.\u001B[0m\u001B[32;1m\u001B[1;3mThat's the answer to the question.\n",
"Final Answer: As of April 17, 2023, the population of Canada is 38,662,830.\u001B[0m\n",
>>>>>>> 2b6f6392b1ff679ed0ff246202f9a2cf5b3f9b12:examples/Conversational_agents_using_tools.ipynb
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n"
"\u001B[1m> Finished chain.\u001B[0m\n"
]
},
{
@ -580,19 +600,24 @@
"text": [
"\n",
"\n",
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
"\u001b[32;1m\u001b[1;3mThought: I need to search for the current population of Mexico.\n",
"\u001B[1m> Entering new AgentExecutor chain...\u001B[0m\n",
"\u001B[32;1m\u001B[1;3mThought: I need to search for the current population of Mexico.\n",
"Action: Search\n",
"Action Input: \"current population of Mexico\"\u001b[0m\n",
"Action Input: \"current population of Mexico\"\u001B[0m\n",
"\n",
"Observation:\u001b[36;1m\u001b[1;3mMexico, officially the United Mexican States, is a country in the southern portion of North America. It is bordered to the north by the United States; to the south and west by the Pacific Ocean; to the southeast by Guatemala, Belize, and the Caribbean Sea; and to the east by the Gulf of Mexico.\u001b[0m\u001b[32;1m\u001b[1;3mThat's not the answer to the question, I need to refine my search.\n",
"Observation:\u001B[36;1m\u001B[1;3mMexico, officially the United Mexican States, is a country in the southern portion of North America. It is bordered to the north by the United States; to the south and west by the Pacific Ocean; to the southeast by Guatemala, Belize, and the Caribbean Sea; and to the east by the Gulf of Mexico.\u001B[0m\u001B[32;1m\u001B[1;3mThat's not the answer to the question, I need to refine my search.\n",
"Action: Search\n",
"Action Input: \"population of Mexico 2023\"\u001b[0m\n",
"Action Input: \"population of Mexico 2023\"\u001B[0m\n",
"\n",
<<<<<<< HEAD:examples/How_to_build_a_tool-using_agent_with_Langchain.ipynb
"Observation:\u001b[36;1m\u001b[1;3m132,709,512\u001b[0m\u001b[32;1m\u001b[1;3mI now know the final answer.\n",
"Final Answer: As of 2023, the population of Mexico is 132,709,512.\u001b[0m\n",
=======
"Observation:\u001B[36;1m\u001B[1;3m128,455,567\u001B[0m\u001B[32;1m\u001B[1;3mI now know the final answer.\n",
"Final Answer: As of 2023, the population of Mexico is 128,455,567.\u001B[0m\n",
>>>>>>> 2b6f6392b1ff679ed0ff246202f9a2cf5b3f9b12:examples/Conversational_agents_using_tools.ipynb
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n"
"\u001B[1m> Finished chain.\u001B[0m\n"
]
},
{
@ -650,9 +675,12 @@
],
"source": [
"import wget\n",
"\n",
"# Here is a URL to a zip archive containing the transcribed podcasts\n",
"# Note that this data has already been split into chunks and embeddings from OpenAI's text-embedding-ada-002 embedding model are included\n",
"content_url = 'https://cdn.openai.com/API/examples/data/sysk_podcast_transcripts_embedded.json.zip'\n",
"\n",
"#### The file is ~541 MB so this will take some time\n",
"# Download the file (it is ~541 MB so this will take some time)\n",
"wget.download(content_url)"
]
},
@ -663,13 +691,10 @@
"metadata": {},
"outputs": [],
"source": [
"# Load podcasts\n",
"with zipfile.ZipFile(\"sysk_podcast_transcripts_embedded.json.zip\",\"r\") as zip_ref:\n",
" zip_ref.extractall(\"./data\")\n",
"\n",
"# Opening JSON file\n",
"f = open('./data/sysk_podcast_transcripts_embedded.json')\n",
" \n",
"# Loads podcasts as a dictionary\n",
"processed_podcasts = json.load(f)"
]
},
@ -832,6 +857,8 @@
"metadata": {},
"outputs": [],
"source": [
"# Add the text embeddings to Pinecone\n",
"\n",
"batch_size = 100 # how many embeddings we create and insert at once\n",
"\n",
"for i in tqdm(range(0, len(processed_podcasts), batch_size)):\n",
@ -976,31 +1003,27 @@
},
{
"cell_type": "code",
<<<<<<< HEAD:examples/How_to_build_a_tool-using_agent_with_Langchain.ipynb
"execution_count": 54,
=======
"execution_count": null,
>>>>>>> 2b6f6392b1ff679ed0ff246202f9a2cf5b3f9b12:examples/Conversational_agents_using_tools.ipynb
"id": "d1e12121",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Search', 'Knowledge Base']\n"
]
"metadata": {
"pycharm": {
"is_executing": true
}
],
},
"outputs": [],
"source": [
"# Reinitiate the prompt with our new list of tools\n",
"# Re-initialize the agent with our new list of tools\n",
"prompt_with_history = CustomPromptTemplate(\n",
" template=template_with_history,\n",
" tools=expanded_tools,\n",
" input_variables=[\"input\", \"intermediate_steps\", \"history\"]\n",
")\n",
"\n",
"llm_chain = LLMChain(llm=llm, prompt=prompt_with_history)\n",
"multi_tool_names = [tool.name for tool in expanded_tools]\n",
"\n",
"# Print these to check we have our new tool represented\n",
"print(multi_tool_names)\n",
"multi_tool_agent = LLMSingleActionAgent(\n",
" llm_chain=llm_chain, \n",
" output_parser=output_parser,\n",
@ -1016,7 +1039,7 @@
"metadata": {},
"outputs": [],
"source": [
"multi_tool_memory=ConversationBufferWindowMemory(k=2)\n",
"multi_tool_memory = ConversationBufferWindowMemory(k=2)\n",
"multi_tool_executor = AgentExecutor.from_agent_and_tools(agent=multi_tool_agent, tools=expanded_tools, verbose=True, memory=multi_tool_memory)"
]
},
@ -1034,11 +1057,17 @@
"text": [
"\n",
"\n",
<<<<<<< HEAD:examples/How_to_build_a_tool-using_agent_with_Langchain.ipynb
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
"\u001b[32;1m\u001b[1;3mThought: This is an interesting question. I'm not sure if I have the answer in my knowledge base, so I might need to search for it.\n",
=======
"\u001B[1m> Entering new AgentExecutor chain...\u001B[0m\n",
"\u001B[32;1m\u001B[1;3mThought: This is an interesting question. I'm not sure if this is possible, but I'll try to find out.\n",
>>>>>>> 2b6f6392b1ff679ed0ff246202f9a2cf5b3f9b12:examples/Conversational_agents_using_tools.ipynb
"Action: Search\n",
"Action Input: \"How to live without a bank account\"\u001b[0m\n",
"Action Input: \"How to live without a bank account\"\u001B[0m\n",
"\n",
<<<<<<< HEAD:examples/How_to_build_a_tool-using_agent_with_Langchain.ipynb
"Observation:\u001b[36;1m\u001b[1;3mUnderbanked households have a checking or savings account but also use alternative financial services such as money orders, check cashing, international remittances, payday loans, refund anticipation loans, rent-to-own services, pawnshop loans, or auto title loans, according to the FDIC.\u001b[0m\u001b[32;1m\u001b[1;3mIt seems like there are alternative financial services available for those who don't have a bank account. I should look into this further to provide a more comprehensive answer.\n",
"Action: Search\n",
"Action Input: \"Alternative financial services for those without a bank account\"\u001b[0m\n",
@ -1053,8 +1082,25 @@
"\n",
"Observation:\u001b[33;1m\u001b[1;3m There are a few resources available for alternative financial services or opening a bank account. Prepaid credit cards are becoming more popular and can be found at convenience stores. Capital One offers commercial solutions and a comprehensive suite of financial services tailored to short and long term goals. Airbnb also offers Air Cover for Hosts, which provides $1 million in damage protection, pet damage protection, and income loss protection.\u001b[0m\u001b[32;1m\u001b[1;3mIt's important to note that while prepaid credit cards and alternative financial services can be helpful, they may not offer the same level of protection and benefits as a traditional bank account. It's also important to do research and compare options before making a decision. \n",
"Final Answer: While it is possible to live without a bank account by using alternative financial services, it may come with potential drawbacks and limitations. It's important to do research and compare options before making a decision, and there are resources available for those who may be interested in opening a bank account or exploring alternative financial services.\u001b[0m\n",
=======
"Observation:\u001B[36;1m\u001B[1;3mUnderbanked households have a checking or savings account but also use alternative financial services such as money orders, check cashing, international remittances, payday loans, refund anticipation loans, rent-to-own services, pawnshop loans, or auto title loans, according to the FDIC.\u001B[0m\u001B[32;1m\u001B[1;3mIt seems like there are ways to live without a bank account, but it may not be easy. I should look for more information on alternative financial services.\n",
"Action: Search\n",
"Action Input: \"Alternative financial services for the underbanked\"\u001B[0m\n",
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n"
"Observation:\u001B[36;1m\u001B[1;3mInstead, people who are unbanked use alternative financial services—payday loans, money orders, check cashing services, pawnshop loans, and the like—to meet their banking needs. These financial services fill an important role for unbanked individuals, but they can also cause further financial hardship.\u001B[0m\u001B[32;1m\u001B[1;3mIt seems like there are both advantages and disadvantages to using alternative financial services. I should look for more information on how to manage finances without a bank account.\n",
"Action: Knowledge Base\n",
"Action Input: \"How to manage finances without a bank account\"\u001B[0m\n",
"\n",
"Observation:\u001B[33;1m\u001B[1;3m There are a few things that you can do to manage your finances without a bank account. You can try an alternative currency, get a payday loan from a standard banking institution, or use a prepaid credit card. However, it is important to be aware that prepaid credit cards can be easy to scam, so it is important to be careful when using them.\u001B[0m\u001B[32;1m\u001B[1;3mIt seems like there are some options for managing finances without a bank account, but they may come with risks. I should look for more information on the pros and cons of each option.\n",
"Action: Search\n",
"Action Input: \"Pros and cons of alternative currency, payday loans, and prepaid credit cards\"\u001B[0m\n",
"\n",
"Observation:\u001B[36;1m\u001B[1;3mHere we explore the good, the bad, and the alternatives to cash advances ... Payday loan cash advances: The payday loan operates much like the name implies.\u001B[0m\u001B[32;1m\u001B[1;3mIt seems like there are pros and cons to each option for managing finances without a bank account. I should summarize the information I found to provide a comprehensive answer.\n",
"Thought: Based on my research, it is possible to live without a bank account by using alternative financial services such as payday loans, money orders, check cashing services, pawnshop loans, and prepaid credit cards. However, these options come with risks such as high fees and the potential for scams. It is important to carefully consider the pros and cons of each option and to be cautious when using them. It may also be helpful to seek advice from a financial advisor or credit counselor. \n",
"Final Answer: It is possible to live without a bank account by using alternative financial services, but it is important to carefully consider the risks and to seek advice from a financial professional.\u001B[0m\n",
>>>>>>> 2b6f6392b1ff679ed0ff246202f9a2cf5b3f9b12:examples/Conversational_agents_using_tools.ipynb
"\n",
"\u001B[1m> Finished chain.\u001B[0m\n"
]
},
{
@ -1084,6 +1130,7 @@
"text": [
"\n",
"\n",
<<<<<<< HEAD:examples/How_to_build_a_tool-using_agent_with_Langchain.ipynb
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
"\u001b[32;1m\u001b[1;3mThought: This is a complex topic that requires a balanced perspective\n",
"Action: Knowledge Base\n",
@ -1095,8 +1142,25 @@
"\n",
"Observation:\u001b[36;1m\u001b[1;3mThere are dedicated species survival programs which have helped species come out from the brink of extinction, good examples of that being the black-footed ferrets, the red wolves, the Przewalski's wild horse, and the California condors.\u001b[0m\u001b[32;1m\u001b[1;3mWhile there are valid arguments on both sides, it seems that zoos can have a positive impact on conservation efforts for endangered species.\n",
"Final Answer: Zoos can have both positive and negative effects on animals, but they can play a role in conservation efforts for endangered species. It's important to consider both sides of the argument and do research before forming an opinion.\u001b[0m\n",
=======
"\u001B[1m> Entering new AgentExecutor chain...\u001B[0m\n",
"\u001B[32;1m\u001B[1;3mThought: This is a complex topic that requires a balanced perspective\n",
"Action: Search\n",
"Action Input: \"Pros and cons of zoos for animals\"\u001B[0m\n",
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n"
"Observation:\u001B[36;1m\u001B[1;3mZoos are detrimental to animals' physical health. A study of 35 species of carnivores, including brown bears, cheetahs, and lions, found that zoo enclosures ...\u001B[0m\u001B[32;1m\u001B[1;3mI need to find more information to provide a balanced perspective\n",
"Action: Search\n",
"Action Input: \"Arguments for and against zoos\"\u001B[0m\n",
"\n",
"Observation:\u001B[36;1m\u001B[1;3mWhile zoo advocates and conservationists argue that zoos save endangered species and educate the public, many animal rights activists believe the cost of ...\u001B[0m\u001B[32;1m\u001B[1;3mI need to provide some specific examples to illustrate the arguments for and against zoos\n",
"Action: Knowledge Base\n",
"Action Input: \"What are some specific examples of arguments for and against zoos?\"\u001B[0m\n",
"\n",
"Observation:\u001B[33;1m\u001B[1;3m Arguments for zoos include that they have gotten a lot better in the last 30-40 years, they participate in research and conservation projects, and they have helped to save species from extinction. Arguments against zoos include that they are still businesses, they often don't educate the public as much as they claim, and they still capture animals from the wild.\u001B[0m\u001B[32;1m\u001B[1;3mI now know the final answer\n",
"Final Answer: The debate over whether zoos are good or bad for animals is complex and multifaceted. While some argue that zoos play an important role in conservation and education, others believe that they are detrimental to animals' physical and mental health and that they perpetuate the idea that animals exist for human entertainment. Ultimately, the answer to whether zoos are good or bad for animals depends on a variety of factors, including the quality of the zoo, the species of animals involved, and the specific goals of the zoo.\u001B[0m\n",
>>>>>>> 2b6f6392b1ff679ed0ff246202f9a2cf5b3f9b12:examples/Conversational_agents_using_tools.ipynb
"\n",
"\u001B[1m> Finished chain.\u001B[0m\n"
]
},
{
@ -1123,6 +1187,15 @@
"\n",
"We look forward to seeing what you build!"
]
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [],
"metadata": {
"collapsed": false
}
}
],
"metadata": {

Loading…
Cancel
Save