Metadata-Version: 2.4
Name: langchain-serpbit
Version: 0.1.0
Summary: Google Search for LangChain through Serpbit: GoogleSearchAPIWrapper's tools, on after Google's Custom Search API closes.
Author-email: Serpbit <support@serpbit.com>
License-Expression: MIT
Project-URL: Homepage, https://serpbit.com/custom-search-api-alternative/
Project-URL: Documentation, https://serpbit.com/docs/#sdks
Keywords: langchain,google search,custom search api,serp api,web search,ai agents
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: langchain-core<2,>=0.3
Requires-Dist: serpbit<1,>=0.3.0
Dynamic: license-file

# langchain-serpbit

Google Search for LangChain after Google's Custom Search JSON API stops searching the whole web on January 1, 2027.
These are the Google Search tools of `langchain-google-community`, with the same calls, names and answers, served by
[Serpbit](https://serpbit.com/custom-search-api-alternative/) from Google's own results pages.

```sh
pip install langchain-serpbit
```

Moving is two lines: the import and the key. Make a key at https://app.serpbit.com/keys and set `SERPBIT_API_KEY`.
The search engine id is gone, because the results come from the whole web.

```python
# Before
from langchain_google_community import GoogleSearchAPIWrapper, GoogleSearchResults, GoogleSearchRun
search = GoogleSearchAPIWrapper(k=5)  # GOOGLE_API_KEY, GOOGLE_CSE_ID

# After
from langchain_serpbit import SerpbitSearchAPIWrapper, SerpbitSearchResults, SerpbitSearchRun
search = SerpbitSearchAPIWrapper(k=5)  # SERPBIT_API_KEY

search.run("espresso grinder")  # the results' snippets
search.results("espresso grinder", 3, search_params={"gl": "de", "dateRestrict": "m1"})

tools = [SerpbitSearchRun(api_wrapper=search), SerpbitSearchResults(api_wrapper=search, num_results=4)]
```

The tools keep Google's names, `google_search` and `google_search_results_json`, and Google's descriptions, so
prompts, traces and evaluations stay as they are. `search_params` are Custom Search's own: `gl`, `hl`, `lr`, `safe`,
`dateRestrict`, `siteSearch`, `fileType`, `start`, `exactTerms` and the rest
([the full list](https://serpbit.com/docs/#cse)).

What differs from Google's:
- `siterestrict=True` is refused, because a Custom Search engine's own list of sites does not carry over. To search one
  site, pass `search_params={"siteSearch": "example.com"}`.
- `results()` has no `image` or `thumbnail`, because Serpbit's answer has no `pagemap`.
- A failed call raises the [`serpbit`](https://pypi.org/project/serpbit/) client's errors, such as
  `serpbit.InsufficientCreditsError` when the credits run out.
- A search takes about 2 seconds, against under 1 on Google's API.

Each search costs 1 credit. The free plan gives 1,000 credits a month, with no card.
