Skip to content

Commit

Permalink
API Migration (#17545)
Browse files Browse the repository at this point in the history
  • Loading branch information
david-oplatka authored Jan 20, 2025
1 parent 8a56a71 commit 6f3a661
Show file tree
Hide file tree
Showing 15 changed files with 1,066 additions and 704 deletions.
155 changes: 55 additions & 100 deletions docs/docs/examples/managed/vectaraDemo.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# CHANGELOG — llama-index-indices-managed-vectara

## [0.4.0]

Implementation switched from using Vectara API v1 to API v2.
There are a number of breaking changes involved with this transition:

1. The `vectara_customer_id` parameter was removed from `VectaraIndex`. You no longer need to specify this information when you instantiate an index nor provide the environment variable `VECTARA_CUSTOMER_ID`.
2. The `vectara_corpus_id` parameter was replaced with `vectara_corpus_key`. When creating a `VectaraIndex` object, please either specify `vectara_corpus_key` explicitly or add `VECTARA_CORPUS_KEY` to your environment. This should use the corpus key of your Vectara corpus rather than the corpus ID.
3. The `add_documents()` function was removed and replaced with two new functions for indexing documents. If you want to use the Structured Document type, use the new `add_document()` function. If you would like to use the Core Document type, use the new `add_nodes()` function.
4. For specifying reranker types, `"udf"` has been replaced with `"userfn"`.
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,39 @@ Finally, set up your Vectara corpus. If you don't have a Vectara account, you ca

## Usage

Please note that this usage example is for versions >= 0.4.0 and will not be the same as for earlier versions of Vectara ManagedIndex.

First let's initialize the index with some sample documents.
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.

```python
import os

os.environ["VECTARA_API_KEY"] = "<YOUR_VECTARA_API_KEY>"
os.environ["VECTARA_CORPUS_ID"] = "<YOUR_VECTARA_CORPUS_ID>"
os.environ["VECTARA_CUSTOMER_ID"] = "<YOUR_VECTARA_CUSTOMER_ID>"
os.environ["VECTARA_CORPUS_KEY"] = "<YOUR_VECTARA_CORPUS_KEY>"

from llama_index.indices.managed.vectara import VectaraIndex
from llama_index.core.schema import Document
from llama_index.core.schema import Document, MediaResource

docs = [
Document(
text="""
This is test text for Vectara integration with LlamaIndex.
Users should love their experience with this integration
""",
id_="doc1",
text_resource=MediaResource(
text="""
This is test text for Vectara integration with LlamaIndex.
Users should love their experience with this integration
""",
),
),
Document(
text="""
The Vectara index integration with LlamaIndex implements Vectara's RAG pipeline.
It can be used both as a retriever and query engine.
""",
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.
""",
),
),
]

Expand Down
Loading

0 comments on commit 6f3a661

Please sign in to comment.