# Exploring the World of Language Models: LLMs vs Chat Models
## Understanding LLMs and Chat Models
### LLMs LLMs, such as GPT-3, Bloom, PaLM, and Aurora genAI, take a text string as input and return a text string as output. They are trained on language modeling tasks and can generate human-like text, perform complex reasoning, and even write code. LLMs are powerful and flexible, capable of generating text for a wide range of tasks. However, they can sometimes produce incorrect or nonsensical answers, and their API is less structured compared to Chat Models. Pre-training these models involves presenting large-scale corpora to them and allowing the network to predict the next word, which results in learning the relationships between words. This learning process enables LLMs to generate high-quality text, which can be applied to an array of applications, such as automatic form-filling and predictive text on smartphones. Most of these models are trained on general purpose training dataset, while others are trained on a mix of general and domain-specific data, such as Intel [Aurora genAI](https://www.intel.com/content/www/us/en/newsroom/news/intel-delivers-ai-accelerated-hpc-performance.html#gs.ywqfxl), which is trained on general text, scientific texts, scientific data, and codes related to the domain. The goal of domain specific LLMs is to increase the performance on a particularly domain, while still being able to solve the majority of tasks that general LLM can manage. LLMs have the potential to infiltrate various aspects of human life, including the arts, sciences, and law. With continued development, LLMs will become increasingly integrated into our educational, personal, and professional lives, making them an essential technology to master. You can follow these steps to use a large language model (LLM) like GPT-3 in LangChain. Import the `OpenAI` wrapper from the `langchain.llms` module and Initialize it with the desired model name and any additional arguments. For example, set a high temperature for more random outputs. Then, create a `PromptTemplate` to format the input for the model. Lastly, define an `LLMChain` to combine the model and prompt. Run the chain with the desired input using `.run()`. As mentioned before, remember to set your OpenAI key saved in the “OPENAI_API_KEY” environment variable before running the following codes. Remember to install the required packages with the following command: `pip install langchain==0.0.208 deeplake openai tiktoken`. ```python from langchain.llms import OpenAI from langchain.chains import LLMChain from langchain.prompts import PromptTemplate # Before executing the following code, make sure to have # your OpenAI key saved in the “OPENAI_API_KEY” environment variable. llm = OpenAI(model_name="text-davinci-003", temperature=0) prompt = PromptTemplate( input_variables=["product"], template="What is a good name for a company that makes {product}?", ) chain = LLMChain(llm=llm, prompt=prompt) print( chain.run("wireless headphones") ) ``` ``` Wireless Audio Solutions ``` Here, the input for the chain is the string "wireless headphones". The chain processes the input and generates a result based on the product name. --- ### Chat Models Chat Models are the most popular models in LangChain, such as ChatGPT that can incorporate GPT-3 or GPT-4 at its core. They have gained significant attention due to their ability to learn from human feedback and their user-friendly chat interface. Chat Models, such as ChatGPT, take a list of messages as input and return an `AIMessage`. They typically use LLMs as their underlying technology, but their APIs are more structured. Chat Models are designed to remember previous exchanges with the user in a session and use that context to generate more relevant responses. They also benefit from reinforcement learning from human feedback, which helps improve their responses. However, they may still have limitations in reasoning and require careful handling to avoid generating inappropriate content. API Differences in LangChain **Chat Message Types** In LangChain, three main types of messages are used when interacting with chat models: `SystemMessage`, `HumanMessage`, and `AIMessage`.


# Exploring the World of Language Models: LLMs vs Chat Models
## Understanding LLMs and Chat Models
**SystemMessage**: These messages provide initial instructions, context, or data for the AI model. They set the objectives the AI should follow and can help in controlling the AI's behavior. System messages are not user inputs but rather guidelines for the AI to operate within. **HumanMessage**: These messages come from the user and represent their input to the AI model. The AI model is expected to respond to these messages. In LangChain, you can customize the human prefix (e.g., "User") in the conversation summary to change how the human input is represented. **AIMessage**: These messages are sent from the AI's perspective as it interacts with the human user. They represent the AI's responses to human input. Like HumanMessage, you can also customize the AI prefix (e.g., "AI Assistant" or "AI") in the conversation summary to change how the AI's responses are represented. **An example of using ChatOpenAI with a HumanMessage:** In this section, we are trying to use the LangChain library to create a chatbot that can translate an English sentence into French. This particular use case goes beyond what we covered in the previous lesson. We'll be employing multiple message types to differentiate between users' queries and system instructions instead of relying on a single prompt. This approach will enhance the model's comprehension of the given requirements. First, we create a list of messages, starting with a `SystemMessage` that sets the context for the chatbot, informing it that its role is to be a helpful assistant translating English to French. We then follow it with a `HumanMessage` containing the user’s query, like an English sentence to be translated. ```python from langchain.chat_models import ChatOpenAI from langchain.schema import ( HumanMessage, SystemMessage ) chat = ChatOpenAI(model_name="gpt-4", temperature=0) messages = [ SystemMessage(content="You are a helpful assistant that translates English to French."), HumanMessage(content="Translate the following sentence: I love programming.") ] chat(messages) ``` ```python AIMessage(content="J'aime la programmation.", additional_kwargs={}, example=False) ``` As you can see, we pass the list of messages to the chatbot using the `chat()` function. The chatbot processes the input messages, considers the context provided by the system message, and then translates the given English sentence into French. <aside> 💡 `SystemMessage` represents the messages generated by the system that wants to use the model, which could include instructions, notifications, or error messages. These messages are not generated by the human user or the AI chatbot but are instead produced by the underlying system to provide context, guidance, or status updates. </aside> Using the generate method, you can also generate completions for multiple sets of messages. Each batch of messages can have its own `SystemMessage` and will perform independently. The following code shows the first set of messages translate the sentences from English to French, while the second ones do the opposite. ```python batch_messages = [ [ SystemMessage(content="You are a helpful assistant that translates English to French."), HumanMessage(content="Translate the following sentence: I love programming.") ], [ SystemMessage(content="You are a helpful assistant that translates French to English."), HumanMessage(content="Translate the following sentence: J'aime la programmation.") ], ] print( chat.generate(batch_messages) ) ``` ```python LLMResult(generations=[[ChatGeneration(text="J'aime la programmation.", generation_info=None, message=AIMessage(content="J'aime la programmation.", additional_kwargs={}, example=False))], [ChatGeneration(text='I love programming.', generation_info=None, message=AIMessage(content='I love programming.', additional_kwargs={}, example=False))]], llm_output={'token_usage': {'prompt_tokens': 65, 'completion_tokens': 11, 'total_tokens': 76}, 'model_name': 'gpt-4'}) ``` As a comparison, here's what LLM and Chat Model APIs look like in LangChain. ```python llm_output: {'product': 'Translate the following text from English to French: Hello, how are you?', 'text': '\n\nBonjour, comment allez-vous?'} chat_output: content='Bonjour, comment ça va ?' additional_kwargs={} example=False ``` ### Conclusion LLMs and Chat Models each have their advantages and disadvantages. LLMs are powerful and flexible, capable of generating text for a wide range


# Exploring the World of Language Models: LLMs vs Chat Models
## Understanding LLMs and Chat Models
of tasks. However, their API is less structured compared to Chat Models. On the other hand, Chat Models offer a more structured API and are better suited for conversational tasks. Also, they can remember previous exchanges with the user, making them more suitable for engaging in meaningful conversations. Additionally, they benefit from reinforcement learning from human feedback, which helps improve their responses. They still have some limitations in reasoning and may require careful handling to avoid hallucinations and generating inappropriate content. In the next lesson we’ll see how GPT-4 and ChatGPT can be used for context-aware chat applications via APIs. *Intel and the Intel logo are trademarks of Intel Corporation or its subsidiaries.* **RESOURCES:** [ChatGPT and the Large Language Models (LLMs).](https://medium.com/chatgpt-learning-asia/chatgpt-and-the-large-language-models-llms-2b4b1f6e9962) [Large language models (LLMs) vs. ChatGPT](https://www.thoughtspot.com/data-trends/ai/large-language-models-vs-chatgpt) [A Complete Guide to LangChain: Building Powerful Applications with Large Language Models](https://notes.replicatecodex.com/a-complete-guide-to-langchain-building-powerful-applications-with-large-language-models/) --- You can find the code of this lesson in this online [Notebook](https://colab.research.google.com/drive/1ziTn4Z5s_SPZnEClz_TKZov7HmigCcSj?usp=sharing).


# LangChain's Tool Utilization: Examining Diverse Applications through Illustrative Scenarios
### Introduction Tools are modular, reusable components meticulously designed to accomplish specific tasks or provide answers to distinct types of questions. By integrating these tools seamlessly into the system, users can effortlessly tap into a diverse range of functionalities and information sources to tackle challenges and generate meaningful responses. In this lesson, we will explore the various Tools in LangChain, uncovering their unique capabilities. ![Image by Midjourney](LangChain's%20Tool%20Utilization%20Examining%20Diverse%20App%20ba65b907e6124e46bdce00898389f13c/agents.png) Image by Midjourney A few notable examples of tools in LangChain, without getting into technical details, are: - **Google Search**: This tool uses the Google Search API to fetch relevant information from the web, which can be used to answer queries related to current events, facts, or any topic where a quick search can provide accurate results. - **Requests**: This tool employs the popular Python library "requests" to interact with web services, access APIs, or obtain data from different online sources. It can be particularly useful for gathering structured data or specific information from a web service. - **Python REPL**: The Python REPL (Read-Eval-Print Loop) tool allows users to execute Python code on-the-fly to perform calculations, manipulate data, or test algorithms. It serves as an interactive programming environment within the LangChain system. - **Wikipedia**: The Wikipedia tool leverages the Wikipedia API to search and retrieve relevant articles, summaries, or specific information from the vast repository of knowledge on the Wikipedia platform. - **Wolfram Alpha**: With this tool, users can tap into the powerful computational knowledge engine of Wolfram Alpha to answer complex questions, perform advanced calculations, or generate visual representations of data. ---


# LangChain's Tool Utilization: Examining Diverse Applications through Illustrative Scenarios
## ****LangChain Agents and Toolkits****
In LangChain, an Agent is a bot that acts using natural language instructions and can use tools to answer its queries. Based on user input, it is also used to determine which actions to take and in what order. An action can either be using a tool (such as a search engine or a calculator) and processing its output or returning a response to the user. Agents are powerful when used correctly, as they can dynamically call chains based on user input. An agent has access to a suite of tools and can decide which of these tools to call, depending on the user input. Tools are functions that perform specific duties. To create an agent in LangChain, you can use the `initialize_agent` function along with the `load_tools` function to prepare the tools the agent can use. For example, you can create a simple agent using the following code. It can use the [SerpApi](https://serpapi.com/) service to fetch Google search results or the Python requests wrapper when required. Remember to install the required packages with the following command: `pip install langchain==0.0.208 deeplake openai google-search-results tiktoken`. ```python from langchain.agents import load_tools from langchain.agents import initialize_agent from langchain.agents import AgentType from langchain import OpenAI llm = OpenAI(model_name="text-davinci-003", temperature=0) tools = load_tools(['serpapi', 'requests_all'], llm=llm, serpapi_api_key=SERPAPI_API_KEY) agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True) ``` You can use the `run` method with a natural language input to run the agent. ```python agent.run("tell me what is midjourney?") ``` The agent will then use the tool to look for an answer to the query. We’ll see some output examples later in this lesson.


# LangChain's Tool Utilization: Examining Diverse Applications through Illustrative Scenarios
## Google-Search
LLMs inherently possess knowledge only up to the point at which they were trained, leaving them unaware of any information beyond that timeframe. Integrating search engines as tools within the LangChain system presents a significant advantage. The LangChain library provides a Google Search API wrapper that you can use within your project. You can use this wrapper as a **standalone utility** or as a tool **within an agent**. First, make sure you have an API Key and Custom Search Engine ID for the Google Search API. If you don’t already have a Custom Search Engine ID, the following tutorial is a helpful guide for generating one. [How to get Search Engine ID](https://help.elfsight.com/article/331-how-to-get-search-engine-id) Also, getting Google Search API is straightforward. If you have Google Cloud Platform access, you’d just go to the credentials page ****and ****click Create credentials > API key. [Setting up API keys - API Console Help](https://support.google.com/googleapi/answer/6158862?hl=en) Set them as environment variables like the following. Then, you can use `GoogleSearchAPIWrapper` to receive `k` top search results given a query. ```python import os os.environ["OPENAI_API_KEY"] = "<YOUR-OPENAI-API-KEY>" os.environ["GOOGLE_API_KEY"] = "<YOUR-GOOGLE-API-KEY>" os.environ["GOOGLE_CSE_ID"] = "<YOUR-GOOGLE-CSE-ID>" # As a standalone utility: from langchain. utilities import GoogleSearchAPIWrapper search = GoogleSearchAPIWrapper() search.results("What is the capital of Spain?", 3) ``` ``` [{'title': 'Madrid | History, Population, Climate, & Facts | Britannica', 'link': 'https://www.britannica.com/place/Madrid', 'snippet': "May 23, 2023 ... Madrid, city, capital of Spain and of Madrid provincia (province). Spain's arts and financial center, the city proper, and province form a\xa0..."}, {'title': 'Madrid - Eurocities', 'link': 'https://eurocities.eu/cities/madrid/', 'snippet': 'As the Spanish capital, Madrid is home to embassies and international organizations, major companies and financial institutions. It ranks first in Spain for the\xa0...'}, {'title': 'Madrid - Wikipedia', 'link': 'https://en.wikipedia.org/wiki/Madrid', 'snippet': 'Madrid is the capital and most populous city of Spain. The city has almost 3.6 million inhabitants and a metropolitan area population of approximately 6.7\xa0...'}] ``` In the LangChain library, using the available tools requires some necessary steps to be taken. First, you need to initialize an agent, which is the central manager for effectively using these tools. Then, we need to define the language model that we want the agent to use. ```python from langchain.llms import OpenAI llm = OpenAI(model_name="text-davinci-003", temperature=0) ``` Now, we can initialize an agent and load the `google-search` tool for it to use. The agent will load the search results and provide them to the `llm` to answer our question. The `ZERO_SHOT_REACT_DESCRIPTION` type gives the freedom to choose any of the defined tools to provide context for the model based on their description. (You can use different agent types, [read more](https://python.langchain.com/en/latest/modules/agents/agents/agent_types.html)) ```python from langchain.agents import initialize_agent, load_tools, AgentType tools = load_tools(["google-search"]) agent = initialize_agent( tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True ) print( agent("What is the national drink in Spain?") ) ``` ``` **> Entering new AgentExecutor chain...** ***I should research this online. Action: Google Search Action Input: National drink in Spain*** Observation: Sangría is Spain's national drink, so, of course, it belongs on this list! Spain is famous for its wine, which is the base of this drink. Although there is nothing officially considered the national alcoholic drink of Spain, many people would say is the Spanish sherry wine (also known as vino de ... Apr 20, 2021 ... Spanish horchata is a very popular sweet, creamy drink made by mixing the milky juice of tiger nuts with white sugar. The drink must be ... "Very Old Rare Sherry", Pedro Ximenez by Garvey. Jerez de la Frontera (Andalusia, Spain), aged 30 years. Sherry is a national liquor of Spain. Nov 27, 2012 ... The fervor with which Spaniards drink gin & tonics is, to say the


# LangChain's Tool Utilization: Examining Diverse Applications through Illustrative Scenarios
## Google-Search
... gin tonic is the national drink (and that ampersands are expendable). Jul 25, 2022 ... Orujo is an ancient Spanish pomace brandy that is enjoyed throughout the country, but it is usually associated with northern Spain—namely ... Even out of the country, people recognize the sherry wine as a very typical drink from Spain. Of course, when talking about the Spanish national drink, we could ... Horchata. A cooling creamy drink for summer, horchata (or orxata as it is also spelled in Valencian and Catalan) can be found in specialised ... Feb 22, 2023 ... Undoubtedly, sangria is one of the typical drinks of Spain. For some, it is even considered the national drink of Spain. Jul 10, 2022 ... But it couldn´t be another way, as wine is the national drink of Spain. You could probably not know that Spain is the second largest wine ... Thought: I now know the final answer. ***Final Answer: The national drink of Spain is Sherry wine.*** **> Finished chain.** {'input': 'What is the national drink in Spain?', 'output': 'The national drink of Spain is Sherry wine.'} ```


# LangChain's Tool Utilization: Examining Diverse Applications through Illustrative Scenarios
## Requests
The internet is an extensive source of information that Large Language Models cannot access directly. LangChain offers a convenient wrapper built around the Python Requests module to facilitate seamless interaction between LLMs and this wealth of information. This wrapper accepts a URL as an input and efficiently retrieves data from the specified URL, allowing LLMs to obtain and process web-based content effortlessly. In this example, we’ll set up a fake RESTful backend using mockapi.io. To do it, follow these steps: 1. Go to [mockapi.io](https://mockapi.io/) and sign up for a free account. 2. After signing up, log in to your account. 3. Click on "New Project" (the "+" icon) and give your project a name. You don't need to fill in any optional fields. 4. Once the project is created, click on it to view your unique API endpoint. 5. Click on "New Resource" to create a new resource for your API. For example, if you want to create an endpoint for users, you can name the resource "users.” 6. Define the schema for your resource. For instance, if you want each user to have an `id`, `name`, and `email`, you can use the following schema: ```python { "id": "integer", "name": "string", "email": "string" } ``` Click on the "Create" button to create the resource with the defined schema. This fake backend will have an endpoint to retrieve information about fake users stored in the backend. A dictionary will represent each user. For instance: ```python { "id": "1", "name": "John Doe", "email": "john.doe@example.com" } ``` Let's use the LangChain tools to interact with our fake RESTful backend. First, import the necessary libraries and initialize the agent with the desired tools. Then, ask the agent to do an HTTP call at “https://644696c1ee791e1e2903b0bb.mockapi.io/user”: this is the address of our specific mockapi instance, where you should find 30 users. If you want to try your mockapi instance, then replace the address with “https://<YOUR-MOCKAPI-SERVER-ID>.mockapi.io/user”. ```python from langchain.agents import AgentType tools = load_tools(["requests_all"], llm=llm) agent = initialize_agent( tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True ) response = agent.run("Get the list of users at https://644696c1ee791e1e2903b0bb.mockapi.io/user and tell me the total number of users") ``` To get a request: ``` **> Entering new AgentExecutor chain...** ***I need to get the content from this URL Action: requests_get Action Input: https://644696c1ee791e1e2903b0bb.mockapi.io/user*** Observation: ***[{"createdAt": "2023-04-24T07:55:47.634Z", "name": "Mr. Kelly Balistreri", "avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/1244.jpg", "id": "1"},{"createdAt": "2023-04-24T03:54:44.108Z", "name": "Bradley Cronin", "avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/615.jpg", "id": "2"},{"createdAt": "2023-04-24T14:32:29.991Z" , "name": "Jennifer Block Sr.", "avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/105.jpg", "id": "3"},*** ***[…]*** ***{"createdAt": "2023-04-24T06:10:38.771Z", "name": "Paula Kshlerin", "avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/1145.jpg", "id": "28"},{"createdAt": "2023-04-24T03:15:33.343Z", "name": "Roberto Blanda", "avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/575.jpg", "id": "29"},{"createdAt": "2023-04-23T18:20:58.632Z", "name": "Mr. Lisa Erdman", "avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/1172.jpg", "id": "30"}]*** Thought: ***I now know the list of users Final Answer: The list of users from the URL https://644696c1ee791e1e2903b0bb.mockapi.io/user is: [{"createdAt": "2023-04-24T07:55:47.634Z", "name": "Mr. Kelly Balistreri", "avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/1244.jpg", "id": "1"},{"createdAt": "2023-04-24T03:54:44.108Z", "name": "Bradley Cronin", "avatar": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/615.jpg", "id": "2"},{"createdAt": "2023-04-24T14:32:29.991Z", "name":"*** […] Thought: ***I now know the final answer Final Answer: There are 30 users.*** **> Finished chain.** ``` As seen in this example, the agent, initialized with the Request tool and the OpenAI language model, processes the given prompt. It identifies the need to fetch data from the provided URL using a GET request, which is facilitated by the tool of the `request`. Upon retrieving the user data, the agent analyzes the number of users and returns the result, completing the task. ### Python-REPL Another tool feature in LangChain is the Python REPL tool, which allows you to execute Python code generated by the language model. This can be useful for complex calculations where the language model generates code to calculate the answer since LLMs are not


# LangChain's Tool Utilization: Examining Diverse Applications through Illustrative Scenarios
## Requests
good at solving algorithmic and math problems. Here’s an example of Python-REPL tool usage: ```python tools = load_tools(["python_repl"], llm=llm) agent = initialize_agent( tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True ) print( agent.run("Create a list of random strings containing 4 letters, list should contain 30 examples, and sort the list alphabetically") ) ``` ``` **> Entering new AgentExecutor chain...** ***I need to generate a list of random strings, sort them, and then print the result Action: Python REPL Action Input: import random my_list = [] for i in range(30): my_list.append(''.join(random.choices(string.ascii_lowercase, k=4))) my_list.sort() print(my_list)*** Observation: NameError("name 'string' is not defined") Thought: ***I need to import the string module Action: Python REPL Action Input: import random import string my_list = [] for i in range(30): my_list.append(''.join(random.choices(string.ascii_lowercase, k=4))) my_list.sort() print(my_list)*** Observation: ***['aojl', 'biyx', 'bkjq', 'bttr', 'cuef', 'culv', 'czzv', 'djwy', 'eflj', 'ekpr', 'enhg', 'epdq', 'epel', 'hxkp', 'jbrk', 'lbaw', 'mdho', 'nrmc', 'nuqk', 'nybt', 'ptdx', 'smkx', 'sosm', 'srjl', 'swnl', 'uuub', 'vgpw', 'ycli', 'zfln', 'zhsz']*** Thought: I now know the final answer ***Final Answer: ['aojl', 'biyx', 'bkjq', 'bttr', 'cuef', 'culv', 'czzv', 'djwy', 'eflj', 'ekpr', 'enhg', 'epdq', 'epel', 'hxkp', 'jbrk', 'lbaw', 'mdho', 'nrmc', 'nuqk', 'nybt', 'ptdx', 'smkx', 'sosm', 'srjl', 'swnl', 'uuub', 'vgpw', 'ycli', 'zfln', 'zhsz']*** **> Finished chain.** ['aojl', 'biyx', 'bkjq', 'bttr', 'cuef', 'culv', 'czzv', 'djwy', 'eflj', 'ekpr', 'enhg', 'epdq', 'epel', 'hxkp', 'jbrk', 'lbaw', 'mdho', 'nrmc', 'nuqk', 'nybt', 'ptdx', 'smkx', 'sosm', 'srjl', 'swnl', 'uuub', 'vgpw', 'ycli', 'zfln', 'zhsz'] ``` ### Wikipedia The Wikipedia API tool in LangChain is a powerful tool that allows language models to interact with the Wikipedia API to fetch information and use it to answer questions. Be aware that you need to install the Wikipedia python package using the `pip install Wikipedia` command. The codes are tested using the `1.4.0` version. However, use the latest version of the libraries. ```python agent = initialize_agent( tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True ) tools = load_tools(["wikipedia"]) print( agent.run("What is Nostradamus know for") ) ``` ``` **> Entering new AgentExecutor chain...** ***He is a famous prophet Action: Python REPL Action Input: print("Nostradamus is known for his prophecies")*** Observation: Nostradamus is known for his prophecies Thought: ***I now know the final answer Final Answer: Nostradamus is known for his prophecies*** **> Finished chain.** Nostradamus is known for his prophecies ``` ### Wolfram-Alpha In LangChain, you can integrate Wolfram Alpha by using the WolframAlphaAPIWrapper utility. First, you need to set up a Wolfram Alpha developer account and get your APP ID. [Wolfram|Alpha APIs: Computational Knowledge Integration](https://products.wolframalpha.com/api) Then, install the Wolfram Alpha Python library with `pip install Wolframalpha`. After that, you can set the Wolfram Alpha APP ID as an environment variable in your code: ```python import os os.environ["WOLFRAM_ALPHA_APPID"] = "your_app_id" from langchain. utilities.wolfram_alpha import WolframAlphaAPIWrapper wolfram = WolframAlphaAPIWrapper() result = wolfram.run("What is 2x+5 = -3x + 7?") print(result) # Output: 'x = 2/5' ``` Utilizing the WolframAlphaAPIWrapper from the LangChain library, this code solves the algebraic equation. Let’s observe the WolframAlpha as a tool: ```python tools = load_tools(["wolfram-alpha"]) agent = initialize_agent( tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True ) print( agent.run("How many days until the next Solar eclipse") ) ``` ``` **> Entering new AgentExecutor chain... *I need to find out when the next Solar eclipse is Action: Wolfram Alpha Action Input: When is the next Solar eclipse*** Observation: ***Assumption: next | solar eclipse | after today Answer: Saturday, October 14, 2023 (6 months from now)*** Thought: ***I now know the final answer Final Answer: 6 months from now, Saturday, October 14, 2023.*> Finished chain.*** '6 months from now, Saturday, October 14, 2023.' ``` ### ****A Showcase of Resourceful Collaboration**** Agents have the capability to employ a variety of tools in order to provide comprehensive and accurate responses to


# LangChain's Tool Utilization: Examining Diverse Applications through Illustrative Scenarios
## Requests
complex inquiries. These agents are better equipped to deliver well-rounded solutions by integrating resources such as Wikipedia and Wolfram-Alpha. Here’s an example of it: ```python tools = load_tools(["wolfram-alpha", "wikipedia"], llm=llm) agent = initialize_agent( tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True ) agent.run("Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?") ``` ``` **> Entering new AgentExecutor chain...** ***I should look up Olivia Wilde's boyfriend on Wikipedia and then use Wolfram Alpha to calculate his age raised to 0.23 power. Action: Wikipedia Action Input: Olivia Wilde's boyfriend*** Observation: ***Page: Olivia Cooke Summary: Olivia Kate Cooke (born 27 December 1993) is an English actress. In television, she has starred as Emma Decody in the thriller Bates Motel (2013–2017), Becky Sharp in the period drama Vanity Fair (2018), and Alicent Hightower in the fantasy drama House of the Dragon (2022–present).*** Thought: ***I now know Olivia Wilde's boyfriend is Harry Styles. Action: Wolfram Alpha Action Input: Harry Styles' age raised to the 0.23 power*** Observation: ***Wolfram Alpha wasn't able to answer it*** Thought: ***I should try a different approach Action: Wolfram Alpha Action Input: Olivia Wilde's age raised to the 0.23 power*** Observation: ***Assumption: (age | of Olivia Wilde (actor) | today )^0.23 Answer: 9.0278 days^(23/100)*** Thought: ***I now know the final answer Final Answer: Harry Styles' age raised to 0.23 power is 9.0278 days^(23/100).*> Finished chain.*** "Harry Styles' age raised to the 0.23 power is 9.0278 days^(23/100)." ``` --- ### Conclusion LangChain agents successfully bring together various tools, like Wikipedia and Wolfram-Alpha, to create a seamless knowledge integration experience. By combining the strengths of these resources, the agents are able to provide clear, accurate, and detailed answers to more complex questions. Defining custom tools involves creating new classes, functions, or modules that serve specific purposes within your language processing pipeline. These custom tools can enhance or modify existing language processing capabilities provided by the LangChain library or create entirely new functionalities tailored to your specific needs. More on Defining Custom tools will be covered in lessons to come. Happy Learning! In the next lesson, we’ll build a bot able to refine paragraphs of articles by looking for additional context information online and adding it to that paragraph. --- You can find the code of this lesson in this online [Notebook](https://colab.research.google.com/drive/1Vt12K2s6M8lxavepe5O0SkAyltin_zSC?usp=sharing).


# Building Applications Powered by LLMs with LangChain
### Introduction LangChain is designed to assist developers in building end-to-end applications using language models. It offers an array of tools, components, and interfaces that simplify the process of creating applications powered by large language models and chat models. LangChain streamlines managing interactions with LLMs, chaining together multiple components, and integrating additional resources, such as APIs and databases. Having gained a foundational understanding of the library in previous lesson, let's now explore various examples of utilizing prompts to accomplish multiple tasks. ### Prompt use case: A key feature of LangChain is its support for prompts, which encompasses prompt management, prompt optimization, and a generic interface for all LLMs. The framework also provides common utilities for working with LLMs. `ChatPromptTemplate` is used to create a structured conversation with the AI model, making it easier to manage the flow and content of the conversation. In LangChain, message prompt templates are used to construct and work with prompts, allowing us to exploit the underlying chat model's potential fully. System and Human prompts differ in their roles and purposes when interacting with chat models. `SystemMessagePromptTemplate` provides initial instructions, context, or data for the AI model, while `HumanMessagePromptTemplate` are messages from the user that the AI model responds to. To illustrate it, let’s create a chat-based assistant that helps users find information about movies. Ensure your OpenAI key is stored in environment variables using the “OPENAI_API_KEY” name. Remember to install the required packages with the following command: `pip install langchain==0.0.208 deeplake openai tiktoken`. ```python from langchain.chat_models import ChatOpenAI from langchain.prompts.chat import ( ChatPromptTemplate, SystemMessagePromptTemplate, HumanMessagePromptTemplate, ) # Before executing the following code, make sure to have # your OpenAI key saved in the “OPENAI_API_KEY” environment variable. chat = ChatOpenAI(model_name="gpt-3.5-turbo", temperature=0) template = "You are an assistant that helps users find information about movies." system_message_prompt = SystemMessagePromptTemplate.from_template(template) human_template = "Find information about the movie {movie_title}." human_message_prompt = HumanMessagePromptTemplate.from_template(human_template) chat_prompt = ChatPromptTemplate.from_messages([system_message_prompt, human_message_prompt]) response = chat(chat_prompt.format_prompt(movie_title="Inception").to_messages()) print(response.content) ``` ``` Inception is a 2010 science fiction action film directed by Christopher Nolan. The film stars Leonardo DiCaprio, Ken Watanabe, Joseph Gordon-Levitt, Ellen Page, Tom Hardy, Dileep Rao, Cillian Murphy, Tom Berenger, and Michael Caine. The plot follows a professional thief who steals information by infiltrating the subconscious of his targets. He is offered a chance to have his criminal history erased as payment for the implantation of another person's idea into a target's subconscious. The film was a critical and commercial success, grossing over $829 million worldwide and receiving numerous accolades, including four Academy Awards. ``` Using the `to_messages` object in LangChain allows you to convert the formatted value of a chat prompt template into a list of message objects. This is useful when working with chat models, as it provides a structured way to manage the conversation and ensures that the chat model can understand the context and roles of the messages. --- ### Summarization chain example: LangChain prompts can be found in various use cases, such as summarization or question-answering chains. For example, when creating a **summarization chain**, LangChain enables interaction with an external data source to fetch data for use in the generation step. This could involve summarizing a lengthy piece of text or answering questions using specific data sources. The following code will initialize the language model using `OpenAI` class with a temperature of 0 - because we want deterministic output. The `load_summarize_chain` function accepts an instance of the language model and returns a pre-built summarization chain. Lastly, the `PyPDFLoader` class is responsible for loading PDF files and converting them into a format suitable for processing by LangChain. It is important to note that


# Building Applications Powered by LLMs with LangChain
you need to install the `pypdf` package to run the following code. Although it is highly recommended to install the latest versions of this package, the codes have been tested on version `3.10.0`. Please refer to course introduction lesson for more information on installing packages. ```python # Import necessary modules from langchain import OpenAI, PromptTemplate from langchain.chains.summarize import load_summarize_chain from langchain.document_loaders import PyPDFLoader # Initialize language model llm = OpenAI(model_name="text-davinci-003", temperature=0) # Load the summarization chain summarize_chain = load_summarize_chain(llm) # Load the document using PyPDFLoader document_loader = PyPDFLoader(file_path="path/to/your/pdf/file.pdf") document = document_loader.load() # Summarize the document summary = summarize_chain(document) print(summary['output_text']) ``` ``` This document provides a summary of useful Linux commands for starting and stopping, accessing and mounting file systems, finding files and text within files, the X Window System, moving, copying, deleting and viewing files, installing software, user administration, little known tips and tricks, configuration files and what they do, file permissions, X shortcuts, printing, and a link to an official Linux pocket protector. ``` In this example, the code uses the default summarization chain provided by the `load_summarize_chain` function. However, you can customize the summarization process by providing prompt templates. **Let’s recap:** OpenAI is initialized with a temperature of 0 for focused and deterministic language model generation. The `load_summarize_chain` function loads a summarization chain, and PyPDFLoader fetches PDF data, which is loaded as a string input for the summarization chain, generating a summary of the text. --- ### QA chain example: We can also use LangChain to manage prompts for asking general questions from the LLMs. These models are proficient in addressing fundamental inquiries. Nevertheless, it is crucial to remain mindful of the potential issue of hallucinations, where the models may generate non-factual information. To address this concern, we will later introduce the Retrieval chain as a means to overcome this problem. ```python from langchain.prompts import PromptTemplate from langchain.chains import LLMChain from langchain.llms import OpenAI prompt = PromptTemplate(template="Question: {question}\nAnswer:", input_variables=["question"]) llm = OpenAI(model_name="text-davinci-003", temperature=0) chain = LLMChain(llm=llm, prompt=prompt) ``` We define a custom prompt template by creating an instance of the `PromptTemplate` class. The template string contains a placeholder `{question}` ****for the input question, followed by a newline character and the "Answer:" label. The `input_variables` argument is set to the list of available placeholders in the prompt (like a question in this case) to indicate the name of the variable that the chain will replace in the template`.run()` method. We then instantiate an OpenAI model named `text-davinci-003` with a temperature of 0. The `OpenAI` class is used to create the instance, and the `model_name` and `temperature` arguments are provided. Finally, we create a question-answering chain using the `LLMChain` class. The class constructor takes two arguments: `llm`, which is the instantiated OpenAI model, and `prompt`, which is the custom prompt template we defined earlier. By following these steps, we can process input questions effectively with the custom question-answering, generating appropriate answers using the OpenAI model and the custom prompt template. ```python chain.run("what is the meaning of life?") ``` ``` 'The meaning of life is subjective and can vary from person to person. For some, it may be to find happiness and fulfillment, while for others it may be to make a difference in the world. Ultimately, the meaning of life is up to each individual to decide.’ ``` This example demonstrates how LangChain simplifies the integration of LLMs with custom data sources and prompt templates for question-answering applications. To build more advanced NLP applications, you can further extend this example to include other components, such as data-augmented generation, agents, or memory features. LangChain's support for **chain sequences** also allows developers


# Building Applications Powered by LLMs with LangChain
to create more complex applications with multiple calls to LLMs or other utilities. These chains can serve various purposes: personal assistants, chatbots, querying tabular data, interacting with APIs, extraction, evaluation, and summarization. ### Conclusion LangChain solves the problem of easy integration with other sources of data, tools, and different LLMs by providing a comprehensive framework for managing prompts, optimizing them, and creating a universal interface for all LLMs. In the next lesson we’ll learn more about popular language models and the recent trend in chat-based language models. **RESOURCES:** [langchain](https://pypi.org/project/langchain/) [A Complete Guide to LangChain: Building Powerful Applications with Large Language Models](https://notes.replicatecodex.com/a-complete-guide-to-langchain-building-powerful-applications-with-large-language-models/) [Summarization | 🦜🔗 Langchain](https://python.langchain.com/docs/modules/chains/popular/summarize) --- You can find the code of this lesson in this online [Notebook](https://colab.research.google.com/drive/19ZUQouUvFZBQIwRkrAevVPe6ASBbkYax?usp=sharing).


# Build a Customer Support Question Answering Chatbot
### Introduction As we witness accelerated technological progress, large language models like GPT-4 and ChatGPT have emerged as significant breakthroughs in the tech landscape. These state-of-the-art models demonstrate exceptional prowess in content generation. However, they are not without their share of challenges, such as biases and hallucinations. Despite these limitations, LLMs have the potential to bring about a transformative impact on chatbot development. Traditional, primarily intent-based chatbots have been designed to respond to specific user intents. These intents comprise a collection of sample questions and corresponding responses. For instance, a "Restaurant Recommendations" intent might include sample questions like "Can you suggest a good Italian restaurant nearby?" or "Where can I find the best sushi in town?" with responses such as "You can try the Italian restaurant 'La Trattoria' nearby" or "The top-rated sushi place in town is 'Sushi Palace.'" When users interact with the chatbot, their queries are matched to the most similar intent, generating the associated response. However, as LLMs continue to evolve, chatbot development is shifting toward more sophisticated and dynamic solutions capable of handling a broader range of user inquiries with greater precision and nuance. ### Having a Knowledge Base LLMs can significantly enhance chatbot functionality by associating broader intents with documents from a Knowledge Base (KB) instead of specific questions and answers. This approach streamlines intent management and generates more tailored responses to user inquiries. GPT3 has a maximum prompt size of around 4,000 tokens, which is substantial but insufficient for incorporating an entire knowledge base in a single prompt. Future LLMs may not have this limitation while retaining the text generation capabilities. However, for now, we need to design a solution around it. ### Workflow This project aims to build a chatbot that leverages GPT3 to search for answers within documents. The workflow for the experiment is explained in the following diagram. ![Screenshot 2023-06-09 at 13.24.32.png](Build%20a%20Customer%20Support%20Question%20Answering%20Chatbo%20674941168efb45daad500fb17d4223fb/Screenshot_2023-06-09_at_13.24.32.png) First we scrape some content from online articles, we split them into small chunks, compute their embeddings and store them in Deep Lake. Then, we use a user query to retrieve the most relevant chunks from Deep Lake, we put them into a prompt, which will be used to generate the final answer by the LLM. It is important to note that there is always a risk of generating hallucinations or false information when using LLMs. Although this might not be acceptable for many customers support use cases, the chatbot can still be helpful for assisting operators in drafting answers that they can double-check before sending them to the user. In the next steps, we'll explore how to manage conversations with GPT-3 and provide examples to demonstrate the effectiveness of this workflow: First, set up the `OPENAI_API_KEY` and `ACTIVELOOP_TOKEN` environment variables with your API keys and tokens. As we’re going to use the `SeleniumURLLoader` LangChain class, and it uses the `unstructured` and `selenium` Python library, let’s install it using `pip`. It is recommended to install the latest version of the library. Nonetheless, please be aware that the code has been tested specifically on version `0.7.7`. ```python pip install unstructured selenium ``` Remember to install the required packages with the following command: `pip install langchain==0.0.208 deeplake openai tiktoken`. We’ll now import the necessary libraries. ```python from langchain.embeddings.openai import OpenAIEmbeddings from langchain.vectorstores import DeepLake from langchain.text_splitter import CharacterTextSplitter from langchain import OpenAI from langchain.document_loaders import SeleniumURLLoader from langchain import PromptTemplate ``` These libraries provide functionality for handling OpenAI embeddings, managing vector storage, splitting text, and interacting with the OpenAI API. They also enable the creation of a context-aware question-answering system, incorporating retrieval and text generation. The database for our chatbot will


# Build a Customer Support Question Answering Chatbot
consist of articles regarding technical issues. ```python # we'll use information from the following articles urls = ['https://beebom.com/what-is-nft-explained/', 'https://beebom.com/how-delete-spotify-account/', 'https://beebom.com/how-download-gif-twitter/', 'https://beebom.com/how-use-chatgpt-linux-terminal/', 'https://beebom.com/how-delete-spotify-account/', 'https://beebom.com/how-save-instagram-story-with-music/', 'https://beebom.com/how-install-pip-windows/', 'https://beebom.com/how-check-disk-usage-linux/'] ``` ### ****1: Split the documents into chunks and compute their embeddings**** We load the documents from the provided URLs and split them into chunks using the `CharacterTextSplitter` with a chunk size of 1000 and no overlap: ```python # use the selenium scraper to load the documents loader = SeleniumURLLoader(urls=urls) docs_not_splitted = loader.load() # we split the documents into smaller chunks text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0) docs = text_splitter.split_documents(docs_not_splitted) ``` Next, we compute the embeddings using `OpenAIEmbeddings` and store them in a Deep Lake vector store on the cloud. In an ideal production scenario, we could upload a whole website or course lesson on a Deep Lake dataset, allowing for search among even thousands or millions of documents. As we are using a cloud serverless Deep Lake dataset, applications running on different locations can easily access the same centralized dataset without the need of deploying a vector store on a custom machine. Let’s now modify the following code by adding your Activeloop organization ID. It worth noting that the org id is your username by default. ```python # Before executing the following code, make sure to have # your OpenAI key saved in the “OPENAI_API_KEY” environment variable. embeddings = OpenAIEmbeddings(model="text-embedding-ada-002") # create Deep Lake dataset # TODO: use your organization id here. (by default, org id is your username) my_activeloop_org_id = "<YOUR-ACTIVELOOP-ORG-ID>" my_activeloop_dataset_name = "langchain_course_customer_support" dataset_path = f"hub://{my_activeloop_org_id}/{my_activeloop_dataset_name}" db = DeepLake(dataset_path=dataset_path, embedding_function=embeddings) # add documents to our Deep Lake dataset db.add_documents(docs) ``` To retrieve the most similar chunks to a given query, we can use the `similarity_search` method of the Deep Lake vector store: ```python # let's see the top relevant documents to a specific query query = "how to check disk usage in linux?" docs = db.similarity_search(query) print(docs[0].page_content) ``` The previous code will show something like the following output. ```python Home How To How to Check Disk Usage in Linux (4 Methods) How to Check Disk Usage in Linux (4 Methods) Beebom Staff Last Updated: February 21, 2023 3:15 pm There may be times when you need to download some important files or transfer some photos to your Linux system, but face a problem of insufficient disk space. You head over to your file manager to delete the large files which you no longer require, but you have no clue which of them are occupying most of your disk space. In this article, we will show some easy methods to check disk usage in Linux from both the terminal and the GUI application. Monitor Disk Usage in Linux (2023) Table of Contents Check Disk Space Using the df Command Display Disk Usage in Human Readable FormatDisplay Disk Occupancy of a Particular Type Check Disk Usage using the du Command Display Disk Usage in Human Readable FormatDisplay Disk Usage for a Particular DirectoryCompare Disk Usage of Two Directories ``` ### **2: Craft a prompt for GPT-3 using the suggested strategies** We will create a prompt template that incorporates role-prompting, relevant Knowledge Base information, and the user's question: ```python # let's write a prompt for a customer support chatbot that # answer questions using information extracted from our db template = """You are an exceptional customer support chatbot that gently answer questions. You know the following context information. {chunks_formatted} Answer to the following question from a customer. Use only information from the previous context information. Do not invent stuff. Question: {query} Answer:""" prompt = PromptTemplate( input_variables=["chunks_formatted", "query"], template=template, ) ``` The template sets the chatbot's persona as


# Build a Customer Support Question Answering Chatbot
an exceptional customer support chatbot. The template takes two input variables: `chunks_formatted`, which consists of the pre-formatted chunks from articles, and `query`, representing the customer's question. The objective is to generate an accurate answer using only the provided chunks without creating any false or invented information. ### 3**: Utilize the GPT3 model with a temperature of 0 for text generation** To generate a response, we first retrieve the top-k (e.g., top-3) chunks most similar to the user query, format the prompt, and send the formatted prompt to the GPT3 model with a temperature of 0. ```python # the full pipeline # user question query = "How to check disk usage in linux?" # retrieve relevant chunks docs = db.similarity_search(query) retrieved_chunks = [doc.page_content for doc in docs] # format the prompt chunks_formatted = "\n\n".join(retrieved_chunks) prompt_formatted = prompt.format(chunks_formatted=chunks_formatted, query=query) # generate answer llm = OpenAI(model="text-davinci-003", temperature=0) answer = llm(prompt_formatted) print(answer) ``` The output: ```python You can check disk usage in Linux using the df command to check disk space and the du command to check disk usage. You can also use the GUI application to check disk usage in a human readable format. For more information, please refer to the article "How to Check Disk Usage in Linux (4 Methods)" on Beebom. ``` ### Issues with Generating Answers using GPT-3 In the previous example, the chatbot generally performs well. However, there are certain situations where it could fail. Suppose we ask, "Is the Linux distribution free?" and provide GPT-3 with a document about kernel features as context. It might generate an answer like "Yes, the Linux distribution is free to download and use," even if such information is not present in the context document. Producing false information is highly undesirable for customer service chatbots! GPT-3 is less likely to generate false information when the answer to the user's question is contained within the context. Since user questions are often brief and ambiguous, we cannot always rely on the semantic search step to retrieve the correct document. Thus, there is always a risk of generating false information. ### Conclusion GPT-3 is highly effective in creating conversational chatbots capable of answering specific questions based on the contextual information provided in the prompt. However, it can be challenging to ensure that the model generates answers solely based on the context, as it has a tendency to hallucinate (i.e., generate new, potentially false information). The severity of generating false information varies depending on the use case. To conclude, we implemented a context-aware question-answering system using LangChain, following the provided code and strategies. The process involved splitting documents into chunks, computing their embeddings, implementing a retriever to find similar chunks, crafting a prompt for GPT-3, and using the GPT3 model for text generation. This approach demonstrates the potential of leveraging GPT-3 to create powerful and contextually accurate chatbots while also highlighting the need to be cautious about the possibility of generating false information. In the next lesson, you’ll see how to leverage Deep Lake and GPT-4 for building a sales assistant. **Sources:** [Learn Prompting: Your Guide to Communicating with AI](https://learnprompting.org/docs/applied_prompting/build_chatbot_from_kb)


Current Insights and Trends of Agents

# Current Insights and Trends of Agents
### **Introduction** This lesson aims to dive into the latest developments and trends in AI agents. We'll talk about popular AI agents and their fascinating features and explore the exciting possibilities they may hold for the future. We start by discussing the previously mentioned **AutoGPT** experiment that pushes GPT-4 towards full autonomy which has gained notable attention and popularity, even outperforming well-established projects like PyTorch in terms of GitHub stars. Next, we delve into the emergence of "**Plan-and-Execute**" agents that separate high-level planning from immediate execution and the ways these agents could be improved for better efficiency and performance. Following that, we explore **GPT-4's plug-in** and **code interpreter** capabilities, which augment the model's abilities and potential uses, facilitating tasks like data analysis, visualization, and internet interaction. We also provide insights on how to access and use these plugins. Lastly, we probe into the ongoing debate in AI about the efficiency of the "Small context window with a retriever approach" versus a "large context window without retrievers approach.” We'll examine each method's potential trade-offs and benefits, emphasizing the 100k tokens context window of the new **Anthropic model**. ### AutoGPT AutoGPT, an experimental open-source project aimed at making GPT-4 fully autonomous, has recently gained significant attention on GitHub, reaching 100k stars in less than three months. This surpasses the popularity of PyTorch, a widely used deep learning framework with 74k stars on GitHub. The rapid growth of AutoGPT's popularity can be attributed to its ability to inspire developers and enthusiasts. AutoGPT has been described as an experiment to test and understand the limits of GPT-4 (and 3.5) as a potential autonomous agent. While it may not be perfect yet, its capabilities are growing quickly. There are differing opinions on AutoGPT's current usefulness. Some users believe it is overhyped and cannot truly "run a business autonomously.” Others argue that it is still experimental and that its potential will become more evident as it evolves. AutoGPT's simplicity has been noted by some developers, who claim that the code is easy to understand compared to more complex projects. This simplicity has contributed to its rapid popularity on GitHub. AutoGPT's autonomous capabilities have raised concerns about potential misuse and the need for safeguards to prevent unethical activities. ### Planning Agents In the realm of "Plan-and-Execute" agents, the segregation of planning and execution is a step forward for agents able to solve more complex tasks. With strategies to enhance these agents, such as support for long sequences of steps and revisiting plans, we are looking at the future of sophisticated and dynamic AI systems. This approach separates higher-level planning from immediate execution and consists of **a planner** and **an executor**. The planner, typically a language model, uses its reasoning ability to devise a course of action and manage any ambiguities or edge cases. A parser can be appended at the end to translate the raw language model's output into a sequence of steps. On the other hand, the executor is responsible for actualizing these high-level objectives. Given a single step, it discerns the necessary tools or actions to fulfill that step, which could be accomplished in single or multiple stages. This architecture offers several advantages. By decoupling planning from execution, one language model can concentrate solely on planning, and another can focus on execution, enhancing reliability on both fronts. It also facilitates the replacement of these components with smaller, fine-tuned models in the future. However, the major drawback of this method is the increased number of calls to the language models. Still, due to the separation of concerns, these calls can potentially be made to smaller models,


Current Insights and Trends of Agents

# Current Insights and Trends of Agents
which would be faster and more cost-effective. Moving forward, there are several ways to enhance the "Plan-and-Execute" agents. These include: 1. **Support for Long Sequences of Steps:** Currently, only a few steps are handled. 2. **Revisiting Plans:** Presently, planning only happens once, in the beginning, and is never revisited. However, there may be a need for a mechanism that allows for periodic revisiting and adjustment of the plan, either after each step or as necessary. 3. **Evaluation:** Many of these enhancements are somewhat unbenchmarked. Therefore, more rigorous evaluation methods for agent frameworks are needed. 4. **Selection of Execution Chain:** At present, only a single execution chain exists. However, it might be beneficial to have multiple execution chains, with the planner specifying which one to use based on the task at hand. ### The ChatGPT Code Interpreter GPT-4, OpenAI's latest iteration of its model, has introduced the use of plugins to extend its capabilities. Among these plugins, namely the ChatGPT Code Interpreter and the ChatGPT Web Browser, aim to augment GPT-4's abilities, enabling it to interact with the internet, conduct data analysis, visualizations, and file conversions. As the AI's core training data extends only until September 2021, the generated text will contain information up to this point in time. The internet access plugin can bypass this constraint, allowing users to ask queries on recent events such as: "What was the outcome of the Celtics game last night?” Another notable plugin offered by OpenAI is the Code Interpreter, which facilitates intricate computations using Python. This plugin essentially acts as a proactive junior programmer, enhancing workflow efficiency. This plugin has been utilized for various tasks, such as visualizing lighthouses, performing basic video editing, and analyzing large datasets. The blog post on the official OpenAI portal stated: > *“We provide our models with a working Python interpreter in a sandboxed, firewalled execution environment and some ephemeral disk space. Code run by our interpreter plugin is evaluated in a persistent session that is alive for the duration of a chat conversation (with an upper-bound timeout), and subsequent calls can build on top of each other. We support uploading files to the current conversation workspace and downloading the results of your work.”* > **Accessing ChatGPT Code Interpreter** To access this plugin, users need to subscribe to ChatGPT Plus, and it is gradually being made available to all subscribers. Once you gain access, the plugin can be installed by navigating to the three-dot menu next to your login name at the bottom-left of the window, selecting the Beta features menu, and toggling on 'Plug-ins.’ If you wish for GPT-4 to access the internet as well, toggle on 'Web browsing.’ Then, under the language model selector, you can find the drop-down menu to select and install the Code Interpreter. With this plugin enabled, users have the option to interact with GPT-4 with enhanced capabilities. ### **ChatGPT Web Browser Plugin** The ChatGPT Web Browser plugin offers GPT-4 internet accessibility, enabling it to interact with web content. This functionality is particularly advantageous for tasks such as searching for information, browsing social media, or generating code snippets based on specific websites. ChatGPT plugins fall into two categories: internal and external. Internal plugins are managed and hosted by OpenAI. This includes tools like the web browser and the code interpreter, which enhance the AI's capabilities. On the other hand, external plugins are built and provided by third-party entities. The introduction of plugins such as the ChatGPT Code Interpreter and Web Browser significantly broadens the capabilities and potential uses of GPT-4. These tools allow GPT-4 to interact with the internet, perform tasks like


Current Insights and Trends of Agents

# Current Insights and Trends of Agents
data analysis and visualization, and access up-to-date information. ### **Plug-in Limitations** ChatGPT plugins, while introducing innovative features, also reveal some challenges and potential problems. A primary concern revolves around the centralization of power and influence, as these plugins could lead users to interact predominantly with ChatGPT, overshadowing individual websites and businesses. There’s the risk of chatbots diverting web traffic and affecting revenue for industries across. For instance, while a certain travel planning plugin is useful, there could be instances where users might prefer to use the direct website since the plugin only presents a subset of results compared to the full site. All businesses may not favor the plugin approach. It is noted that plugins pull users out of their app's experience. This sentiment could drive businesses to create their own AI services. For example, a popular online grocery service and a travel company are developing AI assistants, leveraging AI technology while keeping users within their platforms. ### Anthropic **Claude** 100k token window In the realm of large language model question-answering tasks, there's an ongoing debate about the necessity of a document retrieval stage, especially when using models with extensive context windows, specifically focusing on the **Claude model** developed by Anthropic, which is renowned for its sizeable 100k token context window. **Retrieval-based Architectures and Their Role** The process typically followed in question-answering tasks involves retrieval-based architectures. They work by sourcing relevant documents and using an LLM to convert the retrieved information into a response. The Claude model boasts a substantially larger context window compared to many other models. The evaluation of new strategies brings to light the pivotal debate between the "Small context window with a retriever approach" and its counterpart, the "Large context window without retrievers’ approach.” The choice between these two becomes a significant point of consideration given the evolving trends in the industry. 1. **The Impact of Larger Context Windows**: Larger context windows, such as Anthropic's 100k token context window, significantly enhance LLM functionality. With the ability to process and understand a broader range of text, the need for a retriever can be eliminated. However, this approach comes with limitations, including higher latency and potential reductions in accuracy as document length increases. This underlines the importance of considering each application's unique requirements and constraints. 2. **The Relevance of the Retriever-Based Approach**: Despite advancements in larger context windows, the traditional approach of "small context window with a retriever architecture" still retains significant value. Retrievers can selectively present relevant documents for a specific question or task, maintaining high accuracy even when working with a large text corpus. In addition, retrievers can drastically reduce latency times compared to models without retrievers. In scenarios where latency isn't a critical factor and the corpus is relatively small, retriever-less approaches could be a viable option, especially as LLM context windows continue to expand and models become quicker. Both models have unique strengths and face different challenges. The selection between the two largely depends on the application's specific needs, such as the size of the text corpus, acceptable latency, and the required level of accuracy. ### Conclusion Our discussion explored the latest trends in agent-based technology, including popular agents and their applications. AutoGPT emerged as a standout, inspiring many with its autonomous capabilities. Equally noteworthy is the increasing use of Language Learning Models for planning in multi-agent architectures. The growing trend of GPT-4 plugins, such as the browser and code interpreter plugins, emphasizes the role of customization in software development. We also delved into the nuances of context windows, with Anthropic's 100k tokens context window being a focal point. The trends illustrate the rapid


Current Insights and Trends of Agents

# Current Insights and Trends of Agents
advancement in this field. Customization, evident in the rise of plugins for AI models, is becoming increasingly important. Additionally, discussions around context window sizes hint at the continuous pursuit of accuracy and computational efficiency in AI. These insights signal an exciting future for AI, with these trends expected to shape the AI landscape significantly. Congratulations for finishing the last module of the course! You can now test your new knowledge with the module quizzes.


LangChain cookbook | 🦜🔗 Langchain

Main:  #LangChain cookbook Example code for building applications with LangChain, with an emphasis on more applied and end-to-end examples than contained in the [main documentation](https://python.langchain.com).  Notebook	Description [LLaMA2_sql_chat.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/LLaMA2_sql_chat.ipynb)	Build a chat application that interacts with a SQL database using an open source llm (llama2), specifically demonstrated on an SQLite database containing rosters. [Semi_Structured_RAG.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/Semi_Structured_RAG.ipynb)	Perform retrieval-augmented generation (rag) on documents with semi-structured data, including text and tables, using unstructured for parsing, multi-vector retriever for storing, and lcel for implementing chains. [Semi_structured_and_multi_moda...](https://github.com/langchain-ai/langchain/tree/master/cookbook/Semi_structured_and_multi_modal_RAG.ipynb)	Perform retrieval-augmented generation (rag) on documents with semi-structured data and images, using unstructured for parsing, multi-vector retriever for storage and retrieval, and lcel for implementing chains. [Semi_structured_multi_modal_RA...](https://github.com/langchain-ai/langchain/tree/master/cookbook/Semi_structured_multi_modal_RAG_LLaMA2.ipynb)	Perform retrieval-augmented generation (rag) on documents with semi-structured data and images, using various tools and methods such as unstructured for parsing, multi-vector retriever for storing, lcel for implementing chains, and open source language models like llama2, llava, and gpt4all. [analyze_document.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/analyze_document.ipynb)	Analyze a single long document. [autogpt/autogpt.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/autogpt/autogpt.ipynb)	Implement autogpt, a language model, with langchain primitives such as llms, prompttemplates, vectorstores, embeddings, and tools. [autogpt/marathon_times.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/autogpt/marathon_times.ipynb)	Implement autogpt for finding winning marathon times. [baby_agi.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/baby_agi.ipynb)	Implement babyagi, an ai agent that can generate and execute tasks based on a given objective, with the flexibility to swap out specific vectorstores/model providers. [baby_agi_with_agent.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/baby_agi_with_agent.ipynb)	Swap out the execution chain in the babyagi notebook with an agent that has access to tools, aiming to obtain more reliable information. [camel_role_playing.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/camel_role_playing.ipynb)	Implement the camel framework for creating autonomous cooperative agents in large-scale language models, using role-playing and inception prompting to guide chat agents towards task completion. [causalprogram_aided_language...](https://github.com/langchain-ai/langchain/tree/master/cookbook/causal_program_aided_language_model.ipynb)	Implement the causal program-aided language (cpal) chain, which improves upon the program-aided language (pal) by incorporating causal structure to prevent hallucination in language models, particularly when dealing with complex narratives and math problems with nested dependencies. [code-analysis-deeplake.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/code-analysis-deeplake.ipynb)	Analyze its own code base with the help of gpt and activeloop's deep lake. [custom_agent_with_plugin_retri...](https://github.com/langchain-ai/langchain/tree/master/cookbook/custom_agent_with_plugin_retrieval.ipynb)	Build a custom agent that can interact with ai plugins by retrieving tools and creating natural language wrappers around openapi endpoints. [custom_agent_with_plugin_retri...](https://github.com/langchain-ai/langchain/tree/master/cookbook/custom_agent_with_plugin_retrieval_using_plugnplai.ipynb)	Build a custom agent with plugin retrieval functionality, utilizing ai plugins from the plugnplai directory. [databricks_sql_db.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/databricks_sql_db.ipynb)	Connect to databricks runtimes and databricks sql. [deeplakesemantic_search_over...](https://github.com/langchain-ai/langchain/tree/master/cookbook/deeplake_semantic_search_over_chat.ipynb)	Perform semantic search and question-answering over a group chat using activeloop's deep lake with gpt4. [elasticsearch_db_qa.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/elasticsearch_db_qa.ipynb)	Interact with elasticsearch analytics databases in natural language and build search queries via the elasticsearch dsl API. [extraction_openai_tools.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/extraction_openai_tools.ipynb)	Structured Data Extraction with OpenAI Tools [forward_looking_retrieval_augm...](https://github.com/langchain-ai/langchain/tree/master/cookbook/forward_looking_retrieval_augmented_generation.ipynb)	Implement the forward-looking active retrieval augmented generation (flare) method, which generates answers to questions, identifies uncertain tokens, generates hypothetical questions based on these tokens, and retrieves relevant documents to continue generating the answer. [generativeagents_interactive...](https://github.com/langchain-ai/langchain/tree/master/cookbook/generative_agents_interactive_simulacra_of_human_behavior.ipynb)	Implement a generative agent that simulates human behavior, based on a research paper, using a time-weighted memory object backed by a langchain retriever. [gymnasium_agent_simulation.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/gymnasium_agent_simulation.ipynb)	Create a simple agent-environment interaction loop in simulated environments like text-based games with gym


LangChain cookbook | 🦜🔗 Langchain

nasium. [hugginggpt.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/hugginggpt.ipynb)	Implement hugginggpt, a system that connects language models like chatgpt with the machine learning community via hugging face. [hypothetical_document_embeddin...](https://github.com/langchain-ai/langchain/tree/master/cookbook/hypothetical_document_embeddings.ipynb)	Improve document indexing with hypothetical document embeddings (hyde), an embedding technique that generates and embeds hypothetical answers to queries. [learned_prompt_optimization.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/learned_prompt_optimization.ipynb)	Automatically enhance language model prompts by injecting specific terms using reinforcement learning, which can be used to personalize responses based on user preferences. [llm_bash.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/llm_bash.ipynb)	Perform simple filesystem commands using language learning models (llms) and a bash process. [llm_checker.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/llm_checker.ipynb)	Create a self-checking chain using the llmcheckerchain function. [llm_math.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/llm_math.ipynb)	Solve complex word math problems using language models and python repls. [llm_summarization_checker.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/llm_summarization_checker.ipynb)	Check the accuracy of text summaries, with the option to run the checker multiple times for improved results. [llm_symbolic_math.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/llm_symbolic_math.ipynb)	Solve algebraic equations with the help of llms (language learning models) and sympy, a python library for symbolic mathematics. [meta_prompt.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/meta_prompt.ipynb)	Implement the meta-prompt concept, which is a method for building self-improving agents that reflect on their own performance and modify their instructions accordingly. [multi_modal_output_agent.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/multi_modal_output_agent.ipynb)	Generate multi-modal outputs, specifically images and text. [multi_player_dnd.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/multi_player_dnd.ipynb)	Simulate multi-player dungeons & dragons games, with a custom function determining the speaking schedule of the agents. [multiagent_authoritarian.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/multiagent_authoritarian.ipynb)	Implement a multi-agent simulation where a privileged agent controls the conversation, including deciding who speaks and when the conversation ends, in the context of a simulated news network. [multiagent_bidding.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/multiagent_bidding.ipynb)	Implement a multi-agent simulation where agents bid to speak, with the highest bidder speaking next, demonstrated through a fictitious presidential debate example. [myscale_vector_sql.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/myscale_vector_sql.ipynb)	Access and interact with the myscale integrated vector database, which can enhance the performance of language model (llm) applications. [openai_functions_retrieval_qa....](https://github.com/langchain-ai/langchain/tree/master/cookbook/openai_functions_retrieval_qa.ipynb)	Structure response output in a question-answering system by incorporating openai functions into a retrieval pipeline. [openai_v1_cookbook.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/openai_v1_cookbook.ipynb)	Explore new functionality released alongside the V1 release of the OpenAI Python library. [petting_zoo.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/petting_zoo.ipynb)	Create multi-agent simulations with simulated environments using the petting zoo library. [plan_and_execute_agent.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/plan_and_execute_agent.ipynb)	Create plan-and-execute agents that accomplish objectives by planning tasks with a language model (llm) and executing them with a separate agent. [press_releases.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/press_releases.ipynb)	Retrieve and query company press release data powered by [Kay.ai](https://kay.ai). [program_aided_language_model.i...](https://github.com/langchain-ai/langchain/tree/master/cookbook/program_aided_language_model.ipynb)	Implement program-aided language models as described in the provided research paper. [qa_citations.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/qa_citations.ipynb)	Different ways to get a model to cite its sources. [retrieval_in_sql.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/retrieval_in_sql.ipynb)	Perform retrieval-augmented-generation (rag) on a PostgreSQL database using pgvector. [sales_agent_with_context.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/sales_agent_with_context.ipynb)	Implement a context-aware ai sales agent, salesgpt, that can have natural sales conversations, interact with other systems, and use a product knowledge base to discuss a company's offerings. [self_query_hotel_search.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/self_query_hotel_search.ipynb)	Build a hotel room search feature with self-querying retrieval, using a specific hotel recommendation dataset. [smart_llm.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/smart_llm.ipynb)	Implement a smartllmchain, a self-critique chain that generates multiple output proposals, critiques them to find the best one, and then improves upon it to produce a final output. [tree_of_thought.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/tre


LangChain cookbook | 🦜🔗 Langchain

e_of_thought.ipynb)	Query a large language model using the tree of thought technique. [twitter-the-algorithm-analysis...](https://github.com/langchain-ai/langchain/tree/master/cookbook/twitter-the-algorithm-analysis-deeplake.ipynb)	Analyze the source code of the Twitter algorithm with the help of gpt4 and activeloop's deep lake. [two_agent_debate_tools.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/two_agent_debate_tools.ipynb)	Simulate multi-agent dialogues where the agents can utilize various tools. [two_player_dnd.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/two_player_dnd.ipynb)	Simulate a two-player dungeons & dragons game, where a dialogue simulator class is used to coordinate the dialogue between the protagonist and the dungeon master. [wikibase_agent.ipynb](https://github.com/langchain-ai/langchain/tree/master/cookbook/wikibase_agent.ipynb)	Create a simple wikibase agent that utilizes sparql generation, with testing done on [http://wikidata.org](http://wikidata.org).


YouTube videos | 🦜🔗 Langchain

Main:  On this page #YouTube videos ⛓ icon marks a new addition [last update 2023-09-21]  ###[Official LangChain YouTube channel](https://www.youtube.com/@LangChain)[](#official-langchain-youtube-channel) ###Introduction to LangChain with Harrison Chase, creator of LangChain[](#introduction-to-langchain-with-harrison-chase-creator-of-langchain) - [Building the Future with LLMs, LangChain, & Pinecone](https://youtu.be/nMniwlGyX-c) by [Pinecone](https://www.youtube.com/@pinecone-io) - [LangChain and Weaviate with Harrison Chase and Bob van Luijt - Weaviate Podcast #36](https://youtu.be/lhby7Ql7hbk) by [Weaviate • Vector Database](https://www.youtube.com/@Weaviate) - [LangChain Demo + Q&A with Harrison Chase](https://youtu.be/zaYTXQFR0_s?t=788) by [Full Stack Deep Learning](https://www.youtube.com/@FullStackDeepLearning) - [LangChain Agents: Build Personal Assistants For Your Data (Q&A with Harrison Chase and Mayo Oshin)](https://youtu.be/gVkF8cwfBLI) by [Chat with data](https://www.youtube.com/@chatwithdata) ##Videos (sorted by views)[](#videos-sorted-by-views) - [Using ChatGPT with YOUR OWN Data. This is magical. (LangChain OpenAI API)](https://youtu.be/9AXP7tCI9PI) by [TechLead](https://www.youtube.com/@TechLead) - [First look - ChatGPT + WolframAlpha (GPT-3.5 and Wolfram|Alpha via LangChain by James Weaver)](https://youtu.be/wYGbY811oMo) by [Dr Alan D. Thompson](https://www.youtube.com/@DrAlanDThompson) - [LangChain explained - The hottest new Python framework](https://youtu.be/RoR4XJw8wIc) by [AssemblyAI](https://www.youtube.com/@AssemblyAI) - [Chatbot with INFINITE MEMORY using OpenAI & Pinecone - GPT-3, Embeddings, ADA, Vector DB, Semantic](https://youtu.be/2xNzB7xq8nk) by [David Shapiro ~ AI](https://www.youtube.com/@DavidShapiroAutomator) - [LangChain for LLMs is... basically just an Ansible playbook](https://youtu.be/X51N9C-OhlE) by [David Shapiro ~ AI](https://www.youtube.com/@DavidShapiroAutomator) - [Build your own LLM Apps with LangChain & GPT-Index](https://youtu.be/-75p09zFUJY) by [1littlecoder](https://www.youtube.com/@1littlecoder) - [BabyAGI - New System of Autonomous AI Agents with LangChain](https://youtu.be/lg3kJvf1kXo) by [1littlecoder](https://www.youtube.com/@1littlecoder) - [Run BabyAGI with Langchain Agents (with Python Code)](https://youtu.be/WosPGHPObx8) by [1littlecoder](https://www.youtube.com/@1littlecoder) - [How to Use Langchain With Zapier | Write and Send Email with GPT-3 | OpenAI API Tutorial](https://youtu.be/p9v2-xEa9A0) by [StarMorph AI](https://www.youtube.com/@starmorph) - [Use Your Locally Stored Files To Get Response From GPT - OpenAI | Langchain | Python](https://youtu.be/NC1Ni9KS-rk) by [Shweta Lodha](https://www.youtube.com/@shweta-lodha) - [Langchain JS | How to Use GPT-3, GPT-4 to Reference your own Data | OpenAI Embeddings Intro](https://youtu.be/veV2I-NEjaM) by [StarMorph AI](https://www.youtube.com/@starmorph) - [The easiest way to work with large language models | Learn LangChain in 10min](https://youtu.be/kmbS6FDQh7c) by [Sophia Yang](https://www.youtube.com/@SophiaYangDS) - [4 Autonomous AI Agents: “Westworld” simulation BabyAGI, AutoGPT, Camel, LangChain](https://youtu.be/yWbnH6inT_U) by [Sophia Yang](https://www.youtube.com/@SophiaYangDS) - [AI CAN SEARCH THE INTERNET? Langchain Agents + OpenAI ChatGPT](https://youtu.be/J-GL0htqda8) by [tylerwhatsgood](https://www.youtube.com/@tylerwhatsgood) - [Query Your Data with GPT-4 | Embeddings, Vector Databases | Langchain JS Knowledgebase](https://youtu.be/jRnUPUTkZmU) by [StarMorph AI](https://www.youtube.com/@starmorph) - [Weaviate + LangChain for LLM apps presented by Erika Cardenas](https://youtu.be/7AGj4Td5Lgw) by [Weaviate • Vector Database](https://www.youtube.com/@Weaviate) - [Langchain Overview — How to Use Langchain & ChatGPT](https://youtu.be/oYVYIq0lOtI) by [Python In Office](https://www.youtube.com/@pythoninoffice6568) - [Langchain Overview - How to Use Langchain & ChatGPT](https://youtu.be/oYVYIq0lOtI) by [Python In Office](https://www.youtube.com/@pythoninoffice6568) - [LangChain Tutorials](https://www.youtube.com/watch?v=FuqdVNB_8c0&list=PL9V0lbeJ69brU-ojMpU1Y7Ic58Tap0Cw6) by [Edrick](https://www.youtube.com/@edrickdch): - [LangChain, Chroma DB, OpenAI Beginner Guide | ChatGPT with your PDF](https://youtu.be/FuqdVNB_8c0) - [LangChain 101: The Complete Beginner's Guide](https://youtu.be/P3MAbZ2eMUI) - [Custom langchain Agent & Tools with memory. Turn any Python function into langchain tool with Gpt 3](https://youtu.be/NIG8lXk0ULg) by [echohive](https://www.youtube.com/@echohive) - [Building AI LLM Apps with LangChain (and more?) - LIVE STREAM](https://www.youtube.com/live/M-2Cj_2fzWI?feature=share) by [Nicholas Renotte](https://www.youtube.com/@NicholasRenotte) - [ChatGPT with any YouTube video using langchain and chromadb](https://youtu.be/TQZfB2bzVwU) by [echohive](https://www.youtube.com/@echohive) - [How to Talk to a PDF using LangChain and ChatGPT](https://youtu.be/v2i1YDtrIwk) by [Automata Learning Lab](https://www.youtube.com/@automatalearninglab) - [Langchain Document Loaders Part 1: Unstructured Files](https://youtu.be/O5C0wfsen98) by [Merk](https://www.youtube.com/@merksworld) - [LangChain - Prompt Templates (what all the best prompt engineers use)](https://youtu.be/1aRu8b0XNOQ) by [Nick Daigler](https://www.youtube.com/@nick_daigs) - [LangChain. Crear aplicaciones Python impulsadas por GPT](https://youtu.be/DkW_rDndts8) by [Jesús Conde](https://www.youtube.com/@0utKast) - [Easiest Way to Use GPT In Your Products | LangChain Basics Tutorial](https://youtu.be/fLy0VenZyGc) by [Rachel Woods](https://www.youtube.com/@therachelwoods) - [BabyAGI + GPT-4 Langchain Agent with Internet Access](https://youtu.be/wx1z_hs5P6E) by [tylerwhatsgood](https://www.youtube.com/@tylerwhatsgood) - [Learning LLM Agents. How does it actually work? LangChain, AutoGPT & OpenAI](https://youtu.be/mb_YAABSplk) by [Arnoldas Kemeklis](https://www.youtube.com/@processusAI) - [Get Started with Lan


YouTube videos | 🦜🔗 Langchain

gChain in Node.js](https://youtu.be/Wxx1KUWJFv4) by [Developers Digest](https://www.youtube.com/@DevelopersDigest) - [LangChain + OpenAI tutorial: Building a Q&A system w/ own text data](https://youtu.be/DYOU_Z0hAwo) by [Samuel Chan](https://www.youtube.com/@SamuelChan) - [Langchain + Zapier Agent](https://youtu.be/yribLAb-pxA) by [Merk](https://www.youtube.com/@merksworld) - [Connecting the Internet with ChatGPT (LLMs) using Langchain And Answers Your Questions](https://youtu.be/9Y0TBC63yZg) by [Kamalraj M M](https://www.youtube.com/@insightbuilder) - [Build More Powerful LLM Applications for Business’s with LangChain (Beginners Guide)](https://youtu.be/sp3-WLKEcBg) by[ No Code Blackbox](https://www.youtube.com/@nocodeblackbox) - [LangFlow LLM Agent Demo for 🦜🔗LangChain](https://youtu.be/zJxDHaWt-6o) by [Cobus Greyling](https://www.youtube.com/@CobusGreylingZA) - [Chatbot Factory: Streamline Python Chatbot Creation with LLMs and Langchain](https://youtu.be/eYer3uzrcuM) by [Finxter](https://www.youtube.com/@CobusGreylingZA) - [LangChain Tutorial - ChatGPT mit eigenen Daten](https://youtu.be/0XDLyY90E2c) by [Coding Crashkurse](https://www.youtube.com/@codingcrashkurse6429) - [Chat with a CSV | LangChain Agents Tutorial (Beginners)](https://youtu.be/tjeti5vXWOU) by [GoDataProf](https://www.youtube.com/@godataprof) - [Introdução ao Langchain - #Cortes - Live DataHackers](https://youtu.be/fw8y5VRei5Y) by [Prof. João Gabriel Lima](https://www.youtube.com/@profjoaogabriellima) - [LangChain: Level up ChatGPT !? | LangChain Tutorial Part 1](https://youtu.be/vxUGx8aZpDE) by [Code Affinity](https://www.youtube.com/@codeaffinitydev) - [KI schreibt krasses Youtube Skript 😲😳 | LangChain Tutorial Deutsch](https://youtu.be/QpTiXyK1jus) by [SimpleKI](https://www.youtube.com/@simpleki) - [Chat with Audio: Langchain, Chroma DB, OpenAI, and Assembly AI](https://youtu.be/Kjy7cx1r75g) by [AI Anytime](https://www.youtube.com/@AIAnytime) - [QA over documents with Auto vector index selection with Langchain router chains](https://youtu.be/9G05qybShv8) by [echohive](https://www.youtube.com/@echohive) - [Build your own custom LLM application with Bubble.io & Langchain (No Code & Beginner friendly)](https://youtu.be/O7NhQGu1m6c) by [No Code Blackbox](https://www.youtube.com/@nocodeblackbox) - [Simple App to Question Your Docs: Leveraging Streamlit, Hugging Face Spaces, LangChain, and Claude!](https://youtu.be/X4YbNECRr7o) by [Chris Alexiuk](https://www.youtube.com/@chrisalexiuk) - [LANGCHAIN AI- ConstitutionalChainAI + Databutton AI ASSISTANT Web App](https://youtu.be/5zIU6_rdJCU) by [Avra](https://www.youtube.com/@Avra_b) - [LANGCHAIN AI AUTONOMOUS AGENT WEB APP - 👶 BABY AGI 🤖 with EMAIL AUTOMATION using DATABUTTON](https://youtu.be/cvAwOGfeHgw) by [Avra](https://www.youtube.com/@Avra_b) - [The Future of Data Analysis: Using A.I. Models in Data Analysis (LangChain)](https://youtu.be/v_LIcVyg5dk) by [Absent Data](https://www.youtube.com/@absentdata) - [Memory in LangChain | Deep dive (python)](https://youtu.be/70lqvTFh_Yg) by [Eden Marco](https://www.youtube.com/@EdenMarco) - [9 LangChain UseCases | Beginner's Guide | 2023](https://youtu.be/zS8_qosHNMw) by [Data Science Basics](https://www.youtube.com/@datasciencebasics) - [Use Large Language Models in Jupyter Notebook | LangChain | Agents & Indexes](https://youtu.be/JSe11L1a_QQ) by [Abhinaw Tiwari](https://www.youtube.com/@AbhinawTiwariAT) - [How to Talk to Your Langchain Agent | 11 Labs + Whisper](https://youtu.be/N4k459Zw2PU) by [VRSEN](https://www.youtube.com/@vrsen) - [LangChain Deep Dive: 5 FUN AI App Ideas To Build Quickly and Easily](https://youtu.be/mPYEPzLkeks) by [James NoCode](https://www.youtube.com/@jamesnocode) - [LangChain 101: Models](https://youtu.be/T6c_XsyaNSQ) by [Mckay Wrigley](https://www.youtube.com/@realmckaywrigley) - [LangChain with JavaScript Tutorial #1 | Setup & Using LLMs](https://youtu.be/W3AoeMrg27o) by [Leon van Zyl](https://www.youtube.com/@leonvanzyl) - [LangChain Overview & Tutorial for Beginners: Build Powerful AI Apps Quickly & Easily (ZERO CODE)](https://youtu.be/iI84yym473Q) by [James NoCode](https://www.youtube.com/@jamesnocode) - [LangChain In Action: Real-World Use Case With Step-by-Step Tutorial](https://youtu.be/UO699Szp82M) by [Rabbitmetrics](https://www.youtube.com/@rabbitmetrics) - [Summarizing and Querying Multiple Papers with LangChain](https://youtu.be/p_MQRWH5Y6k) by [Automata Learning Lab](https://www.youtube.com/@automatalearninglab) - [Using Langchain (and Replit) through Tana, ask Google/Wikipedia/Wolfram Alpha to fill out a table](https://youtu.be/Webau9lEzoI) by [Stian Håklev](https://www.youtube.com/@StianHaklev) - [Langchain PDF App (GUI) | Create a ChatGPT For Your PDF in Python](https://youtu.be/wUAUdEw5oxM) by [Alejandro AO - Software & Ai](https://www.youtube.com/@alejandro_ao) - [Auto-GPT with LangChain 🔥 | Create Your Own Personal AI Assistant](https://youtu.be/imDfPmMKEjM) by [Data Science Basics](https://www.youtube.com/@datasciencebasics) - [Create Your OWN Slack AI Assistant with Python & LangChain](https://youtu.be/3jFXRNn2Bu8) by [Dave Ebbelaar](https://www.youtube.com/@daveebbelaar) - [How to Create LOCAL Chatbots with GPT4All and LangChain [Full Guide]](https://youtu.be/4p1Fojur8Zw) by [Liam Ottley](https://www.youtube.com/@LiamOttley) - [Build a Multilingual PDF Search App with LangChain, Cohere and Bubble](https://youtu.be/hOrtuumOrv8) by [Menlo Park Lab](https://www.youtube.com/@menloparklab) - [Building a LangChain Agent (code-free!) Using Bubble and Flowise](https://youtu.be/jDJIIVWTZDE) by [Menlo Park Lab](https://www.youtube.com/@menloparklab) - [Build a LangChain-based Semantic PDF Search App with No-Code Tools Bubble and Flowise](https://youtu.be/s33v5cIeqA4) by [Menlo Park Lab](https://www.youtube.com/@menloparklab) - [LangChain Memory Tutorial | Building a ChatGPT Clone in Python](https://youtu.be/Cwq91cj2Pnc) by [Alejandro AO - Software & Ai](https://www.youtube.com/@alejandro_ao


YouTube videos | 🦜🔗 Langchain

) - [ChatGPT For Your DATA | Chat with Multiple Documents Using LangChain](https://youtu.be/TeDgIDqQmzs) by [Data Science Basics](https://www.youtube.com/@datasciencebasics) - [Llama Index: Chat with Documentation using URL Loader](https://youtu.be/XJRoDEctAwA) by [Merk](https://www.youtube.com/@merksworld) - [Using OpenAI, LangChain, and Gradio to Build Custom GenAI Applications](https://youtu.be/1MsmqMg3yUc) by [David Hundley](https://www.youtube.com/@dkhundley) - [LangChain, Chroma DB, OpenAI Beginner Guide | ChatGPT with your PDF](https://youtu.be/FuqdVNB_8c0) - [Build AI chatbot with custom knowledge base using OpenAI API and GPT Index](https://youtu.be/vDZAZuaXf48) by [Irina Nik](https://www.youtube.com/@irina_nik) - [Build Your Own Auto-GPT Apps with LangChain (Python Tutorial)](https://youtu.be/NYSWn1ipbgg) by [Dave Ebbelaar](https://www.youtube.com/@daveebbelaar) - [Chat with Multiple PDFs | LangChain App Tutorial in Python (Free LLMs and Embeddings)](https://youtu.be/dXxQ0LR-3Hg) by [Alejandro AO - Software & Ai](https://www.youtube.com/@alejandro_ao) - [Chat with a CSV | LangChain Agents Tutorial (Beginners)](https://youtu.be/tjeti5vXWOU) by [Alejandro AO - Software & Ai](https://www.youtube.com/@alejandro_ao) - [Create Your Own ChatGPT with PDF Data in 5 Minutes (LangChain Tutorial)](https://youtu.be/au2WVVGUvc8) by [Liam Ottley](https://www.youtube.com/@LiamOttley) - [Build a Custom Chatbot with OpenAI: GPT-Index & LangChain | Step-by-Step Tutorial](https://youtu.be/FIDv6nc4CgU) by [Fabrikod](https://www.youtube.com/@fabrikod) - [Flowise is an open-source no-code UI visual tool to build 🦜🔗LangChain applications](https://youtu.be/CovAPtQPU0k) by [Cobus Greyling](https://www.youtube.com/@CobusGreylingZA) - [LangChain & GPT 4 For Data Analysis: The Pandas Dataframe Agent](https://youtu.be/rFQ5Kmkd4jc) by [Rabbitmetrics](https://www.youtube.com/@rabbitmetrics) - [GirlfriendGPT - AI girlfriend with LangChain](https://youtu.be/LiN3D1QZGQw) by [Toolfinder AI](https://www.youtube.com/@toolfinderai) - [How to build with Langchain 10x easier | ⛓ LangFlow & Flowise](https://youtu.be/Ya1oGL7ZTvU) by [AI Jason](https://www.youtube.com/@AIJasonZ) - [Getting Started With LangChain In 20 Minutes- Build Celebrity Search Application](https://youtu.be/_FpT1cwcSLg) by [Krish Naik](https://www.youtube.com/@krishnaik06) - ⛓ [Vector Embeddings Tutorial – Code Your Own AI Assistant with GPT-4 API + LangChain + NLP](https://youtu.be/yfHHvmaMkcA?si=5uJhxoh2tvdnOXok) by [FreeCodeCamp.org](https://www.youtube.com/@freecodecamp) - ⛓ [Fully LOCAL Llama 2 Q&A with LangChain](https://youtu.be/wgYctKFnQ74?si=UX1F3W-B3MqF4-K-) by [1littlecoder](https://www.youtube.com/@1littlecoder) - ⛓ [Fully LOCAL Llama 2 Langchain on CPU](https://youtu.be/yhECvKMu8kM?si=IvjxwlA1c09VwHZ4) by [1littlecoder](https://www.youtube.com/@1littlecoder) - ⛓ [Build LangChain Audio Apps with Python in 5 Minutes](https://youtu.be/7w7ysaDz2W4?si=BvdMiyHhormr2-vr) by [AssemblyAI](https://www.youtube.com/@AssemblyAI) - ⛓ [Voiceflow & Flowise: Want to Beat Competition? New Tutorial with Real AI Chatbot](https://youtu.be/EZKkmeFwag0?si=-4dETYDHEstiK_bb) by [AI SIMP](https://www.youtube.com/@aisimp) - ⛓ [THIS Is How You Build Production-Ready AI Apps (LangSmith Tutorial)](https://youtu.be/tFXm5ijih98?si=lfiqpyaivxHFyI94) by [Dave Ebbelaar](https://www.youtube.com/@daveebbelaar) - ⛓ [Build POWERFUL LLM Bots EASILY with Your Own Data - Embedchain - Langchain 2.0? (Tutorial)](https://youtu.be/jE24Y_GasE8?si=0yEDZt3BK5Q-LIuF) by [WorldofAI](https://www.youtube.com/@intheworldofai) - ⛓ [Code Llama powered Gradio App for Coding: Runs on CPU](https://youtu.be/AJOhV6Ryy5o?si=ouuQT6IghYlc1NEJ) by [AI Anytime](https://www.youtube.com/@AIAnytime) - ⛓ [LangChain Complete Course in One Video | Develop LangChain (AI) Based Solutions for Your Business](https://youtu.be/j9mQd-MyIg8?si=_wlNT3nP2LpDKztZ) by [UBprogrammer](https://www.youtube.com/@UBprogrammer) - ⛓ [How to Run LLaMA Locally on CPU or GPU | Python & Langchain & CTransformers Guide](https://youtu.be/SvjWDX2NqiM?si=DxFml8XeGhiLTzLV) by [Code With Prince](https://www.youtube.com/@CodeWithPrince) - ⛓ [PyData Heidelberg #11 - TimeSeries Forecasting & LLM Langchain](https://www.youtube.com/live/Glbwb5Hxu18?si=PIEY8Raq_C9PCHuW) by [PyData](https://www.youtube.com/@PyDataTV) - ⛓ [Prompt Engineering in Web Development | Using LangChain and Templates with OpenAI](https://youtu.be/pK6WzlTOlYw?si=fkcDQsBG2h-DM8uQ) by [Akamai Developer ](https://www.youtube.com/@AkamaiDeveloper) - ⛓ [Retrieval-Augmented Generation (RAG) using LangChain and Pinecone - The RAG Special Episode](https://youtu.be/J_tCD_J6w3s?si=60Mnr5VD9UED9bGG) by [Generative AI and Data Science On AWS](https://www.youtube.com/@GenerativeAIDataScienceOnAWS) - ⛓ [LLAMA2 70b-chat Multiple Documents Chatbot with Langchain & Streamlit |All OPEN SOURCE|Replicate API](https://youtu.be/vhghB81vViM?si=dszzJnArMeac7lyc) by [DataInsightEdge](https://www.youtube.com/@DataInsightEdge01) - ⛓ [Chatting with 44K Fashion Products: LangChain Opportunities and Pitfalls](https://youtu.be/Zudgske0F_s?si=8HSshHoEhh0PemJA) by [Rabbitmetrics](https://www.youtube.com/@rabbitmetrics) - ⛓ [Structured Data Extraction from ChatGPT with LangChain](https://youtu.be/q1lYg8JISpQ?si=0HctzOHYZvq62sve) by [MG](https://www.youtube.com/@MG_cafe) - ⛓ [Chat with Multiple PDFs using Llama 2, Pinecone and LangChain (Free LLMs and Embeddings)](https://youtu.be/TcJ_tVSGS4g?si=FZYnMDJyoFfL3Z2i) by [Muhammad Moin](https://www.youtube.com/@muhammadmoinfaisal) - ⛓ [Integrate Audio into LangChain.js apps in 5 Minutes](https://youtu.be/hNpUSaYZIzs?si=Gb9h7W9A8lzfvFKi) by [AssemblyAI](https://www.youtube.com/@AssemblyAI) - ⛓ [ChatGPT for your data with Local LLM](https://youtu.be/bWrjpwhHEMU?si=uM6ZZ18z9og4M90u) by [Jacob Jedryszek](https://www.youtube.com/@jj09) - ⛓ [Training Chatgpt with your personal data using langchain step by step in detail](https://youtu.be/j3xOMde2v9Y?si=179HsiMU-hEP