redis-ai-resources icon indicating copy to clipboard operation
redis-ai-resources copied to clipboard

redis-ai-resources/python-recipes/RAG /01_redisvl.ipynb- section : Improve personalization by including chat session history

Open amscosta opened this issue 7 months ago • 2 comments

Hi , Trying to reproduce the above section but getting the pink error cell message below. Should I restart the kernel and play those cells in sequence ?


ResponseError Traceback (most recent call last) File ~\litellm-qa-env\Lib\site-packages\redisvl\index\index.py:830, in SearchIndex.search(self, *args, **kwargs) 829 try: --> 830 return self._redis_client.ft(self.schema.index.name).search( # type: ignore 831 *args, **kwargs 832 ) 833 except Exception as e:

File ~\litellm-qa-env\Lib\site-packages\redis\commands\search\commands.py:508, in SearchCommands.search(self, query, query_params) 506 options[NEVER_DECODE] = True --> 508 res = self.execute_command(SEARCH_CMD, *args, **options) 510 if isinstance(res, Pipeline):

File ~\litellm-qa-env\Lib\site-packages\redis\client.py:605, in Redis.execute_command(self, *args, **options) 604 def execute_command(self, *args, **options): --> 605 return self._execute_command(*args, **options)

File ~\litellm-qa-env\Lib\site-packages\redis\client.py:616, in Redis._execute_command(self, *args, **options) 615 try: --> 616 return conn.retry.call_with_retry( 617 lambda: self._send_command_parse_response( 618 conn, command_name, *args, **options 619 ), 620 lambda error: self._disconnect_raise(conn, error), 621 ) 622 finally:

File ~\litellm-qa-env\Lib\site-packages\redis\retry.py:62, in Retry.call_with_retry(self, do, fail) 61 try: ---> 62 return do() 63 except self._supported_errors as error:

File ~\litellm-qa-env\Lib\site-packages\redis\client.py:617, in Redis._execute_command..() 615 try: 616 return conn.retry.call_with_retry( --> 617 lambda: self._send_command_parse_response( 618 conn, command_name, *args, **options 619 ), 620 lambda error: self._disconnect_raise(conn, error), 621 ) 622 finally:

File ~\litellm-qa-env\Lib\site-packages\redis\client.py:588, in Redis._send_command_parse_response(self, conn, command_name, *args, **options) 587 conn.send_command(*args, **options) --> 588 return self.parse_response(conn, command_name, **options)

File ~\litellm-qa-env\Lib\site-packages\redis\client.py:632, in Redis.parse_response(self, connection, command_name, **options) 631 if NEVER_DECODE in options: --> 632 response = connection.read_response(disable_decoding=True) 633 options.pop(NEVER_DECODE)

File ~\litellm-qa-env\Lib\site-packages\redis\connection.py:637, in AbstractConnection.read_response(self, disable_decoding, disconnect_on_error, push_request) 636 try: --> 637 raise response 638 finally:

ResponseError: llmcache: no such index

The above exception was the direct cause of the following exception:

RedisSearchError Traceback (most recent call last) Cell In[42], line 10 8 if user_query.lower() in stopterms or not user_query: 9 break ---> 10 answer = await chat.answer_question(user_query) 11 print(answer, flush=True)

Cell In[40], line 61, in ChatBot.answer_question(self, query) 58 query_vector = self.vectorizer.embed(query) 60 # Check the cache with the vector ---> 61 if result := llmcache.check(vector=query_vector): 62 answer = result[0]['response'] 63 else:

File ~\litellm-qa-env\Lib\site-packages\redisvl\extensions\cache\llm\semantic.py:433, in SemanticCache.check(self, prompt, vector, num_results, return_fields, filter_expression, distance_threshold) 421 query = VectorRangeQuery( 422 vector=vector, 423 vector_field_name=CACHE_VECTOR_FIELD_NAME, (...) 429 dtype=self._vectorizer.dtype, 430 ) 432 # Search the cache! --> 433 cache_search_results = self._index.query(query) 434 redis_keys, cache_hits = self._process_cache_results( 435 cache_search_results, 436 return_fields, # type: ignore 437 ) 439 # Refresh TTL on all found keys

File ~\litellm-qa-env\Lib\site-packages\redisvl\index\index.py:889, in SearchIndex.query(self, query) 887 return self._aggregate(query) 888 else: --> 889 return self._query(query)

File ~\litellm-qa-env\Lib\site-packages\redisvl\index\index.py:858, in SearchIndex._query(self, query) 856 except QueryValidationError as e: 857 raise QueryValidationError(f"Invalid query: {str(e)}") from e --> 858 results = self.search(query.query, query_params=query.params) 859 return process_results(results, query=query, schema=self.schema)

File ~\litellm-qa-env\Lib\site-packages\redisvl\index\index.py:834, in SearchIndex.search(self, *args, **kwargs) 830 return self._redis_client.ft(self.schema.index.name).search( # type: ignore 831 *args, **kwargs 832 ) 833 except Exception as e: --> 834 raise RedisSearchError(f"Error while searching: {str(e)}") from e

RedisSearchError: Error while searching: llmcache: no such index

amscosta avatar May 03 '25 21:05 amscosta

Hey @amscosta I re-ran all the cells in the colab environment and was unable to recreate your issue.

From your error message it seems that the llmcache doesn't exist. This can be for redis connection errors or potentially other unknown reasons.

Check by running this cell: Image

If you're running locally potentially check that your redis instance is running and available on localhost:6379.

rbs333 avatar May 06 '25 18:05 rbs333

Thanks for the output. I am running locally. Can you test locally? Maybe also indicate the exact sequence of cells to be run ?

amscosta avatar May 16 '25 12:05 amscosta