Back to Chatgpt Retrieval Plugin

Redis

docs/providers/redis/setup.md

latest3.5 KB
Original Source

Redis

Redis is a real-time data platform that supports a variety of use cases for everyday applications as well as AI/ML workloads. Use Redis as a low-latency vector engine by creating a Redis database with the Redis Stack docker container. For a hosted/managed solution, try Redis Cloud. See more helpful examples of Redis as a vector database here.

  • The database needs the RediSearch module (>=v2.6) and RedisJSON, which are included in the self-hosted docker compose above.
  • Run the App with the Redis docker image: docker compose up -d in this dir.
  • The app automatically creates a Redis vector search index on the first run. Optionally, create a custom index with a specific name and set it as an environment variable (see below).
  • To enable more hybrid searching capabilities, adjust the document schema here.

Environment Variables:

NameRequiredDescriptionDefault
DATASTOREYesDatastore name, set to redis
BEARER_TOKENYesSecret token
OPENAI_API_KEYYesOpenAI API key
REDIS_HOSTOptionalRedis host urllocalhost
REDIS_PORTOptionalRedis port6379
REDIS_PASSWORDOptionalRedis passwordnone
REDIS_INDEX_NAMEOptionalRedis vector index nameindex
REDIS_DOC_PREFIXOptionalRedis key prefix for the indexdoc
REDIS_DISTANCE_METRICOptionalVector similarity distance metricCOSINE
REDIS_INDEX_TYPEOptionalVector index algorithm typeFLAT

Redis Datastore development & testing

In order to test your changes to the Redis Datastore, you can run the following commands:

bash
# Run the Redis stack docker image
docker run -it --rm -p 6379:6379 redis/redis-stack-server:latest
bash
# Run the Redis datastore tests
poetry run pytest -s ./tests/datastore/providers/redis/test_redis_datastore.py