id
and I want to be able to dynamically filter metadataid
I want to be able to pas that id
as filter to Qdrant. Is that possible?from llama_index.vector_stores.types import ExactMatchFilter, MetadataFilters filters = MetadataFilters(filters=[ExactMatchFilter(key="tool", value="name"), ExactMatchFilter(key="person", value="name")]) query_engine = index.as_query_engine(filters=filters)
id
or by date
. With the SQL Auto Vector Query Engine, is there some way to see the prompt template it provides and for me to further edit / enhance it?VectorIndexAutoRetriever
with the sql vector thing linked above in that notebook, it can dynamically write filters.vector_store_info = VectorStoreInfo( content_info="articles about different cities", metadata_info=[ MetadataInfo(name="title", type="str", description="The name of the city"), ], ) vector_auto_retriever = VectorIndexAutoRetriever( vector_index, vector_store_info=vector_store_info ) retriever_query_engine = RetrieverQueryEngine.from_args( vector_auto_retriever, service_context=service_context )
VectorStoreInfo
object. It also has an optional prompt_template_str
argument.prompt_template
to the VectorStoreInfo I can override the default prompt. I now see that from L40 to L61, you give examples to the prompt on how to filter. That's awesome. https://github.com/jerryjliu/llama_index/blob/502a4d66f8d2beff20e481396ec23949cfc03aa2/llama_index/indices/vector_store/retrievers/auto_retriever/prompts.py#L40And again, this is just controling the vector index side. The SQL auto vector thing also assumes you have a sql query engine setup as well, that connects to a db for text2sql queriesIs my understanding correct then that there is a default prompt setup for vector and another default prompt setup for sql side? And then there's I guess the parent prompt which helps the agent determine which engine to use? = a total of 3 prompts for this SQL Auto Query Engine setup.
you should be able to join any index, not just a vectorSorry what do you mean by any index.
pip uninstall llama-index pip install --upgrade git+https://github.com/jerryjliu/llama_index
pattern1 = r'["\']Quotes["\']: [\'"](.*?)[\'"]'
pattern2 = r'["\']People["\']: [\'"](.*?)[\'"]'
pattern3 = r'["\']Source["\']: [\'"](.*?)[\'"]'
pattern4 = r'["\']Tool Type["\']: [\'"](.*?)[\'"]'
# create nodes list based on patterns
nodes = []
for document in documents:
text = document.text
matches1 = re.findall(pattern1, text)
matches2 = re.findall(pattern2, text)
matches3 = re.findall(pattern3, text)
matches4 = re.findall(pattern4, text)
# takes quotes & people from matches & puts them into list of nodes
for quote, person, url, tool in zip(matches1, matches2, matches3, matches4):
node_name = f"node{len(nodes) + 1}"
node_text = f"{quote}"
extra_info = {"Person": person, "url": url, "tool": tool}
exec(f"{node_name} = Node(text=node_text, extra_info=extra_info)")
nodes.append(eval(node_name))
QA_PROMPT = QuestionAnswerPrompt(QA_PROMPT_TMPL)
# indexing
index = VectorStoreIndex(nodes)
index.insert(nodes)
filters = MetadataFilters(filters=[ExactMatchFilter(key="person", value="Napoleon")])
retriever = index.as_retriever(
similarity_top_k=5,
filters=filters
)
index = VectorStoreIndex(nodes)
filters = MetadataFilters(filters=[ExactMatchFilter(key="Person", value="Sam Altman")])
retriever = index.as_retriever(
similarity_top_k=5,
filters=filters
)