langchain/docs/ecosystem
rogerserper e46cd3b7db
Google Search API integration with serper.dev (wrapper, tests, docs, … (#909)
Adds Google Search integration with [Serper](https://serper.dev) a
low-cost alternative to SerpAPI (10x cheaper + generous free tier).
Includes documentation, tests and examples. Hopefully I am not missing
anything.

Developers can sign up for a free account at
[serper.dev](https://serper.dev) and obtain an api key.

## Usage

```python
from langchain.utilities import GoogleSerperAPIWrapper
from langchain.llms.openai import OpenAI
from langchain.agents import initialize_agent, Tool

import os
os.environ["SERPER_API_KEY"] = ""
os.environ['OPENAI_API_KEY'] = ""

llm = OpenAI(temperature=0)
search = GoogleSerperAPIWrapper()
tools = [
    Tool(
        name="Intermediate Answer",
        func=search.run
    )
]

self_ask_with_search = initialize_agent(tools, llm, agent="self-ask-with-search", verbose=True)
self_ask_with_search.run("What is the hometown of the reigning men's U.S. Open champion?")
```

### Output
```
Entering new AgentExecutor chain...
 Yes.
Follow up: Who is the reigning men's U.S. Open champion?
Intermediate answer: Current champions Carlos Alcaraz, 2022 men's singles champion.
Follow up: Where is Carlos Alcaraz from?
Intermediate answer: El Palmar, Spain
So the final answer is: El Palmar, Spain

> Finished chain.

'El Palmar, Spain'
```
2023-02-15 22:47:17 -08:00
..
ai21.md Docs refactor (#480) 2023-01-02 08:24:09 -08:00
cerebriumai.md Add GooseAI, CerebriumAI, Petals, ForefrontAI (#981) 2023-02-13 21:20:19 -08:00
chroma.md chroma docs (#1012) 2023-02-12 23:02:01 -08:00
cohere.md Docs refactor (#480) 2023-01-02 08:24:09 -08:00
forefrontai.md Add GooseAI, CerebriumAI, Petals, ForefrontAI (#981) 2023-02-13 21:20:19 -08:00
google_search.md docs: small typo google_search.md (#692) 2023-01-22 13:09:15 -08:00
google_serper.md Google Search API integration with serper.dev (wrapper, tests, docs, … (#909) 2023-02-15 22:47:17 -08:00
gooseai.md Add GooseAI, CerebriumAI, Petals, ForefrontAI (#981) 2023-02-13 21:20:19 -08:00
hazy_research.md Docs refactor (#480) 2023-01-02 08:24:09 -08:00
helicone.md Harrison/llm integrations (#1039) 2023-02-13 22:06:25 -08:00
huggingface.md Add links to Hugging Face Hub docs (#518) 2023-01-03 07:43:57 -08:00
nlpcloud.md Docs refactor (#480) 2023-01-02 08:24:09 -08:00
openai.md Docs refactor (#480) 2023-01-02 08:24:09 -08:00
petals.md Add GooseAI, CerebriumAI, Petals, ForefrontAI (#981) 2023-02-13 21:20:19 -08:00
pinecone.md Docs refactor (#480) 2023-01-02 08:24:09 -08:00
promptlayer.md Harrison/llm integrations (#1039) 2023-02-13 22:06:25 -08:00
serpapi.md docs: small typo on serpapi.md (#693) 2023-01-22 13:10:24 -08:00
weaviate.md Docs refactor (#480) 2023-01-02 08:24:09 -08:00
wolfram_alpha.md Harrison/wolfram alpha (#579) 2023-01-11 05:52:19 -08:00