Skip to main content

langchain-blopus

This package contains the LangChain integration with Blopus, a web search and fetch API for LLMs and agents that runs on its own crawler and index rather than reselling another search engine.

pip install -U langchain-blopus

Set your API key, which you can create at blopus.ai/app:

export BLOPUS_API_KEY="blp_live_..."

Tools

BlopusSearch

Searches the live web and returns ranked results with snippets.

from langchain_blopus import BlopusSearch

tool = BlopusSearch()
tool.invoke({"query": "postgres logical replication", "freshness": "pw"})
{
    "query": "postgres logical replication",
    "results": [
        {
            "title": "...",
            "url": "https://...",
            "snippet": "...",
            "domain": "...",
            "score": 0.87,
            "published_at": 1755300000,
            "language": "en",
        }
    ],
}

Useful arguments: count (served in blocks of 10, so it rounds up), freshness (pd, pw, pm, p3m, p1y, all), include_domains, exclude_domains, language, news_only, and include_content to get the cleaned page text inline instead of making a second call.

BlopusFetch

Retrieves the full cleaned text of pages the model selected.

from langchain_blopus import BlopusFetch

BlopusFetch().invoke({"urls": ["https://example.com/article"]})

URLs that were not found come back in failed_urls rather than raising, so one bad URL in a batch does not lose the rest.

Using them with an agent

from langchain.agents import create_agent
from langchain_blopus import BlopusFetch, BlopusSearch

agent = create_agent(model, tools=[BlopusSearch(), BlopusFetch()])

Retriever

BlopusRetriever puts live web results into any chain written against the standard retriever interface, so it drops into an existing RAG pipeline in place of a vector store.

from langchain_blopus import BlopusRetriever

retriever = BlopusRetriever(k=10, freshness="pm")
docs = retriever.invoke("postgres logical replication")

docs[0].page_content        # cleaned article text
docs[0].metadata["source"]  # the URL

It requests full page content by default, because a Document whose page_content is a two-line snippet is close to useless for retrieval.

Async

Every tool and the retriever support ainvoke.

await BlopusSearch().ainvoke({"query": "postgres logical replication"})
await BlopusRetriever().ainvoke("postgres logical replication")

Notes

One topic per search. A query joining several subjects ("economy, sports, Iran") matches nothing, because no single document is about all of them. Issue one search per topic. The tool description states this, and the API returns a note when it detects the mistake, which this package passes straight through.

Billing is in blocks of ten. One search returns up to 10 results for 1 credit, so count rounds up to the next multiple of 10. If your remaining quota cannot cover the request, the API serves a partial page rather than refusing, and sets quota_clamped on the response so you can tell "my quota cut this short" apart from "that is all that exists".

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_blopus-0.1.1.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_blopus-0.1.1-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file langchain_blopus-0.1.1.tar.gz.

File metadata

  • Download URL: langchain_blopus-0.1.1.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for langchain_blopus-0.1.1.tar.gz
Algorithm Hash digest
SHA256 69dc3376332460aed67172f1f827457e41b694f7460217750ac5e369a23f87e8
MD5 9a117058ab8b8763c0a63d47812259c7
BLAKE2b-256 54047a14e940b9fe62e0414d5a0522b84e231eb43fe761db30faa7818cc9f8b2

See more details on using hashes here.

File details

Details for the file langchain_blopus-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_blopus-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b1a7672b33f24f931fcadd76d134f383fce2f8dfc392b1cdd7943554c54f95bf
MD5 839e2ae3c2fa4b9124d319c2b5b76982
BLAKE2b-256 501dcc0884020b200a73fca2f00e23db3cce8ff09a8f6ab9e866ae7976f78d05

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.3

2 files

This release

0.1.1 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page