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.3.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

File details

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

File metadata

File hashes

Hashes for llama_index_readers_astra_db-0.3.0.tar.gz
Algorithm Hash digest
SHA256 53175154712986f826ed305bad20a4c2f0a266b356bb3c6f88e52a38beb1d541
MD5 dcd32d44f0fa476633c0f315354633f6
BLAKE2b-256 6f145437dd61b637f77215bf3e7521e1713d94025af28414d8326f7a18e05056

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_readers_astra_db-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3c234a80769c293c01ae8127d64c2e23dab287f0d54aa3b28581c52fe38d0a2a
MD5 58b6d1754be83db766126dc7ea86cb3b
BLAKE2b-256 7bf334d101a61c1b5b57f9ec99107de396e3b22ed2185d377bda44c8c23ca54d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page