Merge pull request #196 from Serper-API/main

Replaced search tool with google-serper
This commit is contained in:
Elvis Saravia 2023-06-17 10:15:32 -06:00 committed by GitHub
commit 391ae1795c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 13 additions and 13 deletions

View File

@ -91,7 +91,7 @@
"\n", "\n",
"# for LangChain\n", "# for LangChain\n",
"os.environ[\"OPENAI_API_KEY\"] = os.getenv(\"OPENAI_API_KEY\")\n", "os.environ[\"OPENAI_API_KEY\"] = os.getenv(\"OPENAI_API_KEY\")\n",
"os.environ[\"SERPAPI_API_KEY\"] = os.getenv(\"SERPAPI_API_KEY\")" "os.environ[\"SERPER_API_KEY\"] = os.getenv(\"SERPER_API_KEY\")"
] ]
}, },
{ {
@ -910,7 +910,7 @@
"source": [ "source": [
"llm = OpenAI(temperature=0)\n", "llm = OpenAI(temperature=0)\n",
"\n", "\n",
"tools = load_tools([\"serpapi\", \"llm-math\"], llm=llm)\n", "tools = load_tools([\"google-serper\", \"llm-math\"], llm=llm)\n",
"agent = initialize_agent(tools, llm, agent=\"zero-shot-react-description\", verbose=True)" "agent = initialize_agent(tools, llm, agent=\"zero-shot-react-description\", verbose=True)"
] ]
}, },

View File

@ -32,7 +32,7 @@
"\n", "\n",
"# load API keys; you will need to obtain these if you haven't yet\n", "# load API keys; you will need to obtain these if you haven't yet\n",
"os.environ[\"OPENAI_API_KEY\"] = os.getenv(\"OPENAI_API_KEY\")\n", "os.environ[\"OPENAI_API_KEY\"] = os.getenv(\"OPENAI_API_KEY\")\n",
"os.environ[\"SERPAPI_API_KEY\"] = os.getenv(\"SERPAPI_API_KEY\")" "os.environ[\"SERPER_API_KEY\"] = os.getenv(\"SERPER_API_KEY\")"
] ]
}, },
{ {
@ -42,7 +42,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"llm = OpenAI(model_name=\"text-davinci-003\" ,temperature=0)\n", "llm = OpenAI(model_name=\"text-davinci-003\" ,temperature=0)\n",
"tools = load_tools([\"serpapi\", \"llm-math\"], llm=llm)\n", "tools = load_tools([\"google-serper\", \"llm-math\"], llm=llm)\n",
"agent = initialize_agent(tools, llm, agent=\"zero-shot-react-description\", verbose=True)" "agent = initialize_agent(tools, llm, agent=\"zero-shot-react-description\", verbose=True)"
] ]
}, },

View File

@ -126,7 +126,7 @@ load_dotenv()
# carrega les claus API; hauràs d'obtenir-les si encara no les tens # carrega les claus API; hauràs d'obtenir-les si encara no les tens
os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY") os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY")
os.environ["SERPAPI_API_KEY"] = os.getenv("SERPAPI_API_KEY") os.environ["SERPER_API_KEY"] = os.getenv("SERPER_API_KEY")
``` ```
@ -134,7 +134,7 @@ Ara podem configurar l'LLM, les eines que utilitzarem i l'agent que ens permet u
``` python ``` python
llm = OpenAI(model_name="text-davinci-003" ,temperature=0) llm = OpenAI(model_name="text-davinci-003" ,temperature=0)
tools = load_tools(["serpapi", "llm-math"], llm=llm) tools = load_tools(["google-serper", "llm-math"], llm=llm)
agent = initialize_agent(tools, llm, agent="zero-shot-react-description", verbose=True) agent = initialize_agent(tools, llm, agent="zero-shot-react-description", verbose=True)
``` ```

View File

@ -127,7 +127,7 @@ load_dotenv()
# load API keys; you will need to obtain these if you haven't yet # load API keys; you will need to obtain these if you haven't yet
os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY") os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY")
os.environ["SERPAPI_API_KEY"] = os.getenv("SERPAPI_API_KEY") os.environ["SERPER_API_KEY"] = os.getenv("SERPER_API_KEY")
``` ```
@ -135,7 +135,7 @@ Now we can configure the LLM, the tools we will use, and the agent that allows u
``` python ``` python
llm = OpenAI(model_name="text-davinci-003" ,temperature=0) llm = OpenAI(model_name="text-davinci-003" ,temperature=0)
tools = load_tools(["serpapi", "llm-math"], llm=llm) tools = load_tools(["google-serper", "llm-math"], llm=llm)
agent = initialize_agent(tools, llm, agent="zero-shot-react-description", verbose=True) agent = initialize_agent(tools, llm, agent="zero-shot-react-description", verbose=True)
``` ```

View File

@ -116,7 +116,7 @@ load_dotenv()
# load API keys; you will need to obtain these if you haven't yet # load API keys; you will need to obtain these if you haven't yet
os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY") os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY")
os.environ["SERPAPI_API_KEY"] = os.getenv("SERPAPI_API_KEY") os.environ["SERPER_API_KEY"] = os.getenv("SERPER_API_KEY")
``` ```

View File

@ -126,7 +126,7 @@ load_dotenv()
# load API keys; you will need to obtain these if you haven't yet # load API keys; you will need to obtain these if you haven't yet
os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY") os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY")
os.environ["SERPAPI_API_KEY"] = os.getenv("SERPAPI_API_KEY") os.environ["SERPER_API_KEY"] = os.getenv("SERPER_API_KEY")
``` ```
@ -134,7 +134,7 @@ os.environ["SERPAPI_API_KEY"] = os.getenv("SERPAPI_API_KEY")
``` python ``` python
llm = OpenAI(model_name="text-davinci-003" ,temperature=0) llm = OpenAI(model_name="text-davinci-003" ,temperature=0)
tools = load_tools(["serpapi", "llm-math"], llm=llm) tools = load_tools(["google-serper", "llm-math"], llm=llm)
agent = initialize_agent(tools, llm, agent="zero-shot-react-description", verbose=True) agent = initialize_agent(tools, llm, agent="zero-shot-react-description", verbose=True)
``` ```

View File

@ -116,7 +116,7 @@ load_dotenv()
# 载入 API keys; 如果没有,你需要先获取。 # 载入 API keys; 如果没有,你需要先获取。
os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY") os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY")
os.environ["SERPAPI_API_KEY"] = os.getenv("SERPAPI_API_KEY") os.environ["SERPER_API_KEY"] = os.getenv("SERPER_API_KEY")
``` ```
@ -124,7 +124,7 @@ os.environ["SERPAPI_API_KEY"] = os.getenv("SERPAPI_API_KEY")
``` python ``` python
llm = OpenAI(model_name="text-davinci-003" ,temperature=0) llm = OpenAI(model_name="text-davinci-003" ,temperature=0)
tools = load_tools(["serpapi", "llm-math"], llm=llm) tools = load_tools(["google-serper", "llm-math"], llm=llm)
agent = initialize_agent(tools, llm, agent="zero-shot-react-description", verbose=True) agent = initialize_agent(tools, llm, agent="zero-shot-react-description", verbose=True)
``` ```