20
20
from server .config import VECTOR_DIMENSION , RedisDocument
21
21
from server .utils import custom_log
22
22
23
+ assert redis_client is not None
24
+
23
25
cwd = os .path .dirname (__file__ )
24
26
25
27
embedding_model = "text-embedding-3-small"
@@ -34,7 +36,6 @@ def load_corpus(corpus: list[RedisDocument]):
34
36
Raises:
35
37
exception: if failed to load corpus into redis
36
38
"""
37
- assert redis_client is not None
38
39
custom_log ("loading corpus..." )
39
40
40
41
pipeline = redis_client .pipeline ()
@@ -69,8 +70,6 @@ def compute_openai_embeddings(texts):
69
70
70
71
def compute_embeddings ():
71
72
"""Compute embeddings from redis documents."""
72
- assert redis_client is not None
73
-
74
73
custom_log ("computing embeddings..." )
75
74
76
75
# get keys, questions, content
@@ -100,8 +99,6 @@ def load_embeddings(embeddings: list[list[float]]):
100
99
Raises:
101
100
exception: if failed to load embeddings into redis
102
101
"""
103
- assert redis_client is not None
104
-
105
102
custom_log ("loading embeddings into redis..." )
106
103
107
104
# load embeddings into redis
@@ -129,7 +126,6 @@ def create_index(corpus_len: int):
129
126
Raises:
130
127
exception: if failed to create index
131
128
"""
132
- assert redis_client is not None
133
129
custom_log ("creating index..." )
134
130
135
131
schema = (
@@ -196,7 +192,6 @@ def queries(query, queries: list[str]) -> list[dict]:
196
192
Returns:
197
193
list of dictionaries containing query and result
198
194
"""
199
- assert redis_client is not None
200
195
custom_log ("running queries..." )
201
196
202
197
# encode queries
@@ -254,7 +249,6 @@ def embed_corpus(corpus: list[RedisDocument]):
254
249
Raises:
255
250
exception: if failed to load corpus
256
251
"""
257
- assert redis_client is not None
258
252
# flush database
259
253
custom_log ("cleaning database..." )
260
254
redis_client .flushdb ()
0 commit comments