Skip to main content

How To Search Content Which ChatGPT Can’t Find Today — OpenAI | Python

In this article, I’ll show you how can you get your hands dirty with Langchain agents. If you are not aware what Langchain is, I would recommend you to watch my recording here, wherein I just briefed about it.

Langchain agents are the ones who uses LLM to determine what needs to be done and in which order. You can have a quick look at the available agents in the documentation, but I’ll list them here too.

  • zero-shot-react-description
  • react-docstore
  • self-ask-with-search
  • conversational-react-description

Here agents work via tools and tools are nothing but those are functions which will be used by agents to interact with outside world.

List of tools which are available today are:

  • python_repl
  • serpapi
  • wolfram-alpha
  • requests
  • terminal
  • pal-math
  • pal-colored-objects
  • llm-math
  • open-meteo-api
  • news-api
  • tmdb-api
  • google-search
  • searx-search
  • google-serper, etc

In this article, I’m covering serpapi.

Import Required Packages

In order to get started, we need to import these below packages:

from langchain.agents import load_tools
from langchain.agents import initialize_agent
from langchain.llms import OpenAI
import os

Set LLM And Initialize Agent

Next we need to set LLM, which is OpenAI here and then we need to initialize agent as shown below:

llm = OpenAI(temperature=0)
tools = load_tools([“serpapi”])
agent = initialize_agent(tools, llm, agent=”zero-shot-react-description”)

If this is what interests you, check out my complete article here.

Here is the video post too.