llama-index docstore Azure integration
Project description
LlamaIndex Docstore Integration: Azure Table Storage
AzureDocumentStore
allows you to use any compatible Azure Table Storage or CosmosDB as a document store for LlamaIndex.
Installation
Before using the AzureDocumentStore
, ensure you have Python installed and then proceed to install the required packages:
pip install llama-index-storage-docstore-azure
pip install azure-data-tables
pip install azure-identity # Only needed for AAD token authentication
Initializing AzureDocumentStore
AzureDocumentStore
can be initialized in several ways depending on the authentication method and the Azure service (Table Storage or Cosmos DB) you are using:
1. Using a Connection String
from llama_index.storage.docstore.azure import AzureDocumentStore
from llama_index.storage.kvstore.azure.base import ServiceMode
store = AzureDocumentStore.from_connection_string(
connection_string="your_connection_string_here",
namespace="your_namespace",
service_mode=ServiceMode.STORAGE, # or ServiceMode.COSMOS
)
2. Using Account Name and Key
store = AzureDocumentStore.from_account_and_key(
account_name="your_account_name",
account_key="your_account_key",
service_mode=ServiceMode.STORAGE, # or ServiceMode.COSMOS
)
3. Using SAS Token
store = AzureDocumentStore.from_sas_token(
endpoint="your_endpoint",
sas_token="your_sas_token",
service_mode=ServiceMode.STORAGE, # or ServiceMode.COSMOS
)
4. Using Azure Active Directory (AAD) Token
store = AzureDocumentStore.from_aad_token(
endpoint="your_endpoint",
service_mode=ServiceMode.STORAGE, # or ServiceMode.COSMOS
)
End-to-end example:
from llama_index.core import SimpleDirectoryReader, StorageContext
from llama_index.core.node_parser import SentenceSplitter
from llama_index.core import VectorStoreIndex, SimpleKeywordTableIndex
reader = SimpleDirectoryReader("./data/paul_graham/")
documents = reader.load_data()
nodes = SentenceSplitter().get_nodes_from_documents(documents)
storage_context = StorageContext.from_defaults(
docstore=AzureDocumentStore.from_account_and_key(
"your_account_name",
"your_account_key",
service_mode=ServiceMode.STORAGE,
),
)
vector_index = VectorStoreIndex(nodes, storage_context=storage_context)
storage_context.docstore.add_documents(nodes)
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
Built Distribution
File details
Details for the file llama_index_storage_docstore_azure-0.1.2.tar.gz
.
File metadata
- Download URL: llama_index_storage_docstore_azure-0.1.2.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eafd5a33132ae489dd544ea5c90432d020ec2cf34cc373499ca1fe74136bc541 |
|
MD5 | a581970ecd8ebb7d51bcb9bc4ad1e8a6 |
|
BLAKE2b-256 | 799ad602e0a52a9c04221f2381fa0f7faa9d1e2a35bc37c27ddaf3412650d68e |
File details
Details for the file llama_index_storage_docstore_azure-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: llama_index_storage_docstore_azure-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1024-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37b728f4c9c3df7fb363443abf556e19910c1174c16b51dfe1f552ab72a1c3a5 |
|
MD5 | 9bc2af970fe5b8a78e70d06226a650f6 |
|
BLAKE2b-256 | 716f2b4c4a51601393c464d7fc4eeb3a6c50348a66ac44c1126e20d0eedd3e3e |