Skip to main content

llama-index readers astra_db integration

Project description

Astra DB Loader

pip install llama-index-readers-astra-db

The Astra DB Loader returns a set of documents retrieved from Astra DB. The user initializes the loader with an Astra DB index. They then pass in a vector.

Usage

Here's an example usage of the AstraDBReader.

from openai import OpenAI


# Get the credentials for Astra DB
api_endpoint = "https://324<...>f1c.astra.datastax.com"
token = "AstraCS:<...>"

# EXAMPLE: OpenAI embeddings
client = OpenAI(api_key="sk-<...>")

# Call OpenAI (or generate embeddings another way)
response = client.embeddings.create(
    input="Your text string goes here", model="text-embedding-ada-002"
)

# Get the embedding
query_vector = response.data[0].embedding

# Initialize the Reader object
from llama_index.readers.astra_db import AstraDBReader

# Your Astra DB Account will provide you with the endpoint URL and Token
reader = AstraDBReader(
    collection_name="astra_v_table",
    token=token,
    api_endpoint=api_endpoint,
    embedding_dimension=len(query_vector),
)

# Fetch data from the reader
documents = reader.load_data(vector=query_vector, limit=5)

This loader is designed to be used as a way to load data into LlamaIndex.

Note: Please see the AstraDB documentation here.

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

llama_index_readers_astra_db-0.4.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

llama_index_readers_astra_db-0.4.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_readers_astra_db-0.4.0.tar.gz.

File metadata

File hashes

Hashes for llama_index_readers_astra_db-0.4.0.tar.gz
Algorithm Hash digest
SHA256 36c28261e06d3683a3e3eb76234e922097ca7384f03a5b1a3e6638900abd602c
MD5 cf5bf38bb6288d735bc9b752b67e490d
BLAKE2b-256 b4a3fa34e3e34e10ed5f77c019c49817af42f3f9cac8d8896b37855acb1f8e0f

See more details on using hashes here.

File details

Details for the file llama_index_readers_astra_db-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_readers_astra_db-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 71bed42fddbc9a66f3ffcd1f3286c4e0098895d1c041ce3aa4fe2c5ef73bed15
MD5 f5b88c95b2a8ecfd5638970f8c971fc4
BLAKE2b-256 b15dd4353efbfd72ee7bd30a2ce368f24bdf38f52e75e731febef4c1d4585fc6

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