Skip to content

Commit 62e38c7

Browse files
committed
feat: client and api
1 parent c197788 commit 62e38c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+60687
-55365
lines changed

Diff for: .gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
.DS_Store
2-
__pycache__
3-
.env
2+
.vscode

Diff for: .vscode/settings.json

-4
This file was deleted.

Diff for: packages/api/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.DS_Store
2+
__pycache__
3+
.env

Diff for: README.md renamed to packages/api/README.md

File renamed without changes.

Diff for: poetry.lock renamed to packages/api/poetry.lock

+171-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: pyproject.toml renamed to packages/api/pyproject.toml

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ python-dotenv = "^1.0.1"
1515
waitress = "^3.0.0"
1616
flask-cors = "^5.0.0"
1717
faiss-cpu = "^1.9.0"
18+
gdown = "^5.2.0"
19+
pandas = "^2.2.3"
1820

1921
[tool.poetry.scripts]
2022
dev = "semantic_search:dev"
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
import os
22
import faiss
33
import json
4-
import numpy as np
54
from sentence_transformers import SentenceTransformer
65

76
os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE"
87

9-
index = faiss.read_index('semantic_search/models/atharv-naidu-index.index')
8+
index = faiss.read_index("semantic_search/models/atharv-naidu-index.index")
109

11-
with open('semantic_search/models/atharv-naidu-metadata.json', 'r') as f:
10+
with open("semantic_search/models/atharv-naidu-metadata.json", "r") as f:
1211
courses = json.load(f)
1312

1413
# Load the SentenceTransformer model
15-
model = SentenceTransformer('all-MiniLM-L6-v2')
14+
model = SentenceTransformer("all-MiniLM-L6-v2")
15+
1616

1717
# Function to get embeddings for query
1818
def get_embeddings(text):
1919
return model.encode(text, convert_to_tensor=True).cpu().numpy().reshape(1, -1)
2020

21+
2122
# Function to search courses and return them in the specified format
2223
def getCourses(query: str, topK: int):
2324
query_embedding = get_embeddings(query)
@@ -29,7 +30,7 @@ def getCourses(query: str, topK: int):
2930
results = []
3031
for idx, dist in zip(indices[0], distances[0]):
3132
course = courses[idx]
32-
33+
3334
course_result = {
3435
"subject": course["subject"],
3536
"number": course["number"],
@@ -38,10 +39,3 @@ def getCourses(query: str, topK: int):
3839
results.append(course_result)
3940

4041
return results
41-
42-
# Example query
43-
user_query = "data structures"
44-
matched_courses = getCourses(user_query, topK=5)
45-
46-
for course in matched_courses:
47-
print(course)

0 commit comments

Comments
 (0)