Skip to main content

LangChain tools for Quercle web search and URL fetching

Project description

quercle-langchain

LangChain tools for Quercle web search and URL fetching.

Installation

uv add langchain-quercle

Or with pip:

pip install langchain-quercle

Quick Start

from quercle_langchain import QuercleSearchTool, QuercleFetchTool

# Initialize tools (uses QUERCLE_API_KEY env var by default)
search = QuercleSearchTool()
fetch = QuercleFetchTool()

# Or with explicit API key
search = QuercleSearchTool(api_key="qk_...")
fetch = QuercleFetchTool(api_key="qk_...")

Usage with LangChain Agents

from langchain.agents import initialize_agent, AgentType
from langchain_openai import ChatOpenAI
from quercle_langchain import QuercleSearchTool, QuercleFetchTool

# Initialize tools
tools = [QuercleSearchTool(), QuercleFetchTool()]

# Create agent
llm = ChatOpenAI(model="gpt-4")
agent = initialize_agent(
    tools=tools,
    llm=llm,
    agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
)

# Run the agent
result = agent.run("Search for the latest Python release and summarize it")

Direct Tool Usage

Search

from quercle_langchain import QuercleSearchTool

search = QuercleSearchTool()

# Basic search
result = search.invoke({"query": "What is TypeScript?"})
print(result)

# With domain filtering
result = search.invoke({
    "query": "machine learning tutorials",
    "allowed_domains": ["*.edu", "*.org"],
    "blocked_domains": ["ads.com"],
})

Fetch

from quercle_langchain import QuercleFetchTool

fetch = QuercleFetchTool()

result = fetch.invoke({
    "url": "https://docs.python.org/3/whatsnew/3.12.html",
    "prompt": "Summarize the key new features in bullet points",
})
print(result)

Async Usage

Both tools support async operations:

import asyncio
from quercle_langchain import QuercleSearchTool, QuercleFetchTool

async def main():
    search = QuercleSearchTool()
    fetch = QuercleFetchTool()

    # Async search
    result = await search.ainvoke({"query": "async Python programming"})
    print(result)

    # Async fetch
    result = await fetch.ainvoke({
        "url": "https://example.com",
        "prompt": "Extract main topics",
    })
    print(result)

asyncio.run(main())

Configuration

Environment Variable

Set your API key as an environment variable:

export QUERCLE_API_KEY=qk_your_api_key_here

Tool Parameters

Both tools accept these optional parameters:

  • api_key: Your Quercle API key (falls back to QUERCLE_API_KEY env var)
  • timeout: Request timeout in seconds
tool = QuercleSearchTool(
    api_key="qk_...",
    timeout=60.0,
)

Tool Descriptions

QuercleSearchTool

  • Name: search
  • Description: Search the web and get AI-synthesized answers with citations
  • Arguments:
    • query (required): The search query
    • allowed_domains (optional): List of domains to include (e.g., ["*.edu"])
    • blocked_domains (optional): List of domains to exclude

QuercleFetchTool

  • Name: fetch
  • Description: Fetch a URL and analyze its content with AI
  • Arguments:
    • url (required): The URL to fetch
    • prompt (required): Instructions for content analysis

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-0.1.2.tar.gz (64.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-0.1.2-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchain_quercle-0.1.2.tar.gz
  • Upload date:
  • Size: 64.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-0.1.2.tar.gz
Algorithm Hash digest
SHA256 84e2d4e1bcded3de905bf09c2253a4221cfaefe2bae412ebc420826852a1d4ec
MD5 723f970116d8f869552563f4e2002193
BLAKE2b-256 7db4c33de893abd0d32fb26c08997061453da23d77597f8d626f7380d9d636c6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for langchain_quercle-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 63e0f74c8bb75d8cbe132024e4b9a8edd747c54d6802d37d96b8722931daf6bf
MD5 6467cb9fd1b85dd1159bb5c05774bde5
BLAKE2b-256 a6e0f3f8e3f182e0442f339606ba196dfe88fb44c300de5a5e1957506335b54d

See more details on using hashes here.

Provenance

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