Skip to main content

contextfetch-haystack

PyPI - Version PyPI - Python Version

Haystack components for the ContextFetch API:

  • ContextFetchWebSearch: searches the web and returns the results as Documents, with page content as Markdown.
  • ContextFetchFetcher: fetches URLs and returns each page as a Markdown Document.

Installation

pip install contextfetch-haystack

Usage

from haystack_integrations.components.fetchers.contextfetch import ContextFetchFetcher
from haystack_integrations.components.websearch.contextfetch import ContextFetchWebSearch

websearch = ContextFetchWebSearch(top_k=3)
result = websearch.run(query="What are asyncio task groups?")
for doc in result["documents"]:
    print(doc.meta["title"], doc.meta["url"])

fetcher = ContextFetchFetcher()
pages = fetcher.run(urls=["https://docs.python.org/3/library/asyncio-task.html"])
print(pages["documents"][0].content[:500])

Both components read the API key from the CONTEXTFETCH_API_KEY environment variable. Without a key, requests use the keyless tier, which has a small daily allowance per IP. Get a key at contextfetch.dev/get-started.

ContextFetchWebSearch sends pruned_context=True by default, so each Document holds the page pruned to the parts relevant to the query. Pass search_params={"text": True} for whole pages, or {"highlights": True} for the most relevant chunks. Other keys: include_domains, exclude_domains, start_published_date.

Development

hatch run test:unit         # unit tests, no network
hatch run test:integration  # live API tests; they run only when CONTEXTFETCH_API_KEY is set
hatch run test:types
hatch run fmt-check

License

contextfetch-haystack is distributed under the terms of the Apache-2.0 license.

Metadata

Release files for contextfetch-haystack 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for contextfetch-haystack 0.1.0
File Size Uploaded Provenance
contextfetch_haystack-0.1.0.tar.gz 13.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for contextfetch-haystack 0.1.0
File Interpreter ABI Platform
contextfetch_haystack-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.0 kB

Release files / contextfetch_haystack-0.1.0.tar.gz

Download URL contextfetch_haystack-0.1.0.tar.gz
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f5e010606f2e3a38482f1700202b219623d890e71468ba34c70ac3c33466c0a3
BLAKE2b-256 checksum
How to use checksums
a77217fa440ba0cc71f9c36cca477b8a81232c29f65fc86d9f91120bb3a5f408
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / contextfetch_haystack-0.1.0-py3-none-any.whl

Download URL contextfetch_haystack-0.1.0-py3-none-any.whl
Size 11.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1374d4d73f075b9f6ec9b75c592f66790f68455996d41bd2337b63b0376e2464
BLAKE2b-256 checksum
How to use checksums
80765d4ababbcb1c54fdf0ff595d4f197b52ea92b26badfef5bb872706bad7df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for contextfetch-haystack 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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