From c852e3da1f6d309e6cca50bad08dabe6ed0f715f Mon Sep 17 00:00:00 2001 From: Tyler Hutcherson Date: Thu, 1 Aug 2024 19:58:31 -0700 Subject: [PATCH] Bump to 0.3.0 and update docs (#189) Version bump to 0.3.0 and updates documentation/README! --- README.md | 235 ++++++++++++------ docs/_static/js/sidebar.js | 25 +- docs/api/cache.rst | 1 - docs/api/index.md | 1 + docs/api/session_manager.rst | 29 +++ docs/api/vectorizer.rst | 23 ++ docs/overview/cli.ipynb | 46 ++-- pyproject.toml | 2 +- redisvl/extensions/llmcache/base.py | 11 +- redisvl/extensions/llmcache/semantic.py | 4 +- .../session_manager/semantic_session.py | 2 +- redisvl/utils/vectorize/text/custom.py | 3 +- redisvl/version.py | 2 +- 13 files changed, 265 insertions(+), 119 deletions(-) create mode 100644 docs/api/session_manager.rst diff --git a/README.md b/README.md index de5324e0..0ce5a348 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,12 @@ -

🔥 Redis Vector Library

+
+
+

🔥 Vector Library

+
+ +
+ the *AI-native* Redis Python client +
-
- the AI-native Redis Python client -
[![Codecov](https://img.shields.io/codecov/c/github/redis/redis-vl-python/dev?label=Codecov&logo=codecov&token=E30WxqBeJJ)](https://codecov.io/gh/redis/redis-vl-python) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) @@ -18,7 +22,7 @@
Home    Documentation    - More Projects    + Recipes   

@@ -26,25 +30,25 @@ # Introduction -The Python Redis Vector Library (RedisVL) is a tailor-made client for AI applications leveraging [Redis](https://redis.com). +Welcome to the Redis Vector Library – the ultimate Python client designed for AI applications harnessing the power of [Redis](https://redis.io). -It's specifically designed for: +`redisvl` is your go-to tool for: -- Information retrieval & vector similarity search +- Lightning-fast information retrieval & vector similarity search - Real-time RAG pipelines -- Recommendation engines +- Agentic memory structures +- Smart recommendation engines -Enhance your applications with Redis' **speed**, **flexibility**, and **reliability**, incorporating capabilities like vector-based semantic search, full-text search, and geo-spatial search. +## 🚀 Why RedisVL? -# 🚀 Why RedisVL? +In the age of GenAI, **vector databases** and **LLMs** are transforming information retrieval systems. With emerging and popular frameworks like [LangChain](https://github.com/langchain-ai/langchain) and [LlamaIndex](https://www.llamaindex.ai/), innovation is soaring. Yet, many organizations face the challenge of delivering AI solutions **quickly** and at **scale**. -The emergence of the modern GenAI stack, including **vector databases** and **LLMs**, has become increasingly popular due to accelerated innovation & research in information retrieval, the ubiquity of tools & frameworks (e.g. [LangChain](https://github.com/langchain-ai/langchain), [LlamaIndex](https://www.llamaindex.ai/), [EmbedChain](https://github.com/embedchain/embedchain)), and the never-ending stream of business problems addressable by AI. +Enter [Redis](https://redis.io) – a cornerstone of the NoSQL world, renowned for its versatile [data structures](https://redis.io/docs/data-types/) and [processing engines](https://redis.io/docs/interact/). Redis excels in real-time workloads like caching, session management, and search. It's also a powerhouse as a vector database for RAG, an LLM cache, and a chat session memory store for conversational AI. -However, organizations still struggle with delivering reliable solutions **quickly** (*time to value*) at **scale** (*beyond a demo*). +The Redis Vector Library bridges the gap between the AI-native developer ecosystem and Redis's robust capabilities. With a lightweight, elegant, and intuitive interface, RedisVL makes it easy to leverage Redis's power. Built on the [Redis Python](https://github.com/redis/redis-py/tree/master) client, `redisvl` transforms Redis's features into a grammar perfectly aligned with the needs of today's AI/ML Engineers and Data Scientists. -[Redis](https://redis.io) has been a staple for over a decade in the NoSQL world, and boasts a number of flexible [data structures](https://redis.io/docs/data-types/) and [processing engines](https://redis.io/docs/interact/) to handle realtime application workloads like caching, session management, and search. Most notably, Redis has been used as a vector database for RAG, as an LLM cache, and chat session memory store for conversational AI applications. +Unleash the full potential of Redis for your AI projects with `redisvl`. -The vector library **bridges the gap between** the emerging AI-native developer ecosystem and the capabilities of Redis by providing a lightweight, elegant, and intuitive interface. Built on the back of the popular Python client, [`redis-py`](https://github.com/redis/redis-py/tree/master), it abstracts the features Redis into a grammar that is more aligned to the needs of today's AI/ML Engineers or Data Scientists. # 💪 Getting Started @@ -55,31 +59,29 @@ Install `redisvl` into your Python (>=3.8) environment using `pip`: ```bash pip install redisvl ``` -> For more instructions, visit the `redisvl` [installation guide](https://www.redisvl.com/overview/installation.html). +> For more detailed instructions, visit the [installation guide](https://www.redisvl.com/overview/installation.html). ## Setting up Redis Choose from multiple Redis deployment options: -1. [Redis Cloud](https://redis.com/try-free): Managed cloud database (free tier available) +1. [Redis Cloud](https://redis.io/try-free): Managed cloud database (free tier available) 2. [Redis Stack](https://redis.io/docs/getting-started/install-stack/docker/): Docker image for development ```bash docker run -d --name redis-stack -p 6379:6379 -p 8001:8001 redis/redis-stack:latest ``` -3. [Redis Enterprise](https://redis.com/redis-enterprise/): Commercial, self-hosted database +3. [Redis Enterprise](https://redis.io/enterprise/): Commercial, self-hosted database 4. [Azure Cache for Redis Enterprise](https://learn.microsoft.com/azure/azure-cache-for-redis/quickstart-create-redis-enterprise): Fully managed Redis Enterprise on Azure > Enhance your experience and observability with the free [Redis Insight GUI](https://redis.com/redis-enterprise/redis-insight/). -## What's included? - +# Overview -### 🗃️ Redis Index Management -1. [Design an `IndexSchema`](https://www.redisvl.com/user_guide/getting_started_01.html#define-an-indexschema) that models your dataset with built-in Redis [data structures](https://www.redisvl.com/user_guide/hash_vs_json_05.html) (*Hash or JSON*) and indexable fields (*e.g. text, tags, numerics, geo, and vectors*). - [Load a schema](https://www.redisvl.com/user_guide/getting_started_01.html#example-schema-creation) from a [YAML file](schemas/schema.yaml): +## 🗃️ Redis Index Management +1. [Design a schema for your use case](https://www.redisvl.com/user_guide/getting_started_01.html#define-an-indexschema) that models your dataset with built-in Redis and indexable fields (*e.g. text, tags, numerics, geo, and vectors*). [Load a schema](https://www.redisvl.com/user_guide/getting_started_01.html#example-schema-creation) from a YAML file: ```yaml index: name: user-index-v1 @@ -155,7 +157,7 @@ and [fetch](https://www.redisvl.com/user_guide/getting_started_01.html#fetch-an- john = index.fetch("john") ``` -### 🔍 Realtime Search +## 🔍 Retrieval Define queries and perform advanced searches over your indices, including the combination of vectors, metadata filters, and more. @@ -191,32 +193,20 @@ Define queries and perform advanced searches over your indices, including the co - [FilterQuery](https://www.redisvl.com/api/query.html#filterquery) - Standard search using filters and the full-text search - [CountQuery](https://www.redisvl.com/api/query.html#countquery) - Count the number of indexed records given attributes -> Read more about building advanced Redis queries [here](https://www.redisvl.com/user_guide/hybrid_queries_02.html). - - -### 🖥️ Command Line Interface -Create, destroy, and manage Redis index configurations from a purpose-built CLI interface: `rvl`. - -```bash -$ rvl -h +> Read more about building [advanced Redis queries](https://www.redisvl.com/user_guide/hybrid_queries_02.html). -usage: rvl [] - -Commands: - index Index manipulation (create, delete, etc.) - version Obtain the version of RedisVL - stats Obtain statistics about an index -``` -> Read more about using the `redisvl` CLI [here](https://www.redisvl.com/user_guide/cli.html). +## 🔧 Utilities -### ⚡ Community Integrations -Integrate with popular embedding models and providers to greatly simplify the process of vectorizing unstructured data for your index and queries: -- [Cohere](https://www.redisvl.com/api/vectorizer/html#coheretextvectorizer) +### Vectorizers +Integrate with popular embedding providers to greatly simplify the process of vectorizing unstructured data for your index and queries: +- [AzureOpenAI](https://www.redisvl.com/api/vectorizer.html#azureopenaitextvectorizer) +- [Cohere](https://www.redisvl.com/api/vectorizer.html#coheretextvectorizer) +- [Custom](https://www.redisvl.com/api/vectorizer.html#customtextvectorizer) +- [GCP VertexAI](https://www.redisvl.com/api/vectorizer.html#vertexaitextvectorizer) +- [HuggingFace](https://www.redisvl.com/api/vectorizer.html#hftextvectorizer) - [Mistral](https://www.redisvl.com/api/vectorizer/html#mistralaitextvectorizer) - [OpenAI](https://www.redisvl.com/api/vectorizer.html#openaitextvectorizer) -- [HuggingFace](https://www.redisvl.com/api/vectorizer.html#hftextvectorizer) -- [GCP VertexAI](https://www.redisvl.com/api/vectorizer.html#vertexaitextvectorizer) ```python from redisvl.utils.vectorize import CohereTextVectorizer @@ -235,53 +225,144 @@ embeddings = co.embed_many( ) ``` -> Learn more about using `redisvl` Vectorizers in your workflows [here](https://www.redisvl.com/user_guide/vectorizers_04.html). +> Learn more about using [vectorizers]((https://www.redisvl.com/user_guide/vectorizers_04.html)) in your embedding workflows. -### 💫 Beyond Vector Search -In order to perform well in production, modern GenAI applications require much more than vector search for retrieval. `redisvl` provides some common extensions that -aim to improve applications working with LLMs: -- **LLM Semantic Caching** is designed to increase application throughput and reduce the cost of using LLM models in production by leveraging previously generated knowledge. +### Rerankers +[Integrate with popular reranking providers](https://www.redisvl.com/user_guide/rerankers_06.html) to improve the relevancy of the initial search results from Redis - ```python - from redisvl.extensions.llmcache import SemanticCache - # init cache with TTL (expiration) policy and semantic distance threshhold - llmcache = SemanticCache( - name="llmcache", - ttl=360, - redis_url="redis://localhost:6379" - ) - llmcache.set_threshold(0.2) # can be changed on-demand - # store user queries and LLM responses in the semantic cache - llmcache.store( - prompt="What is the capital city of France?", - response="Paris", - metadata={} +## 💫 Extensions +We're excited to announce the support for **RedisVL Extensions**. These modules implement interfaces exposing best practices and design patterns for working with LLM memory and agents. We've taken the best from what we've learned from our users (that's you) as well as bleeding-edge customers, and packaged it up. + +*Have an idea for another extension? Open a PR or reach out to us at applied.ai@redis.com. We're always open to feedback.* + +### LLM Semantic Caching +Increase application throughput and reduce the cost of using LLM models in production by leveraging previously generated knowledge with the [`SemanticCache`](https://www.redisvl.com/api/cache.html#semanticcache). + +```python +from redisvl.extensions.llmcache import SemanticCache + +# init cache with TTL and semantic distance threshold +llmcache = SemanticCache( + name="llmcache", + ttl=360, + redis_url="redis://localhost:6379", + distance_threshold=0.1 +) + +# store user queries and LLM responses in the semantic cache +llmcache.store( + prompt="What is the capital city of France?", + response="Paris", + metadata={} +) + +# quickly check the cache with a slightly different prompt (before invoking an LLM) +response = llmcache.check(prompt="What is France's capital city?") +print(response[0]["response"]) +``` +```stdout +>>> "Paris" +``` + +> Learn more about [semantic caching]((https://www.redisvl.com/user_guide/llmcache_03.html)) for LLMs. + +### LLM Session Management + +Improve personalization and accuracy of LLM responses by providing user chat history as context. Manage access to the session data using recency or relevancy, *powered by vector search* with the [`SemanticSessionManager`](). + +```python +from redisvl.extensions.session_manager import SemanticSessionManager + +session = SemanticSessionManager( + name="my-session", + redis_url="redis://localhost:6379" +) + +session.add_messages([ + {"role": "user", "content": "hello, how are you?"}, + {"role": "assistant", "content": "I'm doing fine, thanks."}, + {"role": "user", "content": "what is the weather going to be today?"}, + {"role": "assistant", "content": "I don't know"} +]) +``` +Get recent chat history: +```python +session.get_recent(top_k=1) +``` +```stdout +>>> {"role": "assistant", "content": "I don't know"} +``` +Get relevant chat history (powered by vector search): +```python +session.get_relevant("weather", top_k=1) +``` +```stdout +>>> {"role": "user", "content": "what is the weather going to be today?"} +``` +> Learn more about [LLM session management]((https://www.redisvl.com/user_guide/session_manager_07.html)). + + +### LLM Semantic Routing +Build fast decision models that run directly in Redis and route user queries to the nearest "route" or "topic". + +```python +routes = [ + Route( + name="greeting", + references=["hello", "hi"], + metadata={"type": "greeting"}, + distance_threshold=0.3, ) + Route( + name="farewell", + references=["bye", "goodbye"], + metadata={"type": "farewell"}, + distance_threshold=0.3, + ), +] + +# build semantic router from routes +router = SemanticRouter( + name="topic-router", + routes=routes, + redis_url="redis://localhost:6379", +) - # quickly check the cache with a slightly different prompt (before invoking an LLM) - response = llmcache.check(prompt="What is France's capital city?") - print(response[0]["response"]) - ``` - ```stdout - >>> "Paris" - ``` - > Learn more about Semantic Caching [here](https://www.redisvl.com/user_guide/llmcache_03.html). +router("Hi, good morning") +``` +```stdout +>>> RouteMatch(name='greeting', distance=0.09384023) +``` +> Learn more about [semantic routing](https://www.redisvl.com/user_guide/semantic_router_08.html). -- **LLM Session Management (COMING SOON)** aims to improve personalization and accuracy of the LLM application by providing user chat session information and conversational memory. -- **LLM Contextual Access Control (COMING SOON)** aims to improve security concerns by preventing malicious, irrelevant, or problematic user input from reaching LLMs and infrastructure. +## 🖥️ Command Line Interface +Create, destroy, and manage Redis index configurations from a purpose-built CLI interface: `rvl`. + +```bash +$ rvl -h + +usage: rvl [] + +Commands: + index Index manipulation (create, delete, etc.) + version Obtain the version of RedisVL + stats Obtain statistics about an index +``` +> Read more about using the [CLI](https://www.redisvl.com/user_guide/cli.html). -## Helpful Links +## 😁 Helpful Links -To get started, check out the following guides: +For additional help, check out the following resources: - [Getting Started Guide](https://www.redisvl.com/user_guide/getting_started_01.html) - [API Reference](https://www.redisvl.com/api/index.html) - [Example Gallery](https://www.redisvl.com/examples/index.html) - - [Official Redis Vector Search Docs](https://redis.io/docs/interact/search-and-query/advanced-concepts/vectors/) + - [Redis AI Recipes](https://github.com/redis-developer/redis-ai-resources) + - [Official Redis Vector API Docs](https://redis.io/docs/interact/search-and-query/advanced-concepts/vectors/) ## 🫱🏼‍🫲🏽 Contributing diff --git a/docs/_static/js/sidebar.js b/docs/_static/js/sidebar.js index 00b49dd5..d713fc99 100644 --- a/docs/_static/js/sidebar.js +++ b/docs/_static/js/sidebar.js @@ -4,29 +4,26 @@ const toc = [ { title: "Install", path: "/overview/installation.html" }, { title: "CLI", path: "/overview/cli.html" }, ]}, - { header: "User Guides", toc: [ - { title: "Getting Started", path: "/user_guide/getting_started_01.html" }, - { title: "Query and Filter", path: "/user_guide/hybrid_queries_02.html" }, - { title: "JSON vs Hash Storage", path: "/user_guide/hash_vs_json_05.html" }, - { title: "Vectorizers", path: "/user_guide/vectorizers_04.html" }, - { title: "Rerankers", path: "/user_guide/rerankers_06.html" }, - { title: "Semantic Caching", path: "/user_guide/llmcache_03.html" }, - { title: "Semantic Routing", path: "/user_guide/semantic_router_08.html" }, - ]}, { header: "API", toc: [ { title: "Schema", path: "/api/schema.html"}, { title: "Search Index", path: "/api/searchindex.html" }, { title: "Query", path: "/api/query.html" }, { title: "Filter", path: "/api/filter.html" }, - ]}, - { header: "Utils", toc: [ { title: "Vectorizers", path: "/api/vectorizer.html" }, { title: "Rerankers", path: "/api/reranker.html" }, - ]}, - { header: "Extensions", toc: [ { title: "LLM Cache", path: "/api/cache.html" }, + { title: "LLM Session Manager", path: "/api/session_manager.html" }, { title: "Semantic Router", path: "/api/router.html" }, - ]} + ]}, + { header: "User Guides", toc: [ + { title: "Getting Started", path: "/user_guide/getting_started_01.html" }, + { title: "Query and Filter", path: "/user_guide/hybrid_queries_02.html" }, + { title: "JSON vs Hash Storage", path: "/user_guide/hash_vs_json_05.html" }, + { title: "Using Vectorizers", path: "/user_guide/vectorizers_04.html" }, + { title: "Using Rerankers", path: "/user_guide/rerankers_06.html" }, + { title: "Semantic Caching", path: "/user_guide/llmcache_03.html" }, + { title: "Semantic Routing", path: "/user_guide/semantic_router_08.html" }, + ]}, ]; document.addEventListener('DOMContentLoaded', function() { diff --git a/docs/api/cache.rst b/docs/api/cache.rst index 9c921c60..14132316 100644 --- a/docs/api/cache.rst +++ b/docs/api/cache.rst @@ -1,4 +1,3 @@ - ********* LLM Cache ********* diff --git a/docs/api/index.md b/docs/api/index.md index 14371397..e6f8ca24 100644 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -18,6 +18,7 @@ filter vectorizer reranker cache +session_manager router ``` diff --git a/docs/api/session_manager.rst b/docs/api/session_manager.rst new file mode 100644 index 00000000..9b885a35 --- /dev/null +++ b/docs/api/session_manager.rst @@ -0,0 +1,29 @@ +******************* +LLM Session Manager +******************* + + +SemanticSessionManager +====================== + +.. _semantic_session_manager_api: + +.. currentmodule:: redisvl.extensions.session_manager + +.. autoclass:: SemanticSessionManager + :show-inheritance: + :members: + :inherited-members: + + +StandardSessionManager +====================== + +.. _standard_session_manager_api: + +.. currentmodule:: redisvl.extensions.session_manager + +.. autoclass:: StandardSessionManager + :show-inheritance: + :members: + :inherited-members: \ No newline at end of file diff --git a/docs/api/vectorizer.rst b/docs/api/vectorizer.rst index 8f2d8a97..139c985f 100644 --- a/docs/api/vectorizer.rst +++ b/docs/api/vectorizer.rst @@ -26,6 +26,18 @@ OpenAITextVectorizer :members: +AzureOpenAITextVectorizer +========================= + +.. _azureopenaitextvectorizer_api: + +.. currentmodule:: redisvl.utils.vectorize.text.azureopenai + +.. autoclass:: AzureOpenAITextVectorizer + :show-inheritance: + :members: + + VertexAITextVectorizer ====================== @@ -49,3 +61,14 @@ CohereTextVectorizer :show-inheritance: :members: + +CustomTextVectorizer +==================== + +.. _customtextvectorizer_api: + +.. currentmodule:: redisvl.utils.vectorize.text.custom + +.. autoclass:: CustomTextVectorizer + :show-inheritance: + :members: \ No newline at end of file diff --git a/docs/overview/cli.ipynb b/docs/overview/cli.ipynb index 12ee7384..3189c4bc 100644 --- a/docs/overview/cli.ipynb +++ b/docs/overview/cli.ipynb @@ -24,7 +24,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "\u001b[32m09:44:14\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m RedisVL version 0.2.3\n" + "\u001b[32m22:33:29\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m RedisVL version 0.3.0\n" ] } ], @@ -46,9 +46,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Overwriting schema.yaml\n" + ] + } + ], "source": [ "%%writefile schema.yaml\n", "\n", @@ -79,7 +87,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "\u001b[32m14:22:33\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Index created successfully\n" + "\u001b[32m22:33:31\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Index created successfully\n" ] } ], @@ -97,8 +105,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "\u001b[32m14:22:34\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Indices:\n", - "\u001b[32m14:22:34\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m 1. vectorizers\n" + "\u001b[32m22:33:33\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Indices:\n", + "\u001b[32m22:33:33\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m 1. vectorizers\n" ] } ], @@ -125,12 +133,12 @@ "│ vectorizers │ HASH │ ['doc'] │ [] │ 0 │\n", "╰──────────────┴────────────────┴────────────┴─────────────────┴────────────╯\n", "Index Fields:\n", - "╭───────────┬─────────────┬────────┬────────────────┬────────────────╮\n", - "│ Name │ Attribute │ Type │ Field Option │ Option Value │\n", - "├───────────┼─────────────┼────────┼────────────────┼────────────────┤\n", - "│ sentence │ sentence │ TEXT │ WEIGHT │ 1 │\n", - "│ embedding │ embedding │ VECTOR │ │ │\n", - "╰───────────┴─────────────┴────────┴────────────────┴────────────────╯\n" + "╭───────────┬─────────────┬────────┬────────────────┬────────────────┬────────────────┬────────────────┬────────────────┬────────────────┬─────────────────┬────────────────╮\n", + "│ Name │ Attribute │ Type │ Field Option │ Option Value │ Field Option │ Option Value │ Field Option │ Option Value │ Field Option │ Option Value │\n", + "├───────────┼─────────────┼────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼─────────────────┼────────────────┤\n", + "│ sentence │ sentence │ TEXT │ WEIGHT │ 1 │ │ │ │ │ │ │\n", + "│ embedding │ embedding │ VECTOR │ algorithm │ FLAT │ data_type │ FLOAT32 │ dim │ 768 │ distance_metric │ COSINE │\n", + "╰───────────┴─────────────┴────────┴────────────────┴────────────────┴────────────────┴────────────────┴────────────────┴────────────────┴─────────────────┴────────────────╯\n" ] } ], @@ -148,7 +156,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "\u001b[32m14:22:36\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Index deleted successfully\n" + "\u001b[32m22:33:36\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Index deleted successfully\n" ] } ], @@ -166,7 +174,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "\u001b[32m14:22:38\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Indices:\n" + "\u001b[32m22:33:37\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Indices:\n" ] } ], @@ -193,7 +201,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "\u001b[32m14:22:39\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Index created successfully\n" + "\u001b[32m22:33:40\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Index created successfully\n" ] } ], @@ -211,8 +219,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "\u001b[32m14:22:40\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Indices:\n", - "\u001b[32m14:22:40\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m 1. vectorizers\n" + "\u001b[32m22:33:42\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Indices:\n", + "\u001b[32m22:33:42\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m 1. vectorizers\n" ] } ], @@ -272,7 +280,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "\u001b[32m14:22:42\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Index deleted successfully\n" + "\u001b[32m22:33:45\u001b[0m \u001b[34m[RedisVL]\u001b[0m \u001b[1;30mINFO\u001b[0m Index deleted successfully\n" ] } ], @@ -297,7 +305,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.14" + "version": "3.11.9" } }, "nbformat": 4, diff --git a/pyproject.toml b/pyproject.toml index 333bd95a..103e43e5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "redisvl" -version = "0.2.3" +version = "0.3.0" description = "Python client library and CLI for using Redis as a vector database" authors = ["Redis Inc. "] license = "MIT" diff --git a/redisvl/extensions/llmcache/base.py b/redisvl/extensions/llmcache/base.py index d11a404f..7505352c 100644 --- a/redisvl/extensions/llmcache/base.py +++ b/redisvl/extensions/llmcache/base.py @@ -54,6 +54,13 @@ def store( metadata.""" raise NotImplementedError - def hash_input(self, prompt: str): - """Hashes the input using SHA256.""" + def hash_input(self, prompt: str) -> str: + """Hashes the input prompt using SHA256. + + Args: + prompt (str): Input string to be hashed. + + Returns: + str: Hashed string. + """ return hashify(prompt) diff --git a/redisvl/extensions/llmcache/semantic.py b/redisvl/extensions/llmcache/semantic.py index f9518614..f0f38a04 100644 --- a/redisvl/extensions/llmcache/semantic.py +++ b/redisvl/extensions/llmcache/semantic.py @@ -200,7 +200,7 @@ def drop( Args: ids (Optional[str]): The document ID or IDs to remove from the cache. - keys (Optional[str]): + keys (Optional[str]): The Redis keys to remove from the cache. """ if ids is not None: self._index.drop_keys([self._index.key(id) for id in ids]) @@ -300,6 +300,8 @@ def check( key = cache_search_result["id"] self._refresh_ttl(key) + print(cache_search_result, flush=True) + # Create cache hit cache_hit = CacheHit(**cache_search_result) cache_hit_dict = { diff --git a/redisvl/extensions/session_manager/semantic_session.py b/redisvl/extensions/session_manager/semantic_session.py index a0903b99..5ce0318d 100644 --- a/redisvl/extensions/session_manager/semantic_session.py +++ b/redisvl/extensions/session_manager/semantic_session.py @@ -151,7 +151,7 @@ def get_relevant( as_text (bool): Whether to return the prompts and responses as text or as JSON top_k (int): The number of previous messages to return. Default is 5. - fallback (bool): Whether to drop back to recent conversation history + fall_back (bool): Whether to drop back to recent conversation history if no relevant context is found. session_tag (Optional[str]): Tag to be added to entries to link to a specific session. Defaults to instance uuid. diff --git a/redisvl/utils/vectorize/text/custom.py b/redisvl/utils/vectorize/text/custom.py index 56155f5b..bf0eec4a 100644 --- a/redisvl/utils/vectorize/text/custom.py +++ b/redisvl/utils/vectorize/text/custom.py @@ -44,7 +44,6 @@ def __init__( embed_many: Optional[Callable] = None, aembed: Optional[Callable] = None, aembed_many: Optional[Callable] = None, - model: str = "custom_vectorizer", ): """Initialize the Custom vectorizer. @@ -72,7 +71,7 @@ def __init__( self._validate_aembed_many(aembed_many) self._aembed_many_func = aembed_many - super().__init__(model=model, dims=self._set_model_dims()) + super().__init__(model=self.type, dims=self._set_model_dims()) def _validate_embed(self, func: Callable): """calls the func with dummy input and validates that it returns a vector""" diff --git a/redisvl/version.py b/redisvl/version.py index d31c31ea..493f7415 100644 --- a/redisvl/version.py +++ b/redisvl/version.py @@ -1 +1 @@ -__version__ = "0.2.3" +__version__ = "0.3.0"