Vectara
VectaraIndex #
Bases: BaseManagedIndex
Vectara Index.
The Vectara index implements a managed index that uses Vectara as the backend. Vectara performs a lot of the functions in traditional indexes in the backend: - breaks down a document into chunks (nodes) - Creates the embedding for each chunk (node) - Performs the search for the top k most similar nodes to a query - Optionally can perform summarization of the top k nodes
Parameters:
Name | Type | Description | Default |
---|---|---|---|
show_progress
|
bool
|
Whether to show tqdm progress bars. Defaults to False. |
False
|
Source code in llama-index-integrations/indices/llama-index-indices-managed-vectara/llama_index/indices/managed/vectara/base.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 |
|
add_document #
add_document(doc: Document, corpus_key: Optional[str] = None, title: Optional[str] = None, description: Optional[str] = None, max_chars_per_chunk: Optional[int] = None) -> None
" Indexes a document into a corpus using the Vectara Structured Document format.
Full API Docs: https://docs.vectara.com/docs/api-reference/indexing-apis/indexing#structured-document-object-definition
Parameters:
Name | Type | Description | Default |
---|---|---|---|
doc
|
Document
|
The document object to be indexed. You should provide the value you want for the document id in the corpus as the id_ member of this object. You should provide any document_metadata in the metadata member of this object. |
required |
corpus_key
|
str
|
If multiple corpora are provided for this index, the corpus_key of the corpus you want to add the document to. |
None
|
title
|
str
|
The title of the document. |
None
|
description
|
str
|
The description of the document. |
None
|
max_chars_per_chunk
|
int
|
The maximum number of characters per chunk. |
None
|
Source code in llama-index-integrations/indices/llama-index-indices-managed-vectara/llama_index/indices/managed/vectara/base.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
|
add_nodes #
add_nodes(nodes: Sequence[Node], document_id: str, document_metadata: Optional[Dict] = {}, corpus_key: Optional[str] = None) -> None
Indexes a document into a corpus using the Vectara Core Document format.
Full API Docs: https://docs.vectara.com/docs/api-reference/indexing-apis/indexing#core-document-object-definition
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nodes
|
Sequence[Node]
|
The user-specified document parts. You should provide any part_metadata in the metadata member of each node. |
required |
document_id
|
str
|
The document id (must be unique for the corpus). |
required |
document_metadata
|
Dict
|
The document_metadata to be associated with this document. |
{}
|
corpus_key
|
str
|
If multiple corpora are provided for this index, the corpus_key of the corpus you want to add the document to. |
None
|
Source code in llama-index-integrations/indices/llama-index-indices-managed-vectara/llama_index/indices/managed/vectara/base.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
|
insert_file #
insert_file(file_path: str, metadata: Optional[dict] = None, chunking_strategy: Optional[dict] = None, enable_table_extraction: Optional[bool] = False, filename: Optional[str] = None, corpus_key: Optional[str] = None, **insert_kwargs: Any) -> Optional[str]
Vectara provides a way to add files (binary or text) directly via our API where pre-processing and chunking occurs internally in an optimal way This method provides a way to use that API in Llama_index.
ruff: noqa: E501#
Full API Docs: https://docs.vectara.com/docs/rest-api/upload-file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
str
|
local file path Files could be text, HTML, PDF, markdown, doc/docx, ppt/pptx, etc. see API docs for full list |
required |
metadata
|
Optional[dict]
|
Optional dict of metadata associated with the file |
None
|
chunking_strategy
|
Optional[dict]
|
Optional dict specifying max number of characters per chunk |
None
|
enable_table_extraction
|
Optional[bool]
|
Optional bool specifying whether or not to extract tables from document |
False
|
filename
|
Optional[str]
|
Optional string specifying the filename |
None
|
Returns:
Type | Description |
---|---|
Optional[str]
|
List of ids associated with each of the files indexed |
Source code in llama-index-integrations/indices/llama-index-indices-managed-vectara/llama_index/indices/managed/vectara/base.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 |
|
delete_ref_doc #
delete_ref_doc(ref_doc_id: str, delete_from_docstore: bool = True, **delete_kwargs: Any) -> None
Delete a document from a Vectara corpus.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ref_doc_id
|
str
|
ID of the document to delete |
required |
delete_from_docstore
|
bool
|
Whether to delete the document from the corpus. If False, no change is made to the index or corpus. |
True
|
corpus_key
|
str
|
corpus key to delete the document from. This should be specified if there are multiple corpora in the index. |
required |
Source code in llama-index-integrations/indices/llama-index-indices-managed-vectara/llama_index/indices/managed/vectara/base.py
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 |
|
update_ref_doc #
update_ref_doc(document: Document, **update_kwargs: Any) -> None
Update a document's metadata in a Vectara corpus.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
document
|
Document
|
The document to update. Make sure to include id_ argument for proper identification within the corpus. |
required |
corpus_key
|
str
|
corpus key to modify the document from. This should be specified if there are multiple corpora in the index. |
required |
metadata
|
dict
|
dictionary specifying any modifications or additions to the document's metadata. |
required |
Source code in llama-index-integrations/indices/llama-index-indices-managed-vectara/llama_index/indices/managed/vectara/base.py
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 |
|
as_retriever #
as_retriever(**kwargs: Any) -> BaseRetriever
Return a Retriever for this managed index.
Source code in llama-index-integrations/indices/llama-index-indices-managed-vectara/llama_index/indices/managed/vectara/base.py
442 443 444 445 446 447 448 |
|
from_documents
classmethod
#
from_documents(documents: Sequence[Document], show_progress: bool = False, callback_manager: Optional[CallbackManager] = None, transformations: Optional[List[TransformComponent]] = None, **kwargs: Any) -> IndexType
Build a Vectara index from a sequence of documents.
Source code in llama-index-integrations/indices/llama-index-indices-managed-vectara/llama_index/indices/managed/vectara/base.py
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 |
|