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 ("markdown" or "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 ("markdown" or "html")
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 ("markdown" or "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.3.tar.gz (65.0 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.3-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchain_quercle-1.0.3.tar.gz
  • Upload date:
  • Size: 65.0 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.3.tar.gz
Algorithm Hash digest
SHA256 02b1b520b8e5820ce90ec7711fd9e34801002baddc2693e8c9465ffdb2fe5969
MD5 cd3fdefe205863582e379d6445392579
BLAKE2b-256 ce5d8e2e3753f6ccddf3420240f9b98e54af1381fc60d4df2c81a67bf1873507

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_quercle-1.0.3.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.3-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_quercle-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4a58fc0b6ac7811c1529c5f329123af7446a28cf70af613b6e70e16ae7a6be31
MD5 dd99b225d8c3a2e2345212ad76e3baf7
BLAKE2b-256 523558539cf0fee29c81f63ff81ab2d164ee80d642522c8a5b758563d3d39657

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_quercle-1.0.3-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