Skip to content

Commit d74053a

Browse files
add support for cache construction from an index (#33)
PR introduces the ability to load an LLMCache from an underlying index. Also makes some adjustments to the index class to support this. - Add support for `SemanticCache.from_index(...)` - Update implementation of the `SearchIndex`: - move `key_field` as a `load` method arg - add `_get_key` method to create the redis key for an object and associated test - Update `SearchIndex.from_existing(...)` to accept a `redis_url` and `connection_args`
1 parent 6a38262 commit d74053a

File tree

18 files changed

+268
-136
lines changed

18 files changed

+268
-136
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ index:
6767
name: user_index
6868
storage_type: hash
6969
prefix: users
70-
key_field: user
7170

7271
fields:
7372
# define tag fields

conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
aredis = get_async_redis_connection(REDIS_ADDRESS)
1212
redis = get_redis_connection(REDIS_ADDRESS)
1313

14+
@pytest.fixture()
15+
def redis_url():
16+
return REDIS_ADDRESS
1417

1518
@pytest.fixture
1619
def async_client():

docs/examples/openai_qna.ipynb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,8 +748,6 @@
748748
"index:\n",
749749
" name: wiki\n",
750750
" prefix: oaiWiki\n",
751-
" key_field: id\n",
752-
" storage_type: hash\n",
753751
"\n",
754752
"fields:\n",
755753
" text:\n",

docs/user_guide/getting_started_01.ipynb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@
122122
"The index specification determines how data will be stored in Redis. This includes\n",
123123
"- ``name``: the name of the index\n",
124124
"- (Optional) ``prefix``: key prefix for each loaded entry\n",
125-
"- (Optional) ``key_field``: field within the dataset to use as unique keys. If not specified, a unique key will be generated for each entry.\n",
126125
"\n",
127126
"The field specification determines what fields within the dataset will be available for queries. Each field corresponds to the name of a **column** within the dataset. The values within each specified column are arguments for the creation of that index that correspond directly to ``redis-py`` arguments.\n",
128127
"\n",
@@ -134,8 +133,6 @@
134133
"index:\n",
135134
" name: user_index\n",
136135
" prefix: v1\n",
137-
" key_field: user\n",
138-
" storage_type: hash\n",
139136
"\n",
140137
"fields:\n",
141138
" # define tag fields\n",
@@ -168,8 +165,6 @@
168165
" \"index\": {\n",
169166
" \"name\": \"user_index\",\n",
170167
" \"prefix\": \"v1\",\n",
171-
" \"key_field\": \"user\",\n",
172-
" \"storage_type\": \"hash\",\n",
173168
" },\n",
174169
" \"fields\": {\n",
175170
" \"tag\": [{\"name\": \"credit_score\"}],\n",

docs/user_guide/hybrid_queries_02.ipynb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@
109109
" \"index\": {\n",
110110
" \"name\": \"user_index\",\n",
111111
" \"prefix\": \"v1\",\n",
112-
" \"key_field\": \"user\",\n",
113-
" \"storage_type\": \"hash\",\n",
114112
" },\n",
115113
" \"fields\": {\n",
116114
" \"tag\": [{\"name\": \"credit_score\"}],\n",

docs/user_guide/providers_03.ipynb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@
124124
"index:\n",
125125
" name: providers\n",
126126
" prefix: rvl\n",
127-
" storage_type: hash\n",
128127
"\n",
129128
"fields:\n",
130129
" text:\n",

redisvl/cli/index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def _connect_to_index(self, args: Namespace) -> SearchIndex:
124124
exit(0)
125125

126126
if args.index:
127-
index = SearchIndex.from_existing(conn, args.index)
127+
index = SearchIndex.from_existing(name=args.index, url=url)
128128
elif args.schema:
129129
index = SearchIndex.from_yaml(args.schema)
130130
index.set_client(conn)

0 commit comments

Comments
 (0)