Skip to main content

LangChain tools for Quercle web search and URL fetching

Project description

langchain-quercle

Quercle web search, fetch, and extraction tools for LangChain.

Installation

uv add langchain-quercle
# or
pip install langchain-quercle

Setup

Set your API key as an environment variable:

export QUERCLE_API_KEY=qk_...

Get your API key at quercle.dev.

Quick Start

from quercle_langchain import QuercleSearchTool, QuercleFetchTool

search = QuercleSearchTool()
result = search.invoke("latest developments in AI agents")
print(result)

Tools

Tool Description Key Args
QuercleSearchTool AI-synthesized web search with citations query, allowed_domains, blocked_domains
QuercleFetchTool Fetch a URL and analyze content with AI url, prompt
QuercleRawSearchTool Raw web search results (markdown/JSON) query, format, use_safeguard
QuercleRawFetchTool Raw URL content (markdown/HTML) url, format, use_safeguard
QuercleExtractTool Extract relevant content chunks from a URL url, query, format, use_safeguard

Direct Tool Usage

Sync

from quercle_langchain import (
    QuercleSearchTool,
    QuercleFetchTool,
    QuercleRawSearchTool,
    QuercleRawFetchTool,
    QuercleExtractTool,
)

# AI-synthesized search
search = QuercleSearchTool()
result = search.invoke("best practices for building AI agents")
print(result)

# Search with domain filtering
result = search.invoke({
    "query": "Python documentation",
    "allowed_domains": ["docs.python.org"],
})

# Fetch and analyze a page with AI
fetch = QuercleFetchTool()
result = fetch.invoke({
    "url": "https://en.wikipedia.org/wiki/Python_(programming_language)",
    "prompt": "Summarize the key features of Python",
})
print(result)

# Raw search results
raw_search = QuercleRawSearchTool()
result = raw_search.invoke({"query": "Python tutorials", "format": "json"})
print(result)

# Raw URL content
raw_fetch = QuercleRawFetchTool()
result = raw_fetch.invoke({"url": "https://example.com", "use_safeguard": True})
print(result)

# Extract relevant content from a URL
extract = QuercleExtractTool()
result = extract.invoke({
    "url": "https://en.wikipedia.org/wiki/Python_(programming_language)",
    "query": "What are Python's main features?",
    "format": "json",
})
print(result)

Async

import asyncio
from quercle_langchain import (
    QuercleSearchTool,
    QuercleFetchTool,
    QuercleRawSearchTool,
    QuercleRawFetchTool,
    QuercleExtractTool,
)

async def main():
    # AI-synthesized search
    search = QuercleSearchTool()
    result = await search.ainvoke("latest AI agent frameworks")
    print(result)

    # Fetch and analyze with AI
    fetch = QuercleFetchTool()
    result = await fetch.ainvoke({
        "url": "https://en.wikipedia.org/wiki/TypeScript",
        "prompt": "What is TypeScript?",
    })
    print(result)

    # Raw search results
    raw_search = QuercleRawSearchTool()
    result = await raw_search.ainvoke({"query": "Python tutorials", "format": "json"})
    print(result)

    # Raw URL content
    raw_fetch = QuercleRawFetchTool()
    result = await raw_fetch.ainvoke({"url": "https://example.com"})
    print(result)

    # Extract relevant content
    extract = QuercleExtractTool()
    result = await extract.ainvoke({
        "url": "https://en.wikipedia.org/wiki/TypeScript",
        "query": "What is TypeScript used for?",
    })
    print(result)

asyncio.run(main())

Custom API Key

search = QuercleSearchTool(api_key="qk_...")
fetch = QuercleFetchTool(api_key="qk_...")
raw_search = QuercleRawSearchTool(api_key="qk_...")
raw_fetch = QuercleRawFetchTool(api_key="qk_...")
extract = QuercleExtractTool(api_key="qk_...")

Agentic Usage

With LangGraph ReAct Agent

from quercle_langchain import (
    QuercleSearchTool,
    QuercleFetchTool,
    QuercleRawSearchTool,
    QuercleRawFetchTool,
    QuercleExtractTool,
)
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent

model = ChatOpenAI(model="gpt-4o")
tools = [
    QuercleSearchTool(),
    QuercleFetchTool(),
    QuercleRawSearchTool(),
    QuercleRawFetchTool(),
    QuercleExtractTool(),
]

agent = create_react_agent(model, tools)

response = agent.invoke({
    "messages": [
        {"role": "user", "content": "Search for the latest AI news and summarize the top story"}
    ]
})

print(response["messages"][-1].content)

Streaming

for chunk in agent.stream(
    {"messages": [{"role": "user", "content": "Research WebAssembly trends"}]},
    stream_mode="values",
):
    print(chunk["messages"][-1].content)

With Anthropic

from langchain_anthropic import ChatAnthropic

model = ChatAnthropic(model="claude-sonnet-4-20250514")
agent = create_react_agent(model, tools)

API Reference

QuercleSearchTool

AI-synthesized web search with citations.

Parameter Type Required Description
query str Yes The search query
allowed_domains list[str] No Only include results from these domains
blocked_domains list[str] No Exclude results from these domains

QuercleFetchTool

Fetch a URL and analyze its content with AI.

Parameter Type Required Description
url str Yes The URL to fetch
prompt str Yes Instructions for content analysis

QuercleRawSearchTool

Raw web search results without AI synthesis.

Parameter Type Required Description
query str Yes The search query
format str No Output format (e.g. "json")
use_safeguard bool No Enable prompt-injection detection

QuercleRawFetchTool

Raw URL content without AI processing.

Parameter Type Required Description
url str Yes The URL to fetch
format str No Output format (e.g. "json")
use_safeguard bool No Enable prompt-injection detection

QuercleExtractTool

Extract content chunks relevant to a query from a URL.

Parameter Type Required Description
url str Yes The URL to fetch and extract from
query str Yes What information to extract
format str No Output format (e.g. "json")
use_safeguard bool No Enable prompt-injection detection

Configuration

All tools accept these constructor parameters:

Parameter Default Description
api_key QUERCLE_API_KEY env var Your Quercle API key
timeout None Request timeout in seconds

License

MIT

Project details


Download files

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

Source Distribution

langchain_quercle-1.0.1.tar.gz (66.3 kB view details)

Uploaded Source

Built Distribution

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

langchain_quercle-1.0.1-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file langchain_quercle-1.0.1.tar.gz.

File metadata

  • Download URL: langchain_quercle-1.0.1.tar.gz
  • Upload date:
  • Size: 66.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for langchain_quercle-1.0.1.tar.gz
Algorithm Hash digest
SHA256 75226b2df9bc5d7c8cb1bf7460b4fe9eb91687529c593032882d4779a4b381bb
MD5 b7623d358b08e5f531532fc2d07c89d7
BLAKE2b-256 84ae3bc24e98f1baa8715f4a07609f52c456da06a6aaf87490e525e5f714929d

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_quercle-1.0.1.tar.gz:

Publisher: publish.yml on quercledev/langchain-quercle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langchain_quercle-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_quercle-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0665b4ac0bf16773d9d74825461b1d0d6fca1f44c84f0b7eb5ec4308bf67ccaf
MD5 13c7d87f1740d96095ad6d8bda5974de
BLAKE2b-256 24666f10aed48943a664c8de54cc866217f3614838c8699e400f2faaf1d4d918

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_quercle-1.0.1-py3-none-any.whl:

Publisher: publish.yml on quercledev/langchain-quercle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page