Skip to main content

No project description provided

Project description

test

Astra Store

Installation

pip install astra-haystack

Local Development

install astra-haystack package locally to run integration tests:

Open in gitpod: Open in Gitpod

Switch Python version to 3.9 (Requires 3.8+ but not 3.12)

pyenv install 3.9
pyenv local 3.9

Local install for the package pip install -e . To execute integration tests, add needed environment variables ASTRA_DB_API_ENDPOINT=<id> ASTRA_DB_APPLICATION_TOKEN=<token> and execute python examples/example.py

Install requirements pip install -r requirements.txt

Export environment variables

export ASTRA_DB_API_ENDPOINT=
export ASTRA_DB_APPLICATION_TOKEN=
export COLLECTION_NAME=
export OPENAI_API_KEY=

run the python examples python example/example.py or python example/pipeline_example.py

Usage

This package includes Astra Document Store and Astra Embedding Retriever classes that integrate with Haystack, allowing you to easily perform document retrieval or RAG with Astra, and include those functions in Haystack pipelines.

In order to use the Document Store directly:

Import the Document Store:

from haystack_integrations.document_stores.astra import AstraDocumentStore
from haystack.document_stores.types.policy import DuplicatePolicy

Load in environment variables:

api_endpoint = os.getenv("ASTRA_DB_API_ENDPOINT", "")
token = os.getenv("ASTRA_DB_APPLICATION_TOKEN", "")
collection_name = os.getenv("COLLECTION_NAME", "haystack_vector_search")

Create the Document Store object:

document_store = AstraDocumentStore(
    api_endpoint=api_endpoint,
    token=token,
    collection_name=collection_name,
    duplicates_policy=DuplicatePolicy.SKIP,
    embedding_dim=384,
)

Then you can use the document store functions like count_document below: document_store.count_documents()

Using the Astra Embedding Retriever with Haystack Pipelines

Create the Document Store object like above, then import and create the Pipeline:

from haystack import Pipeline
pipeline = Pipeline()

Add your AstraEmbeddingRetriever into the pipeline pipeline.add_component(instance=AstraEmbeddingRetriever(document_store=document_store), name="retriever")

Add other components and connect them as desired. Then run your pipeline: pipeline.run(...)

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

astra_haystack-0.6.0.tar.gz (23.8 kB view details)

Uploaded Source

Built Distribution

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

astra_haystack-0.6.0-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file astra_haystack-0.6.0.tar.gz.

File metadata

  • Download URL: astra_haystack-0.6.0.tar.gz
  • Upload date:
  • Size: 23.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for astra_haystack-0.6.0.tar.gz
Algorithm Hash digest
SHA256 3939caaaca261cb26d1e0621ee7983e398937908382d1307fe70266ecf88aab4
MD5 9daac162591924a5f0fb12043eb68233
BLAKE2b-256 ba800d9e189290f5ef571931b4f1a7e47299749f591ac48a9154059631ab11f9

See more details on using hashes here.

File details

Details for the file astra_haystack-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for astra_haystack-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 87e7c36f7ec422c0146753199c59818d03259239ff256f22657f945b0030329d
MD5 b29be499b73e358e3451e5e4fa4e938d
BLAKE2b-256 9b63673fc3298c7972cddc11b1d1751576f320c497b350e9cccdd3eca6be70b1

See more details on using hashes here.

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