Skip to content

Commit 5dff898

Browse files
authored
Merge pull request #6 from rishiraj/staging
Staging
2 parents 8ef9dec + e7d178c commit 5dff898

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
jax==0.4.26
2+
sentence-transformers==2.6.1

setup.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
with open("README.md", "r", encoding="utf-8") as fh:
2727
long_description = fh.read()
2828

29+
with open('requirements.txt') as fh:
30+
requirements = fh.read().splitlines()
31+
2932
setuptools.setup(
3033
name="spanking",
3134
version=spanking_version,
@@ -45,7 +48,5 @@
4548
],
4649
python_requires=">=3.9",
4750
entry_points={"console_scripts": ["spanking = spanking.main:main"]},
48-
install_requires=[
49-
"numpy >= 1.26.4",
50-
],
51+
install_requires=requirements,
5152
)

spanking/main.py

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import jax
22
import jax.numpy as jnp
3+
import pickle
34
from sentence_transformers import SentenceTransformer
45

56
class VectorDB:
@@ -37,6 +38,15 @@ def search(self, query, top_k=5):
3738
top_indices = jnp.argsort(similarities)[-top_k:][::-1]
3839
return [(self.texts[i], similarities[i]) for i in top_indices]
3940

41+
def save(self, file_path):
42+
with open(file_path, 'wb') as file:
43+
pickle.dump(self, file)
44+
45+
@staticmethod
46+
def load(file_path):
47+
with open(file_path, 'rb') as file:
48+
return pickle.load(file)
49+
4050
def __len__(self):
4151
return len(self.texts)
4252

0 commit comments

Comments
 (0)