LlamaIndex connects your private data to language models. Use your Qdrant database as its vector store to index documents and query them.
Before you begin
Section titled “Before you begin”You need a Running database with its Endpoint URL and API Key; see Connect to a vector database. You need Python 3.8 or later and a folder of documents.
pip install llama-index llama-index-vector-stores-qdrant qdrant-clientIndex documents and query
Section titled “Index documents and query”<your-endpoint-url> is the Endpoint URL and <your-api-key> is your API key.
<your-data-dir> is the folder of documents. <collection_name> is the collection that stores them.
<your-query> is the question to ask.
import qdrant_clientfrom llama_index.core import VectorStoreIndex, SimpleDirectoryReader, StorageContext, Settingsfrom llama_index.vector_stores.qdrant import QdrantVectorStorefrom llama_index.embeddings.fastembed import FastEmbedEmbedding
# Configure the embedding modelSettings.embed_model = FastEmbedEmbedding(model_name="BAAI/bge-base-en-v1.5")Settings.llm = None
# Load documentsdocuments = SimpleDirectoryReader("<your-data-dir>").load_data()
# Connect and insert into Qdrantclient = qdrant_client.QdrantClient( host="<your-endpoint-url>", port=6333, api_key="<your-api-key>")vector_store = QdrantVectorStore(client=client, collection_name="<collection_name>")storage_context = StorageContext.from_defaults(vector_store=vector_store)index = VectorStoreIndex.from_documents(documents, storage_context=storage_context)
# Queryquery_engine = index.as_query_engine()response = query_engine.query("<your-query>")What to do next
Section titled “What to do next”For more, see the Qdrant LlamaIndex documentation. To create the embeddings with the TIR GenAI API, see Generate vector embeddings. If a connection fails, see Troubleshooting Vector Database.