Description
I’ve got a RAG application and I am trying to improve retrieval accuracy.
After the user enters their query, I have an LLM question pre-processor which expands and classifies the question type. For now it breaks the question type down into either “tech” (general technology question) or “spec” (specific product question), but eventually I’d like to extract more targeting data from the pre-processor… I’d like to use a different filter for each case.
#set filters, etc to match search_type
my_filters=wvc.query.Filter.by_property("file_name").like("ER*")
if search_type == "tech":
my_filters=(wvc.query.Filter.by_property("file_name").like("EP*") |
wvc.query.Filter.by_property("file_name").like("ES*") ),
response = collection.query.hybrid(
filters=my_filters,
query=instring,
query_properties=["page_content","title","semantic_concepts"],
alpha=0.6, #proportion of vector search 1.0 = 100% vector
return_metadata=wvc.query.MetadataQuery(
score=True,
explain_score=True,
),
limit=100,
fusion_type=HybridFusion.RELATIVE_SCORE,
rerank=Rerank(
prop="page_content",
query=instring
),
)
The above construct fails with:
Argument of type "tuple[_Filters] | _Filters" cannot be assigned to parameter "filters" of type "_Filters | None" in function "hybrid"
Yes, I could absolutely set up different queries for each search type, but that seems like it will get long and messy as I add refinements from the pre-processor.
Is there a programatic way to define filters outside of the collection.query() function call?
Server Setup Information
Server Setup Information
Weaviate Server Version: 1.24.1
Deployment Method: docker
Multi Node? Number of Running Nodes: 1
Client Language and Version: python 4.6.1
Any additional Information
above