Skip to content

Commit 00f1c4f

Browse files
committed
app context fixed that
1 parent df3b900 commit 00f1c4f

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

server/nlp/embeddings.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
from server.config import VECTOR_DIMENSION, RedisDocument
2121
from server.utils import custom_log
2222

23+
assert redis_client is not None
24+
2325
cwd = os.path.dirname(__file__)
2426

2527
embedding_model = "text-embedding-3-small"
@@ -34,7 +36,6 @@ def load_corpus(corpus: list[RedisDocument]):
3436
Raises:
3537
exception: if failed to load corpus into redis
3638
"""
37-
assert redis_client is not None
3839
custom_log("loading corpus...")
3940

4041
pipeline = redis_client.pipeline()
@@ -69,8 +70,6 @@ def compute_openai_embeddings(texts):
6970

7071
def compute_embeddings():
7172
"""Compute embeddings from redis documents."""
72-
assert redis_client is not None
73-
7473
custom_log("computing embeddings...")
7574

7675
# get keys, questions, content
@@ -100,8 +99,6 @@ def load_embeddings(embeddings: list[list[float]]):
10099
Raises:
101100
exception: if failed to load embeddings into redis
102101
"""
103-
assert redis_client is not None
104-
105102
custom_log("loading embeddings into redis...")
106103

107104
# load embeddings into redis
@@ -129,7 +126,6 @@ def create_index(corpus_len: int):
129126
Raises:
130127
exception: if failed to create index
131128
"""
132-
assert redis_client is not None
133129
custom_log("creating index...")
134130

135131
schema = (
@@ -196,7 +192,6 @@ def queries(query, queries: list[str]) -> list[dict]:
196192
Returns:
197193
list of dictionaries containing query and result
198194
"""
199-
assert redis_client is not None
200195
custom_log("running queries...")
201196

202197
# encode queries
@@ -254,7 +249,6 @@ def embed_corpus(corpus: list[RedisDocument]):
254249
Raises:
255250
exception: if failed to load corpus
256251
"""
257-
assert redis_client is not None
258252
# flush database
259253
custom_log("cleaning database...")
260254
redis_client.flushdb()

0 commit comments

Comments
 (0)