Prompt Chain

Query Data with Retry Logic

LlamaPack that inserts data into Weaviate and uses the Retry Query Engine for RAG applications.

Works with weaviatellama index

85
Spark score
out of 100
Updated 3 months ago
Version 1.0.0

Add to Favorites

Why it matters

Enhance your RAG applications by integrating data into Weaviate and leveraging a retry query engine for more robust data retrieval and response generation.

Outcomes

What it gets done

01

Index data into Weaviate vector store.

02

Implement a retry mechanism for query failures.

03

Retrieve information using a structured query engine.

04

Utilize individual components like the retriever and query engine.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/li-pack-packs-retry-engine-weaviate | bash

Steps

Steps in the chain

01
Download WeaviateRetryEnginePack

Download the llamapack using llamaindex-cli with the command: llamaindex-cli download-llamapack WeaviateRetryEnginePack --download-dir ./weaviate_pack

02
Import and download pack

Import download_llama_pack from llama_index.core.llama_pack and download the pack: WeaviateRetryEnginePack = download_llama_pack('WeaviateRetryEnginePack', './weaviate_pack')

03
Configure vector store info

Set up VectorStoreInfo with content_info and metadata_info. Define metadata fields like 'category' with type and description for the vector store.

04
Initialize Weaviate client

Import weaviate and create a client instance: client = weaviate.Client()

05
Prepare nodes

Prepare your data nodes to be inserted into Weaviate. Assign them to a variable: nodes = [...]

06
Create the pack

Instantiate WeaviateRetryQueryEnginePack with collection_name, vector_store_info, nodes, and client parameters.

07
Run query

Execute a query using the pack's run() function: response = weaviate_pack.run('Tell me about a Music celebrity.')

Overview

Retry Query Engine

What it does

A LlamaPack that combines Weaviate vector storage with a Retry Query Engine for retrieval-augmented generation applications.

How it connects

Use this pack when you need to set up a RAG application with Weaviate as your vector store and want to leverage the Retry Query Engine functionality.

Source README

Retry Query Engine

This LlamaPack inserts your data into Weaviate and uses the Retry Query Engine for your RAG application.

CLI Usage

You can download llamapacks directly using llamaindex-cli, which comes installed with the llama-index python package:

llamaindex-cli download-llamapack WeaviateRetryEnginePack --download-dir ./weaviate_pack

You can then inspect the files at ./weaviate_pack and use them as a template for your own project.

Code Usage

You can download the pack to a the ./weaviate_pack directory:

from llama_index.core.llama_pack import download_llama_pack

### download and install dependencies
WeaviateRetryEnginePack = download_llama_pack(
    "WeaviateRetryEnginePack", "./weaviate_pack"
)

From here, you can use the pack, or inspect and modify the pack in ./weaviate_pack.

Then, you can set up the pack like so:

### setup pack arguments
from llama_index.core.vector_stores import MetadataInfo, VectorStoreInfo

vector_store_info = VectorStoreInfo(
    content_info="brief biography of celebrities",
    metadata_info=[
        MetadataInfo(
            name="category",
            type="str",
            description=(
                "Category of the celebrity, one of [Sports Entertainment, Business, Music]"
            ),
        ),
    ],
)

import weaviate

client = weaviate.Client()

nodes = [...]

### create the pack
weaviate_pack = WeaviateRetryQueryEnginePack(
    collection_name="test",
    vector_store_info=vector_store_index,
    nodes=nodes,
    client=client,
)

The run() function is a light wrapper around query_engine.query().

response = weaviate_pack.run("Tell me a bout a Music celebritiy.")

You can also use modules individually.

### use the retriever
retriever = weaviate_pack.retriever
nodes = retriever.retrieve("query_str")

### use the query engine
query_engine = weaviate_pack.query_engine
response = query_engine.query("query_str")

Step 1: Download WeaviateRetryEnginePack

Download the llamapack using llamaindex-cli with the command: llamaindex-cli download-llamapack WeaviateRetryEnginePack --download-dir ./weaviate_pack

Step 2: Import and download pack

Import download_llama_pack from llama_index.core.llama_pack and download the pack: WeaviateRetryEnginePack = download_llama_pack('WeaviateRetryEnginePack', './weaviate_pack')

Step 3: Configure vector store info

Set up VectorStoreInfo with content_info and metadata_info. Define metadata fields like 'category' with type and description for the vector store.

Step 4: Initialize Weaviate client

Import weaviate and create a client instance: client = weaviate.Client()

Step 5: Prepare nodes

Prepare your data nodes to be inserted into Weaviate. Assign them to a variable: nodes = [...]

Step 6: Create the pack

Instantiate WeaviateRetryQueryEnginePack with collection_name, vector_store_info, nodes, and client parameters.

Step 7: Run query

Execute a query using the pack's run() function: response = weaviate_pack.run('Tell me about a Music celebrity.')

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.