redis / redis-vl-python

Redis Vector Library (RedisVL) interfaces with Redis' vector database for realtime semantic search, RAG, and recommendation systems.
https://www.redisvl.com/
MIT License
204 stars 29 forks source link

How to apply filter on a semantic cache check() function #184

Closed pradeepdev-1995 closed 3 weeks ago

pradeepdev-1995 commented 1 month ago

Here is how i am using semantic cache

SemanticCacheObject = SemanticCache(
    name=cache_index,                               # underlying search index name
    prefix=cache_prefix,                            # redis key prefix for hash entries
    redis_url=redis_url,                            # redis connection url string
    distance_threshold=distance_threshold,          # semantic cache distance threshold
    ttl=ttl                                         # time to live each key in cache
)
query_embedding = <embedding of my query>
SemanticCacheObject.check(vector=query_embedding, return_fields=["prompt", "response", "metadata"]):

Now I want to filter the responses based on a specific column in the index, before applying the vector search. Then how to apply filter condition on this semantic cache index in check() function. Eg: I am expecting something like this

SemanticCacheObject.check(vector=query_embedding, return_fields=["prompt", "response", "metadata"], 
filter = <column name> )

Is this supported now in redis vl?

tylerhutcherson commented 1 month ago

It is not yet, but will be available in the upcoming 0.3.0 release. How would you expect to be able to define the filter options during configuration of the cache? And what about during cache checking? Any additional inputs?

justin-cechmanek commented 1 month ago

Hi @pradeepdev-1995. We've recently released RedisVL 0.3.0 and added new filtering functionality that is demonstrated in our user guide notebook on semantic caching. We would welcome any feedback you have on these new features.

pradeepdev-1995 commented 1 month ago

@justin-cechmanek Thank you. Will check this