llama-index readers couchbase integration
Project description
LlamaIndex Readers Integration: Couchbase
This loader loads documents from Couchbase cluster. The user specifies a Couchbase client or credentials to initialize the reader. They can specify the SQL++ query to fetch the relevant docs.
Usage
Here's an example usage of the CouchbaseReader.
from llama_index.core.readers import download_loader
import os
CouchbaseLoader = download_loader("CouchbaseReader")
connection_string = (
"couchbase://localhost" # valid Couchbase connection string
)
db_username = "<valid_database_user_with_read_access_to_bucket_with_data>"
db_password = "<password_for_database_user>"
# query is a valid SQL++ query that is passed to client.query()
query = """
SELECT h.* FROM `travel-sample`.inventory.hotel h
WHERE h.country = 'United States'
LIMIT 5
"""
reader = CouchbaseLoader(
connection_string=connection_string,
db_username=db_username,
db_password=db_password,
)
# It is also possible to pass an initialized Couchbase client to the document loader
# from couchbase.auth import PasswordAuthenticator # noqa: E402
# from couchbase.cluster import Cluster # noqa: E402
# from couchbase.options import ClusterOptions # noqa: E402
# auth = PasswordAuthenticator(
# db_username,
# db_password,
# )
# couchbase_client = Cluster(connection_string, ClusterOptions(auth))
# reader = CouchbaseLoader(client=couchbase_client)
# fields to be written to the document
text_fields = ["name", "title", "address", "reviews"]
# metadata fields to be written to the document's metadata
metadata_fields = (["country", "city"],)
documents = reader.load_data(
query=query, text_fields=text_fields, metadata_fields=metadata_fields
)
This loader is designed to be used as a way to load data into LlamaIndex and/or subsequently used as a Tool in a LangChain Agent. See here for examples.
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
Close
Hashes for llama_index_readers_couchbase-0.1.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20e7b483f836e9b3465b84f0ef4b492eb18e66f10a43bd5d61c3f11eb4d01d0f |
|
MD5 | 4737010cfc297fcfa11382fabc177715 |
|
BLAKE2b-256 | 6e8c1412f77b5a4eb038759645c0f39822ea712a839eac32f6d488dac660aa90 |
Close
Hashes for llama_index_readers_couchbase-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c113c5682ab235d9167d5ebb8c0488d62f3ed5ad248bc5ac32023608ab8926db |
|
MD5 | f02eb0bfda22e6fe45bf7840c3fdd60f |
|
BLAKE2b-256 | f495465db518b4f691813ef11abacddc25b7fcbdef4399d68b4fb1ec20faf8eb |