Skip to content

Commit

Permalink
more updates
Browse files Browse the repository at this point in the history
  • Loading branch information
prapooskur committed Feb 28, 2024
1 parent d2ee706 commit ba3f5d0
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fun DetailedResultsScreen(
contentWindowInsets = WindowInsets(0.dp),
topBar = {
BoringNormalTopBar(
titleText = courseInfo.primary_section.title,
titleText = courseInfo.primary_section.title_long,
navController = navController,
)
},
Expand Down
15 changes: 11 additions & 4 deletions android/app/src/main/java/com/pras/slugcourses/ResultsScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import com.pras.slugcourses.api.supabaseQuery
import com.pras.slugcourses.ui.elements.BoringNormalTopBar
import com.pras.slugcourses.ui.elements.CourseCard
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.isActive
import kotlinx.coroutines.withContext

private const val TAG = "results"
Expand Down Expand Up @@ -120,7 +121,7 @@ fun ResultsScreen(

try {
withContext(Dispatchers.IO) {
response = supabaseQuery(
val result = supabaseQuery(
term = term,
status = status,
department = if (useDepartment) department.uppercase() else "",
Expand All @@ -133,11 +134,17 @@ fun ResultsScreen(
inPerson = type.contains(Type.IN_PERSON),
searchType = searchType,
)
dataLoaded = true
if (isActive) {
response = result
dataLoaded = true
}

}
} catch (e: Exception) {
Log.d(TAG, e.toString())
ShortToast("Error: ${e}", context)
if (isActive) {
Log.d(TAG, e.toString())
ShortToast("Error: ${e}", context)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.compose.material3.TopAppBarScrollBehavior
import androidx.compose.material3.rememberTopAppBarState
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextOverflow
import androidx.navigation.NavController


Expand Down Expand Up @@ -62,6 +63,7 @@ fun BoringNormalTopBar(
Text(
modifier = Modifier,
text = titleText,
overflow = TextOverflow.Ellipsis
)
},
navigationIcon = {
Expand Down
Binary file added backend/cache/classdocument
Binary file not shown.
Binary file added backend/cache/updatedclasses
Binary file not shown.
1 change: 1 addition & 0 deletions backend/cache/updatedclasses.json

Large diffs are not rendered by default.

34 changes: 24 additions & 10 deletions backend/populate_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def fetch_course_data(course_input):

#detailedInfo.extend(result[-1] for result in results)
print("array created")
print(detailedInfo)
#print(detailedInfo)

picklefile = open("cache/updatedclasses", mode="wb")
pickle.dump(detailedInfo, picklefile)
Expand All @@ -99,18 +99,32 @@ def fetch_course_data(course_input):

def populate_embeddings(documents: list[Document]):
print("updating embeddings...")
document_embedder = SentenceTransformersDocumentEmbedder(
model="BAAI/bge-large-en-v1.5")
#document_embedder = SentenceTransformersDocumentEmbedder(model="BAAI/bge-large-en-v1.5")
document_embedder = SentenceTransformersDocumentEmbedder(model="WhereIsAI/UAE-Large-V1")
document_embedder.warm_up()
documents_with_embeddings = document_embedder.run(documents)
picklefile = open("cache/updated", mode="wb")
picklefile = open("cache/classembeddings", mode="wb")
pickle.dump(documents_with_embeddings, picklefile)
picklefile.close()

if __name__ == "__main__":
if len(sys.argv) > 1:
if sys.argv[1] == "-c":
print("Updating courses...")
populate()
elif sys.argv[1] == "-e":
print("Populating embeddings")

if "-c" in sys.argv:
populate()

if "-e" in sys.argv:
file = open("cache/updatedclasses", mode="rb")
detailedInfo = pickle.load(file)
file.close()

# Write documents to InMemoryDocumentStore
documents = []
for i in detailedInfo:
documents.append(Document(content=str(i)))

doc_picklefile = open("cache/classdocument", mode="wb")
pickle.dump(documents, doc_picklefile)

populate_embeddings(documents)


0 comments on commit ba3f5d0

Please sign in to comment.