Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: list index out of range while applying filter on semantic cache check #203

Closed
MeharRamzan opened this issue Aug 15, 2024 · 13 comments · Fixed by #208
Closed
Assignees
Labels
bug Something isn't working

Comments

@MeharRamzan
Copy link

I am facing this issue while trying to applying filter on semantic cache check
image
image

@tylerhutcherson
Copy link
Collaborator

For some reason, the result coming back from the cache check step is empty. We need steps to be able to reproduce the entire flow.

Can you clear the db and then re-initialize your SemanticCache and then use the private_cache.store(...) command to populate the entry in the cache?

@MeharRamzan
Copy link
Author

hey @tylerhutcherson, I emptied the Redis database and tried running the code again. The data is successfully stored in Redis, but there's an issue during retrieval.

image
image

@tylerhutcherson tylerhutcherson added the bug Something isn't working label Aug 16, 2024
@tylerhutcherson
Copy link
Collaborator

We're taking a closer look, thanks!

@justin-cechmanek
Copy link
Collaborator

Hi. Can you share with us your redis version, redisvl version, client versions, python version?
I see your code snippets also have some lines above not shown. Is there anything there that may be influence caching?

@MeharRamzan
Copy link
Author

@justin-cechmanek

redis==5.0.8
redisvl==0.3.0
python==3.10.14

here is the complete code.
image

@justin-cechmanek
Copy link
Collaborator

We're having trouble reproducing your error. Can you confirm your 'redis_url' matches what is shown if you print private_cache._index.client, specifically the host and port names? My suspicion currently is that your dotenv setup is different than mine.

@tylerhutcherson
Copy link
Collaborator

We're having trouble reproducing your error. Can you confirm your 'redis_url' matches what is shown if you print private_cache._index.client, specifically the host and port names? My suspicion currently is that your dotenv setup is different than mine.

also please validate which distribution of redis you are using?
https://redis.io/docs/latest/operate/oss_and_stack/install/install-stack/docker/

@MeharRamzan
Copy link
Author

@justin-cechmanek here is the output of print(private_cache._index.client)

<redis.client.Redis(<redis.connection.ConnectionPool(<redis.connection.Connection(host=redis-14645.c275.us-east-1-4.ec2.redns.redis-cloud.com,port=14645,db=0)>)>)>

@MeharRamzan
Copy link
Author

@tylerhutcherson I'm new to Redis and still getting familiar with its features. I've recently read the documentation here, signed up for Redis Cloud, created a database and Redis URL, and installed RedisInsight to monitor and manage my setup.

Everything is working well for semantic search, but I'm encountering an issue when applying specific filters. I’m running this on an Ubuntu .

@justin-cechmanek
Copy link
Collaborator

Are you only seeing errors when working with specific filters, or do all cache checks fail to return results?

@MeharRamzan
Copy link
Author

@justin-cechmanek When I use the filters, I get an error, but without the filter, it works perfectly fine. You can see in the picture that I commented out the filter_expression, and it starts working.
image

@tylerhutcherson
Copy link
Collaborator

tylerhutcherson commented Aug 23, 2024

@MeharRamzan My theory is that there is an index with the name private_cache that is old. Because you see:

11:54:53 redisvl.index.index INFO   Index already exists, not overwriting.

^^ That means the index is already configured in Redis (potentially, at some point without the filter field). And thus, it's not overwriting it since it's trying to use the same name private_cache.

To confirm, try either:

  • Run the same example using a different name arg to the SemanticCache.
  • Drop the existing index using private_cache.delete() OR by running flushall on your dev database (you can do this in the console in RedisInsight).

If confirmed, we will work to make this handled better in a patch release along with better documentation.

@justin-cechmanek justin-cechmanek linked a pull request Aug 23, 2024 that will close this issue
@MeharRamzan
Copy link
Author

@tylerhutcherson I tried it again with a new database. I deleted the old one and then tried, and now it is working.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants