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_...")
Standalone Tool Usage
Use the tools directly without any LLM:
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())
Usage with LangChain Chat Models
Using bind_tools() for Single Interactions
Bind tools directly to a chat model for single-turn tool calling:
from langchain_openai import ChatOpenAI
from quercle_langchain import QuercleSearchTool, QuercleFetchTool
# Initialize tools and model
tools = [QuercleSearchTool(), QuercleFetchTool()]
llm = ChatOpenAI(model="gpt-4o")
# Bind tools to the model
llm_with_tools = llm.bind_tools(tools)
# Invoke - the model will decide whether to use tools
response = llm_with_tools.invoke("Search for the latest Python 3.13 features")
# Access tool calls from the response
if response.tool_calls:
for tool_call in response.tool_calls:
print(f"Tool: {tool_call['name']}")
print(f"Args: {tool_call['args']}")
Using Agents for Multi-Step Tasks
For autonomous multi-step tasks, use create_agent:
from langchain.agents import create_agent
from quercle_langchain import QuercleSearchTool, QuercleFetchTool
# Initialize tools
tools = [QuercleSearchTool(), QuercleFetchTool()]
# Create the agent
agent = create_agent(
model="gpt-4o", # or "claude-sonnet-4-5-20250929", "gemini-2.0-flash", etc.
tools=tools,
system_prompt="You are a helpful research assistant.",
)
# Run the agent
result = agent.invoke({
"messages": [{"role": "user", "content": "Search for the latest Python release and summarize the key features"}]
})
# Print the final response
print(result["messages"][-1].content)
With Other LLM Providers
Both bind_tools() and create_agent() work with any LangChain-compatible chat model:
# With Anthropic
from langchain_anthropic import ChatAnthropic
llm = ChatAnthropic(model="claude-sonnet-4-20250514")
llm_with_tools = llm.bind_tools(tools)
# With Google
from langchain_google_genai import ChatGoogleGenerativeAI
llm = ChatGoogleGenerativeAI(model="gemini-2.0-flash")
llm_with_tools = llm.bind_tools(tools)
# Or use create_agent with model strings directly
from langchain.agents import create_agent
agent = create_agent(model="claude-sonnet-4-5-20250929", tools=tools)
agent = create_agent(model="gemini-2.0-flash", tools=tools)
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 toQUERCLE_API_KEYenv 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 queryallowed_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 fetchprompt(required): Instructions for content analysis
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_quercle-0.1.3.tar.gz.
File metadata
- Download URL: langchain_quercle-0.1.3.tar.gz
- Upload date:
- Size: 64.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
300442c7e60bbd28ee276ee03a4beeb9f7230ec8cc4388faec957d6207a1ecf6
|
|
| MD5 |
2b719e02fcd1a7515a2e9a3ce531c213
|
|
| BLAKE2b-256 |
f8f1f8c93493ba9fd8431b179052502033b2b23222c1c2857eeeb362bcba0cb2
|
Provenance
The following attestation bundles were made for langchain_quercle-0.1.3.tar.gz:
Publisher:
publish.yml on quercledev/langchain-quercle
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_quercle-0.1.3.tar.gz -
Subject digest:
300442c7e60bbd28ee276ee03a4beeb9f7230ec8cc4388faec957d6207a1ecf6 - Sigstore transparency entry: 763932754
- Sigstore integration time:
-
Permalink:
quercledev/langchain-quercle@b6ea7c035e3080db880ab445b288a85f355b70b9 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/quercledev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b6ea7c035e3080db880ab445b288a85f355b70b9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file langchain_quercle-0.1.3-py3-none-any.whl.
File metadata
- Download URL: langchain_quercle-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80774d9e298786d4464a660bd363e7e5fad7beeefafea2aa987556f5c3da61eb
|
|
| MD5 |
49678a902dac67d9156d2c0d8a9ac8f9
|
|
| BLAKE2b-256 |
ad09911e36c5eb4b0eea4ddad49f35d951ad4fdded345ecaaad631697173b507
|
Provenance
The following attestation bundles were made for langchain_quercle-0.1.3-py3-none-any.whl:
Publisher:
publish.yml on quercledev/langchain-quercle
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_quercle-0.1.3-py3-none-any.whl -
Subject digest:
80774d9e298786d4464a660bd363e7e5fad7beeefafea2aa987556f5c3da61eb - Sigstore transparency entry: 763932757
- Sigstore integration time:
-
Permalink:
quercledev/langchain-quercle@b6ea7c035e3080db880ab445b288a85f355b70b9 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/quercledev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b6ea7c035e3080db880ab445b288a85f355b70b9 -
Trigger Event:
push
-
Statement type: