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

Update readme and documentation #189

Merged
merged 6 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
235 changes: 158 additions & 77 deletions README.md

Large diffs are not rendered by default.

25 changes: 11 additions & 14 deletions docs/_static/js/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 0 additions & 1 deletion docs/api/cache.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

*********
LLM Cache
*********
Expand Down
1 change: 1 addition & 0 deletions docs/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ filter
vectorizer
reranker
cache
session_manager
router
```

29 changes: 29 additions & 0 deletions docs/api/session_manager.rst
Original file line number Diff line number Diff line change
@@ -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:
23 changes: 23 additions & 0 deletions docs/api/vectorizer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ OpenAITextVectorizer
:members:


AzureOpenAITextVectorizer
=========================

.. _azureopenaitextvectorizer_api:

.. currentmodule:: redisvl.utils.vectorize.text.azureopenai

.. autoclass:: AzureOpenAITextVectorizer
:show-inheritance:
:members:


VertexAITextVectorizer
======================

Expand All @@ -49,3 +61,14 @@ CohereTextVectorizer
:show-inheritance:
:members:


CustomTextVectorizer
====================

.. _customtextvectorizer_api:

.. currentmodule:: redisvl.utils.vectorize.text.custom

.. autoclass:: CustomTextVectorizer
:show-inheritance:
:members:
46 changes: 27 additions & 19 deletions docs/overview/cli.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
],
Expand All @@ -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",
Expand Down Expand Up @@ -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"
]
}
],
Expand All @@ -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"
]
}
],
Expand All @@ -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"
]
}
],
Expand All @@ -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"
]
}
],
Expand All @@ -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"
]
}
],
Expand All @@ -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"
]
}
],
Expand All @@ -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"
]
}
],
Expand Down Expand Up @@ -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"
]
}
],
Expand All @@ -297,7 +305,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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. <applied.ai@redis.com>"]
license = "MIT"
Expand Down
11 changes: 9 additions & 2 deletions redisvl/extensions/llmcache/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 3 additions & 1 deletion redisvl/extensions/llmcache/semantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion redisvl/extensions/session_manager/semantic_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions redisvl/utils/vectorize/text/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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"""
Expand Down
2 changes: 1 addition & 1 deletion redisvl/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.3"
__version__ = "0.3.0"
Loading