llama-index managed vectara integration
Project description
LlamaIndex Managed Integration: Vectara
The Vectara Index provides a simple implementation to Vectara's end-to-end RAG pipeline, including data ingestion, document retrieval, reranking results, summary generation, and hallucination evaluation.
Please note that this documentation applies to versions >= 0.4.0 and will not be the same as for earlier versions of Vectara ManagedIndex.
📌 Setup
First, make sure you have the latest LlamaIndex version installed.
pip install -U llama-index
Next, install the Vectara Index:
pip install -U llama-index-indices-managed-vectara
Finally, set up your Vectara corpus. If you don't have a Vectara account, you can sign up and follow our Quick Start guide to create a corpus and an API key (make sure the api_key has both indexing and query permissions, or use your personal API key).
Once you have your API key, export it as an environment variable:
import os
os.environ["VECTARA_API_KEY"] = "<YOUR_VECTARA_API_KEY>"
os.environ["VECTARA_CORPUS_KEY"] = "<YOUR_VECTARA_CORPUS_KEY>"
🚀 Usage
1. Index Documents
Create an index and add some sample documents:
from llama_index.indices.managed.vectara import VectaraIndex
from llama_index.core.schema import Document, MediaResource
docs = [
Document(
id_="doc1",
text_resource=MediaResource(
text="""
This is test text for Vectara integration with LlamaIndex.
Users should love their experience with this integration
""",
),
),
Document(
id_="doc2",
text_resource=MediaResource(
text="""
The Vectara index integration with LlamaIndex implements Vectara's RAG pipeline.
It can be used both as a retriever and query engine.
""",
),
),
]
index = VectaraIndex.from_documents(docs)
Make sure to always specify a unique id_ for every document you add to your index.
If you don't specify this parameter, a random id will be generated and the document will be separately added to your corpus every time you run your code.
You can now use this index to retrieve documents.
2. Retrieve Documents
Retrieve the top 2 most relevant document for a query:
# Retrieves the top search result
retriever = index.as_retriever(similarity_top_k=2)
results = retriever.retrieve("How will users feel about this new tool?")
print(results[0])
3. Use as a Query Engine
Generate a summary of retrieved results:
query_engine = index.as_query_engine()
results = query_engine.query(
"Which company has partnered with Vectara to implement their RAG pipeline as an index?"
)
print(f"Generated summary: {results.response}\n")
print("Top sources:")
for node in results.source_nodes[:2]:
print(node)
📂 Understanding source_nodes structure
Each node object in source_nodes contains a NodeWithScore object with:
text: The matched text snippet.id_: The unique identifier of the document.metadata: A dictionary containing:- Key-value pairs from the matched part of the document.
- A
documentkey that stores all document-level metadata.
score: The relevance score of the match.
Example Output:
NodeWithScore(
node=Node(
text_resource=MediaResource(
text="This is a test text for Vectara integration with LlamaIndex."
),
id_="doc1",
metadata={
"category": "AI",
"page": 23,
"document": {
"url": "https://www.vectara.com/developers/build/integrations/llamaindex",
"title": "LlamaIndex + Vectara Integration",
"author": "Ofer Mendelevitch",
"date": "2025-03-01"
}
}
),
score=0.89
)
If you want to see the full features and capabilities of VectaraIndex, check out this Jupyter notebook.
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llama_index_indices_managed_vectara-0.6.0.tar.gz.
File metadata
- Download URL: llama_index_indices_managed_vectara-0.6.0.tar.gz
- Upload date:
- Size: 17.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3cb399ab20a1be2d3aedb7ae597b79db5dde53b8f7f86c5c24aa4a49276f201e
|
|
| MD5 |
f50035e8b7b0e721bb415a93dea013d8
|
|
| BLAKE2b-256 |
2391e7a4ffe74b1a6bcd19c4690174b2111ecb5c37a893470cce17d3bae05189
|
File details
Details for the file llama_index_indices_managed_vectara-0.6.0-py3-none-any.whl.
File metadata
- Download URL: llama_index_indices_managed_vectara-0.6.0-py3-none-any.whl
- Upload date:
- Size: 19.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6ecf5004ed7993f502c58ffe01bcc0bc1553586532c63cf804182b0bac1e65e
|
|
| MD5 |
cdb72fe3e8117c7ec4b659b39c2cb61b
|
|
| BLAKE2b-256 |
1d2b6a0d191779ecb537069002474e51f152cf822b1fcbf8895131a6855813c5
|